From 18d6c538a7d8865dca44f4e37d88b54dc30c20e6 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Sat, 9 Aug 2014 17:29:50 +1200 Subject: [PATCH] API: Extract siteconfig out to an external module. --- _config.php | 2 + code/controllers/CMSSettingsController.php | 112 +------ code/model/SiteConfig.php | 312 ------------------ composer.json | 3 +- .../Includes/CMSSettingsController_Content.ss | 27 -- .../CMSSettingsController_EditForm.ss | 33 -- tests/behat/features/settings-main.feature | 37 --- tests/model/SiteConfigTest.php | 38 --- 8 files changed, 10 insertions(+), 554 deletions(-) delete mode 100644 code/model/SiteConfig.php delete mode 100644 templates/Includes/CMSSettingsController_Content.ss delete mode 100644 templates/Includes/CMSSettingsController_EditForm.ss delete mode 100644 tests/behat/features/settings-main.feature delete mode 100644 tests/model/SiteConfigTest.php diff --git a/_config.php b/_config.php index 8dcb80d8..24634c9a 100644 --- a/_config.php +++ b/_config.php @@ -22,3 +22,5 @@ CMSMenu::remove_menu_item('CMSPageHistoryController'); CMSMenu::remove_menu_item('CMSPageReportsController'); CMSMenu::remove_menu_item('CMSPageAddController'); CMSMenu::remove_menu_item('CMSFileAddController'); + +CMSMenu::remove_menu_item("SiteConfigLeftAndMain"); \ No newline at end of file diff --git a/code/controllers/CMSSettingsController.php b/code/controllers/CMSSettingsController.php index a39b402f..49179b08 100644 --- a/code/controllers/CMSSettingsController.php +++ b/code/controllers/CMSSettingsController.php @@ -1,110 +1,10 @@ setCallback('CurrentForm', function() use(&$controller) { - return $controller->renderWith($controller->getTemplatesWithSuffix('_Content')); - }); - return $neg; - } - - /** - * @param null $id Not used. - * @param null $fields Not used. - * @return Form - */ - public function getEditForm($id = null, $fields = null) { - $siteConfig = SiteConfig::current_site_config(); - $fields = $siteConfig->getCMSFields(); - - // Tell the CMS what URL the preview should show - $fields->push(new HiddenField('PreviewURL', 'Preview URL', RootURLController::get_homepage_link())); - // Added in-line to the form, but plucked into different view by LeftAndMain.Preview.js upon load - $fields->push($navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator())); - $navField->setAllowHTML(true); - - $actions = $siteConfig->getCMSActions(); - $form = CMSForm::create( - $this, 'EditForm', $fields, $actions - )->setHTMLID('Form_EditForm'); - $form->setResponseNegotiator($this->getResponseNegotiator()); - $form->addExtraClass('cms-content center cms-edit-form'); - // don't add data-pjax-fragment=CurrentForm, its added in the content template instead - - if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet'); - $form->setHTMLID('Form_EditForm'); - $form->loadDataFrom($siteConfig); - $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); - - // Use