2011-07-06 08:39:34 +02:00
|
|
|
<?php
|
2012-05-18 06:33:34 +02:00
|
|
|
class CMSSettingsController extends LeftAndMain {
|
2011-07-06 08:39:34 +02:00
|
|
|
|
|
|
|
static $url_segment = 'settings';
|
|
|
|
static $url_rule = '/$Action/$ID/$OtherID';
|
|
|
|
static $menu_priority = -1;
|
|
|
|
static $menu_title = 'Settings';
|
2012-07-13 11:00:21 +02:00
|
|
|
|
|
|
|
public function getResponseNegotiator() {
|
|
|
|
$neg = parent::getResponseNegotiator();
|
|
|
|
$controller = $this;
|
|
|
|
$neg->setCallback('CurrentForm', function() use(&$controller) {
|
|
|
|
return $controller->renderWith($controller->getTemplatesWithSuffix('_Content'));
|
|
|
|
});
|
|
|
|
return $neg;
|
|
|
|
}
|
2011-07-06 08:39:34 +02:00
|
|
|
|
2012-03-08 18:19:38 +01:00
|
|
|
/**
|
|
|
|
* @return Form
|
|
|
|
*/
|
2012-03-27 06:05:11 +02:00
|
|
|
function getEditForm($id = null, $fields = null) {
|
2012-03-08 18:19:38 +01:00
|
|
|
$siteConfig = SiteConfig::current_site_config();
|
|
|
|
$fields = $siteConfig->getCMSFields();
|
|
|
|
|
|
|
|
$actions = $siteConfig->getCMSActions();
|
|
|
|
$form = new Form($this, 'EditForm', $fields, $actions);
|
|
|
|
$form->addExtraClass('root-form');
|
2012-05-18 06:33:34 +02:00
|
|
|
$form->addExtraClass('cms-edit-form cms-panel-padded center');
|
2012-07-13 11:00:21 +02:00
|
|
|
// don't add data-pjax-fragment=CurrentForm, its added in the content template instead
|
2012-05-18 06:33:34 +02:00
|
|
|
|
2012-03-08 18:19:38 +01:00
|
|
|
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
|
|
|
|
$form->setHTMLID('Form_EditForm');
|
|
|
|
$form->loadDataFrom($siteConfig);
|
|
|
|
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
|
|
|
|
|
|
|
// Use <button> to allow full jQuery UI styling
|
|
|
|
$actions = $actions->dataFields();
|
|
|
|
if($actions) foreach($actions as $action) $action->setUseButtonTag(true);
|
|
|
|
|
|
|
|
$this->extend('updateEditForm', $form);
|
|
|
|
|
|
|
|
return $form;
|
2011-07-06 08:39:34 +02:00
|
|
|
}
|
2012-03-09 23:35:43 +01:00
|
|
|
|
2012-05-18 06:33:34 +02:00
|
|
|
|
2012-03-09 23:35:43 +01:00
|
|
|
/**
|
|
|
|
* Save the current sites {@link SiteConfig} into the database
|
|
|
|
*
|
|
|
|
* @param array $data
|
|
|
|
* @param Form $form
|
|
|
|
* @return String
|
|
|
|
*/
|
|
|
|
function save_siteconfig($data, $form) {
|
|
|
|
$siteConfig = SiteConfig::current_site_config();
|
|
|
|
$form->saveInto($siteConfig);
|
|
|
|
$siteConfig->write();
|
|
|
|
|
2012-05-18 06:54:33 +02:00
|
|
|
$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.')));
|
2012-07-13 11:00:21 +02:00
|
|
|
return $this->getResponseNegotiator()->respond($this->request);
|
2012-03-09 23:35:43 +01:00
|
|
|
}
|
2011-07-06 08:39:34 +02:00
|
|
|
|
2012-04-18 22:59:31 +02:00
|
|
|
function LinkPreview() {
|
2011-10-29 19:13:19 +02:00
|
|
|
return false;
|
|
|
|
}
|
2012-03-02 20:45:44 +01:00
|
|
|
|
2012-03-27 06:05:11 +02:00
|
|
|
function Breadcrumbs($unlinked = false) {
|
2012-07-18 13:51:30 +02:00
|
|
|
$defaultTitle = self::menu_title_for_class(get_class($this));
|
2012-03-02 20:45:44 +01:00
|
|
|
return new ArrayList(array(
|
|
|
|
new ArrayData(array(
|
2012-07-18 13:51:30 +02:00
|
|
|
'Title' => _t("{$this->class}.MENUTITLE", $defaultTitle),
|
2012-03-02 20:45:44 +01:00
|
|
|
'Link' => false
|
|
|
|
))
|
|
|
|
));
|
|
|
|
}
|
2011-10-29 19:13:19 +02:00
|
|
|
|
2012-03-27 06:05:11 +02:00
|
|
|
}
|