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() {
|
||||
$this->beforeUpdateCMSFields(function($fields) {
|
||||
$self =& $this;
|
||||
$this->beforeUpdateCMSFields(function($fields) use ($self) {
|
||||
|
||||
$posts = $this->getBlogPosts();
|
||||
$excluded = $this->getExcludedSiteTreeClassNames();
|
||||
$posts = $self->getBlogPosts();
|
||||
$excluded = $self->getExcludedSiteTreeClassNames();
|
||||
if(!empty($excluded)) {
|
||||
$posts = $posts->filter("ClassName", $excluded);
|
||||
$gridField = new GridField(
|
||||
@ -56,14 +57,14 @@ class Blog extends Page {
|
||||
$categories = GridField::create(
|
||||
"Categories",
|
||||
_t("Blog.Categories", "Categories"),
|
||||
$this->Categories(),
|
||||
$self->Categories(),
|
||||
$config
|
||||
);
|
||||
|
||||
$tags = GridField::create(
|
||||
"Tags",
|
||||
_t("Blog.Tags", "Tags"),
|
||||
$this->Tags(),
|
||||
$self->Tags(),
|
||||
$config
|
||||
);
|
||||
|
||||
@ -260,8 +261,8 @@ class Blog_Controller extends Page_Controller {
|
||||
* @return string HTML
|
||||
**/
|
||||
public function rss() {
|
||||
$rss = new RSSFeed($this->getBlogPosts(), $this->Link(), $this->MetaDescription, $this->MetaTitle);
|
||||
return $rss->outputToBrowser();
|
||||
$rss = new RSSFeed($this->getBlogPosts(), $this->Link(), $this->MetaDescription, $this->MetaTitle);
|
||||
return $rss->outputToBrowser();
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,13 +59,8 @@ class BlogPost extends Page {
|
||||
|
||||
public function getCMSFields() {
|
||||
|
||||
// Assign to variable & pass for PHP <= 5.4 closure compatibility
|
||||
$data = array(
|
||||
"TagsMap" => $this->Parent()->Tags()->map()->toArray(),
|
||||
"CategoryMap" => $this->Parent()->Categories()->map()->toArray()
|
||||
);
|
||||
|
||||
$this->beforeUpdateCMSFields(function($fields) use ($data) {
|
||||
$self =& $this;
|
||||
$this->beforeUpdateCMSFields(function($fields) use ($self) {
|
||||
// Add Publish date fields
|
||||
$fields->insertAfter(
|
||||
$publishDate = DatetimeField::create("PublishDate", _t("BlogPost.PublishDate", "Publish Date")),
|
||||
@ -74,12 +69,18 @@ class BlogPost extends Page {
|
||||
$publishDate->getDateField()->setConfig("showcalendar", true);
|
||||
|
||||
// Add Categories & Tags fields
|
||||
$categoriesField = ListboxField::create("Categories",
|
||||
_t("BlogPost.Categories", "Categories"), $data['CategoryMap'])->setMultiple(true);
|
||||
$categoriesField = ListboxField::create(
|
||||
"Categories",
|
||||
_t("BlogPost.Categories", "Categories"),
|
||||
$self->Parent()->Categories()->map()->toArray()
|
||||
)->setMultiple(true);
|
||||
$fields->insertAfter($categoriesField, "PublishDate");
|
||||
|
||||
$tagsField = ListboxField::create("Tags", _t("BlogPost.Tags", "Tags"), $data['TagsMap'])
|
||||
->setMultiple(true);
|
||||
$tagsField = ListboxField::create(
|
||||
"Tags",
|
||||
_t("BlogPost.Tags", "Tags"),
|
||||
$self->Parent()->Tags()->map()->toArray()
|
||||
)->setMultiple(true);
|
||||
$fields->insertAfter($tagsField, "Categories");
|
||||
|
||||
// Add featured image
|
||||
@ -87,10 +88,10 @@ class BlogPost extends Page {
|
||||
$uploadField = UploadField::create("FeaturedImage", _t("BlogPost.FeaturedImage", "Featured Image")),
|
||||
"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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user