/**
  * Renders a raw FOFForm and returns the corresponding HTML
  *
  * @param   FOFForm   &$form     The form to render
  * @param   FOFModel  $model     The model providing our data
  * @param   FOFInput  $input     The input object
  * @param   string    $formType  The form type e.g. 'edit' or 'read'
  *
  * @return  string    The HTML rendering of the form
  */
 protected function renderFormRaw(FOFForm &$form, FOFModel $model, FOFInput $input, $formType)
 {
     $html = '';
     foreach ($form->getFieldsets() as $fieldset) {
         $fields = $form->getFieldset($fieldset->name);
         if (isset($fieldset->class)) {
             $class = 'class="' . $fieldset->class . '"';
         } else {
             $class = '';
         }
         $html .= "\t" . '<div id="' . $fieldset->name . '" ' . $class . '>' . PHP_EOL;
         if (isset($fieldset->label) && !empty($fieldset->label)) {
             $html .= "\t\t" . '<h3>' . JText::_($fieldset->label) . '</h3>' . PHP_EOL;
         }
         foreach ($fields as $field) {
             $required = $field->required;
             $labelClass = $field->labelClass;
             $groupClass = $form->getFieldAttribute($field->fieldname, 'groupclass', '', $field->group);
             // Auto-generate label and description if needed
             // Field label
             $title = $form->getFieldAttribute($field->fieldname, 'label', '', $field->group);
             $emptylabel = $form->getFieldAttribute($field->fieldname, 'emptylabel', false, $field->group);
             if (empty($title) && !$emptylabel) {
                 $model->getName();
                 $title = strtoupper($input->get('option') . '_' . $model->getName() . '_' . $field->id . '_LABEL');
             }
             // Field description
             $description = $form->getFieldAttribute($field->fieldname, 'description', '', $field->group);
             /**
              * The following code is backwards incompatible. Most forms don't require a description in their form
              * fields. Having to use emptydescription="1" on each one of them is an overkill. Removed.
              */
             /*
             $emptydescription   = $form->getFieldAttribute($field->fieldname, 'emptydescription', false, $field->group);
             if (empty($description) && !$emptydescription)
             {
             	$description = strtoupper($input->get('option') . '_' . $model->getName() . '_' . $field->id . '_DESC');
             }
             */
             if ($formType == 'read') {
                 $inputField = $field->static;
             } elseif ($formType == 'edit') {
                 $inputField = $field->input;
             }
             if (empty($title)) {
                 $html .= "\t\t\t" . $inputField . PHP_EOL;
                 if (!empty($description) && $formType == 'edit') {
                     $html .= "\t\t\t\t" . '<span class="help-block">';
                     $html .= JText::_($description) . '</span>' . PHP_EOL;
                 }
             } else {
                 $html .= "\t\t\t" . '<div class="control-group ' . $groupClass . '">' . PHP_EOL;
                 $html .= "\t\t\t\t" . '<label class="control-label ' . $labelClass . '" for="' . $field->id . '">' . PHP_EOL;
                 $html .= "\t\t\t\t" . JText::_($title) . PHP_EOL;
                 if ($required) {
                     $html .= ' *';
                 }
                 $html .= "\t\t\t\t" . '</label>' . PHP_EOL;
                 $html .= "\t\t\t\t" . '<div class="controls">' . PHP_EOL;
                 $html .= "\t\t\t\t" . $inputField . PHP_EOL;
                 if (!empty($description)) {
                     $html .= "\t\t\t\t" . '<span class="help-block">';
                     $html .= JText::_($description) . '</span>' . PHP_EOL;
                 }
                 $html .= "\t\t\t\t" . '</div>' . PHP_EOL;
                 $html .= "\t\t\t" . '</div>' . PHP_EOL;
             }
         }
         $html .= "\t" . '</div>' . PHP_EOL;
     }
     return $html;
 }
Esempio n. 2
0
 /**
  * Renders a raw FOFForm and returns the corresponding HTML
  *
  * @param   FOFForm   &$form     The form to render
  * @param   FOFModel  $model     The model providing our data
  * @param   FOFInput  $input     The input object
  * @param   string    $formType  The form type e.g. 'edit' or 'read'
  *
  * @return  string    The HTML rendering of the form
  */
 protected function renderFormRaw(FOFForm &$form, FOFModel $model, FOFInput $input, $formType)
 {
     $html = '';
     foreach ($form->getFieldsets() as $fieldset) {
         $fields = $form->getFieldset($fieldset->name);
         if (isset($fieldset->class)) {
             $class = 'class="' . $fieldset->class . '"';
         } else {
             $class = '';
         }
         $element = empty($fields) ? 'div' : 'fieldset';
         $html .= "\t" . '<' . $element . ' id="' . $fieldset->name . '" ' . $class . '>' . PHP_EOL;
         if (isset($fieldset->label) && !empty($fieldset->label)) {
             $html .= "\t\t" . '<h3>' . JText::_($fieldset->label) . '</h3>' . PHP_EOL;
         }
         foreach ($fields as $field) {
             $label = $field->label;
             $html .= "<div class=\"fof-row\">";
             if (!is_null($label)) {
                 $html .= "\t\t\t" . $label . PHP_EOL;
             }
             if ($formType == 'read') {
                 $html .= "\t\t\t" . $field->static . PHP_EOL;
             } elseif ($formType == 'edit') {
                 $html .= "\t\t\t" . $field->input . PHP_EOL;
             }
             $html .= "</div>";
         }
         $element = empty($fields) ? 'div' : 'fieldset';
         $html .= "\t" . '</' . $element . '>' . PHP_EOL;
     }
     return $html;
 }
Esempio n. 3
0
 /**
  * Renders a FOFForm for a Browse view and returns the corresponding HTML
  *
  * @param   FOFForm   $form      The form to render
  * @param   FOFModel  $model     The model providing our data
  * @param   FOFInput  $input     The input object
  *
  * @return  string    The HTML rendering of the form
  */
 protected function renderFormRead(FOFForm &$form, FOFModel $model, FOFInput $input)
 {
     // Get the key for this model's table
     $key = $model->getTable()->getKeyName();
     $keyValue = $model->getId();
     $html = '';
     foreach ($form->getFieldsets() as $fieldset) {
         $fields = $form->getFieldset($fieldset->name);
         if (isset($fieldset->class)) {
             $class = 'class="' . $fieldset->class . '"';
         } else {
             $class = '';
         }
         $html .= "\t" . '<div id="' . $fieldset->name . '" ' . $class . '>' . PHP_EOL;
         if (isset($fieldset->label) && !empty($fieldset->label)) {
             $html .= "\t\t" . '<h3>' . JText::_($fieldset->label) . '</h3>' . PHP_EOL;
         }
         foreach ($fields as $field) {
             $label = $field->label;
             $static = $field->static;
             $html .= "<div class=\"fof-row\">";
             $html .= "\t\t\t" . $label . PHP_EOL;
             $html .= "\t\t\t" . $static . PHP_EOL;
             $html .= "</div>";
         }
         $html .= "\t" . '</div>' . PHP_EOL;
     }
     return $html;
 }
 /**
  * Renders a FOFForm for a Browse view and returns the corresponding HTML
  *
  * @param   FOFForm   $form      The form to render
  * @param   FOFModel  $model     The model providing our data
  * @param   FOFInput  $input     The input object
  *
  * @return  string    The HTML rendering of the form
  */
 protected function renderFormRead(FOFForm &$form, FOFModel $model, FOFInput $input)
 {
     // Get the key for this model's table
     $key = $model->getTable()->getKeyName();
     $keyValue = $model->getId();
     $html = '';
     foreach ($form->getFieldsets() as $fieldset) {
         $fields = $form->getFieldset($fieldset->name);
         if (isset($fieldset->class)) {
             $class = 'class="' . $fieldset->class . '"';
         } else {
             $class = '';
         }
         $html .= "\t" . '<div id="' . $fieldset->name . '" ' . $class . '>' . PHP_EOL;
         if (isset($fieldset->label) && !empty($fieldset->label)) {
             $html .= "\t\t" . '<h3>' . JText::_($fieldset->label) . '</h3>' . PHP_EOL;
         }
         foreach ($fields as $field) {
             $title = $field->title;
             $required = $field->required;
             $labelClass = $field->labelClass;
             $description = $field->description;
             $input = $field->static;
             if (empty($title)) {
                 $html .= "\t\t\t" . $input . PHP_EOL;
                 if (!empty($description)) {
                     $html .= "\t\t\t\t" . '<span class="help-block">';
                     $html .= JText::_($description) . '</span>' . PHP_EOL;
                 }
             } else {
                 $html .= "\t\t\t" . '<div class="control-group">' . PHP_EOL;
                 $html .= "\t\t\t\t" . '<label class="control-label ' . $labelClass . '" for="' . $field->id . '">' . PHP_EOL;
                 $html .= "\t\t\t\t" . JText::_($title) . PHP_EOL;
                 if ($required) {
                     $html .= ' *';
                 }
                 $html .= "\t\t\t\t" . '</label>' . PHP_EOL;
                 $html .= "\t\t\t\t" . '<div class="controls">' . PHP_EOL;
                 $html .= "\t\t\t\t" . $input . PHP_EOL;
                 if (!empty($description)) {
                     $html .= "\t\t\t\t" . '<span class="help-block">';
                     $html .= JText::_($description) . '</span>' . PHP_EOL;
                 }
                 $html .= "\t\t\t\t" . '</div>' . PHP_EOL;
                 $html .= "\t\t\t" . '</div>' . PHP_EOL;
             }
         }
         $html .= "\t" . '</div>' . PHP_EOL;
     }
     return $html;
 }
Esempio n. 5
0
 /**
  * Renders a raw FOFForm and returns the corresponding HTML
  *
  * @param   FOFForm   &$form     The form to render
  * @param   FOFModel  $model     The model providing our data
  * @param   FOFInput  $input     The input object
  * @param   string    $formType  The form type e.g. 'edit' or 'read'
  *
  * @return  string    The HTML rendering of the form
  */
 protected function renderFormRaw(FOFForm &$form, FOFModel $model, FOFInput $input, $formType)
 {
     $html = '';
     foreach ($form->getFieldsets() as $fieldset) {
         $html .= $this->renderFieldset($fieldset, $form, $model, $input, $formType, false);
     }
     return $html;
 }
Esempio n. 6
0
 /**
  * Renders a raw FOFForm and returns the corresponding HTML
  *
  * @param   FOFForm   &$form     The form to render
  * @param   FOFModel  $model     The model providing our data
  * @param   FOFInput  $input     The input object
  * @param   string    $formType  The form type e.g. 'edit' or 'read'
  *
  * @return  string    The HTML rendering of the form
  */
 protected function renderFormRaw(FOFForm &$form, FOFModel $model, FOFInput $input, $formType)
 {
     $html = '';
     $tabHtml = array();
     // Do we have a tabbed form?
     $isTabbed = $form->getAttribute('tabbed', '0');
     $isTabbed = in_array($isTabbed, array('true', 'yes', 'on', '1'));
     foreach ($form->getFieldsets() as $fieldset) {
         if ($isTabbed && $this->isTabFieldset($fieldset)) {
             continue;
         } elseif ($isTabbed && isset($fieldset->innertab)) {
             $inTab = $fieldset->innertab;
         } else {
             $inTab = '__outer';
         }
         $tabHtml[$inTab][] = $this->renderFieldset($fieldset, $form, $model, $input, $formType, false);
     }
     // If the form is tabbed, render the tabs bars
     if ($isTabbed) {
         $html .= '<ul class="nav nav-tabs">' . PHP_EOL;
         foreach ($form->getFieldsets() as $fieldset) {
             // Only create tabs for tab fieldsets
             $isTabbedFieldset = $this->isTabFieldset($fieldset);
             if (!$isTabbedFieldset) {
                 continue;
             }
             // Only create tabs if we do have a label
             if (!isset($fieldset->label) || empty($fieldset->label)) {
                 continue;
             }
             $label = JText::_($fieldset->label);
             $name = $fieldset->name;
             $liClass = $isTabbedFieldset == 2 ? 'class="active"' : '';
             $html .= "<li {$liClass}><a href=\"#{$name}\" data-toggle=\"tab\">{$label}</a></li>" . PHP_EOL;
         }
         $html .= '</ul>' . "\n\n<div class=\"tab-content\">" . PHP_EOL;
         foreach ($form->getFieldsets() as $fieldset) {
             if (!$this->isTabFieldset($fieldset)) {
                 continue;
             }
             $html .= $this->renderFieldset($fieldset, $form, $model, $input, $formType, false, $tabHtml);
         }
         $html .= "</div>\n";
     }
     if (isset($tabHtml['__outer'])) {
         $html .= implode('', $tabHtml['__outer']);
     }
     return $html;
 }