mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
API Enable rename of widgets
This commit is contained in:
parent
fff7bca419
commit
89eac300c9
@ -3,7 +3,7 @@
|
|||||||
if(class_exists("Widget")) {
|
if(class_exists("Widget")) {
|
||||||
|
|
||||||
class BlogArchiveWidget extends Widget {
|
class BlogArchiveWidget extends Widget {
|
||||||
|
|
||||||
private static $title = "Archive";
|
private static $title = "Archive";
|
||||||
|
|
||||||
private static $cmsTitle = "Archive";
|
private static $cmsTitle = "Archive";
|
||||||
@ -11,6 +11,7 @@ if(class_exists("Widget")) {
|
|||||||
private static $description = "Displays an archive list of posts.";
|
private static $description = "Displays an archive list of posts.";
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
|
"Title" => "Varchar(255)",
|
||||||
"NumberToDisplay" => "Int",
|
"NumberToDisplay" => "Int",
|
||||||
"Type" => "Enum('Monthly, Yearly', 'Monthly')"
|
"Type" => "Enum('Monthly, Yearly', 'Monthly')"
|
||||||
);
|
);
|
||||||
@ -23,15 +24,24 @@ if(class_exists("Widget")) {
|
|||||||
"Blog" => "Blog",
|
"Blog" => "Blog",
|
||||||
);
|
);
|
||||||
|
|
||||||
public function getCMSFields() {
|
public function Title() {
|
||||||
$fields = parent::getCMSFields();
|
return $this->getField('Title') ?: parent::Title();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function populateDefaults() {
|
||||||
|
parent::populateDefaults();
|
||||||
|
$this->setField('Title', parent::Title());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCMSFields() {
|
||||||
$type = $this->dbObject("Type")->enumValues();
|
$type = $this->dbObject("Type")->enumValues();
|
||||||
foreach($type as $k => $v) {
|
foreach($type as $k => $v) {
|
||||||
$type[$k] = _t("BlogArchiveWidget." . ucfirst(strtolower($v)), $v);
|
$type[$k] = _t("BlogArchiveWidget." . ucfirst(strtolower($v)), $v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$fields = FieldList::create();
|
||||||
$fields->merge(array(
|
$fields->merge(array(
|
||||||
|
TextField::create('Title', 'Title', null, 255),
|
||||||
DropdownField::create("BlogID", _t("BlogArchiveWidget.Blog", "Blog"), Blog::get()->map()),
|
DropdownField::create("BlogID", _t("BlogArchiveWidget.Blog", "Blog"), Blog::get()->map()),
|
||||||
DropdownField::create("Type", _t("BlogArchiveWidget.Type", "Type"), $type),
|
DropdownField::create("Type", _t("BlogArchiveWidget.Type", "Type"), $type),
|
||||||
NumericField::create("NumberToDisplay", _t("BlogArchiveWidget.NumberToDisplay", "No. to Display"))
|
NumericField::create("NumberToDisplay", _t("BlogArchiveWidget.NumberToDisplay", "No. to Display"))
|
||||||
@ -57,7 +67,7 @@ if(class_exists("Widget")) {
|
|||||||
|
|
||||||
$articles = $this->Blog()->getBlogPosts()->setDataQuery($query);
|
$articles = $this->Blog()->getBlogPosts()->setDataQuery($query);
|
||||||
if($this->NumberToDisplay > 0) $articles = $articles->limit($this->NumberToDisplay);
|
if($this->NumberToDisplay > 0) $articles = $articles->limit($this->NumberToDisplay);
|
||||||
|
|
||||||
$archive = new ArrayList();
|
$archive = new ArrayList();
|
||||||
if($articles->count() > 0) {
|
if($articles->count() > 0) {
|
||||||
foreach($articles as $article) {
|
foreach($articles as $article) {
|
||||||
@ -82,7 +92,6 @@ if(class_exists("Widget")) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BlogArchiveWidget_Controller extends Widget_Controller {
|
class BlogArchiveWidget_Controller extends Widget_Controller {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,24 +3,36 @@
|
|||||||
if(class_exists("Widget")) {
|
if(class_exists("Widget")) {
|
||||||
|
|
||||||
class BlogCategoriesWidget extends Widget {
|
class BlogCategoriesWidget extends Widget {
|
||||||
|
|
||||||
private static $title = "Categories";
|
private static $title = "Categories";
|
||||||
|
|
||||||
private static $cmsTitle = "Blog Categories";
|
private static $cmsTitle = "Blog Categories";
|
||||||
|
|
||||||
private static $description = "Displays a list of blog categories.";
|
private static $description = "Displays a list of blog categories.";
|
||||||
|
|
||||||
private static $db = array();
|
private static $db = array(
|
||||||
|
"Title" => "Varchar(255)",
|
||||||
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
"Blog" => "Blog",
|
"Blog" => "Blog",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public function Title() {
|
||||||
|
return $this->getField('Title') ?: parent::Title();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function populateDefaults() {
|
||||||
|
parent::populateDefaults();
|
||||||
|
$this->setField('Title', parent::Title());
|
||||||
|
}
|
||||||
|
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
$fields = FieldList::create();
|
$fields = FieldList::create();
|
||||||
$fields->push(
|
$fields->merge(array(
|
||||||
|
TextField::create('Title', 'Title', null, 255),
|
||||||
DropdownField::create("BlogID", _t("BlogCategoriesWidget.Blog", "Blog"), Blog::get()->map())
|
DropdownField::create("BlogID", _t("BlogCategoriesWidget.Blog", "Blog"), Blog::get()->map())
|
||||||
);
|
));
|
||||||
$this->extend("updateCMSFields", $fields);
|
$this->extend("updateCMSFields", $fields);
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
@ -36,7 +48,6 @@ if(class_exists("Widget")) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BlogCategoriesWidget_Controller extends Widget_Controller {
|
class BlogCategoriesWidget_Controller extends Widget_Controller {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
if(class_exists("Widget")) {
|
if(class_exists("Widget")) {
|
||||||
|
|
||||||
class BlogRecentPostsWidget extends Widget {
|
class BlogRecentPostsWidget extends Widget {
|
||||||
|
|
||||||
private static $title = "Recent Posts";
|
private static $title = "Recent Posts";
|
||||||
|
|
||||||
private static $cmsTitle = "Recent Posts";
|
private static $cmsTitle = "Recent Posts";
|
||||||
@ -11,6 +11,7 @@ if(class_exists("Widget")) {
|
|||||||
private static $description = "Displays a list of recent blog posts.";
|
private static $description = "Displays a list of recent blog posts.";
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
|
"Title" => "Varchar(255)",
|
||||||
"NumberOfPosts" => "Int",
|
"NumberOfPosts" => "Int",
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -18,9 +19,19 @@ if(class_exists("Widget")) {
|
|||||||
"Blog" => "Blog",
|
"Blog" => "Blog",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public function Title() {
|
||||||
|
return $this->getField('Title') ?: parent::Title();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function populateDefaults() {
|
||||||
|
parent::populateDefaults();
|
||||||
|
$this->setField('Title', parent::Title());
|
||||||
|
}
|
||||||
|
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
$fields = FieldList::create();
|
$fields = FieldList::create();
|
||||||
$fields->merge(array(
|
$fields->merge(array(
|
||||||
|
TextField::create('Title', 'Title', null, 255),
|
||||||
DropdownField::create("BlogID", _t("BlogRecentPostsWidget.Blog", "Blog"), Blog::get()->map()),
|
DropdownField::create("BlogID", _t("BlogRecentPostsWidget.Blog", "Blog"), Blog::get()->map()),
|
||||||
NumericField::create("NumberOfPosts", _t("BlogRecentPostsWidget.NumberOfPosts", "Number of Posts"))
|
NumericField::create("NumberOfPosts", _t("BlogRecentPostsWidget.NumberOfPosts", "Number of Posts"))
|
||||||
));
|
));
|
||||||
@ -41,7 +52,6 @@ if(class_exists("Widget")) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BlogRecentPostsWidget_Controller extends Widget_Controller {
|
class BlogRecentPostsWidget_Controller extends Widget_Controller {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -3,22 +3,36 @@
|
|||||||
if(class_exists("Widget")) {
|
if(class_exists("Widget")) {
|
||||||
|
|
||||||
class BlogTagsWidget extends Widget {
|
class BlogTagsWidget extends Widget {
|
||||||
|
|
||||||
private static $title = "Tags";
|
private static $title = "Tags";
|
||||||
|
|
||||||
private static $cmsTitle = "Blog Tags";
|
private static $cmsTitle = "Blog Tags";
|
||||||
|
|
||||||
private static $description = "Displays a list of blog tags.";
|
private static $description = "Displays a list of blog tags.";
|
||||||
|
|
||||||
private static $db = array();
|
private static $db = array(
|
||||||
|
"Title" => "Varchar(255)",
|
||||||
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
"Blog" => "Blog",
|
"Blog" => "Blog",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public function Title() {
|
||||||
|
return $this->getField('Title') ?: parent::Title();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function populateDefaults() {
|
||||||
|
parent::populateDefaults();
|
||||||
|
$this->setField('Title', parent::Title());
|
||||||
|
}
|
||||||
|
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
$fields = FieldList::create();
|
$fields = FieldList::create();
|
||||||
$fields->push(DropdownField::create("BlogID", _t("BlogTagsWidget.Blog", "Blog"), Blog::get()->map()));
|
$fields->merge(array(
|
||||||
|
TextField::create('Title', 'Title', null, 255),
|
||||||
|
DropdownField::create("BlogID", _t("BlogTagsWidget.Blog", "Blog"), Blog::get()->map())
|
||||||
|
));
|
||||||
$this->extend("updateCMSFields", $fields);
|
$this->extend("updateCMSFields", $fields);
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
@ -34,7 +48,6 @@ if(class_exists("Widget")) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BlogTagsWidget_Controller extends Widget_Controller {
|
class BlogTagsWidget_Controller extends Widget_Controller {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user