2 /* vim: set expandtab sw=4 ts=4 sts=4: */
7 if (! defined('PHPMYADMIN')) {
13 * void PMA_TableHeader([bool $db_is_information_schema = false])
14 * display table header (<table><thead>...</thead><tbody>)
16 * @param boolean $db_is_information_schema
17 * @param boolean $replication
19 function PMA_TableHeader($db_is_information_schema = false, $replication = false)
21 $cnt = 0; // Let's count the columns...
23 if ($db_is_information_schema) {
29 echo '<table class="data">' . "\n"
31 .'<tr><th></th>' . "\n"
32 .' <th>' . PMA_SortableTableHeader(__('Table'), 'table') . '</th>' . "\n";
35 .' ' . __('Replication') . "\n"
38 echo ' <th colspan="' . $action_colspan . '">' . "\n"
39 .' ' . __('Action') . "\n"
41 // larger values are more interesting so default sort order is DESC
42 .' <th>' . PMA_SortableTableHeader(__('Rows'), 'records', 'DESC')
43 .PMA_showHint(PMA_sanitize(__('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]'))) . "\n"
45 if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
46 echo ' <th>' . PMA_SortableTableHeader(__('Type'), 'type') . '</th>' . "\n";
48 echo ' <th>' . PMA_SortableTableHeader(__('Collation'), 'collation') . '</th>' . "\n";
51 if ($GLOBALS['is_show_stats']) {
52 // larger values are more interesting so default sort order is DESC
53 echo ' <th>' . PMA_SortableTableHeader(__('Size'), 'size', 'DESC') . '</th>' . "\n"
54 // larger values are more interesting so default sort order is DESC
55 . ' <th>' . PMA_SortableTableHeader(__('Overhead'), 'overhead', 'DESC') . '</th>' . "\n";
59 echo '</thead>' . "\n";
60 echo '<tbody>' . "\n";
61 $GLOBALS['colspan_for_structure'] = $cnt +
$action_colspan +
3;
62 } // end function PMA_TableHeader()
66 * Creates a clickable column header for table information
68 * @param string $title title to use for the link
69 * @param string $sort corresponds to sortable data name mapped in libraries/db_info.inc.php
70 * @param string $initial_sort_order
71 * @return string link to be displayed in the table header
73 function PMA_SortableTableHeader($title, $sort, $initial_sort_order = 'ASC')
76 $requested_sort = 'table';
77 $requested_sort_order = $future_sort_order = $initial_sort_order;
79 // If the user requested a sort
80 if (isset($_REQUEST['sort'])) {
81 $requested_sort = $_REQUEST['sort'];
83 if (isset($_REQUEST['sort_order'])) {
84 $requested_sort_order = $_REQUEST['sort_order'];
89 $order_link_params = array();
90 $order_link_params['title'] = __('Sort');
92 // If this column was requested to be sorted.
93 if ($requested_sort == $sort) {
94 if ($requested_sort_order == 'ASC') {
95 $future_sort_order = 'DESC';
96 // current sort order is ASC
97 $order_img = ' <img class="icon ic_s_asc" src="themes/dot.gif" alt="'. __('Ascending') . '" title="'. __('Ascending') . '" id="sort_arrow" />';
98 // but on mouse over, show the reverse order (DESC)
99 $order_link_params['onmouseover'] = 'if ($(\'#sort_arrow\').length > 0) { $(\'#sort_arrow\').attr(\'class\',\'icon ic_s_desc\'); }';
100 // on mouse out, show current sort order (ASC)
101 $order_link_params['onmouseout'] = 'if ($(\'#sort_arrow\').length > 0) { $(\'#sort_arrow\').attr(\'class\',\'icon ic_s_asc\'); }';
103 $future_sort_order = 'ASC';
104 // current sort order is DESC
105 $order_img = ' <img class="icon ic_s_desc" src="themes/dot.gif" alt="'. __('Descending') . '" title="'. __('Descending') . '" id="sort_arrow" />';
106 // but on mouse over, show the reverse order (ASC)
107 $order_link_params['onmouseover'] = 'if ($(\'#sort_arrow\').length > 0) { $(\'#sort_arrow\').attr(\'class\',\'icon ic_s_asc\'); }';
108 // on mouse out, show current sort order (DESC)
109 $order_link_params['onmouseout'] = 'if ($(\'#sort_arrow\').length > 0) { $(\'#sort_arrow\').attr(\'class\',\'icon ic_s_desc\'); }';
113 $_url_params = array(
114 'db' => $_REQUEST['db'],
117 $url = 'db_structure.php'.PMA_generate_common_url($_url_params);
118 // We set the position back to 0 every time they sort.
119 $url .= "&pos=0&sort=$sort&sort_order=$future_sort_order";
121 return PMA_linkOrButton($url, $title . $order_img, $order_link_params);
122 } // end function PMA_SortableTableHeader()