]> git.joonet.de Git - adminer.git/commitdiff
Descending order after second click on column caption
authorJakub Vrana <jakub@vrana.cz>
Thu, 9 Aug 2012 05:40:38 +0000 (22:40 -0700)
committerJakub Vrana <jakub@vrana.cz>
Thu, 9 Aug 2012 05:40:38 +0000 (22:40 -0700)
adminer/select.inc.php

index c429c34d0973505c40f8147dfac4a88c38feb33a..9a0a781f88fb01bda3433d90e8661f086afa0a3c 100644 (file)
@@ -273,11 +273,14 @@ if (!$columns) {
                                        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) . '">' . (!$select || $val ? apply_sql_function($val["fun"], $name) : h(current($select))) . "</a>"; //! columns looking like functions
+                                               echo '<a href="' . h($href . ($order[0] == $column || $order[0] == $key || (!$order && count($group) < count($select) && $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%5B0%5D=1") . "' title='" . lang('descending') . "' class='text'> ↓</a>";
+                                               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>';
                                                }