|
Perforce Chronicle 2012.2/486814
API Documentation
|
A widget that displays a list of content, defaulting to the most recently added content, sorted so that the newest content is first. More...
Public Member Functions | |
| indexAction () | |
| Display the content list. | |
Static Public Member Functions | |
| static | getConfigSubForm ($widget) |
| Get config sub-form to present additional options when configuring a widget of this type. | |
A widget that displays a list of content, defaulting to the most recently added content, sorted so that the newest content is first.
| static Content_ListWidgetController::getConfigSubForm | ( | $ | widget | ) | [static] |
Get config sub-form to present additional options when configuring a widget of this type.
| P4Cms_Widget | $widget | the widget instance being configured. |
{
return new Content_Form_ListWidget;
}
| Content_ListWidgetController::indexAction | ( | ) |
Display the content list.
{
$sortFields = array();
if ($this->getOption('primarySortField')) {
$sortFields[$this->getOption('primarySortField')] = array(
$this->getOption('primarySortOrder') ?: P4Cms_Record_Query::SORT_DESCENDING
);
}
if ($this->getOption('secondarySortField')) {
$sortFields[$this->getOption('secondarySortField')] = array(
$this->getOption('secondarySortOrder') ?: P4Cms_Record_Query::SORT_DESCENDING
);
}
// if no options were specified, provide default
if (empty($sortFields)) {
$sortFields[P4Cms_Record_Query::SORT_DATE] = array(P4Cms_Record_Query::SORT_DESCENDING);
}
$query = P4Cms_Record_Query::create()
->setSortBy($sortFields);
$contentType = $this->getOption('contentType');
if ($contentType instanceof Zend_Config) {
$contentType = $contentType->toArray();
}
$types = $this->getConfigSubForm($this)
->getElement('contentType')
->setValue($contentType)
->getNormalizedTypes();
if (count($types)) {
$filter = new P4Cms_Record_Filter;
$filter->add(
'contentType',
$types,
P4Cms_Record_Filter::COMPARE_EQUAL
);
$query->addFilter($filter);
}
if ($this->getOption('count')) {
$query->setMaxRows($this->getOption('count'));
}
$fields = array();
if ($this->getOption('showIcons')) {
$fields['icon'] = array(
'field' => 'title',
'decorators' => array(
'contentIcon',
'contentLink',
array(
'decorator' => 'htmlTag',
'options' => array(
'tag' => 'span',
'class' => 'content-list-icon-field'
)
)
)
);
}
$fields['title'] = array(
'decorators' => array(
'value',
'contentLink',
array(
'decorator' => 'htmlTag',
'options' => array(
'tag' => 'span',
'class' => 'content-list-title-field'
)
)
)
);
$this->view->query = $query;
$this->view->options = array('fields' => $fields);
}