Column names customization (bug #3194500)

This commit is contained in:
Jakub Vrana 2011-05-24 17:03:48 +02:00
parent 6a491373c2
commit d2c513d1c2
2 changed files with 8 additions and 7 deletions

View file

@ -192,7 +192,7 @@ username.form['driver'].onchange();
} }
/** Print columns box in select /** Print columns box in select
* @param array result of selectColumnsProcess() * @param array result of selectColumnsProcess()[0]
* @param array selectable columns * @param array selectable columns
* @return null * @return null
*/ */

View file

@ -47,10 +47,9 @@ if ($_POST && !$error) {
break; break;
} }
} }
foreach ($select as $key => $val) { foreach ((array) $unselected as $key => $val) {
$val = $_GET["columns"][$key]; if (in_array(idf_escape($key), $select)) {
if (!$val["fun"]) { unset($unselected[$key]);
unset($unselected[$val["col"]]);
} }
} }
if ($_POST["export"]) { if ($_POST["export"]) {
@ -257,13 +256,15 @@ if (!$columns) {
foreach ($rows[0] as $key => $val) { foreach ($rows[0] as $key => $val) {
if ($table_status["Oid"] != "t" || $key != "oid") { if ($table_status["Oid"] != "t" || $key != "oid") {
$val = $_GET["columns"][key($select)]; $val = $_GET["columns"][key($select)];
$field = $fields[$select ? $val["col"] : $key]; $field = $fields[$select ? ($val ? $val["col"] : current($select)) : $key];
$name = ($field ? $adminer->fieldName($field, $rank) : "*"); $name = ($field ? $adminer->fieldName($field, $rank) : "*");
if ($name != "") { if ($name != "") {
$rank++; $rank++;
$names[$key] = $name; $names[$key] = $name;
$column = idf_escape($key); $column = idf_escape($key);
echo '<th><a href="' . h(remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key) . ($order[0] == $column || $order[0] == $key || (!$order && $group[0] == $column) ? '&desc%5B0%5D=1' : '')) . '">' . apply_sql_function($val["fun"], $name) . "</a>"; // $order[0] == $key - COUNT(*) //! columns looking like functions echo '<th><a href="' . h(remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key)
. ($order[0] == $column || $order[0] == $key || (!$order && count($group) < count($select) && $group[0] == $column) ? '&desc%5B0%5D=1' : '') // $order[0] == $key - COUNT(*)
) . '">' . (!$select || $val ? apply_sql_function($val["fun"], $name) : h(current($select))) . "</a>"; //! columns looking like functions
} }
$functions[$key] = $val["fun"]; $functions[$key] = $val["fun"];
next($select); next($select);