mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
FIX Fixed the beforeUpdateCMSFields and made them consistent
This commit is contained in:
parent
78edab24ef
commit
9a77be6226
@ -33,10 +33,11 @@ class Blog extends Page {
|
|||||||
|
|
||||||
|
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
$this->beforeUpdateCMSFields(function($fields) {
|
$self =& $this;
|
||||||
|
$this->beforeUpdateCMSFields(function($fields) use ($self) {
|
||||||
|
|
||||||
$posts = $this->getBlogPosts();
|
$posts = $self->getBlogPosts();
|
||||||
$excluded = $this->getExcludedSiteTreeClassNames();
|
$excluded = $self->getExcludedSiteTreeClassNames();
|
||||||
if(!empty($excluded)) {
|
if(!empty($excluded)) {
|
||||||
$posts = $posts->filter("ClassName", $excluded);
|
$posts = $posts->filter("ClassName", $excluded);
|
||||||
$gridField = new GridField(
|
$gridField = new GridField(
|
||||||
@ -56,14 +57,14 @@ class Blog extends Page {
|
|||||||
$categories = GridField::create(
|
$categories = GridField::create(
|
||||||
"Categories",
|
"Categories",
|
||||||
_t("Blog.Categories", "Categories"),
|
_t("Blog.Categories", "Categories"),
|
||||||
$this->Categories(),
|
$self->Categories(),
|
||||||
$config
|
$config
|
||||||
);
|
);
|
||||||
|
|
||||||
$tags = GridField::create(
|
$tags = GridField::create(
|
||||||
"Tags",
|
"Tags",
|
||||||
_t("Blog.Tags", "Tags"),
|
_t("Blog.Tags", "Tags"),
|
||||||
$this->Tags(),
|
$self->Tags(),
|
||||||
$config
|
$config
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -260,8 +261,8 @@ class Blog_Controller extends Page_Controller {
|
|||||||
* @return string HTML
|
* @return string HTML
|
||||||
**/
|
**/
|
||||||
public function rss() {
|
public function rss() {
|
||||||
$rss = new RSSFeed($this->getBlogPosts(), $this->Link(), $this->MetaDescription, $this->MetaTitle);
|
$rss = new RSSFeed($this->getBlogPosts(), $this->Link(), $this->MetaDescription, $this->MetaTitle);
|
||||||
return $rss->outputToBrowser();
|
return $rss->outputToBrowser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,13 +59,8 @@ class BlogPost extends Page {
|
|||||||
|
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
|
|
||||||
// Assign to variable & pass for PHP <= 5.4 closure compatibility
|
$self =& $this;
|
||||||
$data = array(
|
$this->beforeUpdateCMSFields(function($fields) use ($self) {
|
||||||
"TagsMap" => $this->Parent()->Tags()->map()->toArray(),
|
|
||||||
"CategoryMap" => $this->Parent()->Categories()->map()->toArray()
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->beforeUpdateCMSFields(function($fields) use ($data) {
|
|
||||||
// Add Publish date fields
|
// Add Publish date fields
|
||||||
$fields->insertAfter(
|
$fields->insertAfter(
|
||||||
$publishDate = DatetimeField::create("PublishDate", _t("BlogPost.PublishDate", "Publish Date")),
|
$publishDate = DatetimeField::create("PublishDate", _t("BlogPost.PublishDate", "Publish Date")),
|
||||||
@ -74,12 +69,18 @@ class BlogPost extends Page {
|
|||||||
$publishDate->getDateField()->setConfig("showcalendar", true);
|
$publishDate->getDateField()->setConfig("showcalendar", true);
|
||||||
|
|
||||||
// Add Categories & Tags fields
|
// Add Categories & Tags fields
|
||||||
$categoriesField = ListboxField::create("Categories",
|
$categoriesField = ListboxField::create(
|
||||||
_t("BlogPost.Categories", "Categories"), $data['CategoryMap'])->setMultiple(true);
|
"Categories",
|
||||||
|
_t("BlogPost.Categories", "Categories"),
|
||||||
|
$self->Parent()->Categories()->map()->toArray()
|
||||||
|
)->setMultiple(true);
|
||||||
$fields->insertAfter($categoriesField, "PublishDate");
|
$fields->insertAfter($categoriesField, "PublishDate");
|
||||||
|
|
||||||
$tagsField = ListboxField::create("Tags", _t("BlogPost.Tags", "Tags"), $data['TagsMap'])
|
$tagsField = ListboxField::create(
|
||||||
->setMultiple(true);
|
"Tags",
|
||||||
|
_t("BlogPost.Tags", "Tags"),
|
||||||
|
$self->Parent()->Tags()->map()->toArray()
|
||||||
|
)->setMultiple(true);
|
||||||
$fields->insertAfter($tagsField, "Categories");
|
$fields->insertAfter($tagsField, "Categories");
|
||||||
|
|
||||||
// Add featured image
|
// Add featured image
|
||||||
@ -87,10 +88,10 @@ class BlogPost extends Page {
|
|||||||
$uploadField = UploadField::create("FeaturedImage", _t("BlogPost.FeaturedImage", "Featured Image")),
|
$uploadField = UploadField::create("FeaturedImage", _t("BlogPost.FeaturedImage", "Featured Image")),
|
||||||
"Content"
|
"Content"
|
||||||
);
|
);
|
||||||
$uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
|
$uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
|
||||||
});
|
});
|
||||||
|
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user