make form definition structure the same for setup script and user preferences

This commit is contained in:
Crack
2010-06-21 15:24:07 +02:00
parent b68ba42f9f
commit 3a8de5a716
9 changed files with 48 additions and 69 deletions

View File

@@ -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 restore cache'ing in phpmyadmin.css.php

View File

@@ -177,11 +177,9 @@ class ConfigFile
{ {
// no recursion for numeric arrays // no recursion for numeric arrays
if (is_array($value) && !isset($value[0])) { if (is_array($value) && !isset($value[0])) {
//$prefix .= (empty($prefix) ? '' : '/') . $key;
$prefix .= $key . '/'; $prefix .= $key . '/';
array_walk($value, array($this, '_flattenArray'), $prefix); array_walk($value, array($this, '_flattenArray'), $prefix);
} else { } else {
//$this->_flattenArrayResult[$prefix . '/' . $key] = $value;
$this->_flattenArrayResult[$prefix . $key] = $value; $this->_flattenArrayResult[$prefix . $key] = $value;
} }
} }

View File

@@ -121,12 +121,11 @@ $strSetupForm_Server_pmadb_desc = __('Configure phpMyAdmin database to gain acce
$strSetupForm_Server_pmadb = __('PMA database'); $strSetupForm_Server_pmadb = __('PMA database');
$strSetupForm_Server_tracking_desc = __('Tracking of changes made in database. Requires configured PMA database.'); $strSetupForm_Server_tracking_desc = __('Tracking of changes made in database. Requires configured PMA database.');
$strSetupForm_Server_tracking = __('Changes tracking'); $strSetupForm_Server_tracking = __('Changes tracking');
$strSetupFormset_customization = __('Customization'); $strSetupFormset_Export = __('Customize export options');
$strSetupFormset_export = __('Customize export options'); $strSetupFormset_Features = __('Features');
$strSetupFormset_features = __('Features'); $strSetupFormset_Import = __('Customize import defaults');
$strSetupFormset_import = __('Customize import defaults'); $strSetupFormset_Left_frame = __('Customize navigation frame');
$strSetupFormset_left_frame = __('Customize navigation frame'); $strSetupFormset_Main_frame = __('Customize main frame');
$strSetupFormset_main_frame = __('Customize main frame');
$strSetupForm_Sql_box_desc = __('Customize links shown in SQL Query boxes'); $strSetupForm_Sql_box_desc = __('Customize links shown in SQL Query boxes');
$strSetupForm_Sql_box = __('SQL Query box'); $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'); $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');

View File

@@ -4,12 +4,12 @@
* Fields MUST have their counterparts in the $cfg array. * Fields MUST have their counterparts in the $cfg array.
* *
* There are two possible notations: * 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 * 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.: * 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'))); * 'pmadb' => 'phpmyadmin')));
* *
* @package phpMyAdmin-setup * @package phpMyAdmin-setup
@@ -21,7 +21,7 @@ $forms = array();
$forms['_config.php'] = array( $forms['_config.php'] = array(
'DefaultLang', 'DefaultLang',
'ServerDefault'); 'ServerDefault');
$forms['Server'] = array('Servers' => array(1 => array( $forms['Servers']['Server'] = array('Servers' => array(1 => array(
'verbose', 'verbose',
'host', 'host',
'port', 'port',
@@ -36,11 +36,11 @@ $forms['Server'] = array('Servers' => array(1 => array(
'password', 'password',
'nopassword', 'nopassword',
'auth_swekey_config' => './swekey.conf'))); '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', 'SignonSession',
'SignonURL', 'SignonURL',
'LogoutURL'))); 'LogoutURL')));
$forms['Server_config'] = array('Servers' => array(1 => array( $forms['Servers']['Server_config'] = array('Servers' => array(1 => array(
'only_db', 'only_db',
'hide_db', 'hide_db',
'AllowRoot', 'AllowRoot',
@@ -50,7 +50,7 @@ $forms['Server_config'] = array('Servers' => array(1 => array(
'AllowDeny/rules', 'AllowDeny/rules',
'ShowDatabasesCommand', 'ShowDatabasesCommand',
'CountTables'))); 'CountTables')));
$forms['Server_pmadb'] = array('Servers' => array(1 => array( $forms['Servers']['Server_pmadb'] = array('Servers' => array(1 => array(
'pmadb' => 'phpmyadmin', 'pmadb' => 'phpmyadmin',
'controluser', 'controluser',
'controlpass', 'controlpass',
@@ -65,14 +65,14 @@ $forms['Server_pmadb'] = array('Servers' => array(1 => array(
'table_coords' => 'pma_table_coords', 'table_coords' => 'pma_table_coords',
'pdf_pages' => 'pma_pdf_pages', 'pdf_pages' => 'pma_pdf_pages',
'designer_coords' => 'pma_designer_coords'))); '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_version_auto_create',
'tracking_default_statements', 'tracking_default_statements',
'tracking_add_drop_view', 'tracking_add_drop_view',
'tracking_add_drop_table', 'tracking_add_drop_table',
'tracking_add_drop_database', 'tracking_add_drop_database',
))); )));
$forms['Import_export'] = array( $forms['Features']['Import_export'] = array(
'UploadDir', 'UploadDir',
'SaveDir', 'SaveDir',
'AllowAnywhereRecoding', 'AllowAnywhereRecoding',
@@ -83,7 +83,7 @@ $forms['Import_export'] = array(
'GZipDump', 'GZipDump',
'BZipDump', 'BZipDump',
'CompressOnFly'); 'CompressOnFly');
$forms['Security'] = array( $forms['Features']['Security'] = array(
'blowfish_secret', 'blowfish_secret',
'ForceSSL', 'ForceSSL',
'CheckConfigurationPermissions', 'CheckConfigurationPermissions',
@@ -94,7 +94,7 @@ $forms['Security'] = array(
'LoginCookieValidity', 'LoginCookieValidity',
'LoginCookieStore', 'LoginCookieStore',
'LoginCookieDeleteAll'); 'LoginCookieDeleteAll');
$forms['Sql_queries'] = array( $forms['Features']['Sql_queries'] = array(
'ShowSQL', 'ShowSQL',
'Confirm', 'Confirm',
'QueryHistoryDB', 'QueryHistoryDB',
@@ -106,12 +106,12 @@ $forms['Sql_queries'] = array(
//'QueryWindowWidth', // overridden in theme //'QueryWindowWidth', // overridden in theme
//'QueryWindowHeight', //'QueryWindowHeight',
'QueryWindowDefTab'); 'QueryWindowDefTab');
$forms['Page_titles'] = array( $forms['Features']['Page_titles'] = array(
'TitleDefault', 'TitleDefault',
'TitleTable', 'TitleTable',
'TitleDatabase', 'TitleDatabase',
'TitleServer'); 'TitleServer');
$forms['Other_core_settings'] = array( $forms['Features']['Other_core_settings'] = array(
'NaturalOrder', 'NaturalOrder',
'InitialSlidersState', 'InitialSlidersState',
'ErrorIconic', 'ErrorIconic',
@@ -125,21 +125,21 @@ $forms['Other_core_settings'] = array(
'MemoryLimit', 'MemoryLimit',
'SkipLockedTables', 'SkipLockedTables',
'UseDbSearch'); 'UseDbSearch');
$forms['Left_frame'] = array( $forms['Left_frame']['Left_frame'] = array(
'LeftFrameLight', 'LeftFrameLight',
'LeftDisplayLogo', 'LeftDisplayLogo',
'LeftLogoLink', 'LeftLogoLink',
'LeftLogoLinkWindow', 'LeftLogoLinkWindow',
'LeftPointerEnable'); 'LeftPointerEnable');
$forms['Left_servers'] = array( $forms['Left_frame']['Left_servers'] = array(
'LeftDisplayServers', 'LeftDisplayServers',
'DisplayServersList'); 'DisplayServersList');
$forms['Left_databases'] = array( $forms['Left_frame']['Left_databases'] = array(
'DisplayDatabasesList', 'DisplayDatabasesList',
'LeftFrameDBTree', 'LeftFrameDBTree',
'LeftFrameDBSeparator', 'LeftFrameDBSeparator',
'ShowTooltipAliasDB'); 'ShowTooltipAliasDB');
$forms['Left_tables'] = array( $forms['Left_frame']['Left_tables'] = array(
'LeftDefaultTabTable', 'LeftDefaultTabTable',
'LeftFrameTableSeparator', 'LeftFrameTableSeparator',
'LeftFrameTableLevel', 'LeftFrameTableLevel',
@@ -153,7 +153,7 @@ $forms['Startup'] = array(
'ShowChgPassword', 'ShowChgPassword',
'ShowCreateDb', 'ShowCreateDb',
'SuggestDBName'); 'SuggestDBName');
$forms['Browse'] = array( $forms['Main_frame']['Browse'] = array(
'NavigationBarIconic', 'NavigationBarIconic',
'ShowAll', 'ShowAll',
'MaxRows', 'MaxRows',
@@ -165,7 +165,7 @@ $forms['Browse'] = array(
'ModifyDeleteAtLeft', 'ModifyDeleteAtLeft',
'ModifyDeleteAtRight', 'ModifyDeleteAtRight',
'DefaultDisplay'); 'DefaultDisplay');
$forms['Edit'] = array( $forms['Main_frame']['Edit'] = array(
'ProtectBinary', 'ProtectBinary',
'ShowFunctionFields', 'ShowFunctionFields',
'ShowFieldTypesInDataEditView', 'ShowFieldTypesInDataEditView',
@@ -179,24 +179,24 @@ $forms['Edit'] = array(
'ForeignKeyDropdownOrder', 'ForeignKeyDropdownOrder',
'ForeignKeyMaxLimit', 'ForeignKeyMaxLimit',
'DefaultPropDisplay'); 'DefaultPropDisplay');
$forms['Tabs'] = array( $forms['Main_frame']['Tabs'] = array(
'LightTabs', 'LightTabs',
'PropertiesIconic', 'PropertiesIconic',
'DefaultTabServer', 'DefaultTabServer',
'DefaultTabDatabase', 'DefaultTabDatabase',
'DefaultTabTable', 'DefaultTabTable',
'QueryWindowDefTab'); 'QueryWindowDefTab');
$forms['Sql_box'] = array('SQLQuery' => array( $forms['Main_frame']['Sql_box'] = array('SQLQuery' => array(
'Edit', 'Edit',
'Explain', 'Explain',
'ShowAsPHP', 'ShowAsPHP',
'Validate', 'Validate',
'Refresh')); 'Refresh'));
$forms['Import_defaults'] = array('Import' => array( $forms['Import']['Import_defaults'] = array('Import' => array(
'format', 'format',
'allow_interrupt', 'allow_interrupt',
'skip_queries')); 'skip_queries'));
$forms['Export_defaults'] = array('Export' => array( $forms['Export']['Export_defaults'] = array('Export' => array(
'format', 'format',
'compression', 'compression',
'asfile', 'asfile',

View File

@@ -7,8 +7,7 @@
* $forms['Form group']['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.: * You can assign default values set by special button ("set value: ..."), eg.:
* $forms['Server_pmadb'] = array('Servers' => array(1 => array( * $forms['Server']['pmadb form'] = array('Servers/1/pmadb' => 'phpmyadmin');
* 'pmadb' => 'phpmyadmin')));
* *
* @package phpMyAdmin * @package phpMyAdmin
*/ */

View File

@@ -20,33 +20,18 @@ require_once './setup/lib/form_processing.lib.php';
require './libraries/config/setup.forms.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'); $formset_id = filter_input(INPUT_GET, 'formset');
$mode = filter_input(INPUT_GET, 'mode'); $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'); die('Incorrect formset, check $formsets array in setup/frames/form.inc.php');
} }
$formset = $formsets[$formset_id];
if (isset($GLOBALS['strSetupFormset_' . $formset_id])) { if (isset($GLOBALS['strSetupFormset_' . $formset_id])) {
echo '<h2>' . $GLOBALS['strSetupFormset_' . $formset_id] . '</h2>'; echo '<h2>' . $GLOBALS['strSetupFormset_' . $formset_id] . '</h2>';
} }
$form_display = new FormDisplay(); $form_display = new FormDisplay();
foreach ($formset['forms'] as $form_name) { foreach ($forms[$formset_id] as $form_name => $form) {
$form_display->registerForm($form_name, $forms[$form_name]); $form_display->registerForm($form_name, $form);
} }
process_formset($form_display); process_formset($form_display);
?> ?>

View File

@@ -15,9 +15,9 @@ $separator = PMA_get_arg_separator('html');
?> ?>
<ul> <ul>
<li><a href="index.php"><?php echo __('Overview') ?></a></li> <li><a href="index.php"><?php echo __('Overview') ?></a></li>
<li><a href="?page=form<?php echo $separator ?>formset=features"><?php echo __('Features') ?></a></li> <li><a href="?page=form<?php echo $separator ?>formset=Features"><?php echo __('Features') ?></a></li>
<li><a href="?page=form<?php echo $separator ?>formset=left_frame"><?php echo __('Navigation frame') ?></a></li> <li><a href="?page=form<?php echo $separator ?>formset=Left_frame"><?php echo __('Navigation frame') ?></a></li>
<li><a href="?page=form<?php echo $separator ?>formset=main_frame"><?php echo __('Main frame') ?></a></li> <li><a href="?page=form<?php echo $separator ?>formset=Main_frame"><?php echo __('Main frame') ?></a></li>
<li><a href="?page=form<?php echo $separator ?>formset=import"><?php echo __('Import') ?></a></li> <li><a href="?page=form<?php echo $separator ?>formset=Import"><?php echo __('Import') ?></a></li>
<li><a href="?page=form<?php echo $separator ?>formset=export"><?php echo __('Export') ?></a></li> <li><a href="?page=form<?php echo $separator ?>formset=Export"><?php echo __('Export') ?></a></li>
</ul> </ul>

View File

@@ -43,10 +43,8 @@ if (isset($page_title)) {
echo '<h2>' . $page_title . '</h2>'; echo '<h2>' . $page_title . '</h2>';
} }
$form_display = new FormDisplay(); $form_display = new FormDisplay();
$form_display->registerForm('Server', $forms['Server'], $id); foreach ($forms['Servers'] as $form_name => $form) {
$form_display->registerForm('Server_login_options', $forms['Server_login_options'], $id); $form_display->registerForm($form_name, $form, $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);
process_formset($form_display); process_formset($form_display);
?> ?>

View File

@@ -41,13 +41,8 @@ foreach (array_keys($forms) as $formset) {
echo PMA_generate_html_tabs($tabs, array()); echo PMA_generate_html_tabs($tabs, array());
// handle form display and processing // 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 = ConfigFile::getInstance();
$cf->setAllowedKeys($forms_all_keys); $cf->setAllowedKeys($forms_all_keys);
$cf->updateWithGlobalConfig($GLOBALS['PMA_Config']); $cf->updateWithGlobalConfig($GLOBALS['PMA_Config']);