Пример #1
0
 public function render($content)
 {
     $element = $this->getElement();
     // apply this decorator to Managedfile elements only.
     if (!$element instanceof Project_Form_Element_Managedfile) {
         return $content;
     }
     $view = $element->getView();
     if (!$view instanceof Zend_View_Interface) {
         // do nothing if no view is present.
         return $content;
     }
     // element's FQN
     $name = $element->getFullyQualifiedName();
     $fid = $element->getValue();
     $filepath = null !== $fid && is_int($fid) ? Managedfile::getManagedFilepath($fid) : '';
     $attribs = $element->getAttribs();
     $markup = $view->formText($name, $filepath, $attribs);
     $separator = $this->getSeparator();
     switch ($this->getPlacement()) {
         case self::PREPEND:
             $ret = $markup . $separator . $content;
             break;
         case self::APPEND:
         default:
             $ret = $content . $separator . $markup;
             break;
     }
     return $ret;
 }
Пример #2
0
 public function setValue($value)
 {
     if (null === $value || '' === $value) {
         $this->_fid = null;
         $this->_filepath = '';
         $value = null;
     } elseif (is_numeric($value)) {
         $this->_fid = (int) $value;
         $this->_filepath = Managedfile::getManagedFilepath($this->_fid);
     } elseif (is_string($value)) {
         $this->_filepath = (string) $value;
         $this->_fid = Managedfile::getManagedFid($this->_filepath, true);
     }
 }