From 7245a3bf4d8edc924c26702ee019e14dae8bd50a Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Mon, 30 Apr 2012 22:02:01 +0100 Subject: [PATCH 01/15] Initial refactoring of the generation of the top menu --- libraries/Menu.class.php | 318 +++++++++++++++++++++++++++++++++ libraries/db_links.inc.php | 139 -------------- libraries/header.inc.php | 4 + libraries/server_links.inc.php | 108 ----------- libraries/tbl_links.inc.php | 94 ---------- 5 files changed, 322 insertions(+), 341 deletions(-) create mode 100644 libraries/Menu.class.php diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php new file mode 100644 index 0000000000..16c6b0ddf6 --- /dev/null +++ b/libraries/Menu.class.php @@ -0,0 +1,318 @@ +server = $server; + $this->db = $db; + $this->table = $table; + $this->is_superuser = PMA_isSuperuser(); + + if (! $GLOBALS['is_ajax_request']) { + echo $this->getMenu(); + if (! empty($GLOBALS['message'])) { + PMA_showMessage($GLOBALS['message']); + unset($GLOBALS['message']); + } + } else { + // nothing for now + } + } + + private function getMenu() + { + $tabs = ''; + $url_params = array('db' => $this->db); + if (strlen($this->table)) { + $tabs = $this->getTableTabs(); + $url_params['table'] = $this->table; + } else if (strlen($this->db)) { + $tabs = $this->getDbTabs(); + } else { + $tabs = $this->getServerTabs(); + } + return PMA_generate_html_tabs($tabs, $url_params); + } + + private function getTableTabs() + { + $db_is_information_schema = PMA_is_system_schema($this->db); + $tbl_is_view = PMA_Table::isView($this->db, $this->table); + $table_status = PMA_Table::sGetStatusInfo($this->db, $this->table); + $table_info_num_rows = isset($table_status['Rows']) ? $table_status['Rows'] : 0; + + $tabs = array(); + + $tabs['browse']['icon'] = 'b_browse.png'; + $tabs['browse']['text'] = __('Browse'); + $tabs['browse']['link'] = 'sql.php'; + $tabs['browse']['args']['pos'] = 0; + + $tabs['structure']['icon'] = 'b_props.png'; + $tabs['structure']['link'] = 'tbl_structure.php'; + $tabs['structure']['text'] = __('Structure'); + + $tabs['sql']['icon'] = 'b_sql.png'; + $tabs['sql']['link'] = 'tbl_sql.php'; + $tabs['sql']['text'] = __('SQL'); + + $tabs['search']['icon'] = 'b_search.png'; + $tabs['search']['text'] = __('Search'); + $tabs['search']['link'] = 'tbl_select.php'; + + if (!$db_is_information_schema) { + $tabs['insert']['icon'] = 'b_insrow.png'; + $tabs['insert']['link'] = 'tbl_change.php'; + $tabs['insert']['text'] = __('Insert'); + } + + $tabs['export']['icon'] = 'b_tblexport.png'; + $tabs['export']['link'] = 'tbl_export.php'; + $tabs['export']['args']['single_table'] = 'true'; + $tabs['export']['text'] = __('Export'); + + /** + * Don't display "Import" and "Operations" + * for views and information_schema + */ + if (! $tbl_is_view && !$db_is_information_schema) { + $tabs['import']['icon'] = 'b_tblimport.png'; + $tabs['import']['link'] = 'tbl_import.php'; + $tabs['import']['text'] = __('Import'); + + $tabs['operation']['icon'] = 'b_tblops.png'; + $tabs['operation']['link'] = 'tbl_operations.php'; + $tabs['operation']['text'] = __('Operations'); + } + if (PMA_Tracker::isActive()) { + $tabs['tracking']['icon'] = 'eye.png'; + $tabs['tracking']['text'] = __('Tracking'); + $tabs['tracking']['link'] = 'tbl_tracking.php'; + } + if (!$db_is_information_schema && !PMA_DRIZZLE) { + if (PMA_currentUserHasPrivilege('TRIGGER', $this->db, $this->table) && ! $tbl_is_view) { + $tabs['triggers']['link'] = 'tbl_triggers.php'; + $tabs['triggers']['text'] = __('Triggers'); + $tabs['triggers']['icon'] = 'b_triggers.png'; + } + } + + /** + * Views support a limited number of operations + */ + if ($tbl_is_view && !$db_is_information_schema) { + $tabs['operation']['icon'] = 'b_tblops.png'; + $tabs['operation']['link'] = 'view_operations.php'; + $tabs['operation']['text'] = __('Operations'); + } + + if ($table_info_num_rows == 0 && !$tbl_is_view) { + $tabs['browse']['warning'] = __('Table seems to be empty!'); + $tabs['search']['warning'] = __('Table seems to be empty!'); + } + return $tabs; + } + + private function getDbTabs() + { + $db_is_information_schema = PMA_is_system_schema($this->db); + $num_tables = count(PMA_DBI_get_tables($this->db)); + /** + * Gets the relation settings + */ + $cfgRelation = PMA_getRelationsParam(); + + /** + * export, search and qbe links if there is at least one table + */ + if ($num_tables == 0) { + $tab_qbe['warning'] = __('Database seems to be empty!'); + $tab_search['warning'] = __('Database seems to be empty!'); + $tab_export['warning'] = __('Database seems to be empty!'); + } + + $tab_structure['link'] = 'db_structure.php'; + $tab_structure['text'] = __('Structure'); + $tab_structure['icon'] = 'b_props.png'; + + $tab_sql['link'] = 'db_sql.php'; + $tab_sql['args']['db_query_force'] = 1; + $tab_sql['text'] = __('SQL'); + $tab_sql['icon'] = 'b_sql.png'; + + $tab_export['text'] = __('Export'); + $tab_export['icon'] = 'b_export.png'; + $tab_export['link'] = 'db_export.php'; + + $tab_search['text'] = __('Search'); + $tab_search['icon'] = 'b_search.png'; + $tab_search['link'] = 'db_search.php'; + + if (PMA_Tracker::isActive()) { + $tab_tracking['text'] = __('Tracking'); + $tab_tracking['icon'] = 'eye.png'; + $tab_tracking['link'] = 'db_tracking.php'; + } + + $tab_qbe['text'] = __('Query'); + $tab_qbe['icon'] = 's_db.png'; + $tab_qbe['link'] = 'db_qbe.php'; + + if ($cfgRelation['designerwork']) { + $tab_designer['text'] = __('Designer'); + $tab_designer['icon'] = 'b_relations.png'; + $tab_designer['link'] = 'pmd_general.php'; + } + + if (! $db_is_information_schema) { + $tab_import['link'] = 'db_import.php'; + $tab_import['text'] = __('Import'); + $tab_import['icon'] = 'b_import.png'; + $tab_operation['link'] = 'db_operations.php'; + $tab_operation['text'] = __('Operations'); + $tab_operation['icon'] = 'b_tblops.png'; + if ($this->is_superuser && !PMA_DRIZZLE) { + $tab_privileges['link'] = 'server_privileges.php'; + $tab_privileges['args']['checkprivs'] = $this->db; + // stay on database view + $tab_privileges['args']['viewing_mode'] = 'db'; + $tab_privileges['text'] = __('Privileges'); + $tab_privileges['icon'] = 's_rights.png'; + } + $tab_routines['link'] = 'db_routines.php'; + $tab_routines['text'] = __('Routines'); + $tab_routines['icon'] = 'b_routines.png'; + + $tab_events['link'] = 'db_events.php'; + $tab_events['text'] = __('Events'); + $tab_events['icon'] = 'b_events.png'; + + $tab_triggers['link'] = 'db_triggers.php'; + $tab_triggers['text'] = __('Triggers'); + $tab_triggers['icon'] = 'b_triggers.png'; + } + + /** + * Displays tab links + */ + $tabs = array(); + $tabs[] =& $tab_structure; + $tabs[] =& $tab_sql; + $tabs[] =& $tab_search; + $tabs[] =& $tab_qbe; + $tabs[] =& $tab_export; + if (! $db_is_information_schema) { + $tabs[] =& $tab_import; + $tabs[] =& $tab_operation; + if ($this->is_superuser && !PMA_DRIZZLE) { + $tabs[] =& $tab_privileges; + } + if (!PMA_DRIZZLE) { + $tabs[] =& $tab_routines; + } + if (PMA_MYSQL_INT_VERSION >= 50106 && ! PMA_DRIZZLE) { + if (PMA_currentUserHasPrivilege('EVENT', $this->db)) { + $tabs[] =& $tab_events; + } + } + if (!PMA_DRIZZLE) { + if (PMA_currentUserHasPrivilege('TRIGGER', $this->db)) { + $tabs[] =& $tab_triggers; + } + } + } + if (PMA_Tracker::isActive()) { + $tabs[] =& $tab_tracking; + } + if (! $db_is_information_schema) { + if ($cfgRelation['designerwork']) { + $tabs[] =& $tab_designer; + } + } + return $tabs; + } + + private function getServerTabs() + { + $binary_logs = PMA_DRIZZLE + ? null + : PMA_DBI_fetch_result('SHOW MASTER LOGS', 'Log_name', null, null, PMA_DBI_QUERY_STORE); + + $tabs = array(); + + $tabs['databases']['icon'] = 's_db.png'; + $tabs['databases']['link'] = 'server_databases.php'; + $tabs['databases']['text'] = __('Databases'); + + $tabs['sql']['icon'] = 'b_sql.png'; + $tabs['sql']['link'] = 'server_sql.php'; + $tabs['sql']['text'] = __('SQL'); + + $tabs['status']['icon'] = 's_status.png'; + $tabs['status']['link'] = 'server_status.php'; + $tabs['status']['text'] = __('Status'); + + if ($this->is_superuser && ! PMA_DRIZZLE) { + $tabs['rights']['icon'] = 's_rights.png'; + $tabs['rights']['link'] = 'server_privileges.php'; + $tabs['rights']['text'] = __('Users'); + } + + $tabs['export']['icon'] = 'b_export.png'; + $tabs['export']['link'] = 'server_export.php'; + $tabs['export']['text'] = __('Export'); + + $tabs['import']['icon'] = 'b_import.png'; + $tabs['import']['link'] = 'server_import.php'; + $tabs['import']['text'] = __('Import'); + + $tabs['settings']['icon'] = 'b_tblops.png'; + $tabs['settings']['link'] = 'prefs_manage.php'; + $tabs['settings']['text'] = __('Settings'); + $tabs['settings']['active'] = in_array( + basename($GLOBALS['PMA_PHP_SELF']), + array('prefs_forms.php', 'prefs_manage.php') + ); + + $tabs['synchronize']['icon'] = 's_sync.png'; + $tabs['synchronize']['link'] = 'server_synchronize.php'; + $tabs['synchronize']['text'] = __('Synchronize'); + + if (! empty($binary_logs)) { + $tabs['binlog']['icon'] = 's_tbl.png'; + $tabs['binlog']['link'] = 'server_binlog.php'; + $tabs['binlog']['text'] = __('Binary log'); + } + + if ($this->is_superuser && ! PMA_DRIZZLE) { + $tabs['replication']['icon'] = 's_replication.png'; + $tabs['replication']['link'] = 'server_replication.php'; + $tabs['replication']['text'] = __('Replication'); + } + + $tabs['vars']['icon'] = 's_vars.png'; + $tabs['vars']['link'] = 'server_variables.php'; + $tabs['vars']['text'] = __('Variables'); + + $tabs['charset']['icon'] = 's_asci.png'; + $tabs['charset']['link'] = 'server_collations.php'; + $tabs['charset']['text'] = __('Charsets'); + + if (PMA_DRIZZLE) { + $tabs['plugins']['icon'] = 'b_engine.png'; + $tabs['plugins']['link'] = 'server_plugins.php'; + $tabs['plugins']['text'] = __('Plugins'); + } else { + $tabs['engine']['icon'] = 'b_engine.png'; + $tabs['engine']['link'] = 'server_engines.php'; + $tabs['engine']['text'] = __('Engines'); + } + return $tabs; + } +} + +?> diff --git a/libraries/db_links.inc.php b/libraries/db_links.inc.php index aa09d79b5a..15af9c36bc 100644 --- a/libraries/db_links.inc.php +++ b/libraries/db_links.inc.php @@ -8,16 +8,6 @@ if (! defined('PHPMYADMIN')) { exit; } -/** - * - */ -require_once './libraries/common.inc.php'; - -/** - * Gets the relation settings - */ -$cfgRelation = PMA_getRelationsParam(); - /** * If coming from a Show MySQL link on the home page, * put something in $sub_part @@ -26,133 +16,4 @@ if (empty($sub_part)) { $sub_part = '_structure'; } -/** - * Checks for superuser privileges - */ -$is_superuser = PMA_isSuperuser(); - -/** - * Prepares links - */ - -/** - * export, search and qbe links if there is at least one table - */ -if ($num_tables == 0) { - $tab_qbe['warning'] = __('Database seems to be empty!'); - $tab_search['warning'] = __('Database seems to be empty!'); - $tab_export['warning'] = __('Database seems to be empty!'); -} - -$tab_structure['link'] = 'db_structure.php'; -$tab_structure['text'] = __('Structure'); -$tab_structure['icon'] = 'b_props.png'; - -$tab_sql['link'] = 'db_sql.php'; -$tab_sql['args']['db_query_force'] = 1; -$tab_sql['text'] = __('SQL'); -$tab_sql['icon'] = 'b_sql.png'; - -$tab_export['text'] = __('Export'); -$tab_export['icon'] = 'b_export.png'; -$tab_export['link'] = 'db_export.php'; - -$tab_search['text'] = __('Search'); -$tab_search['icon'] = 'b_search.png'; -$tab_search['link'] = 'db_search.php'; - -if (PMA_Tracker::isActive()) { - $tab_tracking['text'] = __('Tracking'); - $tab_tracking['icon'] = 'eye.png'; - $tab_tracking['link'] = 'db_tracking.php'; -} - -$tab_qbe['text'] = __('Query'); -$tab_qbe['icon'] = 's_db.png'; -$tab_qbe['link'] = 'db_qbe.php'; - -if ($cfgRelation['designerwork']) { - $tab_designer['text'] = __('Designer'); - $tab_designer['icon'] = 'b_relations.png'; - $tab_designer['link'] = 'pmd_general.php'; -} - -if (! $db_is_information_schema) { - $tab_import['link'] = 'db_import.php'; - $tab_import['text'] = __('Import'); - $tab_import['icon'] = 'b_import.png'; - $tab_operation['link'] = 'db_operations.php'; - $tab_operation['text'] = __('Operations'); - $tab_operation['icon'] = 'b_tblops.png'; - if ($is_superuser && !PMA_DRIZZLE) { - $tab_privileges['link'] = 'server_privileges.php'; - $tab_privileges['args']['checkprivs'] = $db; - // stay on database view - $tab_privileges['args']['viewing_mode'] = 'db'; - $tab_privileges['text'] = __('Privileges'); - $tab_privileges['icon'] = 's_rights.png'; - } - $tab_routines['link'] = 'db_routines.php'; - $tab_routines['text'] = __('Routines'); - $tab_routines['icon'] = 'b_routines.png'; - - $tab_events['link'] = 'db_events.php'; - $tab_events['text'] = __('Events'); - $tab_events['icon'] = 'b_events.png'; - - $tab_triggers['link'] = 'db_triggers.php'; - $tab_triggers['text'] = __('Triggers'); - $tab_triggers['icon'] = 'b_triggers.png'; -} - -/** - * Displays tab links - */ -$tabs = array(); -$tabs[] =& $tab_structure; -$tabs[] =& $tab_sql; -$tabs[] =& $tab_search; -$tabs[] =& $tab_qbe; -$tabs[] =& $tab_export; -if (! $db_is_information_schema) { - $tabs[] =& $tab_import; - $tabs[] =& $tab_operation; - if ($is_superuser && !PMA_DRIZZLE) { - $tabs[] =& $tab_privileges; - } - if (!PMA_DRIZZLE) { - $tabs[] =& $tab_routines; - } - if (PMA_MYSQL_INT_VERSION >= 50106 && ! PMA_DRIZZLE) { - if (PMA_currentUserHasPrivilege('EVENT', $db)) { - $tabs[] =& $tab_events; - } - } - if (!PMA_DRIZZLE) { - if (PMA_currentUserHasPrivilege('TRIGGER', $db)) { - $tabs[] =& $tab_triggers; - } - } -} -if (PMA_Tracker::isActive()) { - $tabs[] =& $tab_tracking; -} -if (! $db_is_information_schema) { - if ($cfgRelation['designerwork']) { - $tabs[] =& $tab_designer; - } -} - -$url_params['db'] = $db; - -echo PMA_generate_html_tabs($tabs, $url_params); -unset($tabs); - -/** - * Displays a message - */ -if (!empty($message)) { - PMA_showMessage($message); - unset($message); -} ?> diff --git a/libraries/header.inc.php b/libraries/header.inc.php index 7b4a32c1be..78c0f5d1ce 100644 --- a/libraries/header.inc.php +++ b/libraries/header.inc.php @@ -10,6 +10,7 @@ if (! defined('PHPMYADMIN')) { require_once './libraries/common.inc.php'; require_once './libraries/RecentTable.class.php'; +require_once 'libraries/Menu.class.php'; /** @@ -213,6 +214,9 @@ if (isset($GLOBALS['is_ajax_request']) && !$GLOBALS['is_ajax_request']) { echo ''; } } + + new Menu($GLOBALS['server'], $GLOBALS['db'], $GLOBALS['table']); + /** * Sets a variable to remember headers have been sent */ diff --git a/libraries/server_links.inc.php b/libraries/server_links.inc.php index 3d6b6be4df..1df268e404 100644 --- a/libraries/server_links.inc.php +++ b/libraries/server_links.inc.php @@ -11,116 +11,8 @@ if (! defined('PHPMYADMIN')) { /** * Check parameters */ -require_once './libraries/common.inc.php'; require_once './libraries/server_common.inc.php'; PMA_checkParameters(array('is_superuser', 'url_query'), false); -// Don't print all these links if in an Ajax request -if (!$GLOBALS['is_ajax_request']) { - /** - * Counts amount of navigation tabs - */ - $server_links_count_tabs = 0; - - - /** - * Put something in $sub_part - */ - if (! isset($sub_part)) { - $sub_part = ''; - } - - - /** - * Displays tab links - * Put the links we assume are used less, towards the end - */ - $tabs = array(); - - $tabs['databases']['icon'] = 's_db.png'; - $tabs['databases']['link'] = 'server_databases.php'; - $tabs['databases']['text'] = __('Databases'); - - $tabs['sql']['icon'] = 'b_sql.png'; - $tabs['sql']['link'] = 'server_sql.php'; - $tabs['sql']['text'] = __('SQL'); - - $tabs['status']['icon'] = 's_status.png'; - $tabs['status']['link'] = 'server_status.php'; - $tabs['status']['text'] = __('Status'); - - /*$tabs['process']['icon'] = 's_process.png'; - $tabs['process']['link'] = 'server_processlist.php'; - $tabs['process']['text'] = __('Processes');*/ - - if ($is_superuser && !PMA_DRIZZLE) { - $tabs['rights']['icon'] = 's_rights.png'; - $tabs['rights']['link'] = 'server_privileges.php'; - $tabs['rights']['text'] = __('Users'); - } - - $tabs['export']['icon'] = 'b_export.png'; - $tabs['export']['link'] = 'server_export.php'; - $tabs['export']['text'] = __('Export'); - - $tabs['import']['icon'] = 'b_import.png'; - $tabs['import']['link'] = 'server_import.php'; - $tabs['import']['text'] = __('Import'); - - $tabs['settings']['icon'] = 'b_tblops.png'; - $tabs['settings']['link'] = 'prefs_manage.php'; - $tabs['settings']['text'] = __('Settings'); - $tabs['settings']['active'] = in_array( - basename($GLOBALS['PMA_PHP_SELF']), - array('prefs_forms.php', 'prefs_manage.php') - ); - - $tabs['synchronize']['icon'] = 's_sync.png'; - $tabs['synchronize']['link'] = 'server_synchronize.php'; - $tabs['synchronize']['text'] = __('Synchronize'); - - if (! empty($binary_logs)) { - $tabs['binlog']['icon'] = 's_tbl.png'; - $tabs['binlog']['link'] = 'server_binlog.php'; - $tabs['binlog']['text'] = __('Binary log'); - } - - if ($is_superuser && !PMA_DRIZZLE) { - $tabs['replication']['icon'] = 's_replication.png'; - $tabs['replication']['link'] = 'server_replication.php'; - $tabs['replication']['text'] = __('Replication'); - } - - $tabs['vars']['icon'] = 's_vars.png'; - $tabs['vars']['link'] = 'server_variables.php'; - $tabs['vars']['text'] = __('Variables'); - - $tabs['charset']['icon'] = 's_asci.png'; - $tabs['charset']['link'] = 'server_collations.php'; - $tabs['charset']['text'] = __('Charsets'); - - if (PMA_DRIZZLE) { - $tabs['plugins']['icon'] = 'b_engine.png'; - $tabs['plugins']['link'] = 'server_plugins.php'; - $tabs['plugins']['text'] = __('Plugins'); - } else { - $tabs['engine']['icon'] = 'b_engine.png'; - $tabs['engine']['link'] = 'server_engines.php'; - $tabs['engine']['text'] = __('Engines'); - } - - echo PMA_generate_html_tabs($tabs, array()); - unset($tabs); - - - - /** - * Displays a message - */ - if (!empty($message)) { - PMA_showMessage($message); - unset($message); - } -}// end if ($GLOBALS['is_ajax_request'] == true) ?> diff --git a/libraries/tbl_links.inc.php b/libraries/tbl_links.inc.php index 37684792da..f647bee63c 100644 --- a/libraries/tbl_links.inc.php +++ b/libraries/tbl_links.inc.php @@ -11,8 +11,6 @@ if (! defined('PHPMYADMIN')) { /** * Check parameters */ -require_once './libraries/common.inc.php'; - PMA_checkParameters(array('db', 'table')); /** @@ -39,100 +37,8 @@ $err_url = $cfg['DefaultTabTable'] . PMA_generate_common_url($url_params); */ require_once './libraries/header.inc.php'; -/** - * Ensure that $db_is_information_schema is not null - */ -if (! isset($db_is_information_schema)) { - $db_is_information_schema = false; -} - -/** - * Displays links - */ -$tabs = array(); - -$tabs['browse']['icon'] = 'b_browse.png'; -$tabs['browse']['text'] = __('Browse'); -$tabs['browse']['link'] = 'sql.php'; -$tabs['browse']['args']['pos'] = 0; - -$tabs['structure']['icon'] = 'b_props.png'; -$tabs['structure']['link'] = 'tbl_structure.php'; -$tabs['structure']['text'] = __('Structure'); - -$tabs['sql']['icon'] = 'b_sql.png'; -$tabs['sql']['link'] = 'tbl_sql.php'; -$tabs['sql']['text'] = __('SQL'); - -$tabs['search']['icon'] = 'b_search.png'; -$tabs['search']['text'] = __('Search'); -$tabs['search']['link'] = 'tbl_select.php'; - -if (!$db_is_information_schema) { - $tabs['insert']['icon'] = 'b_insrow.png'; - $tabs['insert']['link'] = 'tbl_change.php'; - $tabs['insert']['text'] = __('Insert'); -} - -$tabs['export']['icon'] = 'b_tblexport.png'; -$tabs['export']['link'] = 'tbl_export.php'; -$tabs['export']['args']['single_table'] = 'true'; -$tabs['export']['text'] = __('Export'); - -/** - * Don't display "Import" and "Operations" - * for views and information_schema - */ -if (! $tbl_is_view && !$db_is_information_schema) { - $tabs['import']['icon'] = 'b_tblimport.png'; - $tabs['import']['link'] = 'tbl_import.php'; - $tabs['import']['text'] = __('Import'); - - $tabs['operation']['icon'] = 'b_tblops.png'; - $tabs['operation']['link'] = 'tbl_operations.php'; - $tabs['operation']['text'] = __('Operations'); -} -if (PMA_Tracker::isActive()) { - $tabs['tracking']['icon'] = 'eye.png'; - $tabs['tracking']['text'] = __('Tracking'); - $tabs['tracking']['link'] = 'tbl_tracking.php'; -} -if (!$db_is_information_schema && !PMA_DRIZZLE) { - if (PMA_currentUserHasPrivilege('TRIGGER', $db, $table) && ! PMA_Table::isView($db, $table)) { - $tabs['triggers']['link'] = 'tbl_triggers.php'; - $tabs['triggers']['text'] = __('Triggers'); - $tabs['triggers']['icon'] = 'b_triggers.png'; - } -} - -/** - * Views support a limited number of operations - */ -if ($tbl_is_view && !$db_is_information_schema) { - $tabs['operation']['icon'] = 'b_tblops.png'; - $tabs['operation']['link'] = 'view_operations.php'; - $tabs['operation']['text'] = __('Operations'); -} - -if ($table_info_num_rows == 0 && !$tbl_is_view) { - $tabs['browse']['warning'] = __('Table seems to be empty!'); - $tabs['search']['warning'] = __('Table seems to be empty!'); -} - -echo PMA_generate_html_tabs($tabs, $url_params); -unset($tabs); - if (PMA_Tracker::isActive() and PMA_Tracker::isTracked($GLOBALS["db"], $GLOBALS["table"])) { $msg = PMA_Message::notice(''.sprintf(__('Tracking of %s is activated.'), htmlspecialchars($GLOBALS["db"] . '.' . $GLOBALS["table"])).''); $msg->display(); } - -/** - * Displays a message - */ -if (!empty($message)) { - PMA_showMessage($message); - unset($message); -} - ?> From 7b85c709a85ad582cf00e27f1a50f2610f5ee0dc Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Mon, 30 Apr 2012 22:24:07 +0100 Subject: [PATCH 02/15] Dropped server_links.inc.php --- libraries/mult_submits.inc.php | 1 - libraries/server_common.inc.php | 2 ++ libraries/server_links.inc.php | 18 ------------------ libraries/user_preferences.inc.php | 4 ---- main.php | 1 - server_binlog.php | 5 ----- server_collations.php | 6 ------ server_databases.php | 6 ------ server_engines.php | 6 ------ server_export.php | 6 +----- server_import.php | 6 ------ server_plugins.php | 6 ------ server_privileges.php | 7 +++++-- server_replication.php | 7 ++----- server_sql.php | 7 ------- server_status.php | 7 ------- server_synchronize.php | 5 ----- server_variables.php | 6 ------ sql.php | 1 - tbl_chart.php | 1 - 20 files changed, 10 insertions(+), 98 deletions(-) delete mode 100644 libraries/server_links.inc.php diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php index 9cdb39dbdb..1a2a2a52aa 100644 --- a/libraries/mult_submits.inc.php +++ b/libraries/mult_submits.inc.php @@ -154,7 +154,6 @@ if (!empty($submit_mult) && !empty($what)) { include './libraries/db_info.inc.php'; } else { include_once './libraries/server_common.inc.php'; - include_once './libraries/server_links.inc.php'; } // Builds the query diff --git a/libraries/server_common.inc.php b/libraries/server_common.inc.php index 50460520e7..b84e4af908 100644 --- a/libraries/server_common.inc.php +++ b/libraries/server_common.inc.php @@ -53,4 +53,6 @@ if ($is_superuser && ! PMA_DRIZZLE) { $binary_logs = PMA_DRIZZLE ? null : PMA_DBI_fetch_result('SHOW MASTER LOGS', 'Log_name', null, null, PMA_DBI_QUERY_STORE); + +PMA_checkParameters(array('is_superuser', 'url_query'), false); ?> diff --git a/libraries/server_links.inc.php b/libraries/server_links.inc.php deleted file mode 100644 index 1df268e404..0000000000 --- a/libraries/server_links.inc.php +++ /dev/null @@ -1,18 +0,0 @@ - diff --git a/libraries/user_preferences.inc.php b/libraries/user_preferences.inc.php index 42deeb886c..3c2a12f14c 100644 --- a/libraries/user_preferences.inc.php +++ b/libraries/user_preferences.inc.php @@ -8,10 +8,6 @@ if (!defined('PHPMYADMIN')) { exit; } - -// show server tabs -require './libraries/server_links.inc.php'; - // build user preferences menu $form_param = filter_input(INPUT_GET, 'form'); diff --git a/main.php b/main.php index 6a0e2489ba..a5735825a4 100644 --- a/main.php +++ b/main.php @@ -41,7 +41,6 @@ $common_url_query = PMA_generate_common_url('', ''); if ($server > 0) { include 'libraries/server_common.inc.php'; include 'libraries/StorageEngine.class.php'; - include 'libraries/server_links.inc.php'; // Use the verbose name of the server instead of the hostname // if a value is set diff --git a/server_binlog.php b/server_binlog.php index db5313d774..1b21133643 100644 --- a/server_binlog.php +++ b/server_binlog.php @@ -16,11 +16,6 @@ require_once 'libraries/common.inc.php'; */ require_once 'libraries/server_common.inc.php'; -/** - * Displays the links - */ -require_once 'libraries/server_links.inc.php'; - $url_params = array(); /** diff --git a/server_collations.php b/server_collations.php index 076b79ca43..5e7844345b 100644 --- a/server_collations.php +++ b/server_collations.php @@ -16,12 +16,6 @@ require_once 'libraries/common.inc.php'; require 'libraries/server_common.inc.php'; -/** - * Displays the links - */ -require 'libraries/server_links.inc.php'; - - /** * Displays the sub-page heading */ diff --git a/server_databases.php b/server_databases.php index ce1011b6ac..e3a032764b 100644 --- a/server_databases.php +++ b/server_databases.php @@ -120,12 +120,6 @@ if ((isset($_REQUEST['drop_selected_dbs']) || isset($_REQUEST['query_type'])) } } -/** - * Displays the links - */ -require 'libraries/server_links.inc.php'; - - /** * Displays the sub-page heading */ diff --git a/server_engines.php b/server_engines.php index 1c26dc6942..c50723ce78 100644 --- a/server_engines.php +++ b/server_engines.php @@ -17,12 +17,6 @@ require_once 'libraries/common.inc.php'; require 'libraries/server_common.inc.php'; require 'libraries/StorageEngine.class.php'; - -/** - * Displays the links - */ -require 'libraries/server_links.inc.php'; - /** * Did the user request information about a certain storage engine? */ diff --git a/server_export.php b/server_export.php index fa14bbb058..3f5d50b7cf 100644 --- a/server_export.php +++ b/server_export.php @@ -9,14 +9,10 @@ * Does the common work */ require_once 'libraries/common.inc.php'; +require 'libraries/server_common.inc.php'; $GLOBALS['js_include'][] = 'export.js'; -/** - * Displays the links - */ -require 'libraries/server_links.inc.php'; - $export_page_title = __('View dump (schema) of databases') . "\n"; $checkall_url = 'server_export.php?' . PMA_generate_common_url() diff --git a/server_import.php b/server_import.php index c1028cdf2f..ef6200d468 100644 --- a/server_import.php +++ b/server_import.php @@ -17,12 +17,6 @@ $GLOBALS['js_include'][] = 'import.js'; */ require 'libraries/server_common.inc.php'; - -/** - * Displays the links - */ -require 'libraries/server_links.inc.php'; - $import_type = 'server'; require 'libraries/display_import.lib.php'; /** diff --git a/server_plugins.php b/server_plugins.php index 26fec2fe11..04d638fa67 100644 --- a/server_plugins.php +++ b/server_plugins.php @@ -22,12 +22,6 @@ $GLOBALS['js_include'][] = 'server_plugins.js'; */ require 'libraries/server_common.inc.php'; - -/** - * Displays the links - */ -require 'libraries/server_links.inc.php'; - /** * Displays the sub-page heading */ diff --git a/server_privileges.php b/server_privileges.php index 0002c6afd4..2c2c48bc28 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -173,7 +173,7 @@ if (isset($dbname)) { * Checks if the user is allowed to do what he tries to... */ if (! $is_superuser) { - include 'libraries/server_links.inc.php'; + include 'libraries/header.inc.php'; echo '

' . "\n" . PMA_getIcon('b_usrlist.png') . __('Privileges') . "\n" @@ -1656,7 +1656,10 @@ if (isset($viewing_mode) && $viewing_mode == 'db') { include 'libraries/db_info.inc.php'; echo "\n"; } else { - include 'libraries/server_links.inc.php'; + if (! empty($GLOBALS['message'])) { + PMA_showMessage($GLOBALS['message']); + unset($GLOBALS['message']); + } } diff --git a/server_replication.php b/server_replication.php index d2be1a32f7..7f10eeed72 100644 --- a/server_replication.php +++ b/server_replication.php @@ -25,7 +25,7 @@ require_once 'libraries/server_synchronize.lib.php'; * Checks if the user is allowed to do what he tries to... */ if (! $is_superuser) { - include 'libraries/server_links.inc.php'; + include 'libraries/header.inc.php'; echo '

' . "\n" . PMA_getIcon('s_replication.png') . __('Replication') . "\n" @@ -181,10 +181,7 @@ if (isset($GLOBALS['sr_take_action'])) { } unset($refresh); } -/** - * Displays the links - */ -require 'libraries/server_links.inc.php'; + echo '
'; echo '

'; diff --git a/server_sql.php b/server_sql.php index 538759066d..82924a22f0 100644 --- a/server_sql.php +++ b/server_sql.php @@ -20,13 +20,6 @@ $GLOBALS['js_include'][] = 'sql.js'; require_once 'libraries/server_common.inc.php'; require_once 'libraries/sql_query_form.lib.php'; - -/** - * Displays the links - */ -require 'libraries/server_links.inc.php'; - - /** * Query box, bookmark, insert data from textfile */ diff --git a/server_status.php b/server_status.php index ffb0cdefdb..f068bbad87 100644 --- a/server_status.php +++ b/server_status.php @@ -772,13 +772,6 @@ PMA_AddJSVar( */ require 'libraries/server_common.inc.php'; - - -/** - * Displays the links - */ -require 'libraries/server_links.inc.php'; - ?>

Date: Mon, 30 Apr 2012 22:40:20 +0100 Subject: [PATCH 03/15] Dropped db_links.inc.php --- db_tracking.php | 5 ----- libraries/db_info.inc.php | 8 ++++---- libraries/db_links.inc.php | 19 ------------------- view_create.php | 8 -------- 4 files changed, 4 insertions(+), 36 deletions(-) delete mode 100644 libraries/db_links.inc.php diff --git a/db_tracking.php b/db_tracking.php index f69ea41aed..4077f75748 100644 --- a/db_tracking.php +++ b/db_tracking.php @@ -57,11 +57,6 @@ if ($num_tables == 0 && count($data['ddlog']) == 0) { // --------------------------------------------------------------------------- -/* - * Display top menu links - */ -require_once 'libraries/db_links.inc.php'; - // Prepare statement to get HEAD version $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' . PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' . diff --git a/libraries/db_info.inc.php b/libraries/db_info.inc.php index 5d1efc2ed8..ab9a278cb7 100644 --- a/libraries/db_info.inc.php +++ b/libraries/db_info.inc.php @@ -283,10 +283,10 @@ if (! isset($total_num_tables)) { unset($each_table, $tbl_group_sql, $db_info_result); /** - * Displays top menu links - * If in an Ajax request, we do not need to show this + * If coming from a Show MySQL link on the home page, + * put something in $sub_part */ -if ($GLOBALS['is_ajax_request'] != true) { - include './libraries/db_links.inc.php'; +if (empty($sub_part)) { + $sub_part = '_structure'; } ?> diff --git a/libraries/db_links.inc.php b/libraries/db_links.inc.php deleted file mode 100644 index 15af9c36bc..0000000000 --- a/libraries/db_links.inc.php +++ /dev/null @@ -1,19 +0,0 @@ - diff --git a/view_create.php b/view_create.php index eb2bb5cee9..385890c2f5 100644 --- a/view_create.php +++ b/view_create.php @@ -93,14 +93,6 @@ if (PMA_isValid($_REQUEST['view'], 'array')) { $view = array_merge($view, $_REQUEST['view']); } -/** - * Displays top menu links - * We use db links because a VIEW is not necessarily on a single table - */ -$num_tables = 0; -if ($GLOBALS['is_ajax_request'] != true) { - include_once './libraries/db_links.inc.php'; -} $url_params['db'] = $GLOBALS['db']; $url_params['reload'] = 1; From 2c805ade8b3323e518238b38f56d5382759f9e7c Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Mon, 30 Apr 2012 23:41:07 +0100 Subject: [PATCH 04/15] Dropped tbl_links.inc.php --- libraries/mult_submits.inc.php | 1 - libraries/rte/rte_main.inc.php | 1 - libraries/tbl_common.php | 14 +++++++++++ libraries/tbl_links.inc.php | 44 ---------------------------------- sql.php | 1 - tbl_addfield.php | 7 +----- tbl_alter.php | 4 ---- tbl_change.php | 6 ----- tbl_chart.php | 1 - tbl_export.php | 7 +----- tbl_import.php | 4 ---- tbl_indexes.php | 3 --- tbl_operations.php | 6 ----- tbl_relation.php | 10 -------- tbl_select.php | 5 ---- tbl_sql.php | 5 ---- tbl_structure.php | 4 ---- tbl_tracking.php | 4 ---- tbl_zoom_select.php | 5 ---- view_operations.php | 5 ---- 20 files changed, 16 insertions(+), 121 deletions(-) delete mode 100644 libraries/tbl_links.inc.php diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php index 1a2a2a52aa..8a2043b99d 100644 --- a/libraries/mult_submits.inc.php +++ b/libraries/mult_submits.inc.php @@ -148,7 +148,6 @@ if (!empty($submit_mult) && !empty($what)) { include './libraries/tbl_common.php'; $url_query .= '&goto=tbl_sql.php&back=tbl_sql.php'; include './libraries/tbl_info.inc.php'; - include_once './libraries/tbl_links.inc.php'; } elseif (strlen($db)) { include './libraries/db_common.inc.php'; include './libraries/db_info.inc.php'; diff --git a/libraries/rte/rte_main.inc.php b/libraries/rte/rte_main.inc.php index bdb43b8a20..ce3b1bcdce 100644 --- a/libraries/rte/rte_main.inc.php +++ b/libraries/rte/rte_main.inc.php @@ -24,7 +24,6 @@ if ($GLOBALS['is_ajax_request'] != true) { */ if (! empty($table) && in_array($table, PMA_DBI_get_tables($db))) { include_once './libraries/tbl_common.php'; - include_once './libraries/tbl_links.inc.php'; } else { $table = ''; include_once './libraries/db_common.inc.php'; diff --git a/libraries/tbl_common.php b/libraries/tbl_common.php index 4b8172f5d2..5e3cd5a7e7 100644 --- a/libraries/tbl_common.php +++ b/libraries/tbl_common.php @@ -25,6 +25,10 @@ $db_is_information_schema = PMA_is_system_schema($db); */ $url_query = PMA_generate_common_url($db, $table); +/** + * Set parameters for links + */ +$url_params = array(); $url_params['db'] = $db; $url_params['table'] = $table; @@ -40,4 +44,14 @@ $err_url = $cfg['DefaultTabTable'] . PMA_generate_common_url($url_params); */ require_once './libraries/db_table_exists.lib.php'; +/** + * Displays headers + */ +require_once './libraries/header.inc.php'; + +if (PMA_Tracker::isActive() and PMA_Tracker::isTracked($GLOBALS["db"], $GLOBALS["table"])) { + $msg = PMA_Message::notice(''.sprintf(__('Tracking of %s is activated.'), htmlspecialchars($GLOBALS["db"] . '.' . $GLOBALS["table"])).''); + $msg->display(); +} + ?> diff --git a/libraries/tbl_links.inc.php b/libraries/tbl_links.inc.php deleted file mode 100644 index f647bee63c..0000000000 --- a/libraries/tbl_links.inc.php +++ /dev/null @@ -1,44 +0,0 @@ - $db,)); -$err_url = $cfg['DefaultTabTable'] . PMA_generate_common_url($url_params); - -/** - * Displays headers - */ -require_once './libraries/header.inc.php'; - -if (PMA_Tracker::isActive() and PMA_Tracker::isTracked($GLOBALS["db"], $GLOBALS["table"])) { - $msg = PMA_Message::notice(''.sprintf(__('Tracking of %s is activated.'), htmlspecialchars($GLOBALS["db"] . '.' . $GLOBALS["table"])).''); - $msg->display(); -} -?> diff --git a/sql.php b/sql.php index dcb5b95cef..9c1cb81477 100644 --- a/sql.php +++ b/sql.php @@ -923,7 +923,6 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { include 'libraries/tbl_common.php'; $url_query .= '&goto=tbl_sql.php&back=tbl_sql.php'; include 'libraries/tbl_info.inc.php'; - include 'libraries/tbl_links.inc.php'; } elseif (strlen($db)) { include 'libraries/db_common.inc.php'; include 'libraries/db_info.inc.php'; diff --git a/tbl_addfield.php b/tbl_addfield.php index b6c38caf75..cbf55dca0b 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -222,13 +222,8 @@ if ($abort == false) { */ include_once 'libraries/tbl_common.php'; include_once 'libraries/tbl_info.inc.php'; - /** - * Displays top menu links - */ + $active_page = 'tbl_structure.php'; - if ($GLOBALS['is_ajax_request'] != true) { - include_once 'libraries/tbl_links.inc.php'; - } /** * Display the form */ diff --git a/tbl_alter.php b/tbl_alter.php index 7c658b332b..1d6c5265f9 100644 --- a/tbl_alter.php +++ b/tbl_alter.php @@ -279,10 +279,6 @@ if (isset($_REQUEST['do_save_data'])) { * $selected comes from multi_submits.inc.php */ if ($abort == false) { - if (!isset($_REQUEST['ajax_request']) || $_REQUEST['ajax_request'] != true) { - include_once 'libraries/tbl_links.inc.php'; - } - if (! isset($selected)) { PMA_checkParameters(array('field')); $selected[] = $_REQUEST['field']; diff --git a/tbl_change.php b/tbl_change.php index da0a5c98b1..d6b46b51a4 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -136,12 +136,6 @@ if (! empty($disp_message)) { PMA_showMessage($disp_message, $disp_query); } -/** - * Displays top menu links - */ -require_once 'libraries/tbl_links.inc.php'; - - /** * Get the analysis of SHOW CREATE TABLE for this table * @todo should be handled by class Table diff --git a/tbl_chart.php b/tbl_chart.php index 1bfb33bb3b..48003ab570 100644 --- a/tbl_chart.php +++ b/tbl_chart.php @@ -29,7 +29,6 @@ if (strlen($GLOBALS['table'])) { $url_params['back'] = 'tbl_sql.php'; include 'libraries/tbl_common.php'; include 'libraries/tbl_info.inc.php'; - include 'libraries/tbl_links.inc.php'; } elseif (strlen($GLOBALS['db'])) { $url_params['goto'] = $cfg['DefaultTabDatabase']; $url_params['back'] = 'sql.php'; diff --git a/tbl_export.php b/tbl_export.php index 6dc545f203..1fe4276f17 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -76,14 +76,9 @@ if (! empty($sql_query)) { // Just crop LIMIT clause $sql_query = $analyzed_sql[0]['section_before_limit'] . $analyzed_sql[0]['section_after_limit']; } - $message = PMA_Message::success(); + PMA_showMessage(PMA_Message::success()); } -/** - * Displays top menu links - */ -require 'libraries/tbl_links.inc.php'; - $export_type = 'table'; require_once 'libraries/display_export.lib.php'; diff --git a/tbl_import.php b/tbl_import.php index 290e2459cf..160764acd4 100644 --- a/tbl_import.php +++ b/tbl_import.php @@ -19,10 +19,6 @@ require_once 'libraries/tbl_common.php'; $url_query .= '&goto=tbl_import.php&back=tbl_import.php'; require_once 'libraries/tbl_info.inc.php'; -/** - * Displays top menu links - */ -require_once 'libraries/tbl_links.inc.php'; $import_type = 'table'; require_once 'libraries/display_import.lib.php'; diff --git a/tbl_indexes.php b/tbl_indexes.php index ef9d3d0703..0e536f7b13 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -131,9 +131,6 @@ if (isset($_REQUEST['do_save_data'])) { // Displays headers (if needed) $GLOBALS['js_include'][] = 'indexes.js'; require_once 'libraries/tbl_info.inc.php'; -if ($GLOBALS['is_ajax_request'] != true) { - include_once 'libraries/tbl_links.inc.php'; -} if (isset($_REQUEST['index']) && is_array($_REQUEST['index'])) { // coming already from form diff --git a/tbl_operations.php b/tbl_operations.php index b117e7a76c..be7b192bd2 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -223,12 +223,6 @@ if ($reread_info) { } unset($reread_info); -/** - * Displays top menu links in non ajax requests - */ -if (!isset($_REQUEST['ajax_request'])) { - include_once 'libraries/tbl_links.inc.php'; -} if (isset($result) && empty($message_to_show)) { // set to success by default, because result set could be empty // (for example, a table rename) diff --git a/tbl_relation.php b/tbl_relation.php index 51930f3a81..12871b6cc1 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -44,16 +44,6 @@ foreach ($post_params as $one_post_param) { */ require_once 'libraries/tbl_info.inc.php'; -// Note: in libraries/tbl_links.inc.php we get and display the table comment. -// For InnoDB, this comment contains the REFER information but any update -// has not been done yet (will be done in tbl_relation.php later). -$avoid_show_comment = true; - -/** - * Displays top menu links - */ -require_once 'libraries/tbl_links.inc.php'; - $options_array = array( 'CASCADE' => 'CASCADE', 'SET_NULL' => 'SET NULL', diff --git a/tbl_select.php b/tbl_select.php index 4120c23590..5ac8cd137d 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -66,11 +66,6 @@ if (! isset($param) || $param[0] == '') { */ include_once 'libraries/tbl_info.inc.php'; - /** - * Displays top menu links - */ - include_once 'libraries/tbl_links.inc.php'; - if (! isset($goto)) { $goto = $GLOBALS['cfg']['DefaultTabTable']; } diff --git a/tbl_sql.php b/tbl_sql.php index 6342ffb9ea..25f03b44b4 100644 --- a/tbl_sql.php +++ b/tbl_sql.php @@ -33,11 +33,6 @@ $back = 'tbl_sql.php'; */ require_once 'libraries/tbl_info.inc.php'; -/** - * Displays top menu links - */ -require_once 'libraries/tbl_links.inc.php'; - /** * Query box, bookmark, insert data from textfile */ diff --git a/tbl_structure.php b/tbl_structure.php index 97f0ee84d4..8032abf91a 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -101,10 +101,6 @@ $url_params['back'] = 'tbl_structure.php'; */ require_once 'libraries/tbl_info.inc.php'; -/** - * Displays top menu links - */ -require_once 'libraries/tbl_links.inc.php'; require_once 'libraries/Index.class.php'; // 2. Gets table keys and retains them diff --git a/tbl_tracking.php b/tbl_tracking.php index 711065b3de..51740c162b 100644 --- a/tbl_tracking.php +++ b/tbl_tracking.php @@ -146,10 +146,6 @@ if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldumpfil * Gets tables informations */ -/** - * Displays top menu links - */ -require_once './libraries/tbl_links.inc.php'; echo '
'; /** diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 3eacd335d4..957c555eea 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -146,11 +146,6 @@ $url_query .= '&goto=tbl_select.php&back=tbl_select.php'; */ require_once './libraries/tbl_info.inc.php'; -/** - * Displays top menu links - */ -require_once './libraries/tbl_links.inc.php'; - if (! isset($goto)) { $goto = $GLOBALS['cfg']['DefaultTabTable']; } diff --git a/view_operations.php b/view_operations.php index 66599ef30c..3dafd94d05 100644 --- a/view_operations.php +++ b/view_operations.php @@ -47,11 +47,6 @@ if (isset($_REQUEST['submitoptions'])) { } } -/** - * Displays top menu links - */ -require_once './libraries/tbl_links.inc.php'; - if (isset($result)) { // set to success by default, because result set could be empty // (for example, a table rename) From 28923b496ece621034280d65fa52a1cd22002f1c Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Mon, 30 Apr 2012 23:46:18 +0100 Subject: [PATCH 05/15] Renamed tbl_common.php to tbl_common.inc.php for better consistency --- libraries/mult_submits.inc.php | 2 +- libraries/rte/rte_main.inc.php | 2 +- libraries/{tbl_common.php => tbl_common.inc.php} | 0 sql.php | 2 +- tbl_addfield.php | 2 +- tbl_alter.php | 2 +- tbl_chart.php | 2 +- tbl_export.php | 2 +- tbl_import.php | 2 +- tbl_indexes.php | 2 +- tbl_operations.php | 2 +- tbl_printview.php | 2 +- tbl_relation.php | 2 +- tbl_select.php | 2 +- tbl_sql.php | 2 +- tbl_structure.php | 2 +- tbl_tracking.php | 2 +- tbl_zoom_select.php | 2 +- view_operations.php | 2 +- 19 files changed, 18 insertions(+), 18 deletions(-) rename libraries/{tbl_common.php => tbl_common.inc.php} (100%) diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php index 8a2043b99d..8e422b07da 100644 --- a/libraries/mult_submits.inc.php +++ b/libraries/mult_submits.inc.php @@ -145,7 +145,7 @@ if (!empty($submit_mult) && !empty($what)) { include_once './libraries/header.inc.php'; if (strlen($table)) { - include './libraries/tbl_common.php'; + include './libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_sql.php&back=tbl_sql.php'; include './libraries/tbl_info.inc.php'; } elseif (strlen($db)) { diff --git a/libraries/rte/rte_main.inc.php b/libraries/rte/rte_main.inc.php index ce3b1bcdce..fa5226bda9 100644 --- a/libraries/rte/rte_main.inc.php +++ b/libraries/rte/rte_main.inc.php @@ -23,7 +23,7 @@ if ($GLOBALS['is_ajax_request'] != true) { * Displays the header and tabs */ if (! empty($table) && in_array($table, PMA_DBI_get_tables($db))) { - include_once './libraries/tbl_common.php'; + include_once './libraries/tbl_common.inc.php'; } else { $table = ''; include_once './libraries/db_common.inc.php'; diff --git a/libraries/tbl_common.php b/libraries/tbl_common.inc.php similarity index 100% rename from libraries/tbl_common.php rename to libraries/tbl_common.inc.php diff --git a/sql.php b/sql.php index 9c1cb81477..53b5a9276d 100644 --- a/sql.php +++ b/sql.php @@ -920,7 +920,7 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { if (! $GLOBALS['is_ajax_request'] || ! $GLOBALS['cfg']['AjaxEnable']) { if (strlen($table)) { - include 'libraries/tbl_common.php'; + include 'libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_sql.php&back=tbl_sql.php'; include 'libraries/tbl_info.inc.php'; } elseif (strlen($db)) { diff --git a/tbl_addfield.php b/tbl_addfield.php index cbf55dca0b..ff7db7c9d4 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -220,7 +220,7 @@ if ($abort == false) { /** * Gets tables informations */ - include_once 'libraries/tbl_common.php'; + include_once 'libraries/tbl_common.inc.php'; include_once 'libraries/tbl_info.inc.php'; $active_page = 'tbl_structure.php'; diff --git a/tbl_alter.php b/tbl_alter.php index 1d6c5265f9..3bd39f075f 100644 --- a/tbl_alter.php +++ b/tbl_alter.php @@ -26,7 +26,7 @@ PMA_checkParameters(array('db', 'table')); /** * Gets tables informations */ -require_once 'libraries/tbl_common.php'; +require_once 'libraries/tbl_common.inc.php'; require_once 'libraries/tbl_info.inc.php'; $active_page = 'tbl_structure.php'; diff --git a/tbl_chart.php b/tbl_chart.php index 48003ab570..8a6d059c09 100644 --- a/tbl_chart.php +++ b/tbl_chart.php @@ -27,7 +27,7 @@ $GLOBALS['js_include'][] = 'canvg/canvg.js'; if (strlen($GLOBALS['table'])) { $url_params['goto'] = $cfg['DefaultTabTable']; $url_params['back'] = 'tbl_sql.php'; - include 'libraries/tbl_common.php'; + include 'libraries/tbl_common.inc.php'; include 'libraries/tbl_info.inc.php'; } elseif (strlen($GLOBALS['db'])) { $url_params['goto'] = $cfg['DefaultTabDatabase']; diff --git a/tbl_export.php b/tbl_export.php index 1fe4276f17..7e3d4ed727 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -15,7 +15,7 @@ $GLOBALS['js_include'][] = 'export.js'; /** * Gets tables informations and displays top links */ -require_once 'libraries/tbl_common.php'; +require_once 'libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_export.php&back=tbl_export.php'; require_once 'libraries/tbl_info.inc.php'; diff --git a/tbl_import.php b/tbl_import.php index 160764acd4..abe6f10a1c 100644 --- a/tbl_import.php +++ b/tbl_import.php @@ -15,7 +15,7 @@ $GLOBALS['js_include'][] = 'import.js'; /** * Gets tables informations and displays top links */ -require_once 'libraries/tbl_common.php'; +require_once 'libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_import.php&back=tbl_import.php'; require_once 'libraries/tbl_info.inc.php'; diff --git a/tbl_indexes.php b/tbl_indexes.php index 0e536f7b13..020210f9f5 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -11,7 +11,7 @@ */ require_once 'libraries/common.inc.php'; require_once 'libraries/Index.class.php'; -require_once 'libraries/tbl_common.php'; +require_once 'libraries/tbl_common.inc.php'; // Get fields and stores their name/type $fields = array(); diff --git a/tbl_operations.php b/tbl_operations.php index be7b192bd2..bc4d55ca2b 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -15,7 +15,7 @@ $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); /** * Runs common work */ -require 'libraries/tbl_common.php'; +require 'libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_operations.php&back=tbl_operations.php'; $url_params['goto'] = $url_params['back'] = 'tbl_operations.php'; diff --git a/tbl_printview.php b/tbl_printview.php index 9b1230c153..e600021f88 100644 --- a/tbl_printview.php +++ b/tbl_printview.php @@ -10,7 +10,7 @@ */ require_once 'libraries/common.inc.php'; -require 'libraries/tbl_common.php'; +require 'libraries/tbl_common.inc.php'; /** * Gets the variables sent or posted to this script, then displays headers diff --git a/tbl_relation.php b/tbl_relation.php index 12871b6cc1..e640687cc5 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -19,7 +19,7 @@ require_once 'libraries/common.inc.php'; $GLOBALS['js_include'][] = 'tbl_relation.js'; -require_once 'libraries/tbl_common.php'; +require_once 'libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_sql.php'; /** diff --git a/tbl_select.php b/tbl_select.php index 5ac8cd137d..5109479086 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -57,7 +57,7 @@ foreach ($post_params as $one_post_param) { */ if (! isset($param) || $param[0] == '') { // Gets some core libraries - include_once 'libraries/tbl_common.php'; + include_once 'libraries/tbl_common.inc.php'; //$err_url = 'tbl_select.php' . $err_url; $url_query .= '&goto=tbl_select.php&back=tbl_select.php'; diff --git a/tbl_sql.php b/tbl_sql.php index 25f03b44b4..3420a051af 100644 --- a/tbl_sql.php +++ b/tbl_sql.php @@ -17,7 +17,7 @@ $GLOBALS['js_include'][] = 'functions.js'; $GLOBALS['js_include'][] = 'makegrid.js'; $GLOBALS['js_include'][] = 'sql.js'; -require 'libraries/tbl_common.php'; +require 'libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_sql.php&back=tbl_sql.php'; require_once 'libraries/sql_query_form.lib.php'; diff --git a/tbl_structure.php b/tbl_structure.php index 8032abf91a..a1399fbd58 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -86,7 +86,7 @@ $cfgRelation = PMA_getRelationsParam(); /** * Runs common work */ -require_once 'libraries/tbl_common.php'; +require_once 'libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_structure.php&back=tbl_structure.php'; $url_params['goto'] = 'tbl_structure.php'; $url_params['back'] = 'tbl_structure.php'; diff --git a/tbl_tracking.php b/tbl_tracking.php index 51740c162b..4740d135b2 100644 --- a/tbl_tracking.php +++ b/tbl_tracking.php @@ -9,7 +9,7 @@ require_once './libraries/common.inc.php'; define('TABLE_MAY_BE_ABSENT', true); -require './libraries/tbl_common.php'; +require './libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_tracking.php&back=tbl_tracking.php'; $url_params['goto'] = 'tbl_tracking.php';; $url_params['back'] = 'tbl_tracking.php'; diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 957c555eea..41726f8537 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -138,7 +138,7 @@ $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values')); */ // Gets some core libraries -require_once './libraries/tbl_common.php'; +require_once './libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_select.php&back=tbl_select.php'; /** diff --git a/view_operations.php b/view_operations.php index 3dafd94d05..45a74b7ebf 100644 --- a/view_operations.php +++ b/view_operations.php @@ -15,7 +15,7 @@ $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); /** * Runs common work */ -require './libraries/tbl_common.php'; +require './libraries/tbl_common.inc.php'; $url_query .= '&goto=view_operations.php&back=view_operations.php'; $url_params['goto'] = $url_params['back'] = 'view_operations.php'; From f3afd09f47ac1076a9cd01cdc519431654678e77 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 1 May 2012 00:01:42 +0100 Subject: [PATCH 06/15] More consistent generation of db tabs in the Menu class --- libraries/Menu.class.php | 148 ++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 86 deletions(-) diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index 16c6b0ddf6..20b6b863cc 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -126,113 +126,89 @@ class Menu { */ $cfgRelation = PMA_getRelationsParam(); + $tabs = array(); + /** * export, search and qbe links if there is at least one table */ if ($num_tables == 0) { - $tab_qbe['warning'] = __('Database seems to be empty!'); - $tab_search['warning'] = __('Database seems to be empty!'); - $tab_export['warning'] = __('Database seems to be empty!'); + $tabs['qbe']['warning'] = __('Database seems to be empty!'); + $tabs['search']['warning'] = __('Database seems to be empty!'); + $tabs['export']['warning'] = __('Database seems to be empty!'); } - $tab_structure['link'] = 'db_structure.php'; - $tab_structure['text'] = __('Structure'); - $tab_structure['icon'] = 'b_props.png'; + $tabs['structure']['link'] = 'db_structure.php'; + $tabs['structure']['text'] = __('Structure'); + $tabs['structure']['icon'] = 'b_props.png'; - $tab_sql['link'] = 'db_sql.php'; - $tab_sql['args']['db_query_force'] = 1; - $tab_sql['text'] = __('SQL'); - $tab_sql['icon'] = 'b_sql.png'; + $tabs['sql']['link'] = 'db_sql.php'; + $tabs['sql']['args']['db_query_force'] = 1; + $tabs['sql']['text'] = __('SQL'); + $tabs['sql']['icon'] = 'b_sql.png'; - $tab_export['text'] = __('Export'); - $tab_export['icon'] = 'b_export.png'; - $tab_export['link'] = 'db_export.php'; + $tabs['search']['text'] = __('Search'); + $tabs['search']['icon'] = 'b_search.png'; + $tabs['search']['link'] = 'db_search.php'; - $tab_search['text'] = __('Search'); - $tab_search['icon'] = 'b_search.png'; - $tab_search['link'] = 'db_search.php'; + $tabs['qbe']['text'] = __('Query'); + $tabs['qbe']['icon'] = 's_db.png'; + $tabs['qbe']['link'] = 'db_qbe.php'; - if (PMA_Tracker::isActive()) { - $tab_tracking['text'] = __('Tracking'); - $tab_tracking['icon'] = 'eye.png'; - $tab_tracking['link'] = 'db_tracking.php'; - } - - $tab_qbe['text'] = __('Query'); - $tab_qbe['icon'] = 's_db.png'; - $tab_qbe['link'] = 'db_qbe.php'; - - if ($cfgRelation['designerwork']) { - $tab_designer['text'] = __('Designer'); - $tab_designer['icon'] = 'b_relations.png'; - $tab_designer['link'] = 'pmd_general.php'; - } + $tabs['export']['text'] = __('Export'); + $tabs['export']['icon'] = 'b_export.png'; + $tabs['export']['link'] = 'db_export.php'; if (! $db_is_information_schema) { - $tab_import['link'] = 'db_import.php'; - $tab_import['text'] = __('Import'); - $tab_import['icon'] = 'b_import.png'; - $tab_operation['link'] = 'db_operations.php'; - $tab_operation['text'] = __('Operations'); - $tab_operation['icon'] = 'b_tblops.png'; - if ($this->is_superuser && !PMA_DRIZZLE) { - $tab_privileges['link'] = 'server_privileges.php'; - $tab_privileges['args']['checkprivs'] = $this->db; + $tabs['import']['link'] = 'db_import.php'; + $tabs['import']['text'] = __('Import'); + $tabs['import']['icon'] = 'b_import.png'; + + $tabs['operation']['link'] = 'db_operations.php'; + $tabs['operation']['text'] = __('Operations'); + $tabs['operation']['icon'] = 'b_tblops.png'; + + if ($this->is_superuser && ! PMA_DRIZZLE) { + $tabs['privileges']['link'] = 'server_privileges.php'; + $tabs['privileges']['args']['checkprivs'] = $this->db; // stay on database view - $tab_privileges['args']['viewing_mode'] = 'db'; - $tab_privileges['text'] = __('Privileges'); - $tab_privileges['icon'] = 's_rights.png'; + $tabs['privileges']['args']['viewing_mode'] = 'db'; + $tabs['privileges']['text'] = __('Privileges'); + $tabs['privileges']['icon'] = 's_rights.png'; } - $tab_routines['link'] = 'db_routines.php'; - $tab_routines['text'] = __('Routines'); - $tab_routines['icon'] = 'b_routines.png'; - - $tab_events['link'] = 'db_events.php'; - $tab_events['text'] = __('Events'); - $tab_events['icon'] = 'b_events.png'; - - $tab_triggers['link'] = 'db_triggers.php'; - $tab_triggers['text'] = __('Triggers'); - $tab_triggers['icon'] = 'b_triggers.png'; - } - - /** - * Displays tab links - */ - $tabs = array(); - $tabs[] =& $tab_structure; - $tabs[] =& $tab_sql; - $tabs[] =& $tab_search; - $tabs[] =& $tab_qbe; - $tabs[] =& $tab_export; - if (! $db_is_information_schema) { - $tabs[] =& $tab_import; - $tabs[] =& $tab_operation; - if ($this->is_superuser && !PMA_DRIZZLE) { - $tabs[] =& $tab_privileges; + if (! PMA_DRIZZLE) { + $tabs['routines']['link'] = 'db_routines.php'; + $tabs['routines']['text'] = __('Routines'); + $tabs['routines']['icon'] = 'b_routines.png'; } - if (!PMA_DRIZZLE) { - $tabs[] =& $tab_routines; + if (PMA_MYSQL_INT_VERSION >= 50106 + && ! PMA_DRIZZLE + && PMA_currentUserHasPrivilege('EVENT', $this->db) + ) { + $tabs['events']['link'] = 'db_events.php'; + $tabs['events']['text'] = __('Events'); + $tabs['events']['icon'] = 'b_events.png'; } - if (PMA_MYSQL_INT_VERSION >= 50106 && ! PMA_DRIZZLE) { - if (PMA_currentUserHasPrivilege('EVENT', $this->db)) { - $tabs[] =& $tab_events; - } - } - if (!PMA_DRIZZLE) { - if (PMA_currentUserHasPrivilege('TRIGGER', $this->db)) { - $tabs[] =& $tab_triggers; - } + if (! PMA_DRIZZLE + && PMA_currentUserHasPrivilege('TRIGGER', $this->db) + ) { + $tabs['triggers']['link'] = 'db_triggers.php'; + $tabs['triggers']['text'] = __('Triggers'); + $tabs['triggers']['icon'] = 'b_triggers.png'; } } + if (PMA_Tracker::isActive()) { - $tabs[] =& $tab_tracking; + $tabs['tracking']['text'] = __('Tracking'); + $tabs['tracking']['icon'] = 'eye.png'; + $tabs['tracking']['link'] = 'db_tracking.php'; } - if (! $db_is_information_schema) { - if ($cfgRelation['designerwork']) { - $tabs[] =& $tab_designer; - } + + if (! $db_is_information_schema && $cfgRelation['designerwork']) { + $tabs['designer']['text'] = __('Designer'); + $tabs['designer']['icon'] = 'b_relations.png'; + $tabs['designer']['link'] = 'pmd_general.php'; } + return $tabs; } From 499868887b3fca0db6a2c6cba620ab1c247ddb35 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 1 May 2012 00:04:10 +0100 Subject: [PATCH 07/15] is_superuser shouldn't be a class attribute (saves a function call when generating tabs for a table) --- libraries/Menu.class.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index 20b6b863cc..6a1d75e3bb 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -4,13 +4,11 @@ class Menu { private $server; private $db; private $table; - private $is_superuser; public function __construct($server, $db, $table){ $this->server = $server; $this->db = $db; $this->table = $table; - $this->is_superuser = PMA_isSuperuser(); if (! $GLOBALS['is_ajax_request']) { echo $this->getMenu(); @@ -121,6 +119,8 @@ class Menu { { $db_is_information_schema = PMA_is_system_schema($this->db); $num_tables = count(PMA_DBI_get_tables($this->db)); + $is_superuser = PMA_isSuperuser(); + /** * Gets the relation settings */ @@ -167,7 +167,7 @@ class Menu { $tabs['operation']['text'] = __('Operations'); $tabs['operation']['icon'] = 'b_tblops.png'; - if ($this->is_superuser && ! PMA_DRIZZLE) { + if ($is_superuser && ! PMA_DRIZZLE) { $tabs['privileges']['link'] = 'server_privileges.php'; $tabs['privileges']['args']['checkprivs'] = $this->db; // stay on database view @@ -214,6 +214,7 @@ class Menu { private function getServerTabs() { + $is_superuser = PMA_isSuperuser(); $binary_logs = PMA_DRIZZLE ? null : PMA_DBI_fetch_result('SHOW MASTER LOGS', 'Log_name', null, null, PMA_DBI_QUERY_STORE); @@ -232,7 +233,7 @@ class Menu { $tabs['status']['link'] = 'server_status.php'; $tabs['status']['text'] = __('Status'); - if ($this->is_superuser && ! PMA_DRIZZLE) { + if ($is_superuser && ! PMA_DRIZZLE) { $tabs['rights']['icon'] = 's_rights.png'; $tabs['rights']['link'] = 'server_privileges.php'; $tabs['rights']['text'] = __('Users'); @@ -264,7 +265,7 @@ class Menu { $tabs['binlog']['text'] = __('Binary log'); } - if ($this->is_superuser && ! PMA_DRIZZLE) { + if ($is_superuser && ! PMA_DRIZZLE) { $tabs['replication']['icon'] = 's_replication.png'; $tabs['replication']['link'] = 'server_replication.php'; $tabs['replication']['text'] = __('Replication'); From ffde8d135fba0ce69f268a032b15c26db6a0e77a Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 1 May 2012 00:25:50 +0100 Subject: [PATCH 08/15] Remove last reference to tbl_links.inc.php --- tbl_structure.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tbl_structure.php b/tbl_structure.php index a1399fbd58..e8e1e07a40 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -70,7 +70,6 @@ if (! empty($submit_mult) && isset($_REQUEST['selected_fld'])) { $action = 'tbl_structure.php'; include 'libraries/mult_submits.inc.php'; //require_once 'libraries/header.inc.php'; - //require_once 'libraries/tbl_links.inc.php'; if (empty($message)) { $message = PMA_Message::success(); @@ -723,14 +722,6 @@ if (! $tbl_is_view && ! $db_is_information_schema) { 20) { - include 'libraries/tbl_links.inc.php'; -} // end if (count($fields) > 20) - /** * Displays indexes */ From ff01dc25b5512f33603da5dd1c21cc26ab75357b Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Wed, 2 May 2012 23:52:20 +0100 Subject: [PATCH 09/15] Moved the render of breadcrumbs to the Menu class --- libraries/Menu.class.php | 124 +++++++++++++++++++++++++++++++++++++++ libraries/header.inc.php | 111 +++-------------------------------- 2 files changed, 131 insertions(+), 104 deletions(-) diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index 6a1d75e3bb..c668d82e82 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -11,6 +11,7 @@ class Menu { $this->table = $table; if (! $GLOBALS['is_ajax_request']) { + echo $this->getBreadcrumbs(); echo $this->getMenu(); if (! empty($GLOBALS['message'])) { PMA_showMessage($GLOBALS['message']); @@ -36,6 +37,129 @@ class Menu { return PMA_generate_html_tabs($tabs, $url_params); } + private function getBreadcrumbs() + { + $retval = ''; + $tbl_is_view = PMA_Table::isView($this->db, $this->table); + $server_info = ! empty($GLOBALS['cfg']['Server']['verbose']) + ? $GLOBALS['cfg']['Server']['verbose'] + : $GLOBALS['cfg']['Server']['host']; + $server_info .= empty($GLOBALS['cfg']['Server']['port']) + ? '' + : ':' . $GLOBALS['cfg']['Server']['port']; + + $separator = " »\n"; + $item = ''; + + if ($GLOBALS['cfg']['NavigationBarIconic'] !== true) { + $item .= '%4$s: '; + } + $item .= '%3$s' . "\n"; + $retval .= "
\n"; + $retval .= "
\n"; + if ($GLOBALS['cfg']['NavigationBarIconic']) { + $retval .= PMA_getImage( + 's_host.png', + '', + array('class' => 'item') + ); + } + $retval .= sprintf( + $item, + $GLOBALS['cfg']['DefaultTabServer'], + PMA_generate_common_url(), + htmlspecialchars($server_info), + __('Server') + ); + + if (strlen($this->db)) { + $retval .= $separator; + if ($GLOBALS['cfg']['NavigationBarIconic']) { + $retval .= PMA_getImage( + 's_db.png', + '', + array('class' => 'item') + ); + } + $retval .= sprintf( + $item, + $GLOBALS['cfg']['DefaultTabDatabase'], + PMA_generate_common_url($this->db), + htmlspecialchars($this->db), + __('Database') + ); + // if the table is being dropped, $_REQUEST['purge'] is set to '1' + // so do not display the table name in upper div + if ( + strlen($this->table) + && + ! (isset($_REQUEST['purge']) && $_REQUEST['purge'] == '1') + ) { + include_once './libraries/tbl_info.inc.php'; + + $retval .= $separator; + if ($GLOBALS['cfg']['NavigationBarIconic']) { + $icon = $tbl_is_view ? 'b_views.png' : 's_tbl.png'; + $retval .= PMA_getImage( + $icon, + '', + array('class' => 'item') + ); + } + $retval .= sprintf( + $item, + $GLOBALS['cfg']['DefaultTabTable'], + PMA_generate_common_url($this->db, $this->table), + str_replace(' ', ' ', htmlspecialchars($this->table)), + $tbl_is_view ? __('View') : __('Table') + ); + + /** + * Displays table comment + */ + if (! empty($show_comment) + && ! isset($GLOBALS['avoid_show_comment']) + ) { + if (strstr($show_comment, '; InnoDB free')) { + $show_comment = preg_replace( + '@; InnoDB free:.*?$@', + '', + $show_comment + ); + } + $retval .= ''; + $retval .= '"' . htmlspecialchars($show_comment); + $retval .= '"' . "\n"; + } // end if + } else { + // no table selected, display database comment if present + /** + * Settings for relations stuff + */ + include_once './libraries/relation.lib.php'; + $cfgRelation = PMA_getRelationsParam(); + + // Get additional information about tables for tooltip is done + // in libraries/db_info.inc.php only once + if ($cfgRelation['commwork']) { + $comment = PMA_getDbComment($this->db); + /** + * Displays table comment + */ + if (! empty($comment)) { + $retval .= '"' + . htmlspecialchars($comment) + . '"' . "\n"; + } // end if + } + } + } + $retval .= '
'; + $retval .= '
'; + return $retval; + } + private function getTableTabs() { $db_is_information_schema = PMA_is_system_schema($this->db); diff --git a/libraries/header.inc.php b/libraries/header.inc.php index 78c0f5d1ce..52bd3df7b8 100644 --- a/libraries/header.inc.php +++ b/libraries/header.inc.php @@ -97,7 +97,12 @@ if (isset($GLOBALS['is_ajax_request']) && !$GLOBALS['is_ajax_request']) { PMA_userprefs_autoload_header(); } - if (!defined('PMA_DISPLAY_HEADING')) { + // add recently used table and reload the navigation + if (strlen($GLOBALS['table']) && $GLOBALS['cfg']['LeftRecentTable'] > 0) { + PMA_addRecentTable($GLOBALS['db'], $GLOBALS['table']); + } + + if (! defined('PMA_DISPLAY_HEADING')) { define('PMA_DISPLAY_HEADING', 1); } @@ -110,113 +115,11 @@ if (isset($GLOBALS['is_ajax_request']) && !$GLOBALS['is_ajax_request']) { /** * Display heading if needed. Design can be set in css file. */ - if (PMA_DISPLAY_HEADING && $GLOBALS['server'] > 0) { - $server_info = ! empty($GLOBALS['cfg']['Server']['verbose']) - ? $GLOBALS['cfg']['Server']['verbose'] - : $GLOBALS['cfg']['Server']['host']; - $server_info .= empty($GLOBALS['cfg']['Server']['port']) - ? '' - : ':' . $GLOBALS['cfg']['Server']['port']; - - $separator = " »\n"; - $item = ''; - - if ($GLOBALS['cfg']['NavigationBarIconic'] !== true) { - $item .= '%4$s: '; - } - $item .= '%3$s' . "\n"; - echo "
\n"; - echo "
\n"; - if ($GLOBALS['cfg']['NavigationBarIconic']) { - echo PMA_getImage('s_host.png', '', array('class' => 'item')) . "\n"; - } - printf( - $item, - $GLOBALS['cfg']['DefaultTabServer'], - PMA_generate_common_url(), - htmlspecialchars($server_info), - __('Server') - ); - - if (strlen($GLOBALS['db'])) { - - echo $separator; - if ($GLOBALS['cfg']['NavigationBarIconic']) { - echo PMA_getImage('s_db.png', '', array('class' => 'item')) . "\n"; - } - printf( - $item, - $GLOBALS['cfg']['DefaultTabDatabase'], - PMA_generate_common_url($GLOBALS['db']), - htmlspecialchars($GLOBALS['db']), - __('Database') - ); - // if the table is being dropped, $_REQUEST['purge'] is set to '1' - // so do not display the table name in upper div - if (strlen($GLOBALS['table']) && ! (isset($_REQUEST['purge']) && $_REQUEST['purge'] == '1')) { - include_once './libraries/tbl_info.inc.php'; - - echo $separator; - if ($GLOBALS['cfg']['NavigationBarIconic']) { - $icon = isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? 'b_views.png' : 's_tbl.png'; - echo PMA_getImage($icon, '', array('class' => 'item')) . "\n"; - } - printf( - $item, - $GLOBALS['cfg']['DefaultTabTable'], - PMA_generate_common_url($GLOBALS['db'], $GLOBALS['table']), - str_replace(' ', ' ', htmlspecialchars($GLOBALS['table'])), - (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? __('View') : __('Table')) - ); - - /** - * Displays table comment - */ - if (!empty($show_comment) && ! isset($GLOBALS['avoid_show_comment'])) { - if (strstr($show_comment, '; InnoDB free')) { - $show_comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment); - } - echo '' - .'"' . htmlspecialchars($show_comment) - .'"' . "\n"; - } // end if - - // add recently used table and reload the navigation - if ($GLOBALS['cfg']['LeftRecentTable'] > 0) { - PMA_addRecentTable($GLOBALS['db'], $GLOBALS['table']); - } - } else { - // no table selected, display database comment if present - /** - * Settings for relations stuff - */ - include_once './libraries/relation.lib.php'; - $cfgRelation = PMA_getRelationsParam(); - - // Get additional information about tables for tooltip is done - // in libraries/db_info.inc.php only once - if ($cfgRelation['commwork']) { - $comment = PMA_getDbComment($GLOBALS['db']); - /** - * Displays table comment - */ - if (! empty($comment)) { - echo '"' - . htmlspecialchars($comment) - . '"' . "\n"; - } // end if - } - } - } - echo '
'; - echo '
'; + new Menu($GLOBALS['server'], $GLOBALS['db'], $GLOBALS['table']); } } - new Menu($GLOBALS['server'], $GLOBALS['db'], $GLOBALS['table']); - /** * Sets a variable to remember headers have been sent */ From e33e486da94380610eb879b609f85d57f6c46f1d Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 5 May 2012 16:47:01 +0100 Subject: [PATCH 10/15] Renamed the Menu class to PMA_Menu --- libraries/Menu.class.php | 2 +- libraries/header.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index c668d82e82..3d91fe5393 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -1,6 +1,6 @@ 0) { - new Menu($GLOBALS['server'], $GLOBALS['db'], $GLOBALS['table']); + new PMA_Menu($GLOBALS['server'], $GLOBALS['db'], $GLOBALS['table']); } } From 42da5489f95625e77e2552b17973bc2c16a79caa Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 5 May 2012 17:00:17 +0100 Subject: [PATCH 11/15] Moved menu rendering to function --- libraries/header.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/header.inc.php b/libraries/header.inc.php index 151b9c3d40..ab62b4d96d 100644 --- a/libraries/header.inc.php +++ b/libraries/header.inc.php @@ -116,7 +116,8 @@ if (isset($GLOBALS['is_ajax_request']) && !$GLOBALS['is_ajax_request']) { * Display heading if needed. Design can be set in css file. */ if (PMA_DISPLAY_HEADING && $GLOBALS['server'] > 0) { - new PMA_Menu($GLOBALS['server'], $GLOBALS['db'], $GLOBALS['table']); + $menu = new PMA_Menu($GLOBALS['server'], $GLOBALS['db'], $GLOBALS['table']); + $menu->display(); } } From 98776b374c47191612fa5ef164f6a2c56e60cd18 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 5 May 2012 17:11:39 +0100 Subject: [PATCH 12/15] Added docblocks to PMA_Menu class --- libraries/Menu.class.php | 89 ++++++++++++++++++++++++++++++++-------- 1 file changed, 71 insertions(+), 18 deletions(-) diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index 3d91fe5393..8c7f60d4b2 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -1,43 +1,81 @@ server = $server; $this->db = $db; $this->table = $table; + } - if (! $GLOBALS['is_ajax_request']) { - echo $this->getBreadcrumbs(); - echo $this->getMenu(); - if (! empty($GLOBALS['message'])) { - PMA_showMessage($GLOBALS['message']); - unset($GLOBALS['message']); - } - } else { - // nothing for now + /** + * Prints the menu and the breadcrumbs + * + * @return void + */ + public function display() + { + echo $this->_getBreadcrumbs(); + echo $this->_getMenu(); + if (! empty($GLOBALS['message'])) { + PMA_showMessage($GLOBALS['message']); + unset($GLOBALS['message']); } } - private function getMenu() + /** + * Returns the menu as HTML + * + * @return string HTML formatted menubar + */ + private function _getMenu() { $tabs = ''; $url_params = array('db' => $this->db); if (strlen($this->table)) { - $tabs = $this->getTableTabs(); + $tabs = $this->_getTableTabs(); $url_params['table'] = $this->table; } else if (strlen($this->db)) { - $tabs = $this->getDbTabs(); + $tabs = $this->_getDbTabs(); } else { - $tabs = $this->getServerTabs(); + $tabs = $this->_getServerTabs(); } return PMA_generate_html_tabs($tabs, $url_params); } - private function getBreadcrumbs() + /** + * Returns the breadcrumbs as HTML + * + * @return string HTML formatted breadcrumbs + */ + private function _getBreadcrumbs() { $retval = ''; $tbl_is_view = PMA_Table::isView($this->db, $this->table); @@ -160,7 +198,12 @@ class PMA_Menu { return $retval; } - private function getTableTabs() + /** + * Returns the table tabs as an array + * + * @return array Data for generating table tabs + */ + private function _getTableTabs() { $db_is_information_schema = PMA_is_system_schema($this->db); $tbl_is_view = PMA_Table::isView($this->db, $this->table); @@ -239,7 +282,12 @@ class PMA_Menu { return $tabs; } - private function getDbTabs() + /** + * Returns the db tabs as an array + * + * @return array Data for generating db tabs + */ + private function _getDbTabs() { $db_is_information_schema = PMA_is_system_schema($this->db); $num_tables = count(PMA_DBI_get_tables($this->db)); @@ -336,7 +384,12 @@ class PMA_Menu { return $tabs; } - private function getServerTabs() + /** + * Returns the server tabs as an array + * + * @return array Data for generating server tabs + */ + private function _getServerTabs() { $is_superuser = PMA_isSuperuser(); $binary_logs = PMA_DRIZZLE From fdb9529677546cbe89caf2b75840b893ca4b0581 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 5 May 2012 17:11:50 +0100 Subject: [PATCH 13/15] Removed pointless include --- libraries/header.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/header.inc.php b/libraries/header.inc.php index ab62b4d96d..36dd18fead 100644 --- a/libraries/header.inc.php +++ b/libraries/header.inc.php @@ -8,7 +8,6 @@ if (! defined('PHPMYADMIN')) { exit; } -require_once './libraries/common.inc.php'; require_once './libraries/RecentTable.class.php'; require_once 'libraries/Menu.class.php'; From 98ae66645791418f751d17320a7477a8bab286d4 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 5 May 2012 17:26:31 +0100 Subject: [PATCH 14/15] Made the Menu class a singleton --- libraries/Menu.class.php | 24 +++++++++++++++++++++--- libraries/header.inc.php | 3 +-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index 8c7f60d4b2..cc43d6a5c8 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -10,7 +10,7 @@ if (! defined('PHPMYADMIN')) { } /** - * Generates and renders the top menu + * Singleton class for generating the top menu * * @package PhpMyAdmin */ @@ -18,9 +18,10 @@ class PMA_Menu { private $server; private $db; private $table; + private static $instance; /** - * Constructor + * Private constructor disables direct object creation * * @param int $server Server id * @param string $db Database name @@ -28,13 +29,30 @@ class PMA_Menu { * * @return New PMA_Table */ - public function __construct($server, $db, $table) + private function __construct($server, $db, $table) { $this->server = $server; $this->db = $db; $this->table = $table; } + /** + * Prints the menu and the breadcrumbs + * + * @return void + */ + public static function getInstance() + { + if (empty(self::$instance)) { + self::$instance = new PMA_Menu( + $GLOBALS['server'], + $GLOBALS['db'], + $GLOBALS['table'] + ); + } + return self::$instance; + } + /** * Prints the menu and the breadcrumbs * diff --git a/libraries/header.inc.php b/libraries/header.inc.php index 36dd18fead..4f66d1256f 100644 --- a/libraries/header.inc.php +++ b/libraries/header.inc.php @@ -115,8 +115,7 @@ if (isset($GLOBALS['is_ajax_request']) && !$GLOBALS['is_ajax_request']) { * Display heading if needed. Design can be set in css file. */ if (PMA_DISPLAY_HEADING && $GLOBALS['server'] > 0) { - $menu = new PMA_Menu($GLOBALS['server'], $GLOBALS['db'], $GLOBALS['table']); - $menu->display(); + PMA_Menu::getInstance()->display(); } } From b0ba9696f5d86d2b6ce7deec3f34177e4191285f Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 1 May 2012 00:08:31 +0100 Subject: [PATCH 15/15] Coding style fixes --- libraries/Menu.class.php | 58 +++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index cc43d6a5c8..5dc6f891e9 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -104,15 +104,15 @@ class PMA_Menu { ? '' : ':' . $GLOBALS['cfg']['Server']['port']; - $separator = " »\n"; + $separator = " »"; $item = ''; if ($GLOBALS['cfg']['NavigationBarIconic'] !== true) { $item .= '%4$s: '; } - $item .= '%3$s' . "\n"; - $retval .= "
\n"; - $retval .= "
\n"; + $item .= '%3$s'; + $retval .= "
"; + $retval .= "
"; if ($GLOBALS['cfg']['NavigationBarIconic']) { $retval .= PMA_getImage( 's_host.png', @@ -183,9 +183,10 @@ class PMA_Menu { $show_comment ); } - $retval .= ''; - $retval .= '"' . htmlspecialchars($show_comment); - $retval .= '"' . "\n"; + $retval .= '"' . htmlspecialchars($comment) - . '"' . "\n"; + . '"'; } // end if } } @@ -225,8 +226,12 @@ class PMA_Menu { { $db_is_information_schema = PMA_is_system_schema($this->db); $tbl_is_view = PMA_Table::isView($this->db, $this->table); + $table_status = PMA_Table::sGetStatusInfo($this->db, $this->table); - $table_info_num_rows = isset($table_status['Rows']) ? $table_status['Rows'] : 0; + $table_info_num_rows = 0; + if (isset($table_status['Rows'])) { + $table_info_num_rows = $table_status['Rows']; + } $tabs = array(); @@ -247,7 +252,7 @@ class PMA_Menu { $tabs['search']['text'] = __('Search'); $tabs['search']['link'] = 'tbl_select.php'; - if (!$db_is_information_schema) { + if (! $db_is_information_schema) { $tabs['insert']['icon'] = 'b_insrow.png'; $tabs['insert']['link'] = 'tbl_change.php'; $tabs['insert']['text'] = __('Insert'); @@ -262,7 +267,7 @@ class PMA_Menu { * Don't display "Import" and "Operations" * for views and information_schema */ - if (! $tbl_is_view && !$db_is_information_schema) { + if (! $tbl_is_view && ! $db_is_information_schema) { $tabs['import']['icon'] = 'b_tblimport.png'; $tabs['import']['link'] = 'tbl_import.php'; $tabs['import']['text'] = __('Import'); @@ -276,24 +281,26 @@ class PMA_Menu { $tabs['tracking']['text'] = __('Tracking'); $tabs['tracking']['link'] = 'tbl_tracking.php'; } - if (!$db_is_information_schema && !PMA_DRIZZLE) { - if (PMA_currentUserHasPrivilege('TRIGGER', $this->db, $this->table) && ! $tbl_is_view) { - $tabs['triggers']['link'] = 'tbl_triggers.php'; - $tabs['triggers']['text'] = __('Triggers'); - $tabs['triggers']['icon'] = 'b_triggers.png'; - } + if (! $db_is_information_schema + && ! PMA_DRIZZLE + && PMA_currentUserHasPrivilege('TRIGGER', $this->db, $this->table) + && ! $tbl_is_view + ) { + $tabs['triggers']['link'] = 'tbl_triggers.php'; + $tabs['triggers']['text'] = __('Triggers'); + $tabs['triggers']['icon'] = 'b_triggers.png'; } /** * Views support a limited number of operations */ - if ($tbl_is_view && !$db_is_information_schema) { + if ($tbl_is_view && ! $db_is_information_schema) { $tabs['operation']['icon'] = 'b_tblops.png'; $tabs['operation']['link'] = 'view_operations.php'; $tabs['operation']['text'] = __('Operations'); } - if ($table_info_num_rows == 0 && !$tbl_is_view) { + if ($table_info_num_rows == 0 && ! $tbl_is_view) { $tabs['browse']['warning'] = __('Table seems to be empty!'); $tabs['search']['warning'] = __('Table seems to be empty!'); } @@ -410,9 +417,16 @@ class PMA_Menu { private function _getServerTabs() { $is_superuser = PMA_isSuperuser(); - $binary_logs = PMA_DRIZZLE - ? null - : PMA_DBI_fetch_result('SHOW MASTER LOGS', 'Log_name', null, null, PMA_DBI_QUERY_STORE); + $binary_logs = null; + if (! PMA_DRIZZLE){ + $binary_logs = PMA_DBI_fetch_result( + 'SHOW MASTER LOGS', + 'Log_name', + null, + null, + PMA_DBI_QUERY_STORE + ); + } $tabs = array();