Apply field name with functions
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@884 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
1e4d11e920
commit
503412367a
|
@ -3,7 +3,7 @@ $where = (isset($_GET["select"]) ? (count($_POST["check"]) == 1 ? where_check($_
|
||||||
$update = ($where && !$_POST["clone"]);
|
$update = ($where && !$_POST["clone"]);
|
||||||
$fields = fields($_GET["edit"]);
|
$fields = fields($_GET["edit"]);
|
||||||
foreach ($fields as $name => $field) {
|
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]);
|
unset($fields[$name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ if ($fields) {
|
||||||
unset($create);
|
unset($create);
|
||||||
echo "<table cellspacing='0'>\n";
|
echo "<table cellspacing='0'>\n";
|
||||||
foreach ($fields as $name => $field) {
|
foreach ($fields as $name => $field) {
|
||||||
echo "<tr><th>" . adminer_field_name($fields, $name);
|
echo "<tr><th>" . adminer_field_name($field);
|
||||||
$value = (isset($row)
|
$value = (isset($row)
|
||||||
? (strlen($row[$name]) && ($field["type"] == "enum" || $field["type"] == "set") ? intval($row[$name]) : $row[$name])
|
? (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"]))
|
: ($_POST["clone"] && $field["auto_increment"] ? "" : (isset($_GET["select"]) ? false : $field["default"]))
|
||||||
|
|
|
@ -55,12 +55,11 @@ function adminer_table_name($row) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Field caption used in select and edit
|
/** Field caption used in select and edit
|
||||||
* @param array all fields in table, result of fields()
|
* @param array single field returned from fields()
|
||||||
* @param string column identifier, function calls are not contained in $fields
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function adminer_field_name($fields, $key) {
|
function adminer_field_name($field) {
|
||||||
return call_adminer('field_name', '<span title="' . htmlspecialchars($fields[$key]["full_type"]) . '">' . htmlspecialchars($key) . '</span>', $fields, $key);
|
return call_adminer('field_name', ($field ? '<span title="' . htmlspecialchars($field["full_type"]) . '">' . htmlspecialchars($field["field"]) . '</span>' : "*"), $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Links after select heading
|
/** Links after select heading
|
||||||
|
|
|
@ -18,7 +18,7 @@ $rights = array(); // privilege => 0
|
||||||
$columns = array(); // selectable columns
|
$columns = array(); // selectable columns
|
||||||
unset($text_length);
|
unset($text_length);
|
||||||
foreach ($fields as $key => $field) {
|
foreach ($fields as $key => $field) {
|
||||||
$name = adminer_field_name($fields, $key);
|
$name = adminer_field_name($field);
|
||||||
if (isset($field["privileges"]["select"]) && strlen($name)) {
|
if (isset($field["privileges"]["select"]) && strlen($name)) {
|
||||||
$columns[$key] = html_entity_decode(strip_tags($name));
|
$columns[$key] = html_entity_decode(strip_tags($name));
|
||||||
if (ereg('text|blob', $field["type"])) {
|
if (ereg('text|blob', $field["type"])) {
|
||||||
|
@ -288,21 +288,25 @@ if (!$columns) {
|
||||||
|
|
||||||
echo "<table cellspacing='0' class='nowrap'>\n";
|
echo "<table cellspacing='0' class='nowrap'>\n";
|
||||||
echo "<thead><tr><td><input type='checkbox' id='all-page' onclick='form_check(this, /check/);'>";
|
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) {
|
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)) {
|
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";
|
echo ($backward_keys ? "<th>" . lang('Relations') : "") . "</thead>\n";
|
||||||
foreach ($descriptions as $n => $row) {
|
foreach ($descriptions as $n => $row) {
|
||||||
$unique_idf = implode('&', unique_idf($row, $indexes)); //! don't use aggregation functions
|
$unique_idf = implode('&', 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']) . '&' . $unique_idf . '">' . lang('edit') . '</a>');
|
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']) . '&' . $unique_idf . '">' . lang('edit') . '</a>');
|
||||||
foreach ($row as $key => $val) {
|
foreach ($row as $key => $val) {
|
||||||
$name = adminer_field_name($fields, $key);
|
if (strlen($names[$key])) {
|
||||||
if (strlen($name)) {
|
|
||||||
if (strlen($val) && (!isset($email_fields[$key]) || strlen($email_fields[$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 = "";
|
$link = "";
|
||||||
if (!isset($val)) {
|
if (!isset($val)) {
|
||||||
|
|
|
@ -32,8 +32,8 @@ function adminer_table_name($row) {
|
||||||
return call_adminer('table_name', htmlspecialchars(strlen($row["Comment"]) ? $row["Comment"] : $row["Name"]), $row);
|
return call_adminer('table_name', htmlspecialchars(strlen($row["Comment"]) ? $row["Comment"] : $row["Name"]), $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
function adminer_field_name($fields, $key) {
|
function adminer_field_name($field) {
|
||||||
return call_adminer('field_name', htmlspecialchars(strlen($fields[$key]["comment"]) ? $fields[$key]["comment"] : $key), $fields, $key);
|
return call_adminer('field_name', ($field ? htmlspecialchars(strlen($field["comment"]) ? $field["comment"] : $field["field"]) : "*"), $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
function adminer_select_links($table_status) {
|
function adminer_select_links($table_status) {
|
||||||
|
|
|
@ -32,9 +32,9 @@ class Adminer {
|
||||||
return htmlspecialchars($row["Comment"]);
|
return htmlspecialchars($row["Comment"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function field_name($fields, $key) {
|
function field_name($field) {
|
||||||
// fields without comments will be ignored
|
// fields without comments will be ignored
|
||||||
return htmlspecialchars($fields[$key]["comment"]);
|
return ($field ? htmlspecialchars($field["comment"]) : "*");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue