Example #1
0
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $separator = ' ';
     $placement = $this->getPlacement();
     $tag = $this->getTag();
     $tagClass = $this->getClass();
     $id = $element->getId();
     $errors = $element->getMessages();
     if (!empty($errors)) {
         $errors = implode('. ', $errors) . '.';
     } else {
         $errors = '';
     }
     if (null !== $tag) {
         $decorator = new Zend_Form_Decorator_HtmlTag();
         if (null !== $tagClass) {
             $decorator->setOptions(array('tag' => $tag, 'id' => $id . '-errors', 'class' => $tagClass));
         } else {
             $decorator->setOptions(array('tag' => $tag, 'id' => $id . '-errors'));
         }
         $errors = $decorator->render($errors);
     }
     switch ($placement) {
         case self::APPEND:
             return $content . $separator . $errors;
         case self::PREPEND:
             return $errors . $separator . $content;
     }
 }
 /**
  * Decorate content and/or element
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $warnings = $element->getAttrib('warning');
     $dimension = $element->getAttrib('dimension');
     $class = ' ' . $this->getOption('class');
     $class .= ' form-group';
     //Add possibility to add custom classes to the form-group class by attribute
     if ($element->getAttrib('formgroupclass')) {
         $class .= ' ' . $element->getAttrib('formgroupclass');
     }
     if ($element->hasErrors()) {
         $class .= ' has-error';
     } elseif (!empty($warnings)) {
         $class .= ' has-warning';
     } elseif (true === $element->getAttrib('success')) {
         $class .= ' has-success';
     }
     $class = trim($class);
     if (!empty($class)) {
         $this->setOption('class', $class);
     }
     $before = implode('', $this->_beforeContent);
     $after = implode('', $this->_afterContent);
     return parent::render($before . $content . $after);
 }
 /**
  * Обернуть элементы управления в контейнер
  * 
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $class = ' ' . $this->getOption('class');
     $dimensionControls = $this->getDimension();
     if (!empty($dimensionControls)) {
         foreach (explode(',', $dimensionControls) as $size) {
             $class .= ' col-' . trim($size);
         }
     }
     if (true == $this->isNoLabel() || null == $element->getLabel()) {
         $dimensionLabel = $this->getDimensionLabel();
         if (!empty($dimensionLabel)) {
             foreach (explode(',', $dimensionLabel) as $size) {
                 $class .= ' col-' . trim(str_replace('-', '-offset-', $size));
             }
         }
     }
     if ('_File' == substr($element->getType(), -5)) {
         $class .= ' form-control-static';
     }
     $class = trim($class);
     if (!empty($class)) {
         $this->setOption('class', $class);
     }
     return parent::render($content);
 }
 /**
  * Render container to appropiate size
  * 
  * @param type $content
  * @return type
  */
 public function render($content)
 {
     $element = $this->getElement();
     $class = $this->getOption('class');
     $dimension = $this->getDimension();
     if (!empty($dimension)) {
         if (is_string($dimension)) {
             foreach (explode(',', $dimension) as $size) {
                 $class .= ' col-' . trim($size);
             }
         }
         $element->setAttrib('dimension', null);
     }
     $class = trim($class);
     if (!empty($class)) {
         $this->setOption('class', $class);
     } else {
         $this->removeOption('class');
     }
     $noAttribs = $this->getOption('noAttribs');
     if (!$noAttribs) {
         $attribs = $this->getOptions();
         if (count($attribs) > 0) {
             return parent::render($content);
         }
     }
     return $content;
 }
Example #5
0
 /**
  * Render
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $clear = $this->getOption('clear');
     $clearTag = $this->getOption('clearTag');
     $this->removeOption('clear');
     $this->removeOption('clearTag');
     $element = $this->getElement();
     $tag = $this->_getCloseTag($this->getTag());
     if (!$element instanceof Zend_Form_Element_Hidden && isset($element->helper) && 'formHidden' !== $element->helper) {
         if (method_exists($element, 'hasErrors') && $element->hasErrors()) {
             $this->setOption('class', 'errors ' . $this->getOption('class'));
         } else {
             if (method_exists($element, 'isErrors') && $element->isErrors()) {
                 $this->setOption('class', 'errors ' . $this->getOption('class'));
             }
         }
     }
     $rendered = parent::render($content);
     if (true === $clear && !empty($clearTag)) {
         if (false !== ($pos = strripos($rendered, $tag))) {
             $start = substr($rendered, 0, $pos);
             $rendered = $start . $this->getOption('clearTag') . $tag;
         }
     }
     return $rendered;
 }
 /**
  * Render feedback wrapped
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $attribs = $this->getOptions();
     if (array_key_exists('class', $attribs)) {
         $classes = explode(' ', $attribs['class']);
         if (!in_array('form-control-feedback', $classes)) {
             array_push($classes, 'form-control-feedback');
         }
         $this->setOption('class', implode(' ', $classes));
     } else {
         $this->setOption('class', 'form-control-feedback');
     }
     if (!array_key_exists('aria-hidden', $attribs)) {
         $this->setOption('aria-hidden', 'true');
     }
     $element = $this->getElement();
     $container = $element->getDecorator('Container');
     if (!empty($container)) {
         $classes = explode(' ', $container->getOption('class'));
         if (!in_array('has-feedback', $classes)) {
             array_push($classes, 'has-feedback');
         }
         $container->setOption('class', implode(' ', $classes));
     }
     return parent::render($content);
 }
Example #7
0
 /**
  * Render errors
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     if ($element->getMessages()) {
         $this->_options['class'] .= ' error';
     }
     return parent::render($content);
 }
 public function render($content)
 {
     $markAsError = count($this->getElement()->getMessages()) > 0;
     if ($markAsError) {
         $this->setOption('class', $this->getOption('class') . ' error');
     }
     return parent::render($content);
 }
Example #9
0
 /**
  * Render a label
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $label = $this->getLabel();
     $separator = $this->getSeparator();
     $placement = $this->getPlacement();
     $tag = $this->getTag();
     $id = $this->getId();
     $class = $this->getClass();
     $options = $this->getOptions();
     unset($options['tagOptions']);
     $tagOptions = $this->getOption('tagOptions', array());
     if (empty($label) && empty($tag)) {
         return $content;
     }
     if (!empty($label)) {
         $options['class'] = $class;
         $label = $view->formLabel($element->getFullyQualifiedName(), trim($label), $options);
     } else {
         $label = ' ';
     }
     if (null !== $tag) {
         $tagOptions['tag'] = $tag;
         if (!isset($tagOptions['id'])) {
             $tagOptions['id'] = $this->getElement()->getName() . '-label';
             if (null !== ($belongsTo = $this->getElement()->getBelongsTo())) {
                 $tagOptions['id'] = $belongsTo . '-' . $tagOptions['id'];
             }
         }
         require_once 'Zend/Form/Decorator/HtmlTag.php';
         $decorator = new Zend_Form_Decorator_HtmlTag();
         $decorator->setOptions($tagOptions);
         $label = $decorator->render($label);
     }
     switch ($placement) {
         case self::APPEND:
             return $content . $separator . $label;
         case self::PREPEND:
             return $label . $separator . $content;
     }
 }
Example #10
0
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $label = $this->getLabel();
     $separator = $this->getSeparator();
     $placement = $this->getPlacement();
     $tag = $this->getTag();
     $tagClass = $this->getTagClass();
     $id = $this->getId();
     $class = $this->getClass();
     $options = $this->getOptions();
     if (empty($label) && empty($tag)) {
         return $content;
     }
     if (!empty($label)) {
         $options['class'] = $class;
         $label = $view->formLabel($element->getFullyQualifiedName(), trim($label), $options);
     } else {
         $label = ' ';
     }
     if (null !== $tag) {
         require_once 'Zend/Form/Decorator/HtmlTag.php';
         $decorator = new Zend_Form_Decorator_HtmlTag();
         if (null !== $this->_tagClass) {
             $decorator->setOptions(array('tag' => $tag, 'id' => $id . '-label', 'class' => $tagClass));
         } else {
             $decorator->setOptions(array('tag' => $tag, 'id' => $id . '-label'));
         }
         $label = $decorator->render($label);
     }
     $buttons = '
         <a id="video" href="#" class="btn btn-mini"><i class="icon-facetime-video"></i> Видео</a>
         <a id="img" href="#" class="btn btn-mini"><i class="icon-picture"></i> Картинка</a>
     ';
     switch ($placement) {
         case self::APPEND:
             return $content . $separator . $label . $buttons;
         case self::PREPEND:
             return $label . $buttons . $separator . $content;
     }
 }
Example #11
0
 public function render($content)
 {
     $form = $this->getElement();
     $translator = $form->getTranslator();
     $view = $form->getView();
     if (null === $form->getActionBar()) {
         return $content;
     }
     $items = array();
     foreach ($form->getActionBar()->getElements() as $item) {
         $item->setView($view)->setTranslator($translator);
         $items[] = $item->render();
     }
     $elementContent = implode('', $items);
     $decorator = new Zend_Form_Decorator_HtmlTag(array('tag' => 'li', 'class' => 'actions'));
     $elementContent = $decorator->render($elementContent);
     return $content . $elementContent;
 }
Example #12
0
 /**
  * Render a label
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     if ($this->getOption('tagClass')) {
         $tagClass = $this->getOption('tagClass');
         $this->removeOption('tagClass');
     }
     $label = $this->getLabel();
     $separator = $this->getSeparator();
     $placement = $this->getPlacement();
     $tag = $this->getTag();
     $id = $this->getId();
     $class = $this->getClass();
     $options = $this->getOptions();
     if (empty($label) && empty($tag)) {
         return $content;
     }
     if (!empty($label)) {
         $options['class'] = $class;
         $label = $view->formLabel($element->getFullyQualifiedName(), trim($label), $options);
     } else {
         $label = '&nbsp;';
     }
     if (null !== $tag) {
         $decorator = new Zend_Form_Decorator_HtmlTag();
         $options = array('tag' => $tag, 'id' => $this->getElement()->getName() . '-label');
         if (isset($tagClass)) {
             $options['class'] = $tagClass;
         }
         $decorator->setOptions($options);
         $label = $decorator->render($label);
     }
     switch ($placement) {
         case self::APPEND:
             return $content . $separator . $label;
         case self::PREPEND:
             return $label . $separator . $content;
     }
 }
Example #13
0
 /**
  * Render a label
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $label = $this->getLabel();
     $separator = $this->getSeparator();
     $placement = $this->getPlacement();
     $tag = $this->getTag();
     $tagClass = method_exists($this, 'getTagClass') ? $this->getTagClass() : false;
     $id = $this->getId();
     $class = $this->getClass();
     $options = $this->getOptions();
     if (empty($label) && empty($tag)) {
         return $content;
     }
     if (in_array(get_class($element), $this->_hiddenLabels)) {
         $label = '';
     } elseif (!empty($label)) {
         $options['class'] = $class;
         $label = $view->formLabel($element->getFullyQualifiedName(), trim($label), $options);
     } else {
         $label = '&#160;';
     }
     if (null !== $tag) {
         require_once 'Zend/Form/Decorator/HtmlTag.php';
         $decorator = new Zend_Form_Decorator_HtmlTag();
         if ($tagClass && null !== $this->_tagClass) {
             $decorator->setOptions(array('tag' => $tag, 'id' => $id . '-label', 'class' => $tagClass));
         } else {
             $decorator->setOptions(array('tag' => $tag, 'id' => $id . '-label'));
         }
         $label = $decorator->render($label);
     }
     switch ($placement) {
         case self::APPEND:
             return $content . $separator . $label;
         case self::PREPEND:
             return $label . $separator . $content;
     }
 }
 /**
  * Renders a form element decorating it with the Twitter's Bootstrap markup
  *
  * @param $content
  *
  * @return string
  */
 public function render($content)
 {
     $class = $this->getOption('class');
     if (null === $class) {
         $class = '';
     }
     $hasErrors = $this->getElement()->hasErrors() ? 'has-error' : '';
     $class .= " form-group {$hasErrors}";
     $this->setOption('class', $class);
     return parent::render($content);
 }
Example #15
0
 /**
  * Render a description
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     // Jdebug($element,'c');
     $description = $element->getHelperBlock();
     $description = trim($description);
     if (!empty($description) && null !== ($translator = $element->getTranslator())) {
         $description = $translator->translate($description);
     }
     if (empty($description)) {
         return $content;
     }
     $separator = $this->getSeparator();
     $placement = $this->getPlacement();
     $tag = $this->getTag();
     $class = $this->getClass();
     $escape = $this->getEscape();
     $options = $this->getOptions();
     if ($escape) {
         $description = $view->escape($description);
     }
     if (!empty($tag)) {
         require_once 'Zend/Form/Decorator/HtmlTag.php';
         $options['tag'] = $tag;
         $decorator = new Zend_Form_Decorator_HtmlTag($options);
         $description = $decorator->render($description);
     }
     switch ($placement) {
         case self::PREPEND:
             return $description . $separator . $content;
         case self::APPEND:
         default:
             return $content . $separator . $description;
     }
 }
 protected function _htmlAttribs(array $attribs)
 {
     $element = $this->getElement();
     if (!is_null($element)) {
         if (!is_null($attribs) && isset($attribs['class'])) {
             $attribs['class'] = $attribs['class'] . ' ' . $this->getElement()->getName() . '-data';
         } else {
             $attribs = array();
             $attribs['class'] = $this->getElement()->getName() . '-data';
         }
     }
     return parent::_htmlAttribs($attribs);
 }
Example #17
0
 /**
  * Render a label
  * 
  * @param  string $content 
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $label = $element->getLabel();
     $label = trim($label);
     if (!empty($label) && null !== ($translator = $element->getTranslator())) {
         $label = $translator->translate($label);
     }
     $separator = $this->getSeparator();
     $placement = $this->getPlacement();
     $options = $this->getOptions();
     $tag = null;
     if (isset($options['tag'])) {
         $tag = $options['tag'];
         unset($options['tag']);
     }
     if (empty($label) && empty($tag)) {
         return $content;
     }
     if (!empty($label)) {
         $label = $view->formLabel($element->getName(), $label, $options);
     }
     if (null !== $tag) {
         require_once 'Zend/Form/Decorator/HtmlTag.php';
         $decorator = new Zend_Form_Decorator_HtmlTag();
         $decorator->setOptions(array('tag' => $tag));
         $label = $decorator->render($label);
     }
     switch ($placement) {
         case self::APPEND:
             return $content . $separator . $label;
         case self::PREPEND:
             return $label . $separator . $content;
     }
 }
Example #18
0
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $description = $element->getDescription();
     $description = trim($description);
     if (!empty($description) && null !== ($translator = $element->getTranslator())) {
         $description = $translator->translate($description);
     }
     if (empty($description)) {
         return $content;
     }
     $separator = $this->getSeparator();
     $placement = $this->getPlacement();
     $class = $this->getClass();
     $escape = $this->getEscape();
     $options = $this->getOptions();
     if ($escape) {
         $description = $view->escape($description);
     }
     $decorator = new Zend_Form_Decorator_HtmlTag(array('tag' => 'div', 'id' => $this->getElement()->getName() . '-desc', 'class' => $class));
     $description = $decorator->render($description);
     $decorator = new Zend_Form_Decorator_HtmlTag(array('tag' => 'td'));
     $description = $decorator->render($description);
     $description = '<td>&nbsp;</td>' . $description;
     $decorator = new Zend_Form_Decorator_HtmlTag(array('tag' => 'tr'));
     $description = $decorator->render($description);
     switch ($placement) {
         case self::PREPEND:
             return $description . $separator . $content;
         case self::APPEND:
         default:
             return $content . $separator . $description;
     }
 }
Example #19
0
 /**
  * Tag Attribute vorbereiten.
  * 
  * Das 'class' Attribute wird auf 'field' gesetzt und die 'id' auf die Element-ID plus '-element'.
  * 
  * @param array $attribs
  * @return array
  */
 protected function _htmlAttribs(array $attribs)
 {
     if (is_null($attribs)) {
         $attribs = array();
     }
     if (!isset($attribs['class'])) {
         $attribs['class'] = 'field';
     }
     $element = $this->getElement();
     if (!is_null($element)) {
         $attribs['id'] = $element->getId() . '-element';
     }
     return parent::_htmlAttribs($attribs);
 }
 /**
  * Renders a form element decorating it with the Twitter's Bootstrap markup
  *
  * @param $content
  *
  * @return string
  */
 public function render($content)
 {
     $class = $this->getOption('class');
     if (null === $class) {
         $classes = [];
     } else {
         $classes = explode(' ', $class);
     }
     $classes[] = 'form-group';
     if ($this->getElement()->hasErrors()) {
         $classes[] = 'has-error';
     }
     $this->setOption('class', trim(implode(' ', $classes)));
     return parent::render($content);
 }
 public function render($content)
 {
     //Mark-As-Error
     if ($this->getElement()->hasErrors()) {
         $this->setOption('class', $this->getOption('class') . ' error');
     }
     if (FALSE === striPos('type-', $this->getOption('class') . '')) {
         $arrElementClasses = array('Zend_Form_Element_Button' => 'button', 'Zend_Form_Element_Captcha' => 'text', 'Zend_Form_Element_Checkbox' => 'check', 'Zend_Form_Element_File' => 'text', 'Zend_Form_Element_Image' => 'button', 'Zend_Form_Element_MultiCheckbox' => 'check', 'Zend_Form_Element_Multiselect' => 'select', 'Zend_Form_Element_Password' => 'text', 'Zend_Form_Element_Radio' => 'check', 'Zend_Form_Element_Reset' => 'button', 'Zend_Form_Element_Select' => 'select', 'Zend_Form_Element_Submit' => 'button', 'Zend_Form_Element_Text' => 'text', 'Zend_Form_Element_Textarea' => 'text');
         foreach ($arrElementClasses as $class => $type) {
             if ($this->getElement() instanceof $class) {
                 $this->setOption('class', $this->getOption('class') . ' type-' . $type);
                 break;
             }
         }
     }
     return parent::render($content);
 }
Example #22
0
 /**
  * Render content wrapped in an HTML tag
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $classes = array('captcha' => 'for="captcha"', 'text' => 'type="text"', 'file' => 'type="file"', 'submit' => 'type="submit"', 'radios' => 'type="radio"', 'password' => 'type="password"', 'checkbox' => 'type="checkbox"', 'hidden' => 'type="hidden"', 'textarea' => '<textarea', 'multiselect' => 'multiple="multiple"', 'select' => '<select', 'link' => '<a ', 'strong' => '<strong ');
     foreach ($classes as $className => $pattern) {
         if (strpos($content, $pattern) === false) {
             continue;
         }
         $class = $this->getOption('class');
         if ($class != '') {
             $class .= ' ' . $className;
         } else {
             $class = $className;
         }
         $this->setOption('class', $class);
         break;
     }
     return parent::render($content);
 }
Example #23
0
 public function render($content)
 {
     $filter = new Zend_Filter_HtmlEntities();
     $content = $filter->filter($content);
     return parent::render($content);
 }
Example #24
0
File: Label.php Project: webino/zf1
 /**
  * Render a label
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $label = $this->getLabel();
     $separator = $this->getSeparator();
     $placement = $this->getPlacement();
     $tag = $this->getTag();
     $tagClass = $this->getTagClass();
     $id = $this->getId();
     $class = $this->getClass();
     $options = $this->getOptions();
     if (empty($label) && empty($tag)) {
         return $content;
     }
     if (!empty($label)) {
         $options['class'] = $class;
         $label = trim($label);
         switch ($placement) {
             case self::IMPLICIT:
                 // Break was intentionally omitted
             // Break was intentionally omitted
             case self::IMPLICIT_PREPEND:
                 $options['escape'] = false;
                 $options['disableFor'] = true;
                 $label = $view->formLabel($element->getFullyQualifiedName(), $label . $separator . $content, $options);
                 break;
             case self::IMPLICIT_APPEND:
                 $options['escape'] = false;
                 $options['disableFor'] = true;
                 $label = $view->formLabel($element->getFullyQualifiedName(), $content . $separator . $label, $options);
                 break;
             case self::APPEND:
                 // Break was intentionally omitted
             // Break was intentionally omitted
             case self::PREPEND:
                 // Break was intentionally omitted
             // Break was intentionally omitted
             default:
                 $label = $view->formLabel($element->getFullyQualifiedName(), $label, $options);
                 break;
         }
     } else {
         $label = '&#160;';
     }
     if (null !== $tag) {
         //require_once 'Zend/Form/Decorator/HtmlTag.php';
         $decorator = new Zend_Form_Decorator_HtmlTag();
         if (null !== $this->_tagClass) {
             $decorator->setOptions(array('tag' => $tag, 'id' => $id . '-label', 'class' => $tagClass));
         } else {
             $decorator->setOptions(array('tag' => $tag, 'id' => $id . '-label'));
         }
         $label = $decorator->render($label);
     }
     switch ($placement) {
         case self::APPEND:
             return $content . $separator . $label;
         case self::PREPEND:
             return $label . $separator . $content;
         case self::IMPLICIT:
             // Break was intentionally omitted
         // Break was intentionally omitted
         case self::IMPLICIT_PREPEND:
             // Break was intentionally omitted
         // Break was intentionally omitted
         case self::IMPLICIT_APPEND:
             return $label;
     }
 }
Example #25
0
 /**
  * Render a captcha image
  * 
  * @param  string $content 
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $tag = $this->getTag();
     $placement = $this->getPlacement();
     $separator = $this->getSeparator();
     $namespace = $this->getOption('namespace');
     $captchaId = $this->getOption('captchaId');
     if (!$namespace || !$captchaId) {
         require_once 'Zend/Form/Decorator/Exception.php';
         $exception = new Zend_Form_Decorator_Exception('namespace or captchaId not set');
         throw $exception;
     }
     $image = '<img src="/app/user/captcha/' . $namespace . '/' . $captchaId . '" alt="CAPTCHA challange" />';
     //$red = imagecolorallocate($image, 255, 0,0);
     if (null !== $tag) {
         require_once 'Zend/Form/Decorator/HtmlTag.php';
         $decorator = new Zend_Form_Decorator_HtmlTag();
         $decorator->setOptions(array('tag' => $tag));
         $image = $decorator->render($image);
     } else {
         $image = '<tr><td>&nbsp;</td><td class=forminput valign="middle" align="left" width="65%">' . $image . '</td></tr>' . "\n";
         $image = '<tr><td>&nbsp;</td><td></td></tr><tr><td>&nbsp;</td><td class=forminput valign="middle" align="left" width="65%">Type the characters you see in the picture below.</td></tr>' . "\n" . $image;
     }
     logfire('captcha', $image);
     switch ($placement) {
         case self::PREPEND:
             return $image . $separator . $content;
         case self::APPEND:
         default:
             return $content . $separator . $image;
     }
 }
Example #26
0
    /**
     * Render a form image
     * 
     * @param  string $content 
     * @return string
     */
    public function render($content)
    {
        $element = $this->getElement();
        $view    = $element->getView();
        if (null === $view) {
            return $content;
        }

        $image     = $this->getImage();
        $tag       = $this->getTag();
        $placement = $this->getPlacement();
        $separator = $this->getSeparator();
        $options   = $this->getOptions();

        $image = $view->formImage($element->getName(), $image, $options); 

        if (null !== $tag) {
            require_once 'Zend/Form/Decorator/HtmlTag.php';
            $decorator = new Zend_Form_Decorator_HtmlTag();
            $decorator->setOptions(array('tag' => $tag));
            $image = $decorator->render($image);
        }

        switch ($placement) {
            case self::PREPEND:
                return $image . $separator . $content;
            case self::APPEND:
            default:
                return $content . $separator . $image;
        }
    }
 /**
  * Render a label
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $label = $this->getTitle();
     $separator = $this->getSeparator();
     $placement = $this->getPlacement();
     $tag = $this->getTag();
     $options = $this->getOptions();
     if (empty($label) || empty($tag)) {
         return $content;
     }
     //if (!empty($label)) {
     //$options['class'] = $class;
     //$label = $view->formLabel($element->getFullyQualifiedName(), trim($label), $options);
     //} else {
     //    $label = '&nbsp;';
     //}
     if (null !== $tag) {
         require_once 'Zend/Form/Decorator/HtmlTag.php';
         $decorator = new Zend_Form_Decorator_HtmlTag();
         $decorator->setOptions(array('tag' => $tag));
         $label = $decorator->render($label);
     }
     switch ($placement) {
         case self::APPEND:
             return $content . $separator . $label;
         case self::PREPEND:
             return $label . $separator . $content;
     }
 }
Example #28
0
File: Image.php Project: Kliwer/lms
 /**
  * Render a form image
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $tag = $this->getTag();
     $placement = $this->getPlacement();
     $separator = $this->getSeparator();
     $name = $element->getFullyQualifiedName();
     $attribs = $this->getAttribs();
     $attribs['id'] = $element->getId();
     $image = $view->formImage($name, $element->getImageValue(), $attribs);
     if (null !== $tag) {
         require_once LIB_DIR . '/Zend/Form/Decorator/HtmlTag.php';
         $decorator = new Zend_Form_Decorator_HtmlTag();
         $decorator->setOptions(array('tag' => $tag));
         $image = $decorator->render($image);
     }
     switch ($placement) {
         case self::PREPEND:
             return $image . $separator . $content;
         case self::APPEND:
         default:
             return $content . $separator . $image;
     }
 }
 /**
  * Render a tooltip
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $tooltip = $element->getAttrib('tooltip');
     $tooltip = trim($tooltip);
     //$element->removeAttrib('tooltip');
     if (empty($tooltip)) {
         return $content;
     }
     $view->headScript()->appendFile(\Zend_Controller_Front::getInstance()->getBaseUrl() . '/gems/js/jquery.cluetip.js');
     $view->headLink()->appendStylesheet(\Zend_Controller_Front::getInstance()->getBaseUrl() . '/gems/js/jquery.cluetip.css');
     $script = "\$('" . $this->getTag() . ".tooltip').cluetip({\n            activation: 'click',\n            sticky: 'true',\n            closeText: '[X]',\n            closePosition:    'title',\n            width: 450,\n            titleAttribute: 'tip',\n            splitTitle: '|'})\n                   \$('#tabContainer').bind( 'tabsselect', function(event, ui) {\n  \$(document).trigger('hideCluetip');\n});";
     $view->jQuery()->addOnLoad($script);
     $separator = $this->getSeparator();
     $placement = $this->getPlacement();
     $class = $this->getClass();
     $tag = $this->getTag();
     $escape = $this->getEscape();
     $options = $this->getOptions();
     if ($escape) {
         $tooltip = $view->escape($tooltip);
     }
     $options['tag'] = $tag;
     $options['tip'] = str_replace('"', '\\"', $tooltip);
     $decorator = new \Zend_Form_Decorator_HtmlTag($options);
     $tooltip = $decorator->render($this->getImg()) . $decorator->setOptions(array('class' => 'thetooltip', 'id' => 'tooltip-' . $this->getElement()->getAttrib('id')))->render($tooltip);
     switch ($placement) {
         case self::PREPEND:
             return $tooltip . $separator . $content;
         case self::APPEND:
         default:
             return $content . $separator . $tooltip;
     }
     /* Misschien later toch toevoegen */
     $helper = $this->getHelper();
     return $view->{$helper}($id, $content, $attribs);
 }