Translation update done using Pootle.
[phpmyadmin/dkf.git] / libraries / db_structure.lib.php
blob7a6dff7d83002bcd9669ea5b5901afa77b282d01
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 * @package phpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 // Display function
13 /**
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']
20 * @uses __('Table')
21 * @uses __('Action')
22 * @uses __('Records')
23 * @uses __('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]')
24 * @uses __('Type')
25 * @uses __('Collation')
26 * @uses __('Size')
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) {
38 $action_colspan = 3;
39 } else {
40 $action_colspan = 6;
43 echo '<table class="data" style="float: left;">' . "\n"
44 .'<thead>' . "\n"
45 .'<tr><th></th>' . "\n"
46 .' <th>' . PMA_SortableTableHeader(__('Table'), 'table') . '</th>' . "\n";
47 if ($replication) {
48 echo ' <th>' . "\n"
49 .' ' . __('Replication') . "\n"
50 .' </th>';
52 echo ' <th colspan="' . $action_colspan . '">' . "\n"
53 .' ' . __('Action') . "\n"
54 .' </th>'
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"
58 .' </th>' . "\n";
59 if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
60 echo ' <th>' . PMA_SortableTableHeader(__('Type'), 'type') . '</th>' . "\n";
61 $cnt++;
62 echo ' <th>' . PMA_SortableTableHeader(__('Collation'), 'collation') . '</th>' . "\n";
63 $cnt++;
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";
70 $cnt += 2;
72 echo '</tr>' . "\n";
73 echo '</thead>' . "\n";
74 echo '<tbody>' . "\n";
75 $GLOBALS['colspan_for_structure'] = $cnt + $action_colspan + 3;
76 } // end function PMA_TableHeader()
79 /**
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')
89 // Set some defaults
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'];
102 $order_img = '';
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\'; }';
116 } else {
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 .= "&amp;pos=0&amp;sort=$sort&amp;sort_order=$future_sort_order";
135 return PMA_linkOrButton($url, $title . $order_img, $order_link_params);
136 } // end function PMA_SortableTableHeader()