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 = ' ' . PMA_getImage('s_asc.png', __('Ascending'), array('class' => 'sort_arrow', 'title' => ''));
98 $order_img .= ' ' . PMA_getImage('s_desc.png', __('Descending'), array('class' => 'sort_arrow hide', 'title' => ''));
99 // but on mouse over, show the reverse order (DESC)
100 $order_link_params['onmouseover'] = "$('.sort_arrow').toggle();";
101 // on mouse out, show current sort order (ASC)
102 $order_link_params['onmouseout'] = "$('.sort_arrow').toggle();";
104 $future_sort_order = 'ASC';
105 // current sort order is DESC
106 $order_img = ' ' . PMA_getImage('s_asc.png', __('Ascending'), array('class' => 'sort_arrow hide', 'title' => ''));
107 $order_img .= ' ' . PMA_getImage('s_desc.png', __('Descending'), array('class' => 'sort_arrow', 'title' => ''));
108 // but on mouse over, show the reverse order (ASC)
109 $order_link_params['onmouseover'] = "$('.sort_arrow').toggle();";
110 // on mouse out, show current sort order (DESC)
111 $order_link_params['onmouseout'] = "$('.sort_arrow').toggle();";
115 $_url_params = array(
116 'db' => $_REQUEST['db'],
119 $url = 'db_structure.php'.PMA_generate_common_url($_url_params);
120 // We set the position back to 0 every time they sort.
121 $url .= "&pos=0&sort=$sort&sort_order=$future_sort_order";
123 return PMA_linkOrButton($url, $title . $order_img, $order_link_params);
124 } // end function PMA_SortableTableHeader()