diff options
-rw-r--r-- | db_sql.php | 2 | ||||
-rw-r--r-- | libraries/classes/Config/Forms/Page/BrowseForm.php | 21 | ||||
-rw-r--r-- | libraries/classes/Config/Forms/Page/DbStructureForm.php | 22 | ||||
-rw-r--r-- | libraries/classes/Config/Forms/Page/EditForm.php | 23 | ||||
-rw-r--r-- | libraries/classes/Config/Forms/Page/ExportForm.php | 12 | ||||
-rw-r--r-- | libraries/classes/Config/Forms/Page/ImportForm.php | 12 | ||||
-rw-r--r-- | libraries/classes/Config/Forms/Page/NaviForm.php | 12 | ||||
-rw-r--r-- | libraries/classes/Config/Forms/Page/PageFormList.php | 25 | ||||
-rw-r--r-- | libraries/classes/Config/Forms/Page/SqlForm.php | 12 | ||||
-rw-r--r-- | libraries/classes/Config/Forms/Page/TableStructureForm.php | 22 | ||||
-rw-r--r-- | libraries/classes/Config/PageSettings.php | 20 | ||||
-rw-r--r-- | server_sql.php | 2 | ||||
-rw-r--r-- | tbl_sql.php | 2 | ||||
-rw-r--r-- | test/classes/config/FormListTest.php | 27 | ||||
-rw-r--r-- | test/classes/config/PageSettingsTest.php | 2 |
15 files changed, 197 insertions, 19 deletions
diff --git a/db_sql.php b/db_sql.php index 3427cec598..72f7639607 100644 --- a/db_sql.php +++ b/db_sql.php @@ -15,7 +15,7 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/config/user_preferences.forms.php'; require_once 'libraries/config/page_settings.forms.php'; -PageSettings::showGroup('Sql_queries'); +PageSettings::showGroup('Sql'); /** * Runs common work diff --git a/libraries/classes/Config/Forms/Page/BrowseForm.php b/libraries/classes/Config/Forms/Page/BrowseForm.php new file mode 100644 index 0000000000..e39a7fd2f1 --- /dev/null +++ b/libraries/classes/Config/Forms/Page/BrowseForm.php @@ -0,0 +1,21 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +namespace PhpMyAdmin\Config\Forms\Page; + +use PhpMyAdmin\Config\Forms\BaseForm; +use PhpMyAdmin\Config\Forms\User\MainForm; + +class BrowseForm extends BaseForm +{ + public static function getForms() + { + return [ + 'Browse' => MainForm::getForms()['Browse'] + ]; + } +} diff --git a/libraries/classes/Config/Forms/Page/DbStructureForm.php b/libraries/classes/Config/Forms/Page/DbStructureForm.php new file mode 100644 index 0000000000..03c9172aae --- /dev/null +++ b/libraries/classes/Config/Forms/Page/DbStructureForm.php @@ -0,0 +1,22 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +namespace PhpMyAdmin\Config\Forms\Page; + +use PhpMyAdmin\Config\Forms\BaseForm; +use PhpMyAdmin\Config\Forms\User\MainForm; + +class DbStructureForm extends BaseForm +{ + public static function getForms() + { + return [ + 'DbStructure' => MainForm::getForms()['DbStructure'] + ]; + } +} + diff --git a/libraries/classes/Config/Forms/Page/EditForm.php b/libraries/classes/Config/Forms/Page/EditForm.php new file mode 100644 index 0000000000..b7b83b0333 --- /dev/null +++ b/libraries/classes/Config/Forms/Page/EditForm.php @@ -0,0 +1,23 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +namespace PhpMyAdmin\Config\Forms\Page; + +use PhpMyAdmin\Config\Forms\BaseForm; +use PhpMyAdmin\Config\Forms\User\MainForm; +use PhpMyAdmin\Config\Forms\User\FeaturesForm; + +class EditForm extends BaseForm +{ + public static function getForms() + { + return [ + 'Edit' => MainForm::getForms()['Edit'], + 'Text_fields' => FeaturesForm::getForms()['Text_fields'], + ]; + } +} diff --git a/libraries/classes/Config/Forms/Page/ExportForm.php b/libraries/classes/Config/Forms/Page/ExportForm.php new file mode 100644 index 0000000000..824be9c7e4 --- /dev/null +++ b/libraries/classes/Config/Forms/Page/ExportForm.php @@ -0,0 +1,12 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +namespace PhpMyAdmin\Config\Forms\Page; + +class ExportForm extends \PhpMyAdmin\Config\Forms\User\ExportForm +{ +} diff --git a/libraries/classes/Config/Forms/Page/ImportForm.php b/libraries/classes/Config/Forms/Page/ImportForm.php new file mode 100644 index 0000000000..991fe621b7 --- /dev/null +++ b/libraries/classes/Config/Forms/Page/ImportForm.php @@ -0,0 +1,12 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +namespace PhpMyAdmin\Config\Forms\Page; + +class ImportForm extends \PhpMyAdmin\Config\Forms\User\ImportForm +{ +} diff --git a/libraries/classes/Config/Forms/Page/NaviForm.php b/libraries/classes/Config/Forms/Page/NaviForm.php new file mode 100644 index 0000000000..33fbf33a83 --- /dev/null +++ b/libraries/classes/Config/Forms/Page/NaviForm.php @@ -0,0 +1,12 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +namespace PhpMyAdmin\Config\Forms\Page; + +class NaviForm extends \PhpMyAdmin\Config\Forms\User\NaviForm +{ +} diff --git a/libraries/classes/Config/Forms/Page/PageFormList.php b/libraries/classes/Config/Forms/Page/PageFormList.php new file mode 100644 index 0000000000..47b8483d6c --- /dev/null +++ b/libraries/classes/Config/Forms/Page/PageFormList.php @@ -0,0 +1,25 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Page preferences form + * + * @package PhpMyAdmin + */ +namespace PhpMyAdmin\Config\Forms\Page; + +use PhpMyAdmin\Config\Forms\BaseFormList; + +class PageFormList extends BaseFormList +{ + protected static $all = array( + 'Browse', + 'DbStructure', + 'Edit', + 'Export', + 'Import', + 'Navi', + 'Sql', + 'TableStructure', + ); + protected static $ns = 'PhpMyAdmin\\Config\\Forms\\Page\\'; +} diff --git a/libraries/classes/Config/Forms/Page/SqlForm.php b/libraries/classes/Config/Forms/Page/SqlForm.php new file mode 100644 index 0000000000..5a276f62ed --- /dev/null +++ b/libraries/classes/Config/Forms/Page/SqlForm.php @@ -0,0 +1,12 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +namespace PhpMyAdmin\Config\Forms\Page; + +class SqlForm extends \PhpMyAdmin\Config\Forms\User\SqlForm +{ +} diff --git a/libraries/classes/Config/Forms/Page/TableStructureForm.php b/libraries/classes/Config/Forms/Page/TableStructureForm.php new file mode 100644 index 0000000000..bf24540d6b --- /dev/null +++ b/libraries/classes/Config/Forms/Page/TableStructureForm.php @@ -0,0 +1,22 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +namespace PhpMyAdmin\Config\Forms\Page; + +use PhpMyAdmin\Config\Forms\BaseForm; +use PhpMyAdmin\Config\Forms\User\MainForm; + +class TableStructureForm extends BaseForm +{ + public static function getForms() + { + return [ + 'TableStructure' => MainForm::getForms()['TableStructure'] + ]; + } +} + diff --git a/libraries/classes/Config/PageSettings.php b/libraries/classes/Config/PageSettings.php index 560e25e65e..c0adb51cd6 100644 --- a/libraries/classes/Config/PageSettings.php +++ b/libraries/classes/Config/PageSettings.php @@ -9,13 +9,12 @@ namespace PhpMyAdmin\Config; use PhpMyAdmin\Config\ConfigFile; use PhpMyAdmin\Config\FormDisplay; +use PhpMyAdmin\Config\Forms\Page\PageFormList; use PhpMyAdmin\Core; use PhpMyAdmin\Message; use PhpMyAdmin\Response; require_once 'libraries/user_preferences.lib.php'; -require 'libraries/config/user_preferences.forms.php'; -require 'libraries/config/page_settings.forms.php'; /** * Page-related settings @@ -57,8 +56,7 @@ class PageSettings */ public function __construct($formGroupName, $elemId = null) { - global $forms; - if (empty($forms[$formGroupName])) { + if (! PageFormList::isValid($formGroupName)) { return; } @@ -74,16 +72,8 @@ class PageSettings $cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings); PMA_userprefsPageInit($cf); - $form_display = new FormDisplay($cf); - foreach ($forms[$formGroupName] as $form_name => $form) { - // skip Developer form if no setting is available - if ($form_name == 'Developer' - && !$GLOBALS['cfg']['UserprefsDeveloperTab'] - ) { - continue; - } - $form_display->registerForm($form_name, $form, 1); - } + $form_class = PageFormList::get($formGroupName); + $form_display = new $form_class($cf); // Process form $error = null; @@ -226,7 +216,7 @@ class PageSettings */ public static function getNaviSettings() { - $object = new PageSettings('Navi_panel', 'pma_navigation_settings'); + $object = new PageSettings('Navi', 'pma_navigation_settings'); $response = Response::getInstance(); $response->addHTML($object->getErrorHTML()); diff --git a/server_sql.php b/server_sql.php index 8d09a41fd3..410c4b8feb 100644 --- a/server_sql.php +++ b/server_sql.php @@ -15,7 +15,7 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/config/user_preferences.forms.php'; require_once 'libraries/config/page_settings.forms.php'; -PageSettings::showGroup('Sql_queries'); +PageSettings::showGroup('Sql'); /** * Does the common work diff --git a/tbl_sql.php b/tbl_sql.php index 40e34f524c..1643354b00 100644 --- a/tbl_sql.php +++ b/tbl_sql.php @@ -15,7 +15,7 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/config/user_preferences.forms.php'; require_once 'libraries/config/page_settings.forms.php'; -PageSettings::showGroup('Sql_queries'); +PageSettings::showGroup('Sql'); /** * Runs common work diff --git a/test/classes/config/FormListTest.php b/test/classes/config/FormListTest.php index a4a157bee9..ff6424f627 100644 --- a/test/classes/config/FormListTest.php +++ b/test/classes/config/FormListTest.php @@ -8,6 +8,7 @@ use PhpMyAdmin\Config\ConfigFile; use PhpMyAdmin\Config\Forms\User\UserFormList; +use PhpMyAdmin\Config\Forms\Page\PageFormList; require_once 'test/PMATestCase.php'; @@ -48,4 +49,30 @@ class FormListTest extends PMATestCase $this->assertFalse($forms->hasErrors()); $this->assertEquals('', $forms->displayErrors()); } + + /** + * Tests for page preferences forms. + */ + public function testPageForms() + { + $cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings); + + /* Static API */ + $this->assertTrue(PageFormList::isValid('Export')); + $this->assertEquals( + 'PhpMyAdmin\\Config\\Forms\\Page\\ExportForm', + PageFormList::get('Export') + ); + $this->assertContains( + 'Export/texytext_columns', + PageFormList::getFields() + ); + + /* Instance handling */ + $forms = new PageFormList($cf); + $this->assertFalse($forms->process()); + $forms->fixErrors(); + $this->assertFalse($forms->hasErrors()); + $this->assertEquals('', $forms->displayErrors()); + } } diff --git a/test/classes/config/PageSettingsTest.php b/test/classes/config/PageSettingsTest.php index 0a4fc9148d..873210f0e2 100644 --- a/test/classes/config/PageSettingsTest.php +++ b/test/classes/config/PageSettingsTest.php @@ -91,7 +91,7 @@ class PageSettingsTest extends PMATestCase ); $this->assertContains( - '<input type="hidden" name="submit_save" value="Navi_panel" />', + '<input type="hidden" name="submit_save" value="Navi" />', $html ); } |