move functons from db_structure-lib script to strucure-lib file

This commit is contained in:
thilinaa 2012-08-10 21:56:57 +05:30
parent c47587d37a
commit 69ce9ac2c4
2 changed files with 172 additions and 1 deletions

View File

@ -128,7 +128,7 @@ echo $common_functions->getListNavigator(
<?php
echo PMA_generate_common_hidden_inputs($db);
PMA_TableHeader($db_is_information_schema, $server_slave_status);
echo PMA_TableHeader($db_is_information_schema, $server_slave_status);
$i = $sum_entries = 0;
$sum_size = (double) 0;

View File

@ -718,4 +718,175 @@ function PMA_getHtmlForRepairtable(
. __('in use')
. '</td>';
}
/**
* void PMA_TableHeader([bool $db_is_information_schema = false])
* display table header (<table><thead>...</thead><tbody>)
*
* @param boolean $db_is_information_schema
* @param boolean $replication
*/
function PMA_TableHeader($db_is_information_schema = false, $replication = false)
{
$cnt = 0; // Let's count the columns...
if ($db_is_information_schema) {
$action_colspan = 3;
} else {
$action_colspan = 6;
}
$html_output = '<table class="data">' . "\n"
.'<thead>' . "\n"
.'<tr><th></th>' . "\n"
.'<th>'
. PMA_SortableTableHeader(__('Table'), 'table')
. '</th>' . "\n";
if ($replication) {
$html_output .= '<th>' . "\n"
.' ' . __('Replication') . "\n"
.'</th>';
}
$html_output .= '<th colspan="' . $action_colspan . '">' . "\n"
.' ' . __('Action') . "\n"
.'</th>'
// larger values are more interesting so default sort order is DESC
.'<th>' . PMA_SortableTableHeader(__('Rows'), 'records', 'DESC')
. PMA_CommonFunctions::getInstance()->showHint(
PMA_sanitize(
__('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]')
)
) . "\n"
.'</th>' . "\n";
if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
$html_output .= '<th>' . PMA_SortableTableHeader(__('Type'), 'type')
. '</th>' . "\n";
$cnt++;
$html_output .= '<th>'
. PMA_SortableTableHeader(__('Collation'), 'collation')
. '</th>' . "\n";
$cnt++;
}
if ($GLOBALS['is_show_stats']) {
// larger values are more interesting so default sort order is DESC
$html_output .= '<th>'
. PMA_SortableTableHeader(__('Size'), 'size', 'DESC')
. '</th>' . "\n"
// larger values are more interesting so default sort order is DESC
. '<th>'
. PMA_SortableTableHeader(__('Overhead'), 'overhead', 'DESC')
. '</th>' . "\n";
$cnt += 2;
}
if ($GLOBALS['cfg']['ShowDbStructureCreation']) {
// larger values are more interesting so default sort order is DESC
$html_output .= '<th>'
. PMA_SortableTableHeader(__('Creation'), 'creation', 'DESC')
. '</th>' . "\n";
$cnt += 2;
}
if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
// larger values are more interesting so default sort order is DESC
$html_output .= '<th>'
. PMA_SortableTableHeader(__('Last update'), 'last_update', 'DESC')
. '</th>' . "\n";
$cnt += 2;
}
if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
// larger values are more interesting so default sort order is DESC
$html_output .= '<th>'
. PMA_SortableTableHeader(__('Last check'), 'last_check', 'DESC')
. '</th>' . "\n";
$cnt += 2;
}
$html_output .= '</tr>' . "\n";
$html_output .= '</thead>' . "\n";
$html_output .= '<tbody>' . "\n";
$GLOBALS['colspan_for_structure'] = $cnt + $action_colspan + 3;
return $html_output;
}
/**
* Creates a clickable column header for table information
*
* @param string $title title to use for the link
* @param string $sort corresponds to sortable data name mapped in
* libraries/db_info.inc.php
* @param string $initial_sort_order initial sort order
*
* @return string link to be displayed in the table header
*/
function PMA_SortableTableHeader($title, $sort, $initial_sort_order = 'ASC')
{
$common_functions = PMA_CommonFunctions::getInstance();
// Set some defaults
$requested_sort = 'table';
$requested_sort_order = $future_sort_order = $initial_sort_order;
// If the user requested a sort
if (isset($_REQUEST['sort'])) {
$requested_sort = $_REQUEST['sort'];
if (isset($_REQUEST['sort_order'])) {
$requested_sort_order = $_REQUEST['sort_order'];
}
}
$order_img = '';
$order_link_params = array();
$order_link_params['title'] = __('Sort');
// If this column was requested to be sorted.
if ($requested_sort == $sort) {
if ($requested_sort_order == 'ASC') {
$future_sort_order = 'DESC';
// current sort order is ASC
$order_img = ' ' . $common_functions->getImage(
's_asc.png',
__('Ascending'),
array('class' => 'sort_arrow', 'title' => '')
);
$order_img .= ' ' . $common_functions->getImage(
's_desc.png',
__('Descending'),
array('class' => 'sort_arrow hide', 'title' => '')
);
// but on mouse over, show the reverse order (DESC)
$order_link_params['onmouseover'] = "$('.sort_arrow').toggle();";
// on mouse out, show current sort order (ASC)
$order_link_params['onmouseout'] = "$('.sort_arrow').toggle();";
} else {
$future_sort_order = 'ASC';
// current sort order is DESC
$order_img = ' ' . $common_functions->getImage(
's_asc.png',
__('Ascending'),
array('class' => 'sort_arrow hide', 'title' => '')
);
$order_img .= ' ' . $common_functions->getImage(
's_desc.png',
__('Descending'),
array('class' => 'sort_arrow', 'title' => '')
);
// but on mouse over, show the reverse order (ASC)
$order_link_params['onmouseover'] = "$('.sort_arrow').toggle();";
// on mouse out, show current sort order (DESC)
$order_link_params['onmouseout'] = "$('.sort_arrow').toggle();";
}
}
$_url_params = array(
'db' => $_REQUEST['db'],
);
$url = 'db_structure.php'.PMA_generate_common_url($_url_params);
// We set the position back to 0 every time they sort.
$url .= "&amp;pos=0&amp;sort=$sort&amp;sort_order=$future_sort_order";
return PMA_CommonFunctions::getInstance()->linkOrButton(
$url, $title . $order_img, $order_link_params
);
}
?>