silverstripe-blog/code/widgets/BlogCategoriesWidget.php
Christopher Pitt 1648defec9 Clean up
2015-05-14 11:23:58 +12:00

69 lines
1.1 KiB
PHP

<?php
if(!class_exists("Widget")) {
return;
}
/**
* @method Blog Blog()
*/
class BlogCategoriesWidget extends Widget {
/**
* @var string
*/
private static $title = 'Categories';
/**
* @var string
*/
private static $cmsTitle = 'Blog Categories';
/**
* @var string
*/
private static $description = 'Displays a list of blog categories.';
/**
* @var array
*/
private static $db = array();
/**
* @var array
*/
private static $has_one = array(
'Blog' => 'Blog',
);
/**
* {@inheritdoc}
*/
public function getCMSFields() {
$this->beforeUpdateCMSFields(function ($fields) {
/**
* @var FieldList $fields
*/
$fields->push(
DropdownField::create('BlogID', _t('BlogCategoriesWidget.Blog', 'Blog'), Blog::get()->map())
);
});
return parent::getCMSFields();
}
/**
* @return array
*/
public function getCategories() {
if($blog = $this->Blog()) {
return $blog->Categories();
}
return array();
}
}
class BlogCategoriesWidget_Controller extends Widget_Controller {
}