$rank = 1; foreach ($rows[0] as $key => $val) { if ($key != $oid) { $val = $_GET["columns"][key($select)]; $field = $fields[$select ? $val ? $val["col"] : current($select) : $key]; $name = $field ? $adminer->fieldName($field, $rank) : "*"; if ($name != "") { $rank++; $names[$key] = $name; $column = idf_escape($key); $href = remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key); $desc = "&desc%5B0%5D=1"; echo '<th onmouseover="columnMouse(this);" onmouseout="columnMouse(this, \' hidden\');">'; echo '<a href="' . h($href . ($order[0] == $column || $order[0] == $key || !$order && $is_group && $group[0] == $column ? $desc : '')) . '">'; // $order[0] == $key - COUNT(*) echo (!$select || $val ? apply_sql_function($val["fun"], $name) : h(current($select))) . "</a>"; //! columns looking like functions echo "<span class='column hidden'>"; echo "<a href='" . h($href . $desc) . "' title='" . lang('descending') . "' class='text'> ↓</a>"; if (!$val["fun"]) { echo '<a href="#fieldset-search" onclick="selectSearch(\'' . h(js_escape($key)) . '\'); return false;" title="' . lang('Search') . '" class="text jsonly"> =</a>'; } echo "</span>"; } $functions[$key] = $val["fun"]; next($select); } } $lengths = array(); if ($_GET["modify"]) { foreach ($rows as $row) {
$rank = 1; foreach ($rows[0] as $key => $val) { if ($key != $oid) { $val = $_GET["columns"][key($select)]; $field = $fields[$select ? $val ? $val["col"] : current($select) : $key]; $name = $field ? $adminer->fieldName($field, $rank) : ($val["fun"] ? "*" : $key); if ($name != "") { $rank++; $names[$key] = $name; $column = idf_escape($key); $href = remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key); $desc = "&desc%5B0%5D=1"; echo '<th onmouseover="columnMouse(this);" onmouseout="columnMouse(this, \' hidden\');">'; echo '<a href="' . h($href . ($order[0] == $column || $order[0] == $key || !$order && $is_group && $group[0] == $column ? $desc : '')) . '">'; // $order[0] == $key - COUNT(*) echo apply_sql_function($val["fun"], $name) . "</a>"; //! columns looking like functions echo "<span class='column hidden'>"; echo "<a href='" . h($href . $desc) . "' title='" . lang('descending') . "' class='text'> ↓</a>"; if (!$val["fun"]) { echo '<a href="#fieldset-search" onclick="selectSearch(\'' . h(js_adminer_escape($key)) . '\'); return false;" title="' . lang('Search') . '" class="text jsonly"> =</a>'; } echo "</span>"; } $functions[$key] = $val["fun"]; next($select); } } $lengths = array(); if ($_GET["modify"]) { foreach ($rows as $row) {
/** Process columns box in select * @param array selectable columns * @param array * @return array (array(select_expressions), array(group_expressions)) */ function selectColumnsProcess($columns, $indexes) { global $functions, $grouping; $select = array(); // select expressions, empty for * $group = array(); // expressions without aggregation - will be used for GROUP BY if an aggregation function is used foreach ((array) $_GET["columns"] as $key => $val) { if ($val["fun"] == "count" || $val["col"] != "" && (!$val["fun"] || in_array($val["fun"], $functions) || in_array($val["fun"], $grouping))) { $select[$key] = apply_sql_function($val["fun"], $val["col"] != "" ? idf_escape($val["col"]) : "*"); if (!in_array($val["fun"], $grouping)) { $group[] = $select[$key]; } } } return array($select, $group); }
echo "<table cellspacing='0' class='nowrap checkable' onclick='tableClick(event);' onkeydown='return editingKeydown(event);'>\n"; echo "<thead><tr>" . (!$group && $select ? "" : "<td><input type='checkbox' id='all-page' onclick='formCheck(this, /check/);'> <a href='" . h($_GET["modify"] ? remove_from_uri("modify") : $_SERVER["REQUEST_URI"] . "&modify=1") . "'>" . lang('edit') . "</a>"); $names = array(); $functions = array(); reset($select); $rank = 1; foreach ($rows[0] as $key => $val) { if ($table_status["Oid"] != "t" || $key != "oid") { $val = $_GET["columns"][key($select)]; $field = $fields[$select ? $val ? $val["col"] : current($select) : $key]; $name = $field ? $adminer->fieldName($field, $rank) : "*"; if ($name != "") { $rank++; $names[$key] = $name; $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 && count($group) < count($select) && $group[0] == $column ? '&desc%5B0%5D=1' : '')) . '">' . (!$select || $val ? apply_sql_function($val["fun"], $name) : h(current($select))) . "</a>"; //! columns looking like functions } $functions[$key] = $val["fun"]; next($select); } } $lengths = array(); if ($_GET["modify"]) { foreach ($rows as $row) { foreach ($row as $key => $val) { $lengths[$key] = max($lengths[$key], min(40, strlen(utf8_decode($val)))); } } } echo ($backward_keys ? "<th>" . lang('Relations') : "") . "</thead>\n";