diff --git a/code/controller/AssetAdmin.php b/code/controller/AssetAdmin.php index ca671a5c..b23388a8 100755 --- a/code/controller/AssetAdmin.php +++ b/code/controller/AssetAdmin.php @@ -358,7 +358,7 @@ JS return $record->ID; } else if($this->isAjax()) { $form = $this->getEditForm($record->ID); - return $form->formHtmlContent(); + return $form->forTemplate(); } else { return $this->redirect(Controller::join_links($this->Link('show'), $record->ID)); } diff --git a/code/controller/CMSMain.php b/code/controller/CMSMain.php index 8293ec21..5de891fc 100755 --- a/code/controller/CMSMain.php +++ b/code/controller/CMSMain.php @@ -345,7 +345,7 @@ JS; $this->response->addHeader('X-Status', _t('LeftAndMain.SAVEDUP')); - return $form->formHtmlContent(); + return $form->forTemplate(); } /** * Get a database record to be managed by the CMS @@ -438,14 +438,6 @@ JS; $actions = $record->getCMSActions(); } - // Add a default or custom validator. - // @todo Currently the default Validator.js implementation - // adds javascript to the document body, meaning it won't - // be included properly if the associated fields are loaded - // through ajax. This means only serverside validation - // will kick in for pages+validation loaded through ajax. - // This will be solved by using less obtrusive javascript validation - // in the future, see http://open.silverstripe.com/ticket/2915 and http://open.silverstripe.com/ticket/3386 if($record->hasMethod('getCMSValidator')) { $validator = $record->getCMSValidator(); } else { @@ -464,7 +456,7 @@ JS; $form->addExtraClass('cms-edit-form'); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); // TODO Can't merge $FormAttributes in template at the moment - $form->addExtraClass('cms-content center ss-tabset'); + $form->addExtraClass('cms-content center ss-tabset ' . $this->BaseCSSClasses()); if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet'); if(!$record->canEdit() || $record->IsDeletedFromStage) { @@ -505,6 +497,19 @@ JS; return $form; } + + public function currentPageID() { + $id = parent::currentPageID(); + + // Fall back to homepage record + if(!$id) { + $homepageSegment = RootURLController::get_homepage_link(); + $homepageRecord = DataObject::get_one('SiteTree', sprintf('"URLSegment" = \'%s\'', $homepageSegment)); + if($homepageRecord) $id = $homepageRecord->ID; + } + + return $id; + } //------------------------------------------------------------------------------------------// // Data saving handlers @@ -578,7 +583,7 @@ JS; $form = $this->getEditForm($record->ID); } - return $form->formHtmlContent(); + return $form->forTemplate(); } @@ -615,7 +620,7 @@ JS; return $record->ID; } else if(Director::is_ajax()) { $form = $this->getEditForm($record->ID); - return $form->formHtmlContent(); + return $form->forTemplate(); } else { return $this->redirect(Controller::join_links($this->Link('show'), $record->ID)); } @@ -757,7 +762,7 @@ JS; $form = $this->getEditForm($record->ID); - return $form->formHtmlContent(); + return $form->forTemplate(); } /** @@ -791,7 +796,7 @@ JS; 'Live', "\"SiteTree_Live\".\"ID\" = $recordID" ); - return ($liveRecord) ? $form->formHtmlContent() : ""; + return ($liveRecord) ? $form->forTemplate() : ""; } else { $this->redirectBack(); } @@ -988,7 +993,7 @@ JS; $form = $this->getEditForm($record->ID); - return $form->formHtmlContent(); + return $form->forTemplate(); } function publish($data, $form) { @@ -1013,7 +1018,7 @@ JS; // Reload form, data and actions might have changed $form = $this->getEditForm($record->ID); - return $form->formHtmlContent(); + return $form->forTemplate(); } function performRollback($id, $version) { @@ -1187,7 +1192,7 @@ JS; } if($this->isAjax()) { - return $form->formHtmlContent(); + return $form->forTemplate(); } else { $templateData = $this->customise(array( "EditForm" => $form @@ -1426,7 +1431,7 @@ JS; // Reload form, data and actions might have changed $form = $this->getEditForm($restoredPage->ID); - return $form->formHtmlContent(); + return $form->forTemplate(); } function duplicate($request) { @@ -1450,7 +1455,7 @@ JS; // Reload form, data and actions might have changed $form = $this->getEditForm($newPage->ID); - return $form->formHtmlContent(); + return $form->forTemplate(); } else { user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING); } @@ -1471,7 +1476,7 @@ JS; // Reload form, data and actions might have changed $form = $this->getEditForm($newPage->ID); - return $form->formHtmlContent(); + return $form->forTemplate(); } else { user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING); } diff --git a/code/controller/CMSPagesController.php b/code/controller/CMSPagesController.php index 98a6f74e..db7e66b0 100644 --- a/code/controller/CMSPagesController.php +++ b/code/controller/CMSPagesController.php @@ -13,8 +13,21 @@ class CMSPagesController extends CMSMain { } function show($request) { - $c = new CMSPageEditController(); - return $this->redirect(Controller::join_links($c->Link('show'), $request->param('ID'))); + if($request->param('ID')) { + $c = new CMSPageEditController(); + return $this->redirect(Controller::join_links($c->Link('show'), $request->param('ID'))); + } else { + return parent::show($request); + } + } + + function Link($action = null) { + // Special case: All show links should redirect to the page edit interface instead (mostly from tree nodes) + if(preg_match('/^show/', $action)) { + return singleton('CMSPageEditController')->Link($action); + } else { + return parent::Link($action); + } } } \ No newline at end of file diff --git a/code/controller/CMSSettingsController.php b/code/controller/CMSSettingsController.php new file mode 100644 index 00000000..93bcac8f --- /dev/null +++ b/code/controller/CMSSettingsController.php @@ -0,0 +1,13 @@ +RootForm(); + } + +} \ No newline at end of file diff --git a/code/controller/ContentController.php b/code/controller/ContentController.php index ea3f2f18..de7c3652 100755 --- a/code/controller/ContentController.php +++ b/code/controller/ContentController.php @@ -120,6 +120,12 @@ class ContentController extends Controller { return Security::permissionFailure($this, sprintf($message, Controller::join_links($link, "?stage=Live"))); } } + + // Redirect to admin UI if user is logged in + if($this->URLSegment != 'Security' && Permission::check('CMS_ACCESS_CMSMain') && !$this->request->getVar('cms-preview-disabled')) { + $cmsController = singleton('CMSPageEditController'); + return Director::redirect(Controller::join_links($cmsController->Link('show'), $this->dataRecord->ID, '?cms-preview-expanded=1')); + } // Use theme from the site config if(($config = SiteConfig::current_site_config()) && $config->Theme) { diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php index dd57482a..d2b61b8c 100755 --- a/code/model/SiteTree.php +++ b/code/model/SiteTree.php @@ -1987,7 +1987,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid // "unpublish" $unpublish = FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete'); $unpublish->describe(_t('SiteTree.BUTTONUNPUBLISHDESC', 'Remove this page from the published site')); - $unpublish->addExtraClass('delete'); + $unpublish->addExtraClass('unpublish'); $unpublish->addExtraClass('ss-ui-action-destructive'); $actions->push($unpublish); } @@ -2025,7 +2025,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } // "save" - $actions->push(new FormAction('save',_t('CMSMain.SAVE','Save'))); + $actions->push($saveDraftAction = new FormAction('save',_t('CMSMain.SAVE','Save Draft'))); + $saveDraftAction->addExtraClass('save-draft'); } } @@ -2411,13 +2412,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } elseif($this->IsAddedToStage) { $tag = "ins title=\"" . _t('SiteTree.ADDEDTODRAFT', 'Added to draft site') . "\""; } elseif($this->IsModifiedOnStage) { - $tag = "span title=\"" . _t('SiteTree.MODIFIEDONDRAFT', 'Modified on draft site') . "\" class=\"modified\""; + $tag = "span title=\"" . _t('SiteTree.MODIFIEDONDRAFT', 'Modified on draft site') . "\" class=\"status modified\""; } else { $tag = ''; } $text = Convert::raw2xml(str_replace(array("\n","\r"),"",$this->MenuTitle)); - return ($tag) ? "<$tag>" . $text . "" . strtok($tag,' ') . ">" : $text; + return ($tag) ? ""."<$tag>" . $text . "" . strtok($tag,' ') . ">" : "". $text; } /** diff --git a/javascript/AssetAdmin.js b/javascript/AssetAdmin.js index 805f5f2d..74127f5a 100755 --- a/javascript/AssetAdmin.js +++ b/javascript/AssetAdmin.js @@ -47,7 +47,7 @@ var currNode = $('.cms-tree')[0].firstSelected(); if(currNode) { var url = $(currNode).find('a').attr('href'); - $('.cms-edit-form').loadForm(url); + $('.cms-content').loadForm(url); } $('.cms-tree')[0].setCustomURL('admin/assets/getsubtree'); $('.cms-tree')[0].reload({onSuccess: function() { diff --git a/javascript/CMSMain.js b/javascript/CMSMain.js index 77c5c3e5..5e048d6a 100644 --- a/javascript/CMSMain.js +++ b/javascript/CMSMain.js @@ -201,8 +201,9 @@ if (e.button!=2) { var $link = $(this); $link.addClass('loading'); - jQuery('.cms-edit-form').entwine('ss').loadForm( + jQuery('.cms-content').entwine('ss').loadForm( $(this).attr('href'), + null, function(e) { $link.removeClass('loading'); } @@ -263,8 +264,9 @@ var link = $(this).siblings('.versionlink').find('a').attr('href'); td.addClass('loading'); - jQuery('.cms-edit-form').entwine('ss').loadForm( + jQuery('.cms-content').entwine('ss').loadForm( link, + null, function(e) { td.removeClass('loading'); } @@ -314,8 +316,9 @@ data.push({name:$button.attr('name'), value: $button.val()}); if(loadEditForm) { - jQuery('.cms-edit-form').entwine('ss').loadForm( + jQuery('.cms-content').entwine('ss').loadForm( this.attr('action'), + null, function(e) { $button.removeClass('loading'); }, diff --git a/javascript/CMSPagesController.Tree.js b/javascript/CMSPagesController.Tree.js index 3aeca1d9..e69de29b 100644 --- a/javascript/CMSPagesController.Tree.js +++ b/javascript/CMSPagesController.Tree.js @@ -1,7 +0,0 @@ -(function($) { - $('.cms-tree').bind('select_node.jstree', function(e, data) { - var node = data.rslt.obj, url = $(node).find('a:first').attr('href'); - if(url && url != '#') document.location.href = url; - return false; - }); -}(jQuery)); \ No newline at end of file diff --git a/templates/Includes/AssetAdmin_Content.ss b/templates/Includes/AssetAdmin_Content.ss index 638f7239..d1ec94a3 100644 --- a/templates/Includes/AssetAdmin_Content.ss +++ b/templates/Includes/AssetAdmin_Content.ss @@ -1,4 +1,4 @@ -