protected function getInput() { $end = $this->element['end']; $styles = $this->element['styles']; $background = $this->element['background'] ? 'background-image: url(' . $this->getPathToImages() . '/images/' . $this->element['background'] . ');' : ''; $tag = $this->element['tag']; if ($end == '1') { // $html = '</li></'.$tag.'><li>'; $html = '</' . $tag . '><div><div>'; } else { // $html = '</li><'.$tag.' style="'.$background.$styles.'" ><li>'; $html = '</div></div><' . $tag . ' style="' . $background . $styles . '" >'; } // var_dump($html); $identifier = 'menustyles'; $form = new JForm($identifier); JForm::addFormPath(JPATH_SITE . '/modules/mod_slideshowck/elements/test'); if (!($formexists = $form->loadFile($identifier, false))) { echo '<p style="color:red">' . JText::_('Problem loading the file : ' . $identifier . '.xml') . '</p>'; return ''; } $fields = $form->getFieldset(); foreach ($fields as $key => $field) { // echo '<div class="ckpopup_row">'; $html .= $form->getLabel(str_replace($identifier . "_", "", $key), $identifier); $html .= $form->getInput(str_replace($identifier . "_", "", $key), $identifier); // echo '</div>'; } return $html; }
/** * Display date form field. If field value equal database null date reset to empty string. * * @param string $field form field name * @return string field form html */ public function date($field) { static $nullDate; if (empty($nullDate)) { $db = JFactory::getDbo(); /* @var $db JDatabaseMySQL */ $nullDate = $db->getNullDate(); } if ($this->form->getValue($field) == $nullDate) { $this->form->setValue($field, null, ''); } return $this->form->getInput($field); }
/** * result html input code (in "LIst" type use extraValues and extraOptions) * @result string html code * @param string $fieldName */ public function getInput($fieldName) { $actValue = $this->extraValues[$fieldName]; $result = parent::getInput($fieldName); //$result = str_replace(' value="'.$actValue.'">',' value="'.$actValue.'" selected="selected">',$result); if (substr($result, 0, 7) == '<select') { $options = ''; foreach ($this->extraOptions[$fieldName] as $fn => $fv) { if ($fv == $actValue) { $options .= '<option value="' . $fv . '" selected="selected">' . $fn . '</option>'; } else { $options .= '<option value="' . $fv . '">' . $fn . '</option>'; } } $result = str_replace('</select>', $options . '</select>', $result); } return $result; }
/** * * @param JForm $form form object * @param string $name name of the fieldset * @param string $group name of the group * @param string $type may be classic, table, params * @return string Raw HTML text */ public static function renderFieldset($form, $name, $defaults, $group = null, $type = 1, $title = 1) { $fieldsets = $form->getFieldsets($group); $fieldset = $fieldsets[$name]; if (is_array($defaults)) { $registry = new JRegistry(); $registry->loadArray($defaults); $defaults = $registry; } /*else if(is_string($item->params)) { $registry = new JRegistry; $registry->loadString($item->params); $defaults = $registry; }*/ $fields = $form->getFieldset($name); $defaultGetName = empty($group) ? '%2$s' : '%s.%s'; $doc = JFactory::getDocument(); $doc->addStyleSheet(JURI::root() . 'libraries/mint/forms/style.css'); $out = ''; switch ($type) { case FORM_STYLE_CLASSIC: if ($title && $fieldset->label) { $out .= '<fieldset class="adminform whitebg"><legend>' . JText::_($fieldset->label) . '</legend>'; } if (isset($fieldset->description) && !empty($fieldset->description)) { $out .= '<small class="small">' . JText::_($fieldset->description) . '</small>'; } $out .= '<ul class="adminformlist">'; foreach ($fields as $key => $field) { $out .= '<li>'; if (!$field->hidden) { $out .= $field->label; } $out .= $form->getInput($field->fieldname, $group, $defaults->get(sprintf($defaultGetName, $group, $field->fieldname))); $out .= '</li>'; } $out .= '</ul>'; if ($title) { $out .= '</fieldset>'; } break; case FORM_STYLE_TABLE: if ($title && $fieldset->label) { $out .= '<legend>' . JText::_($fieldset->label) . '</legend>'; } if (isset($fieldset->description) && !empty($fieldset->description)) { $out .= '<small>' . JText::_($fieldset->description) . '</small><br /><br />'; } $out .= '<table class="table table-bordered table-striped table-hover">'; $i = 1; $hidden = array(); foreach ($fields as $key => $field) { if ($field->hidden) { $hidden[] = $field; continue; } if ($field->type == 'Caddress' || $field->type == 'Ccontacts' || $field->type == 'Clinks' || $field->type == 'Cobaltevents') { if (trim($out) == '<legend>' . JText::_($fieldset->label) . '</legend><table class="table table-bordered table-striped table-hover">') { $out = '<legend>' . JText::_($fieldset->label) . '</legend>'; } else { $out .= '</table>'; } //$out .= '<tr class="row'.$i = 1 - $i.'"><td colspan="2">'; if ($field->type != 'Cobaltevents') { $out .= '<legend>' . $field->label . '</legend>'; $out .= '<br />'; } $out .= $form->getInput($field->fieldname, $group, $defaults->get(sprintf($defaultGetName, $group, $field->fieldname))); //$out .= '</td></tr>'; $out .= '<br /><table class="table table-bordered table-striped table-hover">'; } else { $out .= '<tr><td>'; if (substr($field->description, 0, 3) == 'XX_') { $out .= '<img src="' . JUri::root(true) . '/media/mint/icons/16/exclamation-button.png" alt="Important" class="pull-right">'; } $out .= $field->label; $out .= '</td><td nowrap="nowrap">'; $out .= $form->getInput($field->fieldname, $group, $defaults->get(sprintf($defaultGetName, $group, $field->fieldname))); $out .= '</td></tr>'; } } $out .= '</table>'; foreach ($hidden as $field) { $out .= $field->input; } break; case FORM_STYLE_PARAMS: $hidden = array(); if ($title && $fieldset->label) { $out .= '<h2 class="params-title">' . JText::_($fieldset->label) . '</h2>'; } if (isset($fieldset->description) && !empty($fieldset->description)) { $out .= '<p class="params-description">' . JText::_($fieldset->description) . '</p>'; } foreach ($fields as $key => $field) { if ($field->hidden) { $hidden[] = $field; continue; } $switch = array('checkbox'); if (in_array(strtolower($field->type), $switch)) { $out .= '<div class="params-line">'; $out .= $form->getInput($field->fieldname, $group, $defaults->get(sprintf($defaultGetName, $group, $field->fieldname))); $out .= $field->label; $out .= '</div>'; } else { $out .= '<div class="params-line">'; $out .= $field->label; $out .= $form->getInput($field->fieldname, $group, $defaults->get(sprintf($defaultGetName, $group, $field->fieldname))); $out .= '</div>'; } } foreach ($hidden as $field) { $out .= $form->getInput($field->fieldname, $group, $defaults->get(sprintf($defaultGetName, $group, $field->fieldname))); } $out .= '<br />'; break; } return $out; }