mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 09:05:58 +00:00
API Enable rename of widgets
This commit is contained in:
parent
fff7bca419
commit
89eac300c9
@ -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"))
|
||||||
@ -84,5 +94,4 @@ if(class_exists("Widget")) {
|
|||||||
class BlogArchiveWidget_Controller extends Widget_Controller {
|
class BlogArchiveWidget_Controller extends Widget_Controller {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,17 +10,29 @@ if(class_exists("Widget")) {
|
|||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -38,5 +50,4 @@ if(class_exists("Widget")) {
|
|||||||
class BlogCategoriesWidget_Controller extends Widget_Controller {
|
class BlogCategoriesWidget_Controller extends Widget_Controller {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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"))
|
||||||
));
|
));
|
||||||
@ -43,5 +54,4 @@ if(class_exists("Widget")) {
|
|||||||
class BlogRecentPostsWidget_Controller extends Widget_Controller {
|
class BlogRecentPostsWidget_Controller extends Widget_Controller {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -10,15 +10,29 @@ if(class_exists("Widget")) {
|
|||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -36,5 +50,4 @@ if(class_exists("Widget")) {
|
|||||||
class BlogTagsWidget_Controller extends Widget_Controller {
|
class BlogTagsWidget_Controller extends Widget_Controller {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user