Perforce Chronicle 2012.2/486814
API Documentation
|
Renders a content select control. More...
Public Member Functions | |
contentSelect ($id, $value=null, $params=array(), $attribs=array()) | |
Render the content select markup needed to declare the dijit. | |
Protected Attributes | |
$_dijit = 'p4cms.content.ContentSelect' | |
$_module = 'p4cms.content.ContentSelect' |
Renders a content select control.
Allows the user to select one or more content entries. The content select control is a dijit that supports both single and multi-select (toggled via multiple = true/false). Callers can also specify browse options to influence the content select dialog that appears when the browse button is clicked.
Content_View_Helper_ContentSelect::contentSelect | ( | $ | id, |
$ | value = null , |
||
$ | params = array() , |
||
$ | attribs = array() |
||
) |
Render the content select markup needed to declare the dijit.
string | $id | Zend provides no documentation for this param. |
string | $value | Zend provides no documentation for this param. |
array | $params | Zend provides no documentation for this param. |
array | $attribs | Zend provides no documentation for this param. |
{ if (!array_key_exists('id', $attribs)) { $attribs['id'] = $id; } $id = $attribs['id']; // normalize values to an array and remove nulls $value = array_values(array_filter((array) $value)); // lookup entry data (titles, content types) for selected content ids. if ($value) { $params['entryData'] = array(); $entries = P4Cms_Content::fetchAll( array( 'ids' => (array) $value, 'limitFields' => array('title', 'contentType') ) ); foreach ($entries as $entry) { $params['entryData'][$entry->getId()] = array( 'title' => $entry->getTitle(), 'type' => $entry->getContentTypeId() ); } } // flatten the browse options, otherwise there are issues with // the multidimensional associative array in javascript if (array_key_exists('browseOptions', $attribs)) { $filter = new P4Cms_Filter_FlattenArray; $params['browseOptions'] = $filter->filter($attribs['browseOptions']); } // json-encode select parameters - prepare dijit is supposed to do this // but it corrupts values because it does some very silly quote mangling. $params['selected'] = $value; $params['validTypes'] = isset($attribs['validTypes']) ? $attribs['validTypes'] : null; foreach (array('browseOptions', 'multiple', 'selected', 'entryData', 'validTypes') as $param) { if (array_key_exists($param, $params)) { $params[$param] = Zend_Json::encode($params[$param]); } } // get the attributes ready for use in a dijit $attribs = $this->_prepareDijit($attribs, $params, 'element'); return "<div " . $this->_htmlAttribs($attribs) . "></div>"; }
Content_View_Helper_ContentSelect::$_dijit = 'p4cms.content.ContentSelect' [protected] |
Content_View_Helper_ContentSelect::$_module = 'p4cms.content.ContentSelect' [protected] |