示例#1
0
文件: Label.php 项目: jasmun/Noco100
 /**
  * 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 = ' ';
     }
     if (null !== $tag) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Form/Decorator/HtmlTag.php';
         $decorator = new IfwPsn_Vendor_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;
     }
 }
示例#2
0
文件: Image.php 项目: jasmun/Noco100
 /**
  * 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 IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Form/Decorator/HtmlTag.php';
         $decorator = new IfwPsn_Vendor_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;
     }
 }
示例#3
0
 /**
  * Render a description
  *
  * @param  string $content
  * @return string
  */
 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();
     $tag = $this->getTag();
     $class = $this->getClass();
     $escape = $this->getEscape();
     $options = $this->getOptions();
     if ($escape) {
         $description = $view->escape($description);
     }
     if (!empty($tag)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Form/Decorator/HtmlTag.php';
         $options['tag'] = $tag;
         $decorator = new IfwPsn_Vendor_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;
     }
 }