MINOR: Allow decorating db and cms fields of widgets in one decorator. Thanks to smurkas

This commit is contained in:
Saophalkun Ponlu 2010-12-10 03:20:26 +00:00
parent 438feba01e
commit eb52713954
3 changed files with 28 additions and 16 deletions

View File

@ -29,13 +29,17 @@ class ArchiveWidget extends Widget {
static $description = 'Show a list of months or years in which there are blog posts, and provide links to them.'; static $description = 'Show a list of months or years in which there are blog posts, and provide links to them.';
function getCMSFields() { function getCMSFields() {
$fields = new FieldSet( $fields = parent::getCMSFields();
new OptionsetField(
'DisplayMode', $fields->merge(
_t('ArchiveWidget.DispBY', 'Display by'), new FieldSet(
array( new OptionsetField(
'month' => _t('ArchiveWidget.MONTH', 'month'), 'DisplayMode',
'year' => _t('ArchiveWidget.YEAR', 'year') _t('ArchiveWidget.DispBY', 'Display by'),
array(
'month' => _t('ArchiveWidget.MONTH', 'month'),
'year' => _t('ArchiveWidget.YEAR', 'year')
)
) )
) )
); );

View File

@ -40,10 +40,14 @@ class RSSWidget extends Widget {
} }
function getCMSFields() { function getCMSFields() {
$fields = new FieldSet( $fields = parent::getCMSFields();
new TextField("RSSTitle", _t('RSSWidget.CT', "Custom title for the feed")),
new TextField("RssUrl", _t('RSSWidget.URL', "URL of the other page's RSS feed. Please make sure this URL points to an RSS feed.")), $fields->merge(
new NumericField("NumberToShow", _t('RSSWidget.NTS', "Number of Items to show")) new FieldSet(
new TextField("RSSTitle", _t('RSSWidget.CT', "Custom title for the feed")),
new TextField("RssUrl", _t('RSSWidget.URL', "URL of the other page's RSS feed. Please make sure this URL points to an RSS feed.")),
new NumericField("NumberToShow", _t('RSSWidget.NTS', "Number of Items to show"))
)
); );
$this->extend('updateCMSFields', $fields); $this->extend('updateCMSFields', $fields);

View File

@ -27,10 +27,14 @@ class TagCloudWidget extends Widget {
static $popularities = array( 'not-popular', 'not-very-popular', 'somewhat-popular', 'popular', 'very-popular', 'ultra-popular' ); static $popularities = array( 'not-popular', 'not-very-popular', 'somewhat-popular', 'popular', 'very-popular', 'ultra-popular' );
function getCMSFields() { function getCMSFields() {
$fields = new FieldSet( $fields = parent::getCMSFields();
new TextField("Title", _t("TagCloudWidget.TILE", "Title")),
new TextField("Limit", _t("TagCloudWidget.LIMIT", "Limit number of tags")), $fields->merge(
new OptionsetField("Sortby",_t("TagCloudWidget.SORTBY","Sort by"),array("alphabet"=>_t("TagCloudWidget.SBAL", "alphabet"),"frequency"=>_t("TagCloudWidget.SBFREQ", "frequency"))) new FieldSet(
new TextField("Title", _t("TagCloudWidget.TILE", "Title")),
new TextField("Limit", _t("TagCloudWidget.LIMIT", "Limit number of tags")),
new OptionsetField("Sortby",_t("TagCloudWidget.SORTBY","Sort by"),array("alphabet"=>_t("TagCloudWidget.SBAL", "alphabet"),"frequency"=>_t("TagCloudWidget.SBFREQ", "frequency")))
)
); );
$this->extend('updateCMSFields', $fields); $this->extend('updateCMSFields', $fields);