'',
'afterLink' => '',
'beforeDelete' => '',
'afterDelete' => '',
'beforeElement' => '',
'afterElement' => '',
);
public function __call($method, $args)
{
if ('getAdditionalHtml' == substr($method, 0, 17)) {
$section = substr($method, 17);
return $this->_getAdditionalHtml($section);
} elseif ('setAdditionalHtml' == substr($method, 0, 17)) {
$section = substr($method, 17);
return $this->_setAdditionalHtml($section, $args[0]);
}
// require_once 'Zend/Form/Decorator/Exception.php';
throw new Zend_Form_Decorator_Exception(sprintf('Method %s does not exist', $method));
}
public function render($content)
{
$element = $this->getElement();
$msgDownload = 'download';
$msgDelete = 'delete';
if (($translator = $element->getTranslator())) {
$msgDownload = $translator->translate($msgDownload);
$msgDelete = $translator->translate($msgDelete);
}
$content = parent::render($content);
$topHtml = '';
if ($element->getValue()) {
$topHtml = $this->_additionalHtml['beforeLink']
. '' . $msgDownload . ''
. $this->_additionalHtml['afterLink']
. ''
. $this->_additionalHtml['beforeDelete'];
if (!$element->isRequired()) {
if (empty($this->_additionalHtml['beforeDelete'])) {
$topHtml .= '
';
}
$topHtml .= ' ';
}
$topHtml .= $this->_additionalHtml['afterDelete'] . '
';
}
return $topHtml . $this->_additionalHtml['beforeElement'] . $content . $this->_additionalHtml['afterElement'];
}
public function setAdditionalHtml($options = array())
{
foreach ($options as $section => $html) {
$this->_setAdditionalHtml($section, $html);
}
}
protected function _setAdditionalHtml($section, $html)
{
if (!isset($this->_additionalHtml[$section])) {
// require_once 'Zend/Form/Decorator/Exception.php';
throw new Zend_Form_Decorator_Exception('Invalid section for decorator additional HTML');
}
$this->_additionalHtml[$section] = $html;
}
protected function _getAdditionalHtml($section = null)
{
if (empty($section)) {
return $this->_additionalHtml;
}
if (isset($this->_additionalHtml[$section])) {
return $this->_additionalHtml[$section];
}
return '';
}
}