hasAuth() && $doc->getAuth()->getSuMode()) {
$table = new Qs_Db_Table('DPageItemType');
$sources = $table->get4Select(array('type', 'title'));
$this->addElement(
'select',
'placeholders',
array('label' => 'Placeholder Data Source', 'multiOptions' => array('' => 'None') + (array) $sources)
);
}
return $this;
}
protected function _initPlaceholdersElements($placeholdersSource)
{
if (!empty($placeholdersSource)) {
$separator = (false !== strpos($placeholdersSource, '\\')) ? '\\' : '_';
$placeholderSourceObj = 'App'. $separator . $placeholdersSource . 'Obj';
if (class_exists($placeholderSourceObj)) {
/** @var Qs_Db_Obj $placeholderObj */
$placeholderObj = new $placeholderSourceObj();
$placeholders = $placeholderObj->getPlaceholders();
if (!empty($placeholders)) {
$placeholderValues = array();
foreach ($placeholders as $name => $description) {
$placeholderValues[] = $name . ' - ' . $description;
}
$this->addElement(
'static',
'placeholdersValues',
array('value' => 'Placeholders: ' . implode(', ', $placeholderValues))
);
}
}
}
return $this;
}
public function setDefaults(array $defaults = array())
{
parent::setDefaults($defaults);
if (!empty($defaults['config']['placeholders'])) {
$this->_initPlaceholdersElements($defaults['config']['placeholders']);
}
return $this;
}
public function renderView(Zend_View_Interface $view = null)
{
if ($this->getElements()) {
parent::renderView($view);
}
return false;
}
public function render(Zend_View_Interface $view = null)
{
$placeholdersContent = '';
if (null !== ($element = $this->getElement('placeholdersValues'))) {
$placeholdersContent = $element->render();
$this->removeElement('placeholdersValues');
}
$content = parent::render($view);
if ($this->getElements()) {
return $placeholdersContent . $content;
}
return $placeholdersContent;
}
}