Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Apply field name with functions

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@884 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
commit 503412367a1c3e04df7149e3826820e7cfd2f1e8 1 parent 1e4d11e
jakubvrana authored
View
4 adminer/edit.inc.php
@@ -3,7 +3,7 @@
$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 @@
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"]))
View
7 adminer/include/adminer.inc.php
@@ -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
View
16 adminer/select.inc.php
@@ -18,7 +18,7 @@
$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 @@
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)) {
View
4 editor/include/adminer.inc.php
@@ -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) {
View
4 examples/editor-cds/index.php
@@ -32,9 +32,9 @@ function table_name($row) {
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"]) : "*");
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.