]> git.joonet.de Git - adminer.git/commitdiff
Display images in Editor
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Fri, 24 Jul 2009 10:14:36 +0000 (10:14 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Fri, 24 Jul 2009 10:14:36 +0000 (10:14 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@898 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/include/adminer.inc.php
adminer/select.inc.php
editor/include/adminer.inc.php

index 8a0f8e1e30598dc1e371a8ea6bcd8113baffc4ea..a91850f7afebed957b829b830873df95ebdd0ced 100644 (file)
@@ -114,6 +114,9 @@ function adminer_row_descriptions($rows, $foreign_keys) {
 */
 function adminer_select_val($val, $link, $field) {
        $return = ($field["type"] == "char" ? "<code>$val</code>" : $val);
+       if (ereg('blob|binary', $field["type"]) && !is_utf8($val)) {
+               $return = lang('%d byte(s)', strlen($val));
+       }
        return call_adminer('select_val', ($link ? "<a href=\"$link\">$return</a>" : $return), $val, $link);
 }
 
index 2202573800b8ce3f974db4e9dadd9b0cd3585b54..537928b5988e6aeba836b92bcb0bd9a20fcb5441 100644 (file)
@@ -319,13 +319,13 @@ if (!$columns) {
                                                $link = "";
                                                if (!isset($val)) {
                                                        $val = "<i>NULL</i>";
-                                               } elseif (ereg('blob|binary', $fields[$key]["type"]) && !is_utf8($val)) { //! download link may be printed even with is_utf8
-                                                       $link = htmlspecialchars($SELF . 'download=' . urlencode($_GET["select"]) . '&field=' . urlencode($key) . '&') . $unique_idf;
-                                                       $val = lang('%d byte(s)', strlen($val));
                                                } else {
+                                                       if (ereg('blob|binary', $fields[$key]["type"]) && strlen($val)) {
+                                                               $link = htmlspecialchars($SELF . 'download=' . urlencode($_GET["select"]) . '&field=' . urlencode($key) . '&') . $unique_idf;
+                                                       }
                                                        if (!strlen(trim($val, " \t"))) {
                                                                $val = "&nbsp;";
-                                                       } elseif (strlen($text_length) && ereg('blob|text', $fields[$key]["type"])) {
+                                                       } elseif (strlen($text_length) && ereg('blob|text', $fields[$key]["type"]) && is_utf8($val)) {
                                                                $val = nl2br(shorten_utf8($val, max(0, intval($text_length)))); // usage of LEFT() would reduce traffic but complicate query
                                                        } else {
                                                                $val = nl2br(htmlspecialchars($val));
index a9a9c536312fa25c9b47fe1219178b005cfe65b1..8103e43bca49c8865914d28012b9ee2b8752038a 100644 (file)
@@ -108,10 +108,14 @@ function adminer_row_descriptions($rows, $foreign_keys) {
 }
 
 function adminer_select_val($val, $link, $field) {
-       return call_adminer('select_val', ($link
-               ? "<a href=\"$link\">$val</a>"
-               : ($val == "<i>NULL</i>" ? "&nbsp;" : $val)
-       ), $val, $link);
+       $return = ($val == "<i>NULL</i>" ? "&nbsp;" : $val);
+       if (ereg('blob|binary', $field["type"]) && !is_utf8($val)) {
+               $return = lang('%d byte(s)', strlen($val));
+               if (ereg("^(GIF|\xFF\xD8\xFF|\x89\x50\x4E\x47\x0D\x0A\x1A\x0A)", $val)) { // GIF|JPG|PNG, getimagetype() works with filename
+                       $return = "<img src=\"$link\" alt='$return'>";
+               }
+       }
+       return call_adminer('select_val', ($link ? "<a href=\"$link\">$return</a>" : $return), $val, $link);
 }
 
 function adminer_message_query($query) {