/**
  * 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;
 }
Пример #2
0
 /**
  * Renders a label for a fieldset.
  *
  * @param   object  	$field  	The field of the label to render
  * @param   FOFForm   	&$form      The form to render
  * @param 	string		$title		The title of the label
  *
  * @return 	string		The rendered label
  */
 protected function renderFieldsetLabel($field, FOFForm &$form, $title)
 {
     $html = '';
     $labelClass = $field->labelClass ? $field->labelClass : $field->labelclass;
     // Joomla! 2.5/3.x use different case for the same name
     $required = $field->required;
     if ($required) {
         $labelClass .= ' required';
     }
     $tooltip = $form->getFieldAttribute($field->fieldname, 'tooltip', '', $field->group);
     if (!empty($tooltip)) {
         JHtml::_('behavior.tooltip');
         $tooltipText = JText::_($title) . '::' . JText::_($tooltip);
         $labelClass .= ' hasTip';
         $html .= "\t\t\t\t" . '<label id="' . $field->id . '-lbl" class="' . $labelClass . '" for="' . $field->id . '" title="' . $tooltipText . '" rel="tooltip">';
     } else {
         $html .= "\t\t\t\t" . '<label class="' . $labelClass . '" for="' . $field->id . '">';
     }
     $html .= JText::_($title);
     if ($required) {
         $html .= '<span class="star">&nbsp;*</span>';
     }
     $html .= "\t\t\t\t" . '</label>' . PHP_EOL;
     return $html;
 }
 /**
  * Renders a label for a fieldset.
  *
  * @param   object  	$field  	The field of the label to render
  * @param   FOFForm   	&$form      The form to render
  * @param 	string		$title		The title of the label
  *
  * @return 	string		The rendered label
  */
 protected function renderFieldsetLabel($field, FOFForm &$form, $title)
 {
     $html = '';
     $labelClass = $field->labelClass ? $field->labelClass : $field->labelclass;
     // Joomla! 2.5/3.x use different case for the same name
     $required = $field->required;
     $tooltip = $form->getFieldAttribute($field->fieldname, 'tooltip', '', $field->group);
     if (!empty($tooltip)) {
         JHtml::_('bootstrap.tooltip');
         $tooltipText = '<strong>' . JText::_($title) . '</strong><br />' . JText::_($tooltip);
         $html .= "\t\t\t\t" . '<label class="control-label hasTooltip ' . $labelClass . '" for="' . $field->id . '" title="' . $tooltipText . '" rel="tooltip">';
     } else {
         $html .= "\t\t\t\t" . '<label class="control-label ' . $labelClass . '" for="' . $field->id . '">';
     }
     $html .= JText::_($title);
     if ($required) {
         $html .= ' *';
     }
     $html .= '</label>' . PHP_EOL;
     return $html;
 }
Пример #4
0
    /**
     * Renders a label for a fieldset.
     *
     * @param   object  	$field  	The field of the label to render
     * @param   FOFForm   	&$form      The form to render
     * @param 	string		$title		The title of the label
     *
     * @return 	string		The rendered label
     */
    protected function renderFieldsetLabel($field, FOFForm &$form, $title)
    {
        $html = '';
        $labelClass = $field->labelClass ? $field->labelClass : $field->labelclass;
        // Joomla! 2.5/3.x use different case for the same name
        $required = $field->required;
        $tooltip = $form->getFieldAttribute($field->fieldname, 'tooltip', '', $field->group);
        if (!empty($tooltip)) {
            if (version_compare(JVERSION, '3.0', 'ge')) {
                static $loadedTooltipScript = false;
                if (!$loadedTooltipScript) {
                    $js = <<<JS
(function(\$)
{
\t\$(document).ready(function()
\t{
\t\t\$('.fof-tooltip').tooltip({placement: 'top'});
\t});
})(akeeba.jQuery);
JS;
                    $document = FOFPlatform::getInstance()->getDocument();
                    if ($document instanceof JDocument) {
                        $document->addScriptDeclaration($js);
                    }
                    $loadedTooltipScript = true;
                }
                $tooltipText = '<strong>' . JText::_($title) . '</strong><br />' . JText::_($tooltip);
                $html .= "\t\t\t\t" . '<label class="control-label fof-tooltip ' . $labelClass . '" for="' . $field->id . '" title="' . $tooltipText . '" data-toggle="fof-tooltip">';
            } else {
                // Joomla! 2.5 has a conflict with the jQueryUI tooltip, therefore we
                // have to use native Joomla! 2.5 tooltips
                JHtml::_('behavior.tooltip');
                $tooltipText = JText::_($title) . '::' . JText::_($tooltip);
                $html .= "\t\t\t\t" . '<label class="control-label hasTip ' . $labelClass . '" for="' . $field->id . '" title="' . $tooltipText . '" rel="tooltip">';
            }
        } else {
            $html .= "\t\t\t\t" . '<label class="control-label ' . $labelClass . '" for="' . $field->id . '">';
        }
        $html .= JText::_($title);
        if ($required) {
            $html .= ' *';
        }
        $html .= '</label>' . PHP_EOL;
        return $html;
    }