diff --git a/code/GridFieldPageSectionsExtension.php b/code/GridFieldPageSectionsExtension.php index b84c41e..c93c274 100644 --- a/code/GridFieldPageSectionsExtension.php +++ b/code/GridFieldPageSectionsExtension.php @@ -164,7 +164,7 @@ public function getColumnContent($gridField, $record, $columnName) { return ViewableData::create()->customise(array( "ButtonField" => $field, - "Title" => $record->Title, + "Title" => $record->i18n_singular_name(), ))->renderWith("GridFieldPageElement"); } @@ -173,7 +173,7 @@ public function getColumnContent($gridField, $record, $columnName) { $temp = $record; while ($temp->_Parent) { $temp = $temp->_Parent; - $link = Controller::join_links("item", $temp->ID, + $link = Controller::join_links("item", $temp->ID, "ItemEditForm", "field", "Children", $link ); } diff --git a/code/PageElement.php b/code/PageElement.php index dba91d6..c7510d6 100644 --- a/code/PageElement.php +++ b/code/PageElement.php @@ -32,8 +32,6 @@ function canCreate($member = null) { return true; } ); public static $summary_fields = array( - 'SingularName', - 'ID', 'GridFieldPreview', ); @@ -56,7 +54,7 @@ public function onBeforeWrite() { $list = $this->Children()->Sort("SortOrder")->toArray(); $count = count($list); - for ($i = 1; $i <= $count; $i++) { + for ($i = 1; $i <= $count; $i++) { $this->Children()->Add($list[$i - 1], array("SortOrder" => $i * 2)); } } @@ -77,12 +75,13 @@ public function getChildrenGridField() { ->addComponent($addNewButton) ->addComponent(new GridFieldPageSectionsExtension($this->owner)) ->addComponent(new GridFieldDetailForm()); - + $dataColumns->setFieldCasting(array('GridFieldPreview' => 'HTMLText->RAW')); + return new GridField("Children", "Children", $this->Children(), $config); } public function getGridFieldPreview() { - return null; + return $this->Title; } public function getCMSFields() { @@ -97,7 +96,7 @@ public function getCMSFields() { return $fields; } - + public function getParentIDs() { $IDArr = array($this->ID); foreach($this->Parents() as $parent) { @@ -117,7 +116,7 @@ public function forTemplate($parentList = "") { $parents = ArrayList::create(); $splits = explode(",", $parentList); $num = count($splits); - for ($i = 0; $i < $num - 1; $i++) { + for ($i = 0; $i < $num - 1; $i++) { $parents->add(PageElement::get()->byID($splits[$i])); } $page = SiteTree::get()->byID($splits[$num - 1]); @@ -127,4 +126,19 @@ public function forTemplate($parentList = "") { array("ParentList" => $parentList, "Parents" => $parents, "Page" => $page) ); } + + public function getBetterButtonsUtils() { + $fieldList = FieldList::create(array( + BetterButtonPrevNextAction::create(), + )); + return $fieldList; + } + + public function getBetterButtonsActions() { + $fieldList = FieldList::create(array( + BetterButton_SaveAndClose::create(), + BetterButton_Save::create(), + )); + return $fieldList; + } } diff --git a/code/PageSectionsExtension.php b/code/PageSectionsExtension.php index 913d7c3..c0888c2 100644 --- a/code/PageSectionsExtension.php +++ b/code/PageSectionsExtension.php @@ -27,7 +27,7 @@ public function extraStatics($class = null, $extensionClass = null) { Config::inst()->update($class, "many_many_extraFields", $many_many_extraFields); return array(); } - + public static function getAllowedPageElements() { $classes = array_values(ClassInfo::subclassesFor("PageElement")); $classes = array_diff($classes, ["PageElement"]); @@ -44,12 +44,12 @@ public function onBeforeWrite() { $list = $this->owner->$name()->Sort("SortOrder")->toArray(); $count = count($list); - for ($i = 1; $i <= $count; $i++) { + for ($i = 1; $i <= $count; $i++) { $this->owner->$name()->Add($list[$i - 1], array("SortOrder" => $i * 2)); } } } - + public function updateCMSFields(FieldList $fields) { $sections = $this->owner->config()->get("page_sections"); if (!$sections) $sections = array("Main"); @@ -58,7 +58,7 @@ public function updateCMSFields(FieldList $fields) { $name = "PageSection".$section; $fields->removeByName($name); - + if ($this->owner->ID) { $addNewButton = new GridFieldAddNewMultiClass(); $addNewButton->setClasses($this->owner->getAllowedPageElements()); @@ -74,6 +74,8 @@ public function updateCMSFields(FieldList $fields) { ->addComponent($addNewButton) ->addComponent(new GridFieldPageSectionsExtension($this->owner)) ->addComponent(new GridFieldDetailForm()); + $dataColumns = $config->getComponentByType('GridFieldDataColumns'); + $dataColumns->setFieldCasting(array('GridFieldPreview' => 'HTMLText->RAW')); $f = new GridField($name, $section, $this->owner->$name(), $config); $fields->addFieldToTab("Root.PageSections", $f); @@ -82,7 +84,7 @@ public function updateCMSFields(FieldList $fields) { } public function PageSection($name = "Main") { - $elements = $this->owner->getVersionedRelation("PageSection" . $name); + $elements = $this->owner->{"PageSection" . $name}(); return $this->owner->renderWith( "RenderChildren", array("Elements" => $elements, "ParentList" => strval($this->owner->ID))