From 3a8de5a7162edde4c3dee33f1cb63bcb14137d25 Mon Sep 17 00:00:00 2001 From: Crack Date: Mon, 21 Jun 2010 15:24:07 +0200 Subject: [PATCH] make form definition structure the same for setup script and user preferences --- .gsoc/todo.txt | 5 +++ libraries/config/ConfigFile.class.php | 2 - libraries/config/messages.inc.php | 11 +++-- libraries/config/setup.forms.php | 46 ++++++++++----------- libraries/config/user_preferences.forms.php | 3 +- setup/frames/form.inc.php | 23 ++--------- setup/frames/menu.inc.php | 10 ++--- setup/frames/servers.inc.php | 10 ++--- user_preferences.php | 7 +--- 9 files changed, 48 insertions(+), 69 deletions(-) diff --git a/.gsoc/todo.txt b/.gsoc/todo.txt index 4dd9492f8..1da79aa5e 100644 --- a/.gsoc/todo.txt +++ b/.gsoc/todo.txt @@ -1 +1,6 @@ +cache'ing of user preferences to avoid round trips to server on each page refresh + +backlog: +- Import and Export options + restore cache'ing in phpmyadmin.css.php diff --git a/libraries/config/ConfigFile.class.php b/libraries/config/ConfigFile.class.php index ffbcea1ad..c91a964cc 100644 --- a/libraries/config/ConfigFile.class.php +++ b/libraries/config/ConfigFile.class.php @@ -177,11 +177,9 @@ class ConfigFile { // no recursion for numeric arrays if (is_array($value) && !isset($value[0])) { - //$prefix .= (empty($prefix) ? '' : '/') . $key; $prefix .= $key . '/'; array_walk($value, array($this, '_flattenArray'), $prefix); } else { - //$this->_flattenArrayResult[$prefix . '/' . $key] = $value; $this->_flattenArrayResult[$prefix . $key] = $value; } } diff --git a/libraries/config/messages.inc.php b/libraries/config/messages.inc.php index fe9de51cd..490f32ec2 100644 --- a/libraries/config/messages.inc.php +++ b/libraries/config/messages.inc.php @@ -121,12 +121,11 @@ $strSetupForm_Server_pmadb_desc = __('Configure phpMyAdmin database to gain acce $strSetupForm_Server_pmadb = __('PMA database'); $strSetupForm_Server_tracking_desc = __('Tracking of changes made in database. Requires configured PMA database.'); $strSetupForm_Server_tracking = __('Changes tracking'); -$strSetupFormset_customization = __('Customization'); -$strSetupFormset_export = __('Customize export options'); -$strSetupFormset_features = __('Features'); -$strSetupFormset_import = __('Customize import defaults'); -$strSetupFormset_left_frame = __('Customize navigation frame'); -$strSetupFormset_main_frame = __('Customize main frame'); +$strSetupFormset_Export = __('Customize export options'); +$strSetupFormset_Features = __('Features'); +$strSetupFormset_Import = __('Customize import defaults'); +$strSetupFormset_Left_frame = __('Customize navigation frame'); +$strSetupFormset_Main_frame = __('Customize main frame'); $strSetupForm_Sql_box_desc = __('Customize links shown in SQL Query boxes'); $strSetupForm_Sql_box = __('SQL Query box'); $strSetupForm_Sql_queries_desc = __('SQL queries settings, for SQL Query box options see [a@?page=form&formset=main_frame#tab_Sql_box]Navigation frame[/a] settings'); diff --git a/libraries/config/setup.forms.php b/libraries/config/setup.forms.php index 2f78f6732..2ddc0e97a 100644 --- a/libraries/config/setup.forms.php +++ b/libraries/config/setup.forms.php @@ -4,12 +4,12 @@ * Fields MUST have their counterparts in the $cfg array. * * There are two possible notations: - * $forms['Form name'] = array('Servers' => array(1 => array('host'))); + * $forms['Form group']['Form name'] = array('Servers' => array(1 => array('host'))); * can be written as - * $forms['Form name'] = array('Servers/1/host'); + * $forms['Form group']['Form name'] = array('Servers/1/host'); * * You can assign default values set by special button ("set value: ..."), eg.: - * $forms['Server_pmadb'] = array('Servers' => array(1 => array( + * $forms['Servers']['Server_pmadb'] = array('Servers' => array(1 => array( * 'pmadb' => 'phpmyadmin'))); * * @package phpMyAdmin-setup @@ -21,7 +21,7 @@ $forms = array(); $forms['_config.php'] = array( 'DefaultLang', 'ServerDefault'); -$forms['Server'] = array('Servers' => array(1 => array( +$forms['Servers']['Server'] = array('Servers' => array(1 => array( 'verbose', 'host', 'port', @@ -36,11 +36,11 @@ $forms['Server'] = array('Servers' => array(1 => array( 'password', 'nopassword', 'auth_swekey_config' => './swekey.conf'))); -$forms['Server_login_options'] = array('Servers' => array(1 => array( +$forms['Servers']['Server_login_options'] = array('Servers' => array(1 => array( 'SignonSession', 'SignonURL', 'LogoutURL'))); -$forms['Server_config'] = array('Servers' => array(1 => array( +$forms['Servers']['Server_config'] = array('Servers' => array(1 => array( 'only_db', 'hide_db', 'AllowRoot', @@ -50,7 +50,7 @@ $forms['Server_config'] = array('Servers' => array(1 => array( 'AllowDeny/rules', 'ShowDatabasesCommand', 'CountTables'))); -$forms['Server_pmadb'] = array('Servers' => array(1 => array( +$forms['Servers']['Server_pmadb'] = array('Servers' => array(1 => array( 'pmadb' => 'phpmyadmin', 'controluser', 'controlpass', @@ -65,14 +65,14 @@ $forms['Server_pmadb'] = array('Servers' => array(1 => array( 'table_coords' => 'pma_table_coords', 'pdf_pages' => 'pma_pdf_pages', 'designer_coords' => 'pma_designer_coords'))); -$forms['Server_tracking'] = array('Servers' => array(1 => array( +$forms['Servers']['Server_tracking'] = array('Servers' => array(1 => array( 'tracking_version_auto_create', 'tracking_default_statements', 'tracking_add_drop_view', 'tracking_add_drop_table', 'tracking_add_drop_database', ))); -$forms['Import_export'] = array( +$forms['Features']['Import_export'] = array( 'UploadDir', 'SaveDir', 'AllowAnywhereRecoding', @@ -83,7 +83,7 @@ $forms['Import_export'] = array( 'GZipDump', 'BZipDump', 'CompressOnFly'); -$forms['Security'] = array( +$forms['Features']['Security'] = array( 'blowfish_secret', 'ForceSSL', 'CheckConfigurationPermissions', @@ -94,7 +94,7 @@ $forms['Security'] = array( 'LoginCookieValidity', 'LoginCookieStore', 'LoginCookieDeleteAll'); -$forms['Sql_queries'] = array( +$forms['Features']['Sql_queries'] = array( 'ShowSQL', 'Confirm', 'QueryHistoryDB', @@ -106,12 +106,12 @@ $forms['Sql_queries'] = array( //'QueryWindowWidth', // overridden in theme //'QueryWindowHeight', 'QueryWindowDefTab'); -$forms['Page_titles'] = array( +$forms['Features']['Page_titles'] = array( 'TitleDefault', 'TitleTable', 'TitleDatabase', 'TitleServer'); -$forms['Other_core_settings'] = array( +$forms['Features']['Other_core_settings'] = array( 'NaturalOrder', 'InitialSlidersState', 'ErrorIconic', @@ -125,21 +125,21 @@ $forms['Other_core_settings'] = array( 'MemoryLimit', 'SkipLockedTables', 'UseDbSearch'); -$forms['Left_frame'] = array( +$forms['Left_frame']['Left_frame'] = array( 'LeftFrameLight', 'LeftDisplayLogo', 'LeftLogoLink', 'LeftLogoLinkWindow', 'LeftPointerEnable'); -$forms['Left_servers'] = array( +$forms['Left_frame']['Left_servers'] = array( 'LeftDisplayServers', 'DisplayServersList'); -$forms['Left_databases'] = array( +$forms['Left_frame']['Left_databases'] = array( 'DisplayDatabasesList', 'LeftFrameDBTree', 'LeftFrameDBSeparator', 'ShowTooltipAliasDB'); -$forms['Left_tables'] = array( +$forms['Left_frame']['Left_tables'] = array( 'LeftDefaultTabTable', 'LeftFrameTableSeparator', 'LeftFrameTableLevel', @@ -153,7 +153,7 @@ $forms['Startup'] = array( 'ShowChgPassword', 'ShowCreateDb', 'SuggestDBName'); -$forms['Browse'] = array( +$forms['Main_frame']['Browse'] = array( 'NavigationBarIconic', 'ShowAll', 'MaxRows', @@ -165,7 +165,7 @@ $forms['Browse'] = array( 'ModifyDeleteAtLeft', 'ModifyDeleteAtRight', 'DefaultDisplay'); -$forms['Edit'] = array( +$forms['Main_frame']['Edit'] = array( 'ProtectBinary', 'ShowFunctionFields', 'ShowFieldTypesInDataEditView', @@ -179,24 +179,24 @@ $forms['Edit'] = array( 'ForeignKeyDropdownOrder', 'ForeignKeyMaxLimit', 'DefaultPropDisplay'); -$forms['Tabs'] = array( +$forms['Main_frame']['Tabs'] = array( 'LightTabs', 'PropertiesIconic', 'DefaultTabServer', 'DefaultTabDatabase', 'DefaultTabTable', 'QueryWindowDefTab'); -$forms['Sql_box'] = array('SQLQuery' => array( +$forms['Main_frame']['Sql_box'] = array('SQLQuery' => array( 'Edit', 'Explain', 'ShowAsPHP', 'Validate', 'Refresh')); -$forms['Import_defaults'] = array('Import' => array( +$forms['Import']['Import_defaults'] = array('Import' => array( 'format', 'allow_interrupt', 'skip_queries')); -$forms['Export_defaults'] = array('Export' => array( +$forms['Export']['Export_defaults'] = array('Export' => array( 'format', 'compression', 'asfile', diff --git a/libraries/config/user_preferences.forms.php b/libraries/config/user_preferences.forms.php index dbc1ef691..a60c162d2 100644 --- a/libraries/config/user_preferences.forms.php +++ b/libraries/config/user_preferences.forms.php @@ -7,8 +7,7 @@ * $forms['Form group']['Form name'] = array('Servers/1/host'); * * You can assign default values set by special button ("set value: ..."), eg.: - * $forms['Server_pmadb'] = array('Servers' => array(1 => array( - * 'pmadb' => 'phpmyadmin'))); + * $forms['Server']['pmadb form'] = array('Servers/1/pmadb' => 'phpmyadmin'); * * @package phpMyAdmin */ diff --git a/setup/frames/form.inc.php b/setup/frames/form.inc.php index 604189ea7..91feebb00 100644 --- a/setup/frames/form.inc.php +++ b/setup/frames/form.inc.php @@ -20,33 +20,18 @@ require_once './setup/lib/form_processing.lib.php'; require './libraries/config/setup.forms.php'; -$formsets = array( - 'features' => array( - 'forms' => array('Import_export', 'Security', 'Sql_queries', 'Page_titles', - 'Other_core_settings')), - 'left_frame' => array( - 'forms' => array('Left_frame', 'Left_servers', 'Left_databases', 'Left_tables')), - 'main_frame' => array( - 'forms' => array('Startup', 'Browse', 'Edit', 'Tabs', 'Sql_box')), - 'import' => array( - 'forms' => array('Import_defaults')), - 'export' => array( - 'forms' => array('Export_defaults')) -); - $formset_id = filter_input(INPUT_GET, 'formset'); $mode = filter_input(INPUT_GET, 'mode'); -if (!isset($formsets[$formset_id])) { +if (!isset($forms[$formset_id])) { die('Incorrect formset, check $formsets array in setup/frames/form.inc.php'); } -$formset = $formsets[$formset_id]; if (isset($GLOBALS['strSetupFormset_' . $formset_id])) { echo '

' . $GLOBALS['strSetupFormset_' . $formset_id] . '

'; } $form_display = new FormDisplay(); -foreach ($formset['forms'] as $form_name) { - $form_display->registerForm($form_name, $forms[$form_name]); +foreach ($forms[$formset_id] as $form_name => $form) { + $form_display->registerForm($form_name, $form); } process_formset($form_display); -?> +?> \ No newline at end of file diff --git a/setup/frames/menu.inc.php b/setup/frames/menu.inc.php index 1da38512b..262812118 100644 --- a/setup/frames/menu.inc.php +++ b/setup/frames/menu.inc.php @@ -15,9 +15,9 @@ $separator = PMA_get_arg_separator('html'); ?> diff --git a/setup/frames/servers.inc.php b/setup/frames/servers.inc.php index 5fe22f960..6cb24f6d1 100644 --- a/setup/frames/servers.inc.php +++ b/setup/frames/servers.inc.php @@ -43,10 +43,8 @@ if (isset($page_title)) { echo '

' . $page_title . '

'; } $form_display = new FormDisplay(); -$form_display->registerForm('Server', $forms['Server'], $id); -$form_display->registerForm('Server_login_options', $forms['Server_login_options'], $id); -$form_display->registerForm('Server_config', $forms['Server_config'], $id); -$form_display->registerForm('Server_pmadb', $forms['Server_pmadb'], $id); -$form_display->registerForm('Server_tracking', $forms['Server_tracking'], $id); +foreach ($forms['Servers'] as $form_name => $form) { + $form_display->registerForm($form_name, $form, $id); +} process_formset($form_display); -?> +?> \ No newline at end of file diff --git a/user_preferences.php b/user_preferences.php index d0a0abeea..dcab713fa 100644 --- a/user_preferences.php +++ b/user_preferences.php @@ -41,13 +41,8 @@ foreach (array_keys($forms) as $formset) { echo PMA_generate_html_tabs($tabs, array()); // handle form display and processing -$forms_all_keys = array(); -foreach ($forms as $formset) { - foreach ($formset as $form) { - $forms_all_keys = array_merge($forms_all_keys, $form); - } -} +$forms_all_keys = PMA_read_userprefs_fieldnames($forms); $cf = ConfigFile::getInstance(); $cf->setAllowedKeys($forms_all_keys); $cf->updateWithGlobalConfig($GLOBALS['PMA_Config']);