Add OK and Cancel button for grid editing
[phpmyadmin/arisferyanto.git] / libraries / db_structure.lib.php
blobc70b6bf88f24ea8375e052d0e53d980ecff97cb0
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 * @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) {
24 $action_colspan = 3;
25 } else {
26 $action_colspan = 6;
29 echo '<table class="data">' . "\n"
30 .'<thead>' . "\n"
31 .'<tr><th></th>' . "\n"
32 .' <th>' . PMA_SortableTableHeader(__('Table'), 'table') . '</th>' . "\n";
33 if ($replication) {
34 echo ' <th>' . "\n"
35 .' ' . __('Replication') . "\n"
36 .' </th>';
38 echo ' <th colspan="' . $action_colspan . '">' . "\n"
39 .' ' . __('Action') . "\n"
40 .' </th>'
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"
44 .' </th>' . "\n";
45 if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
46 echo ' <th>' . PMA_SortableTableHeader(__('Type'), 'type') . '</th>' . "\n";
47 $cnt++;
48 echo ' <th>' . PMA_SortableTableHeader(__('Collation'), 'collation') . '</th>' . "\n";
49 $cnt++;
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";
56 $cnt += 2;
58 echo '</tr>' . "\n";
59 echo '</thead>' . "\n";
60 echo '<tbody>' . "\n";
61 $GLOBALS['colspan_for_structure'] = $cnt + $action_colspan + 3;
62 } // end function PMA_TableHeader()
65 /**
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')
75 // Set some defaults
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'];
88 $order_img = '';
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();";
103 } else {
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 .= "&amp;pos=0&amp;sort=$sort&amp;sort_order=$future_sort_order";
123 return PMA_linkOrButton($url, $title . $order_img, $order_link_params);
124 } // end function PMA_SortableTableHeader()