2 /* vim: set expandtab sw=4 ts=4 sts=4: */
8 if (! defined('PHPMYADMIN')) {
14 * void PMA_TableHeader([bool $db_is_information_schema = false])
15 * display table header (<table><thead>...</thead><tbody>)
17 * @uses PMA_showHint()
18 * @uses $GLOBALS['cfg']['PropertiesNumColumns']
19 * @uses $GLOBALS['is_show_stats']
23 * @uses __('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]')
25 * @uses __('Collation')
27 * @uses __('Overhead')
28 * @uses $GLOBALS['colspan_for_structure']
29 * @uses PMA_SortableTableHeader()
30 * @param boolean $db_is_information_schema
31 * @param boolean $replication
33 function PMA_TableHeader($db_is_information_schema = false, $replication = false)
35 $cnt = 0; // Let's count the columns...
37 if ($db_is_information_schema) {
43 echo '<table class="data" style="float: left;">' . "\n"
45 .'<tr><th></th>' . "\n"
46 .' <th>' . PMA_SortableTableHeader(__('Table'), 'table') . '</th>' . "\n";
49 .' ' . __('Replication') . "\n"
52 echo ' <th colspan="' . $action_colspan . '">' . "\n"
53 .' ' . __('Action') . "\n"
55 // larger values are more interesting so default sort order is DESC
56 .' <th>' . PMA_SortableTableHeader(__('Records'), 'records', 'DESC')
57 .PMA_showHint(PMA_sanitize(__('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]'))) . "\n"
59 if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
60 echo ' <th>' . PMA_SortableTableHeader(__('Type'), 'type') . '</th>' . "\n";
62 echo ' <th>' . PMA_SortableTableHeader(__('Collation'), 'collation') . '</th>' . "\n";
65 if ($GLOBALS['is_show_stats']) {
66 // larger values are more interesting so default sort order is DESC
67 echo ' <th>' . PMA_SortableTableHeader(__('Size'), 'size', 'DESC') . '</th>' . "\n"
68 // larger values are more interesting so default sort order is DESC
69 . ' <th>' . PMA_SortableTableHeader(__('Overhead'), 'overhead', 'DESC') . '</th>' . "\n";
73 echo '</thead>' . "\n";
74 echo '<tbody>' . "\n";
75 $GLOBALS['colspan_for_structure'] = $cnt +
$action_colspan +
3;
76 } // end function PMA_TableHeader()
80 * Creates a clickable column header for table information
82 * @param string title to use for the link
83 * @param string corresponds to sortable data name mapped in libraries/db_info.inc.php
84 * @param string initial sort order
85 * @returns string link to be displayed in the table header
87 function PMA_SortableTableHeader($title, $sort, $initial_sort_order = 'ASC')
90 $requested_sort = 'table';
91 $requested_sort_order = $future_sort_order = $initial_sort_order;
93 // If the user requested a sort
94 if (isset($_REQUEST['sort'])) {
95 $requested_sort = $_REQUEST['sort'];
97 if (isset($_REQUEST['sort_order'])) {
98 $requested_sort_order = $_REQUEST['sort_order'];
103 $order_link_params = array();
104 $order_link_params['title'] = __('Sort');
106 // If this column was requested to be sorted.
107 if ($requested_sort == $sort) {
108 if ($requested_sort_order == 'ASC') {
109 $future_sort_order = 'DESC';
110 // current sort order is ASC
111 $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="'. __('Ascending') . '" title="'. __('Ascending') . '" id="sort_arrow" />';
112 // but on mouse over, show the reverse order (DESC)
113 $order_link_params['onmouseover'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
114 // on mouse out, show current sort order (ASC)
115 $order_link_params['onmouseout'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
117 $future_sort_order = 'ASC';
118 // current sort order is DESC
119 $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_desc.png" width="11" height="9" alt="'. __('Descending') . '" title="'. __('Descending') . '" id="sort_arrow" />';
120 // but on mouse over, show the reverse order (ASC)
121 $order_link_params['onmouseover'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
122 // on mouse out, show current sort order (DESC)
123 $order_link_params['onmouseout'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
127 $_url_params = array(
128 'db' => $_REQUEST['db'],
131 $url = 'db_structure.php'.PMA_generate_common_url($_url_params);
132 // We set the position back to 0 every time they sort.
133 $url .= "&pos=0&sort=$sort&sort_order=$future_sort_order";
135 return PMA_linkOrButton($url, $title . $order_img, $order_link_params);
136 } // end function PMA_SortableTableHeader()