Translation update done using Pootle.
[phpmyadmin-themes.git] / libraries / db_structure.lib.php
blob6f91d448c85856e04b0caba8ec5541c43a00aea4
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
7 if (! defined('PHPMYADMIN')) {
8 exit;
11 // Display function
12 /**
13 * void PMA_TableHeader([bool $db_is_information_schema = false])
14 * display table header (<table><thead>...</thead><tbody>)
16 * @uses PMA_showHint()
17 * @uses $GLOBALS['cfg']['PropertiesNumColumns']
18 * @uses $GLOBALS['is_show_stats']
19 * @uses $GLOBALS['colspan_for_structure']
20 * @uses PMA_SortableTableHeader()
21 * @param boolean $db_is_information_schema
22 * @param boolean $replication
24 function PMA_TableHeader($db_is_information_schema = false, $replication = false)
26 $cnt = 0; // Let's count the columns...
28 if ($db_is_information_schema) {
29 $action_colspan = 3;
30 } else {
31 $action_colspan = 6;
34 echo '<table class="data" style="float: left;">' . "\n"
35 .'<thead>' . "\n"
36 .'<tr><th></th>' . "\n"
37 .' <th>' . PMA_SortableTableHeader(__('Table'), 'table') . '</th>' . "\n";
38 if ($replication) {
39 echo ' <th>' . "\n"
40 .' ' . __('Replication') . "\n"
41 .' </th>';
43 echo ' <th colspan="' . $action_colspan . '">' . "\n"
44 .' ' . __('Action') . "\n"
45 .' </th>'
46 // larger values are more interesting so default sort order is DESC
47 .' <th>' . PMA_SortableTableHeader(__('Rows'), 'records', 'DESC')
48 .PMA_showHint(PMA_sanitize(__('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]'))) . "\n"
49 .' </th>' . "\n";
50 if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
51 echo ' <th>' . PMA_SortableTableHeader(__('Type'), 'type') . '</th>' . "\n";
52 $cnt++;
53 echo ' <th>' . PMA_SortableTableHeader(__('Collation'), 'collation') . '</th>' . "\n";
54 $cnt++;
56 if ($GLOBALS['is_show_stats']) {
57 // larger values are more interesting so default sort order is DESC
58 echo ' <th>' . PMA_SortableTableHeader(__('Size'), 'size', 'DESC') . '</th>' . "\n"
59 // larger values are more interesting so default sort order is DESC
60 . ' <th>' . PMA_SortableTableHeader(__('Overhead'), 'overhead', 'DESC') . '</th>' . "\n";
61 $cnt += 2;
63 echo '</tr>' . "\n";
64 echo '</thead>' . "\n";
65 echo '<tbody>' . "\n";
66 $GLOBALS['colspan_for_structure'] = $cnt + $action_colspan + 3;
67 } // end function PMA_TableHeader()
70 /**
71 * Creates a clickable column header for table information
73 * @param string title to use for the link
74 * @param string corresponds to sortable data name mapped in libraries/db_info.inc.php
75 * @param string initial sort order
76 * @returns string link to be displayed in the table header
78 function PMA_SortableTableHeader($title, $sort, $initial_sort_order = 'ASC')
80 // Set some defaults
81 $requested_sort = 'table';
82 $requested_sort_order = $future_sort_order = $initial_sort_order;
84 // If the user requested a sort
85 if (isset($_REQUEST['sort'])) {
86 $requested_sort = $_REQUEST['sort'];
88 if (isset($_REQUEST['sort_order'])) {
89 $requested_sort_order = $_REQUEST['sort_order'];
93 $order_img = '';
94 $order_link_params = array();
95 $order_link_params['title'] = __('Sort');
97 // If this column was requested to be sorted.
98 if ($requested_sort == $sort) {
99 if ($requested_sort_order == 'ASC') {
100 $future_sort_order = 'DESC';
101 // current sort order is ASC
102 $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="'. __('Ascending') . '" title="'. __('Ascending') . '" id="sort_arrow" />';
103 // but on mouse over, show the reverse order (DESC)
104 $order_link_params['onmouseover'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
105 // on mouse out, show current sort order (ASC)
106 $order_link_params['onmouseout'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
107 } else {
108 $future_sort_order = 'ASC';
109 // current sort order is DESC
110 $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_desc.png" width="11" height="9" alt="'. __('Descending') . '" title="'. __('Descending') . '" id="sort_arrow" />';
111 // but on mouse over, show the reverse order (ASC)
112 $order_link_params['onmouseover'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
113 // on mouse out, show current sort order (DESC)
114 $order_link_params['onmouseout'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
118 $_url_params = array(
119 'db' => $_REQUEST['db'],
122 $url = 'db_structure.php'.PMA_generate_common_url($_url_params);
123 // We set the position back to 0 every time they sort.
124 $url .= "&amp;pos=0&amp;sort=$sort&amp;sort_order=$future_sort_order";
126 return PMA_linkOrButton($url, $title . $order_img, $order_link_params);
127 } // end function PMA_SortableTableHeader()