getAttribute() 공개 메소드

Returns the value of an attribute of the form itself
부터: 2.0
public getAttribute ( string $attribute, mixed $default = null ) : mixed
$attribute string The name of the attribute
$default mixed Optional default value to return
리턴 mixed
예제 #1
0
파일: ViewTemplate.php 프로젝트: akeeba/fof
 /**
  * Returns the rendered view template
  *
  * @return string
  */
 protected function getRenderedTemplate($isRepeatable = false)
 {
     $sourceTemplate = isset($this->element['source']) ? (string) $this->element['source'] : null;
     $sourceView = isset($this->element['source_view']) ? (string) $this->element['source_view'] : null;
     $sourceViewType = isset($this->element['source_view_type']) ? (string) $this->element['source_view_type'] : 'html';
     $sourceComponent = isset($this->element['source_component']) ? (string) $this->element['source_component'] : null;
     if (empty($sourceTemplate)) {
         return '';
     }
     $sourceContainer = empty($sourceComponent) ? $this->form->getContainer() : Container::getInstance($sourceComponent);
     if (empty($sourceView)) {
         $viewObject = new View($sourceContainer, array('name' => 'FAKE_FORM_VIEW'));
     } else {
         $viewObject = $sourceContainer->factory->view($sourceView, $sourceViewType);
     }
     $viewObject->populateFromModel($this->form->getModel());
     return $viewObject->loadAnyTemplate($sourceTemplate, array('model' => $isRepeatable ? $this->item : $this->form->getModel(), 'form' => $this->form, 'formType' => $this->form->getAttribute('type', 'edit'), 'fieldValue' => $this->value, 'fieldElement' => $this->element));
 }
예제 #2
0
파일: Callback.php 프로젝트: Joal01/fof
 /**
  * Returns the rendered view template
  *
  * @return string
  */
 protected function getCallbackResults()
 {
     $source_file = empty($this->element['source_file']) ? '' : (string) $this->element['source_file'];
     $source_class = empty($this->element['source_class']) ? '' : (string) $this->element['source_class'];
     $source_method = empty($this->element['source_method']) ? '' : (string) $this->element['source_method'];
     if (empty($source_class) || empty($source_method)) {
         return '';
     }
     // Maybe we have to load a file?
     if (!empty($source_file)) {
         $source_file = $this->form->getContainer()->template->parsePath($source_file, true);
         if ($this->form->getContainer()->filesystem->fileExists($source_file)) {
             include_once $source_file;
         }
     }
     // Make sure the class exists
     if (class_exists($source_class, true)) {
         // ...and so does the option
         if (in_array($source_method, get_class_methods($source_class))) {
             return $source_class::$source_method(array('model' => $this->form->getModel(), 'form' => $this->form, 'formType' => $this->form->getAttribute('type', 'edit'), 'fieldValue' => $this->value, 'fieldElement' => $this->element));
         }
     }
     return '';
 }
예제 #3
0
 /**
  * Renders a Form and returns the corresponding HTML
  *
  * @param   Form      &$form         The form to render
  * @param   DataModel $model         The model providing our data
  * @param   string    $formType      The form type: edit, browse or read
  * @param   boolean   $raw           If true, the raw form fields rendering (without the surrounding form tag) is
  *                                   returned.
  *
  * @return  string    The HTML rendering of the form
  */
 function renderForm(Form &$form, DataModel $model, $formType = null, $raw = false)
 {
     $useChosen = $form->getAttribute('chosen', 'select');
     $useChosen = in_array($useChosen, array('false', 'no', 'off', '0')) ? '' : $useChosen;
     if ($useChosen) {
         \JHtml::_('formbehavior.chosen', $useChosen);
     }
     if (is_null($formType)) {
         $formType = $form->getAttribute('type', 'edit');
     } else {
         $formType = strtolower($formType);
     }
     switch ($formType) {
         case 'browse':
             return $this->renderFormBrowse($form, $model);
             break;
         case 'read':
             if ($raw) {
                 return $this->renderFormRaw($form, $model, 'read');
             } else {
                 return $this->renderFormRead($form, $model);
             }
             break;
         default:
             if ($raw) {
                 return $this->renderFormRaw($form, $model, 'edit');
             } else {
                 return $this->renderFormEdit($form, $model);
             }
             break;
     }
 }