diff --git a/_config.php b/_config.php index b4cf76ec..97caa90f 100644 --- a/_config.php +++ b/_config.php @@ -32,4 +32,6 @@ Object::add_extension('File', 'SiteTreeFileExtension'); // TODO Remove once we can configure CMSMenu through static, nested configuration files CMSMenu::remove_menu_item('CMSPageEditController'); -CMSMenu::remove_menu_item('CMSPageSettingsController'); \ No newline at end of file +CMSMenu::remove_menu_item('CMSPageSettingsController'); +CMSMenu::remove_menu_item('CMSPageHistoryController'); +CMSMenu::remove_menu_item('CMSPageReportsController'); \ No newline at end of file diff --git a/code/controller/CMSMain.php b/code/controller/CMSMain.php index 885200a0..d58dd7ed 100644 --- a/code/controller/CMSMain.php +++ b/code/controller/CMSMain.php @@ -139,7 +139,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr * Return the entire site tree as a nested set of ULs */ public function SiteTreeAsUL() { - $this->generateDataTreeHints(); $this->generateTreeStylingJS(); // Pre-cache sitetree version numbers for querying efficiency @@ -172,8 +171,10 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr $fields = new FieldSet( new TextField('Term', _t('CMSSearch.FILTERLABELTEXT', 'Content')), - $dateFrom = new DateField('LastEditedFrom', _t('CMSSearch.FilterDateFrom', 'from')), - $dateTo = new DateField('LastEditedTo', _t('CMSSearch.FilterDateFrom', 'to')), + $dateGroup = new FieldGroup( + $dateFrom = new DateField('LastEditedFrom', _t('CMSSearch.FilterDateFrom', 'from')), + $dateTo = new DateField('LastEditedTo', _t('CMSSearch.FilterDateFrom', 'to')) + ), new DropdownField( 'FilterClass', _t('CMSMain.SearchTreeFormPagesDropdown', 'Pages'), @@ -189,6 +190,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr ) // new TextField('MetaTags', _t('CMSMain.SearchMetaTags', 'Meta tags')) ); + $dateGroup->subfieldParam = 'FieldHolder'; $dateFrom->setConfig('showcalendar', true); $dateTo->setConfig('showcalendar', true); @@ -210,27 +212,43 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr return $this->getsubtree($this->request); } - public function generateDataTreeHints() { - $classes = ClassInfo::subclassesFor( $this->stat('tree_class') ); + /** + * Create serialized JSON string with site tree hints data to be injected into + * 'data-hints' attribute of root node of jsTree. + * + * @return String Serialized JSON + */ + public function SiteTreeHints() { + $classes = ClassInfo::subclassesFor( $this->stat('tree_class') ); $def['Root'] = array(); + $def['Root']['disallowedChildren'] = array(); + $def['Root']['disallowedParents'] = array(); foreach($classes as $class) { $obj = singleton($class); if($obj instanceof HiddenClass) continue; - + $allowedChildren = $obj->allowedChildren(); - if($allowedChildren != "none") $def[$class]['allowedChildren'] = $allowedChildren; - $def[$class]['defaultChild'] = $obj->defaultChild(); - $def[$class]['defaultParent'] = isset(SiteTree::get_by_link($obj->defaultParent())->ID) ? SiteTree::get_by_link($obj->defaultParent())->ID : null; - - if($obj->stat('can_be_root')) { - $def['Root']['allowedChildren'][] = $class; + //SiteTree::allowedChildren() returns null rather than an empty array if SiteTree::allowed_chldren == 'none' + if ($allowedChildren == null) $allowedChildren = array(); + $def[$class]['disallowedChildren'] = array_keys(array_diff($classes, $allowedChildren)); + + $defaultChild = $obj->defaultChild(); + if ($defaultChild != 'Page' && $defaultChild != null) $def[$class]['defaultChild'] = $defaultChild; + + $defaultParent = isset(SiteTree::get_by_link($obj->defaultParent())->ID) ? SiteTree::get_by_link($obj->defaultParent())->ID : null; + if ($defaultParent != 1 && $defaultParent != null) $def[$class]['defaultParent'] = $defaultParent; + + if(is_array($def[$class]['disallowedChildren'])) foreach($def[$class]['disallowedChildren'] as $disallowedChild) { + $def[$disallowedChild]['disallowedParents'][] = $class; } + + //Are any classes allowed to be parents of root? + $def['Root']['disallowedParents'][] = $class; } - // Put data hints into a script tag at the top - Requirements::customScript("siteTreeHints = " . Convert::raw2json($def) . ";"); + return Convert::raw2xml(Convert::raw2json($def)); } public function generateTreeStylingJS() { @@ -1279,6 +1297,8 @@ JS; $fields = new FieldSet( // new HiddenField("ParentID", false, ($this->parentRecord) ? $this->parentRecord->ID : null), + // TODO Should be part of the form attribute, but not possible in current form API + $hintsField = new LiteralField('Hints', sprintf('', $this->SiteTreeHints())), $parentField = new TreeDropdownField("ParentID", _t('CMSMain.AddFormParentLabel', 'Parent page'), 'SiteTree'), new OptionsetField("PageType", "", $pageTypes, 'Page') ); @@ -1294,6 +1314,7 @@ JS; $this->extend('updatePageOptions', $fields); $form = new Form($this, "AddForm", $fields, $actions); + $form->addExtraClass('cms-add-form'); return $form; } diff --git a/code/controller/CMSPageEditController.php b/code/controller/CMSPageEditController.php index 47dfe085..aac1cc92 100644 --- a/code/controller/CMSPageEditController.php +++ b/code/controller/CMSPageEditController.php @@ -7,7 +7,15 @@ class CMSPageEditController extends CMSMain { function getEditForm($id = null, $fields = null) { $record = $this->getRecord($id ? $id : $this->currentPageID()); - return parent::getEditForm($record, ($record) ? $record->getCMSFields() : null); + $form = parent::getEditForm($record, ($record) ? $record->getCMSFields() : null); + + // TODO Replace with preview button + $form->Fields()->addFieldToTab( + 'Root.Main', + new LiteralField('SwitchView', sprintf('
%s
', $this->SwitchView())) + ); + + return $form; } } \ No newline at end of file diff --git a/code/controller/CMSPageHistoryController.php b/code/controller/CMSPageHistoryController.php new file mode 100644 index 00000000..2a1c38d2 --- /dev/null +++ b/code/controller/CMSPageHistoryController.php @@ -0,0 +1,12 @@ +
- ... + Not implemented yet
- ... + Not implemented yet
diff --git a/templates/Includes/CMSPageHistoryController_Content.ss b/templates/Includes/CMSPageHistoryController_Content.ss new file mode 100644 index 00000000..eca8c331 --- /dev/null +++ b/templates/Includes/CMSPageHistoryController_Content.ss @@ -0,0 +1,3 @@ +
+ Not implemented yet +
\ No newline at end of file diff --git a/templates/Includes/CMSPageReportsController_Content.ss b/templates/Includes/CMSPageReportsController_Content.ss new file mode 100644 index 00000000..eca8c331 --- /dev/null +++ b/templates/Includes/CMSPageReportsController_Content.ss @@ -0,0 +1,3 @@ +
+ Not implemented yet +
\ No newline at end of file diff --git a/templates/Includes/CMSPagesController_Content.ss b/templates/Includes/CMSPagesController_Content.ss index ade81db3..352e4e54 100644 --- a/templates/Includes/CMSPagesController_Content.ss +++ b/templates/Includes/CMSPagesController_Content.ss @@ -34,14 +34,10 @@ <% include CMSPagesController_ContentToolbar %> -
+
$SiteTreeAsUL
-
- <% include CMSPagesController_ContentToolbar %> -
-
$AddForm
@@ -49,11 +45,11 @@
- ... + Not implemented yet
- ... + Not implemented yet