]> git.joonet.de Git - adminer.git/commitdiff
Apply field name with functions
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 23 Jul 2009 15:49:59 +0000 (15:49 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 23 Jul 2009 15:49:59 +0000 (15:49 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@884 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/edit.inc.php
adminer/include/adminer.inc.php
adminer/select.inc.php
editor/include/adminer.inc.php
examples/editor-cds/index.php

index 157d5c5c892093b7d6f38461e68cea4b1d6e4c9d..22ee2d866274c2cb642f3fbbf6a87f7ca1cafa73 100644 (file)
@@ -3,7 +3,7 @@ $where = (isset($_GET["select"]) ? (count($_POST["check"]) == 1 ? where_check($_
 $update = ($where && !$_POST["clone"]);
 $fields = fields($_GET["edit"]);
 foreach ($fields as $name => $field) {
-       if ((isset($_GET["default"]) ? $field["auto_increment"] || ereg('text|blob', $field["type"]) : !isset($field["privileges"][$update ? "update" : "insert"])) || !strlen(adminer_field_name($fields, $name))) {
+       if ((isset($_GET["default"]) ? $field["auto_increment"] || ereg('text|blob', $field["type"]) : !isset($field["privileges"][$update ? "update" : "insert"])) || !strlen(adminer_field_name($field))) {
                unset($fields[$name]);
        }
 }
@@ -73,7 +73,7 @@ if ($fields) {
        unset($create);
        echo "<table cellspacing='0'>\n";
        foreach ($fields as $name => $field) {
-               echo "<tr><th>" . adminer_field_name($fields, $name);
+               echo "<tr><th>" . adminer_field_name($field);
                $value = (isset($row)
                        ? (strlen($row[$name]) && ($field["type"] == "enum" || $field["type"] == "set") ? intval($row[$name]) : $row[$name])
                        : ($_POST["clone"] && $field["auto_increment"] ? "" : (isset($_GET["select"]) ? false : $field["default"]))
index d5814d44bf0da04d214d6402f9b120906480cd77..9a0f08b1842c23878bebbddf255729d459a95672 100644 (file)
@@ -55,12 +55,11 @@ function adminer_table_name($row) {
 }
 
 /** Field caption used in select and edit
-* @param array all fields in table, result of fields()
-* @param string column identifier, function calls are not contained in $fields 
+* @param array single field returned from fields()
 * @return string
 */
-function adminer_field_name($fields, $key) {
-       return call_adminer('field_name', '<span title="' . htmlspecialchars($fields[$key]["full_type"]) . '">' . htmlspecialchars($key) . '</span>', $fields, $key);
+function adminer_field_name($field) {
+       return call_adminer('field_name', ($field ? '<span title="' . htmlspecialchars($field["full_type"]) . '">' . htmlspecialchars($field["field"]) . '</span>' : "*"), $field);
 }
 
 /** Links after select heading
index 745f7009d062e15fa9cb1a0378b8c5bc14a5e03d..153188c9785e13c870c2a2aff502f314a41336d6 100644 (file)
@@ -18,7 +18,7 @@ $rights = array(); // privilege => 0
 $columns = array(); // selectable columns
 unset($text_length);
 foreach ($fields as $key => $field) {
-       $name = adminer_field_name($fields, $key);
+       $name = adminer_field_name($field);
        if (isset($field["privileges"]["select"]) && strlen($name)) {
                $columns[$key] = html_entity_decode(strip_tags($name));
                if (ereg('text|blob', $field["type"])) {
@@ -288,21 +288,25 @@ if (!$columns) {
                        
                        echo "<table cellspacing='0' class='nowrap'>\n";
                        echo "<thead><tr><td><input type='checkbox' id='all-page' onclick='form_check(this, /check/);'>";
+                       $names = array();
+                       reset($select);
                        foreach ($rows[0] as $key => $val) {
-                               $name = adminer_field_name($fields, $key);
+                               $val = $_GET["columns"][key($select)];
+                               $name = adminer_field_name($fields[$select ? $val["col"] : $key]);
                                if (strlen($name)) {
-                                       echo '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($key) && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . "\">$name</a>";
+                                       $names[$key] = $name;
+                                       echo '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($key) && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . ($val["fun"] ? strtoupper($val["fun"]) . " $name" : $name) . "</a>";
                                }
+                               next($select);
                        }
                        echo ($backward_keys ? "<th>" . lang('Relations') : "") . "</thead>\n";
                        foreach ($descriptions as $n => $row) {
                                $unique_idf = implode('&amp;', unique_idf($row, $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) {
-                                       $name = adminer_field_name($fields, $key);
-                                       if (strlen($name)) {
+                                       if (strlen($names[$key])) {
                                                if (strlen($val) && (!isset($email_fields[$key]) || strlen($email_fields[$key]))) {
-                                                       $email_fields[$key] = (is_email($val) ? $name : ""); //! filled e-mails may be contained on other pages
+                                                       $email_fields[$key] = (is_email($val) ? $names[$key] : ""); //! filled e-mails may be contained on other pages
                                                }
                                                $link = "";
                                                if (!isset($val)) {
index 3e33d18c27972945f374adc80a7c0ff8079b5b2d..27f75fe259b3bab6007f7b982a48d79c5719e8d3 100644 (file)
@@ -32,8 +32,8 @@ function adminer_table_name($row) {
        return call_adminer('table_name', htmlspecialchars(strlen($row["Comment"]) ? $row["Comment"] : $row["Name"]), $row);
 }
 
-function adminer_field_name($fields, $key) {
-       return call_adminer('field_name', htmlspecialchars(strlen($fields[$key]["comment"]) ? $fields[$key]["comment"] : $key), $fields, $key);
+function adminer_field_name($field) {
+       return call_adminer('field_name', ($field ? htmlspecialchars(strlen($field["comment"]) ? $field["comment"] : $field["field"]) : "*"), $field);
 }
 
 function adminer_select_links($table_status) {
index 5a777e3ff8a7669fc4ca2e7b21f8118bd649b9a2..0f9c1002974c465c7e7f974ba6bafbc0b0523c3a 100644 (file)
@@ -32,9 +32,9 @@ class Adminer {
                return htmlspecialchars($row["Comment"]);
        }
        
-       function field_name($fields, $key) {
+       function field_name($field) {
                // fields without comments will be ignored
-               return htmlspecialchars($fields[$key]["comment"]);
+               return ($field ? htmlspecialchars($field["comment"]) : "*");
        }
        
 }