Пример #1
0
 /**
  * Render an element
  *
  * @param  string $content
  * @return string
  * @throws \UnexpectedValueException if element or view are not registered
  */
 public function render($content = '')
 {
     $element = $this->getElement();
     $separator = $this->getSeparator();
     $helpers = $element->getHelpers();
     if (empty($helpers)) {
         $helpers = $this->getDefaultHelpers();
     }
     $attribs['id'] = $element->getId();
     foreach ($helpers as $i => $helper) {
         $helpers[$i] = Helper::factory($helper, $element);
     }
     $sections = [];
     foreach ($helpers as $helper) {
         call_user_func_array([$helper['helper'], 'init'], [$helper['element']]);
         $sections[] = call_user_func_array([$helper['helper'], '_'], [$helper['element']]);
     }
     $elementContent = implode($separator, $sections);
     foreach (array_reverse($helpers) as $helper) {
         $elementContent .= call_user_func([$helper['helper'], 'endTag']);
     }
     switch ($this->getPlacement()) {
         case self::APPEND:
             return $content . $separator . $elementContent;
         case self::PREPEND:
             return $elementContent . $separator . $content;
         default:
             return $elementContent;
     }
 }
Пример #2
0
 /**
  * Render filter form field
  *
  * @param \Engine\Crud\Grid\Filter\Field $field
  * @return string
  */
 public static function renderField(\Engine\Crud\Grid\Filter\Field $field)
 {
     $helperName = self::getFieldHelper($field);
     $helper = \Engine\Crud\Decorator\Helper::factory($helperName, $field);
     $elementContent = call_user_func_array([$helper['helper'], '_'], [$helper['element']]);
     $elementContent .= call_user_func([$helper['helper'], 'endTag']);
     return $elementContent;
 }
Пример #3
0
 /**
  * Render filter form field
  *
  * @param \Engine\Crud\Form\Field $field
  * @return string
  */
 public function renderField(Field $field)
 {
     $helpers = $field->getHelpers();
     foreach ($helpers as $i => $helper) {
         $helpers[$i] = Helper::factory($helper, $field);
     }
     $sections = [];
     foreach ($helpers as $helper) {
         $sections[] = call_user_func_array([$helper['helper'], '_'], [$helper['element']]);
     }
     $separator = $this->getSeparator();
     $elementContent = implode($separator, $sections);
     foreach (array_reverse($helpers) as $helper) {
         $elementContent .= $sections[] = call_user_func([$helper['helper'], 'endTag']);
     }
     return $elementContent;
 }
Пример #4
0
 /**
  * Render an element
  *
  * @param  string $content
  * @return string
  * @throws \UnexpectedValueException if element or view are not registered
  */
 public function render($content = '')
 {
     $element = $this->getElement();
     $separator = $this->getSeparator();
     $helpers = $element->getHelpers();
     if (empty($helpers)) {
         $helpers = $this->getDefaultHelpers();
     }
     $attribs['id'] = $element->getId();
     foreach ($helpers as $i => $helper) {
         $helpers[$i] = Helper::factory($helper, $element);
     }
     $sections = [];
     $continue = false;
     foreach ($helpers as $i => $helper) {
         $helper['createFile'] = false;
         call_user_func_array([$helper['helper'], 'init'], [$helper['element']]);
         $endTag = call_user_func([$helper['helper'], 'endTag']);
         if (call_user_func([$helper['helper'], 'createJs'])) {
             $objectName = call_user_func([$helper['helper'], 'getName']);
             $path = call_user_func_array([$helper['helper'], 'getJsFilePath'], [$objectName]);
             $path = PUBLIC_PATH . "/extjs/apps/" . $path;
             if (!$this->_checkFile($path)) {
                 if ($endTag) {
                     $continue = false;
                 }
                 $helper['createFile'] = $path;
             } else {
                 if ($endTag) {
                     $continue = true;
                 }
                 continue;
             }
         }
         if ($endTag === false && $helper['createFile']) {
             if (!file_put_contents($helper['createFile'], call_user_func_array([$helper['helper'], '_'], [$helper['element']]))) {
                 throw new \Engine\Exception("File '" . $helper['createFile'] . "' not save");
             }
         } else {
             if ($continue) {
                 continue;
             }
             if ($endTag !== '') {
                 $key = $i;
                 $sections[$key] = [];
                 $helpers[$key]['createFile'] = $helper['createFile'];
             }
             $sections[$key][] = call_user_func_array([$helper['helper'], '_'], [$helper['element']]);
         }
     }
     foreach ($sections as $key => $fileSections) {
         $elementContent = implode("", $fileSections);
         $elementContent .= call_user_func([$helpers[$key]['helper'], 'endTag']);
         if (!file_put_contents($helpers[$key]['createFile'], $elementContent)) {
             throw new \Engine\Exception("File '" . $helpers[$key]['createFile'] . "' not save");
         }
     }
     return;
     switch ($this->getPlacement()) {
         case self::APPEND:
             return $content . $separator . $elementContent;
         case self::PREPEND:
             return $elementContent . $separator . $content;
         default:
             return $elementContent;
     }
 }