Permalink
Browse files

Pass $field to select_val

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@897 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
jakubvrana
jakubvrana committed Jul 24, 2009
1 parent b8eaaa8 commit 78e49f0106c658bd5b2575d6e9fd450daf91a6a7
Showing with 12 additions and 13 deletions.
  1. +4 −2 adminer/include/adminer.inc.php
  2. +2 −2 adminer/include/functions.inc.php
  3. +2 −5 adminer/select.inc.php
  4. +4 −4 editor/include/adminer.inc.php
@@ -109,10 +109,12 @@ function adminer_row_descriptions($rows, $foreign_keys) {
/** Value printed in select table
* @param string escaped value to print
* @param string link to foreign key
+* @param array single field returned from fields()
* @return string
*/
-function adminer_select_val($val, $link) {
- return call_adminer('select_val', ($link ? "<a href=\"$link\">$val</a>" : $val), $val, $link);
+function adminer_select_val($val, $link, $field) {
+ $return = ($field["type"] == "char" ? "<code>$val</code>" : $val);
+ return call_adminer('select_val', ($link ? "<a href=\"$link\">$return</a>" : $return), $val, $link);
}
/** Query printed after execution in the message
@@ -364,11 +364,11 @@ function email_header($header) {
return "=?UTF-8?B?" . base64_encode($header) . "?="; //! split long lines
}
-function call_adminer($method, $default, $arg1 = null, $arg2 = null) {
+function call_adminer($method, $default, $arg1 = null, $arg2 = null, $arg3 = null) {
// maintains original method name in minification
if (method_exists('Adminer', $method)) { // user defined class
// can use func_get_args() and call_user_func_array()
- return Adminer::$method($arg1, $arg2);
+ return Adminer::$method($arg1, $arg2, $arg3);
}
return $default; //! $default is evaluated even if not neccessary
}
View
@@ -312,7 +312,7 @@ function apply_sql_function($function, $column) {
$unique_idf = implode('&amp;', unique_idf($rows[$n], $indexes)); //! don't use aggregation functions
echo '<tr' . odd() . '><td><input type="checkbox" name="check[]" value="' . $unique_idf . '" onclick="this.form[\'all\'].checked = false; form_uncheck(\'all-page\');">' . (count($select) != count($group) || information_schema($_GET["db"]) ? '' : ' <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '">' . lang('edit') . '</a>');
foreach ($row as $key => $val) {
- if (strlen($names[$key])) {
+ if (isset($names[$key])) {
if (strlen($val) && (!isset($email_fields[$key]) || strlen($email_fields[$key]))) {
$email_fields[$key] = (is_email($val) ? $names[$key] : ""); //! filled e-mails may be contained on other pages
}
@@ -329,9 +329,6 @@ function apply_sql_function($function, $column) {
$val = nl2br(shorten_utf8($val, max(0, intval($text_length)))); // usage of LEFT() would reduce traffic but complicate query
} else {
$val = nl2br(htmlspecialchars($val));
- if ($fields[$key]["type"] == "char") {
- $val = "<code>$val</code>";
- }
}
// link related items
@@ -348,7 +345,7 @@ function apply_sql_function($function, $column) {
if (!$link && is_email($val)) {
$link = "mailto:$val";
}
- $val = adminer_select_val($val, $link);
+ $val = adminer_select_val($val, $link, $fields[$key]);
echo "<td>$val";
}
}
@@ -107,10 +107,10 @@ function adminer_row_descriptions($rows, $foreign_keys) {
return call_adminer('row_descriptions', $return, $rows, $foreign_keys);
}
-function adminer_select_val($val, $link) {
- return call_adminer('select_val', ($link ?
- "<a href=\"$link\">$val</a>" :
- ($val == "<i>NULL</i>" ? "&nbsp;" : preg_replace('~^<code>(.*)</code>$~', '\\1', $val))
+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);
}

0 comments on commit 78e49f0

Please sign in to comment.