silverstripe-blog/code/widgets/BlogTagsWidget.php

69 lines
1.0 KiB
PHP
Raw Normal View History

2013-08-04 18:38:26 +02:00
<?php
2015-05-09 16:33:12 +02:00
if(!class_exists("Widget")) {
return;
}
2013-08-04 18:38:26 +02:00
2015-05-09 16:33:12 +02:00
/**
* @method Blog Blog()
*/
class BlogTagsWidget extends Widget {
/**
* @var string
*/
private static $title = 'Tags';
2013-08-04 18:38:26 +02:00
2015-05-09 16:33:12 +02:00
/**
* @var string
*/
private static $cmsTitle = 'Blog Tags';
2013-08-04 18:38:26 +02:00
2015-05-09 16:33:12 +02:00
/**
* @var string
*/
private static $description = 'Displays a list of blog tags.';
2013-08-04 18:38:26 +02:00
2015-05-09 16:33:12 +02:00
/**
* @var array
*/
private static $db = array();
2013-08-04 18:38:26 +02:00
2015-05-09 16:33:12 +02:00
/**
* @var array
*/
private static $has_one = array(
'Blog' => 'Blog',
);
2013-10-10 00:09:28 +02:00
2015-05-09 16:33:12 +02:00
/**
* {@inheritdoc}
*/
public function getCMSFields() {
$this->beforeUpdateCMSFields(function ($fields) {
2015-05-13 23:12:48 +02:00
/**
* @var FieldList $fields
*/
$fields->push(
DropdownField::create('BlogID', _t('BlogTagsWidget.Blog', 'Blog'), Blog::get()->map())
);
2015-05-09 16:33:12 +02:00
});
return parent::getCMSFields();
}
2013-08-04 18:38:26 +02:00
2015-05-09 16:33:12 +02:00
/**
* @return array
*/
public function getTags() {
2015-05-14 01:11:50 +02:00
if($blog = $this->Blog()) {
2015-05-09 16:33:12 +02:00
return $blog->Tags();
2013-08-04 18:38:26 +02:00
}
2013-10-10 00:09:28 +02:00
2015-05-09 16:33:12 +02:00
return array();
2013-08-04 18:38:26 +02:00
}
2015-05-09 16:33:12 +02:00
}
2013-08-04 18:38:26 +02:00
2015-05-09 16:33:12 +02:00
class BlogTagsWidget_Controller extends Widget_Controller {
2013-08-04 18:38:26 +02:00
2015-05-09 16:33:12 +02:00
}