hasAuth() && $doc->getAuth()->getSuMode()) { $table = new Qs_Db_Table('DPageItemType'); $sources = $table->get4Select(['type', 'title']); $this->addElement( 'select', 'placeholders', ['label' => 'Placeholder Data Source', 'multiOptions' => ['' => '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 = []; foreach ($placeholders as $name => $description) { $placeholderValues[] = $name . ' - ' . $description; } $this->addElement( 'static', 'placeholdersValues', ['value' => 'Placeholders: ' . implode(', ', $placeholderValues)] ); } } } return $this; } public function setDefaults(array $defaults = []) { 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; } }