From 95372a094fd9e02f59215b5dc101b8bc32ed1637 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 27 May 2009 17:29:08 +0000 Subject: [PATCH] bug #2794840 [core] Cannot redeclare pma_tableheader() --- ChangeLog | 1 + db_structure.php | 120 +++----------------------------- libraries/db_structure.lib.php | 121 +++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+), 110 deletions(-) create mode 100644 libraries/db_structure.lib.php diff --git a/ChangeLog b/ChangeLog index 0fca010ff..2b4fb98f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA 3.3.0.0 (not yet released) + patch #2794819 [navi] Filter for displayed table names, thanks to Michael Valushko - dylfin +- bug #2794840 [core] Cannot redeclare pma_tableheader() 3.2.0.0 (not yet released) - [core] better support for vendor customisation (based on what Debian needs) diff --git a/db_structure.php b/db_structure.php index f2a246a55..07218a5cf 100644 --- a/db_structure.php +++ b/db_structure.php @@ -24,7 +24,14 @@ if (empty($is_info)) { || isset($mult_btn)) { $action = 'db_structure.php'; $err_url = 'db_structure.php?'. PMA_generate_common_url($db); - require './libraries/mult_submits.inc.php'; + + // see bug #2794840; in this case, code path is: + // db_structure.php -> libraries/mult_submits.inc.php -> sql.php + // -> db_structure.php and if we got an error on the multi submit, + // we must display it here and not call again mult_submits.inc.php + if (!$error) { + require './libraries/mult_submits.inc.php'; + } if (empty($message)) { $message = PMA_Message::success(); } @@ -60,115 +67,8 @@ require_once './libraries/bookmark.lib.php'; require_once './libraries/mysql_charsets.lib.php'; $db_collation = PMA_getDbCollation($db); -// Display function -/** - * void PMA_TableHeader([bool $db_is_information_schema = false]) - * display table header (...) - * - * @uses PMA_showHint() - * @uses $GLOBALS['cfg']['PropertiesNumColumns'] - * @uses $GLOBALS['is_show_stats'] - * @uses $GLOBALS['strTable'] - * @uses $GLOBALS['strAction'] - * @uses $GLOBALS['strRecords'] - * @uses $GLOBALS['strApproximateCount'] - * @uses $GLOBALS['strType'] - * @uses $GLOBALS['strCollation'] - * @uses $GLOBALS['strSize'] - * @uses $GLOBALS['strOverhead'] - * @uses $GLOBALS['structure_tbl_col_cnt'] - * @uses PMA_SortableTableHeader() - * @param boolean $db_is_information_schema - */ -function PMA_TableHeader($db_is_information_schema = false) -{ - $cnt = 0; // Let's count the columns... - - if ($db_is_information_schema) { - $action_colspan = 3; - } else { - $action_colspan = 6; - } - - echo '
' . "\n" - .'' . "\n" - .'' . "\n" - .' ' . "\n" - .' ' - .' ' . "\n"; - if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) { - echo ' ' . "\n"; - $cnt++; - echo ' ' . "\n"; - $cnt++; - } - if ($GLOBALS['is_show_stats']) { - echo ' ' . "\n" - . ' ' . "\n"; - $cnt += 2; - } - echo '' . "\n"; - echo '' . "\n"; - echo '' . "\n"; - $GLOBALS['structure_tbl_col_cnt'] = $cnt + $action_colspan + 3; -} // end function PMA_TableHeader() - - -/** - * Creates a clickable column header for table information - * - * @param string title to use for the link - * @param string corresponds to sortable data name mapped in libraries/db_info.inc.php - * @returns string link to be displayed in the table header - */ -function PMA_SortableTableHeader($title, $sort) -{ - // Set some defaults - $requested_sort = 'table'; - $requested_sort_order = 'ASC'; - $sort_order = 'ASC'; - - // 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'] = $GLOBALS['strSort']; - - // If this column was requested to be sorted. - if ($requested_sort == $sort) { - if ($requested_sort_order == 'ASC') { - $sort_order = 'DESC'; - $order_img = ' '. $GLOBALS['strDescending'] . ''; - $order_link_params['onmouseover'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }'; - $order_link_params['onmouseout'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }'; - } else { - $order_img = ' '. $GLOBALS['strAscending'] . ''; - $order_link_params['onmouseover'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }'; - $order_link_params['onmouseout'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }'; - } - } - - $_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 .= "&pos=0&sort=$sort&sort_order=$sort_order"; - - return PMA_linkOrButton($url, $title . $order_img, $order_link_params); -} +// in a separate file to avoid redeclaration of functions in some code paths +require_once './libraries/db_structure.lib.php'; $titles = array(); if (true == $cfg['PropertiesIconic']) { diff --git a/libraries/db_structure.lib.php b/libraries/db_structure.lib.php new file mode 100644 index 000000000..3542e1aee --- /dev/null +++ b/libraries/db_structure.lib.php @@ -0,0 +1,121 @@ +...) + * + * @uses PMA_showHint() + * @uses $GLOBALS['cfg']['PropertiesNumColumns'] + * @uses $GLOBALS['is_show_stats'] + * @uses $GLOBALS['strTable'] + * @uses $GLOBALS['strAction'] + * @uses $GLOBALS['strRecords'] + * @uses $GLOBALS['strApproximateCount'] + * @uses $GLOBALS['strType'] + * @uses $GLOBALS['strCollation'] + * @uses $GLOBALS['strSize'] + * @uses $GLOBALS['strOverhead'] + * @uses $GLOBALS['structure_tbl_col_cnt'] + * @uses PMA_SortableTableHeader() + * @param boolean $db_is_information_schema + */ +function PMA_TableHeader($db_is_information_schema = false) +{ + $cnt = 0; // Let's count the columns... + + if ($db_is_information_schema) { + $action_colspan = 3; + } else { + $action_colspan = 6; + } + + echo '
' . PMA_SortableTableHeader($GLOBALS['strTable'], 'table') . '' . "\n" - .' ' . $GLOBALS['strAction'] . "\n" - .' ' . PMA_SortableTableHeader($GLOBALS['strRecords'], 'records') - .PMA_showHint(PMA_sanitize($GLOBALS['strApproximateCount'])) . "\n" - .' ' . PMA_SortableTableHeader($GLOBALS['strType'], 'type') . '' . PMA_SortableTableHeader($GLOBALS['strCollation'], 'collation') . '' . PMA_SortableTableHeader($GLOBALS['strSize'], 'size') . '' . PMA_SortableTableHeader($GLOBALS['strOverhead'], 'overhead') . '
' . "\n" + .'' . "\n" + .'' . "\n" + .' ' . "\n" + .' ' + .' ' . "\n"; + if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) { + echo ' ' . "\n"; + $cnt++; + echo ' ' . "\n"; + $cnt++; + } + if ($GLOBALS['is_show_stats']) { + echo ' ' . "\n" + . ' ' . "\n"; + $cnt += 2; + } + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + $GLOBALS['structure_tbl_col_cnt'] = $cnt + $action_colspan + 3; +} // end function PMA_TableHeader() + + +/** + * Creates a clickable column header for table information + * + * @param string title to use for the link + * @param string corresponds to sortable data name mapped in libraries/db_info.inc.php + * @returns string link to be displayed in the table header + */ +function PMA_SortableTableHeader($title, $sort) +{ + // Set some defaults + $requested_sort = 'table'; + $requested_sort_order = 'ASC'; + $sort_order = 'ASC'; + + // 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'] = $GLOBALS['strSort']; + + // If this column was requested to be sorted. + if ($requested_sort == $sort) { + if ($requested_sort_order == 'ASC') { + $sort_order = 'DESC'; + $order_img = ' '. $GLOBALS['strDescending'] . ''; + $order_link_params['onmouseover'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }'; + $order_link_params['onmouseout'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }'; + } else { + $order_img = ' '. $GLOBALS['strAscending'] . ''; + $order_link_params['onmouseover'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }'; + $order_link_params['onmouseout'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }'; + } + } + + $_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 .= "&pos=0&sort=$sort&sort_order=$sort_order"; + + return PMA_linkOrButton($url, $title . $order_img, $order_link_params); +} // end function PMA_SortableTableHeader() +?>
' . PMA_SortableTableHeader($GLOBALS['strTable'], 'table') . '' . "\n" + .' ' . $GLOBALS['strAction'] . "\n" + .' ' . PMA_SortableTableHeader($GLOBALS['strRecords'], 'records') + .PMA_showHint(PMA_sanitize($GLOBALS['strApproximateCount'])) . "\n" + .' ' . PMA_SortableTableHeader($GLOBALS['strType'], 'type') . '' . PMA_SortableTableHeader($GLOBALS['strCollation'], 'collation') . '' . PMA_SortableTableHeader($GLOBALS['strSize'], 'size') . '' . PMA_SortableTableHeader($GLOBALS['strOverhead'], 'overhead') . '