/** * Method to load, setup and return a JFormField object based on field data. * * @param string $element The XML element object representation of the form field. * @param string $group The optional dot-separated form group path on which to find the field. * @param mixed $value The optional value to use as the default for the field. * * @return mixed The JFormField object for the field or boolean false on error. * * @since 11.1 */ protected function loadField($element, $group = null, $value = null) { // Get the field type. $type = $element['type'] ? (string) $element['type'] : 'text'; // Load the JFormField object for the field. /** @var $field JFormField */ $field = JFormHelper::loadFieldType($type, true); // If the object could not be loaded, get a text field object. if ($field === false) { $field = JFormHelper::loadFieldType('text', true); } // Get the value for the form field if not set. // Default to the translated version of the 'default' attribute // if 'translate_default' attribute if set to 'true' or '1' // else the value of the 'default' attribute for the field. if ($value === null) { $default = (string) $element['default']; if (($translate = $element['translate_default']) && ((string) $translate == 'true' || (string) $translate == '1')) { $lang = JFactory::getLanguage(); if ($lang->hasKey($default)) { $debug = $lang->setDebug(false); $default = JText::_($default); $lang->setDebug($debug); } else { $default = JText::_($default); } } } if ($field->setup($element, $value, $group)) { return $field; } else { return false; } }
public static function createStatuses() { $app = JFactory::getApplication(); $filter_steps = $app->getUserStateFromRequest('com_imc.issues.filter.steps', 'steps', array()); //get issue statuses JFormHelper::addFieldPath(JPATH_ROOT . '/components/com_imc/models/fields'); $step = JFormHelper::loadFieldType('Step', false); $statuses = $step->getOptions(); if (empty($filter_steps)) { $str = '<ul class="imc_ulist imc_ulist_inline">'; foreach ($statuses as $status) { $str .= '<li>'; $str .= '<input type="checkbox" name="steps[]" value="' . $status->value . '" ' . 'checked="checked"' . '>'; $str .= '<span class="root">' . ' ' . $status->text . '</span>'; $str .= '</li>'; } $str .= '</ul>'; } else { $str = '<ul class="imc_ulist imc_ulist_inline">'; foreach ($statuses as $status) { $str .= '<li>'; $str .= '<input type="checkbox" name="steps[]" value="' . $status->value . '" ' . (in_array($status->value, $filter_steps) ? 'checked="checked"' : '') . '>'; $str .= '<span class="root">' . ' ' . $status->text . '</span>'; $str .= '</li>'; } $str .= '</ul>'; } return $str; }
/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { // use as type here the default basic data field type (as example: Text/Calendar/Textarea/Editor) // see http://docs.joomla.org/Standard_form_field_types $field = JFormHelper::loadFieldType('Calendar'); $field->setForm($this->form); $field->setup($this->element, $this->value); return $field->getInput(); }
/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { global $jlistConfig; $app = JFactory::getApplication(); JHtml::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/helpers'); JHtml::addIncludePath(JPATH_COMPONENT . '/helpers'); $field = JFormHelper::loadFieldType('Text'); $field->setForm($this->form); if ($this->value != '') { $field->setup($this->element, $this->value); } else { $field->setup($this->element, htmlspecialchars(trim($jlistConfig['custom.field.10.values']), ENT_COMPAT, 'UTF-8')); } return $field->getInput(); }
/** * Method to get the HTML of a certain field * * @param null * @return string */ public static function getField($type, $name, $value = null, $array = 'magebridge') { jimport('joomla.form.helper'); jimport('joomla.form.form'); $fileType = preg_replace('/^magebridge\\./', '', $type); include_once JPATH_ADMINISTRATOR . '/components/com_magebridge/fields/' . $fileType . '.php'; $form = new JForm('magebridge'); $field = JFormHelper::loadFieldType($type); if (is_object($field) == false) { $message = JText::sprintf('COM_MAGEBRIDGE_UNKNOWN_FIELD', $type); JFactory::getApplication()->enqueueMessage($message, 'error'); return null; } $field->setName($name); $field->setValue($value); return $field->getHtmlInput(); }
public static function getField($type, $name, $value = null, $array = 'magebridge') { if (MageBridgeHelper::isJoomla15()) { require_once JPATH_ADMINISTRATOR . '/components/com_magebridge/elements/' . $type . '.php'; $fake = null; $class = 'JElement' . ucfirst($type); $object = new $class(); return call_user_func(array($object, 'fetchElement'), $name, $value, $fake, $array); } else { jimport('joomla.form.helper'); jimport('joomla.form.form'); require_once JPATH_ADMINISTRATOR . '/components/com_magebridge/fields/' . $type . '.php'; $form = new JForm('magebridge'); $field = JFormHelper::loadFieldType($type); $field->setName($name); $field->setValue($value); return $field->getHtmlInput(); } }
function getItems() { $items = array(); foreach ($this->element->children() as $element) { // clone element to make it as field $fdata = preg_replace('/<(\\/?)item(\\s|>)/mi', '<\\1field\\2', $element->asXML()); $felement = new SimpleXMLElement($fdata); $field = JFormHelper::loadFieldType((string) $felement['type']); if ($field === false) { $field = JFormHelper::loadFieldType('text'); } // Setup the JFormField object. $field->setForm($this->form); if ($field->setup($felement, null, $this->group . '.' . $this->fieldname)) { $items[] = $field; } } return $items; }
/** * Tests the JForm::__construct method */ public function testConstruct() { $form = new JForm('form1'); $this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new JFormFieldInspector($form); $this->assertThat($field instanceof JFormField, $this->isTrue(), 'Line:' . __LINE__ . ' The JFormField constuctor should return a JFormField object.'); $this->assertThat($field->getForm(), $this->identicalTo($form), 'Line:' . __LINE__ . ' The internal form should be identical to the variable passed in the contructor.'); // Add custom path. JForm::addFieldPath(__DIR__ . '/_testfields'); JFormHelper::loadFieldType('foo.bar'); $field = new FooFormFieldBar($form); $this->assertEquals($field->type, 'FooBar', 'Line:' . __LINE__ . ' The field type should have been guessed by the constructor.'); JFormHelper::loadFieldType('foo'); $field = new JFormFieldFoo($form); $this->assertEquals($field->type, 'Foo', 'Line:' . __LINE__ . ' The field type should have been guessed by the constructor.'); JFormHelper::loadFieldType('modal_foo'); $field = new JFormFieldModal_Foo($form); $this->assertEquals($field->type, 'Modal_Foo', 'Line:' . __LINE__ . ' The field type should have been guessed by the constructor.'); }
protected function addToolbar() { $state = $this->get('State'); $canDo = SimplefilemanagerHelper::getActions($state->get('filter.category_id')); $user = JFactory::getUser(); $bar = JToolBar::getInstance('toolbar'); JToolbarHelper::title(JText::_('COM_SIMPLEFILEMANAGER_MANAGER_SIMPLEFILEMANAGERS'), 'file-2'); // User should be authorized to publish at least in a category if ($canDo->get('core.create') && count($user->getAuthorisedCategories('com_simplefilemanager', 'core.create')) > 0) { JToolbarHelper::addNew('simplefilemanager.add'); } if ($canDo->get('core.edit')) { JToolbarHelper::editList('simplefilemanager.edit'); } if ($canDo->get('core.edit.state')) { JToolbarHelper::publish('simplefilemanagers.publish', 'JTOOLBAR_PUBLISH', true); JToolbarHelper::unpublish('simplefilemanagers.unpublish', 'JTOOLBAR_UNPUBLISH', true); JToolbarHelper::archiveList('simplefilemanagers.archive'); JToolbarHelper::checkin('simplefilemanagers.checkin'); } $state = $this->get('State'); if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolbarHelper::deleteList('', 'simplefilemanagers.delete', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($canDo->get('core.edit.state')) { JToolbarHelper::trash('simplefilemanagers.trash'); } if ($canDo->get('core.admin')) { JToolbarHelper::preferences('com_simplefilemanager'); } JToolBarHelper::help('COM_SIMPLEFILEMANAGER_HELP_VIEW_SIMPLEFILEMANANGERS', false, 'http://www.simplefilemanager.eu/support'); JHtmlSidebar::setAction('index.php?option=com_simplefilemanager&view=simplefilemanagers'); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_state', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.state'), true)); $this->category = JFormHelper::loadFieldType('catid', false); $this->categoryOptions = $this->category->getOptions(); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_CATEGORY'), 'filter_category', JHtml::_('select.options', $this->categoryOptions, 'value', 'text', $this->state->get('filter.category'))); $this->visibilityOptions = array(1 => JText::_('COM_SIMPLEFILEMANAGER_VISIBILITY_PUBLIC'), 2 => JText::_('COM_SIMPLEFILEMANAGER_VISIBILITY_REGISTRED'), 3 => JText::_('COM_SIMPLEFILEMANAGER_VISIBILITY_USER'), 4 => JText::_('COM_SIMPLEFILEMANAGER_VISIBILITY_GROUP'), 5 => JText::_('COM_SIMPLEFILEMANAGER_VISIBILITY_AUTHOR')); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_VISIBILITY'), 'filter_visibility', JHtml::_('select.options', $this->visibilityOptions, 'value', 'text', $this->state->get('filter.visibility'))); }
function getItems() { $items = array(); foreach ($this->element->children() as $element) { // clone element to make it as field $fdata = preg_replace('/<(\\/?)item(\\s|>)/mi', '<\\1field\\2', $element->asXML()); // remove cols, rows, size attributes $fdata = preg_replace('/\\s(cols|rows|size)=(\'|")\\d+(\'|")/mi', '', $fdata); // change type text to textarea $fdata = str_replace('type="text"', 'type="textarea"', $fdata); $felement = new JXMLElement($fdata); $field = JFormHelper::loadFieldType((string) $felement['type']); if ($field === false) { $field = $this->loadFieldType('text'); } // Setup the JFormField object. $field->setForm($this->form); if ($field->setup($felement, null, $this->name)) { $items[] = $field; } } return $items; }
/** * $type, $domId, $value, $options = array(), $formName = null, $disabled = false */ public static function element() { list($type, $domId, $value, $options) = func_get_args(); $options = (array) $options; // Load the JFormField object for the field. JFormHelper::addFieldPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'fields'); $field = JFormHelper::loadFieldType($type, true); // If the object could not be loaded, get a text field object. if ($field === false) { throw new Exception('Cannot load field type ' . $type); } $element = new JXMLElement('<field></field>'); $element->addAttribute('id', $domId); if (!empty($options)) { foreach ($options as $name => $val) { $element->addAttribute($name, $val); } } if (!$field->setup($element, $value, null)) { throw new Exception('Cannot setup field ' . $type); } return $field->input; }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/imc.php'; $state = $this->get('State'); $canDo = ImcHelper::getActions($state->get('filter.category_id')); JToolBarHelper::title(JText::_('COM_IMC_TITLE_ISSUES'), 'drawer'); //Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/issue'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('issue.add', 'JTOOLBAR_NEW'); } if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('issue.edit', 'JTOOLBAR_EDIT'); } } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::custom('issues.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::custom('issues.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); } else { if (isset($this->items[0])) { //If this component does not use state then show a direct delete button as we can not trash JToolBarHelper::deleteList('', 'issues.delete', 'JTOOLBAR_DELETE'); } } if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::archiveList('issues.archive', 'JTOOLBAR_ARCHIVE'); } if (isset($this->items[0]->checked_out)) { JToolBarHelper::custom('issues.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); } } //Show trash and delete for components that uses the state field if (isset($this->items[0]->state)) { if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'issues.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } else { if ($canDo->get('core.edit.state')) { JToolBarHelper::trash('issues.trash', 'JTOOLBAR_TRASH'); JToolBarHelper::divider(); } } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_imc'); } //Set sidebar action - New in 3.0 JHtmlSidebar::setAction('index.php?option=com_imc&view=issues'); $this->extra_sidebar = ''; JHtmlSidebar::addFilter(JText::_("JOPTION_SELECT_CATEGORY"), 'filter_catid', JHtml::_('select.options', JHtml::_('category.options', 'com_imc'), "value", "text", $this->state->get('filter.catid'))); //Get custom field JFormHelper::addFieldPath(JPATH_ROOT . '/components/com_imc/models/fields'); $steps = JFormHelper::loadFieldType('Step', false); $options = $steps->getOptions(); JHtmlSidebar::addFilter(JText::_("COM_IMC_ISSUES_STEPID_FILTER"), 'filter_stepid', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.stepid'), true)); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true)); }
/** * Setting the toolbar */ protected function addToolBar() { JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENTS'), 'support'); JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=help_documents'); JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { JToolBarHelper::addNew('help_document.add'); } // Only load if there are items if (ComponentbuilderHelper::checkArray($this->items)) { if ($this->canEdit) { JToolBarHelper::editList('help_document.edit'); } if ($this->canState) { JToolBarHelper::publishList('help_documents.publish'); JToolBarHelper::unpublishList('help_documents.unpublish'); JToolBarHelper::archiveList('help_documents.archive'); if ($this->canDo->get('core.admin')) { JToolBarHelper::checkin('help_documents.checkin'); } } // Add a batch button if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) { // Get the toolbar object instance $bar = JToolBar::getInstance('toolbar'); // set the batch button name $title = JText::_('JTOOLBAR_BATCH'); // Instantiate a new JLayoutFile instance and render the batch button $layout = new JLayoutFile('joomla.toolbar.batch'); // add the button to the page $dhtml = $layout->render(array('title' => $title)); $bar->appendButton('Custom', $dhtml, 'batch'); } if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) { JToolbarHelper::deleteList('', 'help_documents.delete', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($this->canState && $this->canDelete) { JToolbarHelper::trash('help_documents.trash'); } if ($this->canDo->get('core.export') && $this->canDo->get('help_document.export')) { JToolBarHelper::custom('help_documents.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); } } if ($this->canDo->get('core.import') && $this->canDo->get('help_document.import')) { JToolBarHelper::custom('help_documents.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); } // set help url for this view if found $help_url = ComponentbuilderHelper::getHelpUrl('help_documents'); if (ComponentbuilderHelper::checkString($help_url)) { JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $help_url); } // add the options comp button if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { JToolBarHelper::preferences('com_componentbuilder'); } if ($this->canState) { JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true)); // only load if batch allowed if ($this->canBatch) { JHtmlBatch_::addListSelection(JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), 'batch[published]', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true)); } } JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_ACCESS'), 'filter_access', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { JHtmlBatch_::addListSelection(JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), 'batch[access]', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text')); } // Set Type Selection $this->typeOptions = $this->getTheTypeSelections(); if ($this->typeOptions) { // Type Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_TYPE_LABEL') . ' -', 'filter_type', JHtml::_('select.options', $this->typeOptions, 'value', 'text', $this->state->get('filter.type'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Type Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_TYPE_LABEL') . ' -', 'batch[type]', JHtml::_('select.options', $this->typeOptions, 'value', 'text')); } } // Set Location Selection $this->locationOptions = $this->getTheLocationSelections(); if ($this->locationOptions) { // Location Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_LOCATION_LABEL') . ' -', 'filter_location', JHtml::_('select.options', $this->locationOptions, 'value', 'text', $this->state->get('filter.location'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Location Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_LOCATION_LABEL') . ' -', 'batch[location]', JHtml::_('select.options', $this->locationOptions, 'value', 'text')); } } // Set Admin View Selection $this->admin_viewOptions = JFormHelper::loadFieldType('Adminviewfolderlist')->getOptions(); if ($this->admin_viewOptions) { // Admin View Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_ADMIN_VIEW_LABEL') . ' -', 'filter_admin_view', JHtml::_('select.options', $this->admin_viewOptions, 'value', 'text', $this->state->get('filter.admin_view'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Admin View Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_ADMIN_VIEW_LABEL') . ' -', 'batch[admin_view]', JHtml::_('select.options', $this->admin_viewOptions, 'value', 'text')); } } // Set Site View Selection $this->site_viewOptions = JFormHelper::loadFieldType('Siteviewfolderlist')->getOptions(); if ($this->site_viewOptions) { // Site View Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE_VIEW_LABEL') . ' -', 'filter_site_view', JHtml::_('select.options', $this->site_viewOptions, 'value', 'text', $this->state->get('filter.site_view'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Site View Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE_VIEW_LABEL') . ' -', 'batch[site_view]', JHtml::_('select.options', $this->site_viewOptions, 'value', 'text')); } } }
function blockElementStartHTML($isGroup = false) { $output = ''; $maxRepeatLength = isset($this->element['maxrepeatlength']) ? (int) $this->element['maxrepeatlength'] : 0; $buttons = ''; if ($maxRepeatLength !== 1) { $buttons .= '<a href="#" onclick="javascript:gjVariablefield.delete_current_slide(this); return(false);" class="variablefield_buttons delete_current_slide" >-</a>'; $buttons .= '<a href="#" onclick="javascript:gjVariablefield.add_new_slide(this, ' . $maxRepeatLength . '); return(false);" class="variablefield_buttons add_new_slide" >+</a>'; $buttons .= '<a href="#" onclick="javascript:gjVariablefield.move_up_slide(this); return(false);" class="variablefield_buttons move_up_slide" >⇑</a>'; $buttons .= '<a href="#" onclick="javascript:gjVariablefield.move_down_slide(this); return(false);" class="variablefield_buttons move_down_slide" >⇓</a>'; } if ($isGroup) { // Group name consist of specially prepared below Label and text Input with class .hide // Prepare Label $formfield = JFormHelper::loadFieldType('text'); $formfield->setup($this->element, ''); //Load current XML to get all XML attributes in $formfield $formfield->labelClass = 'groupSlider '; $formfield->labelclass = 'groupSlider '; // Need to set class like this in J3.2+ $formfield->class = 'groupSlider '; // Need to set class like this in J3.2+ if (!empty($this->group_header)) { //We get Label text either from stored plugin params, or from XML attributes $text = $this->group_header; } else { $text = $formfield->element['label'] ? (string) $formfield->element['label'] : (string) $formfield->element['name']; } $goupname = 'variablegroup__' . str_replace('{', '', $this->element['name']); //Is needed for toggler JS $output .= '<div class="variablefield_div repeating_group ' . $goupname . '" >' . '<div class="buttons_container">'; $text = JText::_($text); $formfield->element['label'] = ''; // Prepare buttons $editbutton = '<a href="#" onclick="javascript:gjVariablefield.editGroupName(this); return(false);" class="hasTip editGroupName editGroupNameButton" title="' . JText::_('JACTION_EDIT') . '::">✍</a>'; $editbutton .= '<a href="#" onclick="javascript:gjVariablefield.cancelGroupNameEdit(this); return(false);" class="hasTip cancelGroupNameEdit editGroupNameButton hide " title="' . JText::_('JCANCEL') . '::">✕</a>'; $output .= $formfield->getLabel() . $editbutton . '<span style="float:right;">' . $buttons . '</span>'; //$formfield->getLabel(); //$output .= $editbutton.$buttons; // Prepare input field for group name $formfield->element['size'] = ''; $formfield->element['class'] = 'groupnameEditField'; $formfield->class = 'groupnameEditField'; // Need to set class like this in J3.2+ //$formfield->value = htmlspecialchars($text, ENT_COMPAT, 'UTF-8'); //$formfield->value = addslashes($text); $formfield->value = $text; $formfield->name = 'jform[params][' . $this->fieldname . '][' . (string) $this->fieldname . '][]'; // Remake field name to use group name $formfield->element['readonly'] = 'true'; $formfield->readonly = 'true'; // Need to set class like this in J3.2+ $output .= '<span class="hdr-wrppr">' . $formfield->getInput() . '</span>' . PHP_EOL; $output .= '</div><!-- buttons_container -->'; //Field to store group status - opened or closed $formfield = JFormHelper::loadFieldType('hidden'); $formfield->setup($this->element, ''); $formfield->name = 'jform[params][' . $this->fieldname . '][' . (string) $this->fieldname . '][]'; // Remake field name to use group name $formfield->element['class'] = 'groupState'; $formfield->class = 'groupState'; // Need to set class like this in J3.2+ $formfield->element['disabled'] = null; $formfield->element['onchange'] = null; $formfield->value = $this->open; $output .= $formfield->getInput() . PHP_EOL; //Let show the script, that the group has ended $formfield = JFormHelper::loadFieldType('hidden'); $formfield->setup($this->element, ''); $formfield->name = 'jform[params][' . $this->fieldname . '][' . (string) $this->fieldname . '][]'; // Remake field name to use group name $formfield->value = 'variablefield::' . $this->fieldname; $output .= $formfield->getInput() . PHP_EOL; } else { $output .= '<div class="variablefield_div repeating_element" >' . '<div class="buttons_container">' . $buttons . '</div><!-- buttons_container -->'; } return $output; return $output . '<span class="cleaner"></span>'; }
/** * Setting the toolbar */ protected function addToolBar() { JToolBarHelper::title(JText::_('COM_COSTBENEFITPROJECTION_INTERVENTIONS'), 'wand'); JHtmlSidebar::setAction('index.php?option=com_costbenefitprojection&view=interventions'); JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { JToolBarHelper::addNew('intervention.add'); } // Only load if there are items if (CostbenefitprojectionHelper::checkArray($this->items)) { if ($this->canEdit) { JToolBarHelper::editList('intervention.edit'); } if ($this->canState) { JToolBarHelper::publishList('interventions.publish'); JToolBarHelper::unpublishList('interventions.unpublish'); JToolBarHelper::archiveList('interventions.archive'); if ($this->canDo->get('core.admin')) { JToolBarHelper::checkin('interventions.checkin'); } } // Add a batch button if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) { // Get the toolbar object instance $bar = JToolBar::getInstance('toolbar'); // set the batch button name $title = JText::_('JTOOLBAR_BATCH'); // Instantiate a new JLayoutFile instance and render the batch button $layout = new JLayoutFile('joomla.toolbar.batch'); // add the button to the page $dhtml = $layout->render(array('title' => $title)); $bar->appendButton('Custom', $dhtml, 'batch'); } if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) { JToolbarHelper::deleteList('', 'interventions.delete', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($this->canState && $this->canDelete) { JToolbarHelper::trash('interventions.trash'); } if ($this->canDo->get('core.export') && $this->canDo->get('intervention.export')) { JToolBarHelper::custom('interventions.exportData', 'download', '', 'COM_COSTBENEFITPROJECTION_EXPORT_DATA', true); } } if ($this->canDo->get('core.import') && $this->canDo->get('intervention.import')) { JToolBarHelper::custom('interventions.importData', 'upload', '', 'COM_COSTBENEFITPROJECTION_IMPORT_DATA', false); } // set help url for this view if found $help_url = CostbenefitprojectionHelper::getHelpUrl('interventions'); if (CostbenefitprojectionHelper::checkString($help_url)) { JToolbarHelper::help('COM_COSTBENEFITPROJECTION_HELP_MANAGER', false, $help_url); } // add the options comp button if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { JToolBarHelper::preferences('com_costbenefitprojection'); } if ($this->canState) { JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true)); // only load if batch allowed if ($this->canBatch) { JHtmlBatch_::addListSelection(JText::_('COM_COSTBENEFITPROJECTION_KEEP_ORIGINAL_STATE'), 'batch[published]', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true)); } } JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_ACCESS'), 'filter_access', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { JHtmlBatch_::addListSelection(JText::_('COM_COSTBENEFITPROJECTION_KEEP_ORIGINAL_ACCESS'), 'batch[access]', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text')); } // Set Company Name Selection $this->companyNameOptions = JFormHelper::loadFieldType('Company')->getOptions(); if ($this->companyNameOptions) { // Company Name Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COMPANY_LABEL') . ' -', 'filter_company', JHtml::_('select.options', $this->companyNameOptions, 'value', 'text', $this->state->get('filter.company'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Company Name Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COMPANY_LABEL') . ' -', 'batch[company]', JHtml::_('select.options', $this->companyNameOptions, 'value', 'text')); } } // Set Type Selection $this->typeOptions = $this->getTheTypeSelections(); if ($this->typeOptions) { // Type Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_TYPE_LABEL') . ' -', 'filter_type', JHtml::_('select.options', $this->typeOptions, 'value', 'text', $this->state->get('filter.type'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Type Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_TYPE_LABEL') . ' -', 'batch[type]', JHtml::_('select.options', $this->typeOptions, 'value', 'text')); } } // Set Coverage Selection $this->coverageOptions = $this->getTheCoverageSelections(); if ($this->coverageOptions) { // Coverage Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COVERAGE_LABEL') . ' -', 'filter_coverage', JHtml::_('select.options', $this->coverageOptions, 'value', 'text', $this->state->get('filter.coverage'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Coverage Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COVERAGE_LABEL') . ' -', 'batch[coverage]', JHtml::_('select.options', $this->coverageOptions, 'value', 'text')); } } // Set Duration Selection $this->durationOptions = $this->getTheDurationSelections(); if ($this->durationOptions) { // Duration Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_DURATION_LABEL') . ' -', 'filter_duration', JHtml::_('select.options', $this->durationOptions, 'value', 'text', $this->state->get('filter.duration'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Duration Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_DURATION_LABEL') . ' -', 'batch[duration]', JHtml::_('select.options', $this->durationOptions, 'value', 'text')); } } }
public function setForm() { if (ComponentbuilderHelper::checkArray($this->Components)) { jimport('joomla.form.form'); $radio1 = JFormHelper::loadFieldType('radio', true); // start building add to sales folder xml field $xml = '<field label="Add to Backup Folder & Sales Server <small>(if set)</small>" description="" name="backup" type="radio" class="btn-group btn-group-yesno" default="0">'; $xml .= '<option value="1">Yes</option> <option value="0">No</option>'; $xml .= "</field>"; // prepare the xml $sales = new SimpleXMLElement($xml); // set components to form $radio1->setup($sales, 0); $radio2 = JFormHelper::loadFieldType('radio', true); // start building add to git folder xml field $xml = '<field label="Add to Git Folder" description="" name="git" type="radio" class="btn-group btn-group-yesno" default="1">'; $xml .= '<option value="1">Yes</option> <option value="0">No</option>'; $xml .= "</field>"; // prepare the xml $git = new SimpleXMLElement($xml); // set components to form $radio2->setup($git, 1); $list = JFormHelper::loadFieldType('list', true); // start building componet xml field $xml = '<field label="Components" description="" name="component" type="list" class="btn-group" required="true">'; $xml .= '<option value="">- Select Component -</option>'; foreach ($this->Components as $componet) { $xml .= '<option value="' . $componet->id . '">' . $this->escape($componet->name) . '</option>'; } $xml .= "</field>"; // prepare the xml $componets = new SimpleXMLElement($xml); // set components to form $list->setup($componets, 0); return array($radio1, $radio2, $list); } return false; }
protected function getCustomField($type, $name) { if (MageBridgeHelper::isJoomla15()) { require_once JPATH_COMPONENT . '/elements/' . $type . '.php'; $fake = null; $class = 'JElement' . ucfirst($type); $object = new $class(); return $object->fetchElement($name, MagebridgeModelConfig::load($name), $fake, ''); } else { require_once JPATH_COMPONENT . '/fields/' . $type . '.php'; $class = 'JFormField' . ucfirst($type); $field = JFormHelper::loadFieldType($type); $field->setName($name); $field->setValue(MagebridgeModelConfig::load($name)); return $field->getHtmlInput(); } }
public static function renderBoolButton() { $args = func_get_args(); // get the radio element $button = JFormHelper::loadFieldType('radio'); // setup the properties $name = self::htmlEscape($args[0]); $additional = isset($args[1]) ? (string) $args[1] : ''; $value = $args[2]; $yes = isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES'; $no = isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO'; // prepare the xml $element = new SimpleXMLElement('<field name="' . $name . '" type="radio" class="btn-group"><option ' . $additional . ' value="0">' . $no . '</option><option ' . $additional . ' value="1">' . $yes . '</option></field>'); // run $button->setup($element, $value); return $button->input; }
protected function getInput() { $options = (array) $this->getOptions(); if (empty($options)) { $formfield = JFormHelper::loadFieldType('text'); $formfield->setup($this->element, ''); if (is_array($this->value)) { $formfield->value = implode(',', $this->value); } else { $formfield->value = $this->value; } $formfield->hint = JText::_((string) $this->hint); return $formfield->getInput() . PHP_EOL; } return parent::getInput(); }
/** * Proxy for {@link JFormHelper::loadFieldType()}. * * @param string $type The field type. * @param bool $new Flag to toggle whether we should get a new instance of the object. * * @return mixed JFormField object on success, false otherwise. * * @since 11.1 */ protected function loadFieldType($type, $new = true) { return JFormHelper::loadFieldType($type, $new); }
protected function renderHTML() { $args = func_get_args(); if (RSFormProHelper::isJ('3.0')) { if ($args[0] == 'select.booleanlist') { // 0 - type // 1 - name // 2 - additional // 3 - value // 4 - yes // 5 - no // get the radio element $radio = JFormHelper::loadFieldType('radio'); // setup the properties $name = $this->escape($args[1]); $additional = isset($args[2]) ? (string) $args[2] : ''; $value = $args[3]; $yes = isset($args[4]) ? $this->escape($args[4]) : 'JYES'; $no = isset($args[5]) ? $this->escape($args[5]) : 'JNO'; // prepare the xml $element = new SimpleXMLElement('<field name="' . $name . '" type="radio" class="btn-group"><option ' . $additional . ' value="0">' . $no . '</option><option ' . $additional . ' value="1">' . $yes . '</option></field>'); // run $radio->setup($element, $value); return $radio->input; } } else { if ($args[0] == 'select.booleanlist') { $name = $args[1]; $additional = isset($args[2]) ? (string) $args[2] : ''; $value = $args[3]; $yes = isset($args[4]) ? $this->escape($args[4]) : 'JYES'; $no = isset($args[5]) ? $this->escape($args[5]) : 'JNO'; return JHtml::_($args[0], $name, $additional, $value, $yes, $no); } } }
public function getInput() { $field = JFormHelper::loadFieldType('Textarea'); return $field->getInput(); }
<?php defined('_JEXEC') or die('Restricted access'); JHTML::_('behavior.tooltip'); JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); $deptField = JFormHelper::loadFieldType('userdeptlist', false); $depts = $deptField->getOptions(); ?> <form action="<?php echo JRoute::_('index.php?option=com_orgraph&view=users'); ?> " method="post" name="adminForm" id="adminForm"> <fieldset id="filter-bar"> <div class="filter-search fltlft"> <label class="filter-search-lbl" for="filter_search"><?php echo JText::_('JSEARCH_FILTER_LABEL'); ?> </label> <input type="text" name="filter_search" id="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?> " title="<?php echo JText::_('COM_ORGRAPH_USER_FILTER_NAME'); ?> " /> <button type="submit"><?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?> </button> <button type="button" onclick="document.id('filter_search').value='';this.form.submit();"><?php echo JText::_('JSEARCH_FILTER_CLEAR');
<?php /** * @package Joomla.Tutorials * @subpackage Component * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved. * @license License GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access to this file defined('_JEXEC') or die; JHtml::_('behavior.tooltip'); //Get companie options JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); $categorie = JFormHelper::loadFieldType('categorie', false); $categorieOptions = $categorie->getOptions(); $congressi = JFormHelper::loadFieldType('congressi', false); $congressiOptions = $congressi->getOptions(); ?> <div class="span12"> <form action="<?php echo JRoute::_('index.php?option=com_gglms'); ?> " method="post" name="adminForm" id="adminForm"> <div id="span10 j-toggle-main"> <div clas="js-stools clearfix"> <div class="clearfix"> <div class="js-stools-container-bar">
<?php /* * @package Joomla.Administrator * @subpackage com_users * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JHtml::_('behavior.formvalidation'); JHtml::_('formbehavior.chosen', 'select'); //Get tshirt-size options JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); $membersOptions = JFormHelper::loadFieldType('Members', false); $tshirtOptions = $membersOptions->getOptionsTshirtSize(); // works only if you set your field getOptions on public!! $sexOptions = $membersOptions->getOptionsSex(); // works only if you set your field getOptions on public!! function generateRandomString($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } ?> <script type="text/javascript">
defined('_JEXEC') or die; JHtml::_('behavior.multiselect'); JHtml::_('formbehavior.chosen', 'select'); $this->sortColumn = $this->escape($this->state->get('list.ordering')); $this->sortDirection = $this->escape($this->state->get('list.direction')); //Get tshirt-size options JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); $membersOptions = JFormHelper::loadFieldType('Members', false); $tshirtOptions = $membersOptions->getOptionsTshirtSize(); // works only if you set your field getOptions on public!! //Get camping options $campingOptions = $membersOptions->getOptionsCamping(); // works only if you set your field getOptions on public!! //Get services options JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); $services = JFormHelper::loadFieldType('Services', false); $servicesOptions = $services->getOptions(); // works only if you set your field getOptions on public!! ?> <script language="javascript" type="text/javascript"> function tableOrdering( order, dir, task ) { var form = document.adminForm; form.filter_order.value = order; form.filter_order_Dir.value = dir; document.adminForm.submit( task ); } </script> <div id="j-sidebar-container" class="span2"> <?php
<?php /*if(JFactory::getUser()->authorise('core.delete','com_citybranding.poi.'.$this->item->id)):?> <button class="btn btn-warning delete-button"><?php echo JText::_("COM_CITYBRANDING_DELETE_ITEM"); ?></button> <?php endif; */ ?> </div> <div class="col-lg-6 col-sm-12 col-xs-12 col-lg-push-6"> <div style="padding-bottom: 40px;"> <div class="citybranding-info-wrapper"><span class="glyphicon glyphicon-map-marker" aria-hidden="true"></span> <?php echo $this->item->address; ?> </div> <?php //map $gmap = JFormHelper::loadFieldType('GMap', false); $gmap->__set('mapOnly', true); if ($this->item->category_image != '') { $gmap->__set('icon', JURI::base() . $this->item->category_image); } echo $gmap->showField($this->item->latitude, $this->item->longitude, 18); ?> </div> </div> <div class="col-lg-6 col-sm-12 col-xs-12 col-lg-pull-6"> <div class="citybranding-info-wrapper"> <div class="citybranding-statuses"> <?php foreach ($statuses as $status) { ?>
* * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JHtml::_('behavior.multiselect'); JHtml::_('formbehavior.chosen', 'select'); JHtml::_('behavior.modal', 'a.modal'); $this->sortColumn = $this->escape($this->state->get('list.ordering')); $this->sortDirection = $this->escape($this->state->get('list.direction')); //Get services options JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); $services = JFormHelper::loadFieldType('Services', false); $servicesOptions = $services->getOptions(); // works only if you set your field getOptions on public!! $dates = JFormHelper::loadFieldType('Dates', false); $datesOptions = $dates->getOptions(); // works only if you set your field getOptions on public!! ?> <script language="javascript" type="text/javascript"> function tableOrdering( order, dir, task ) { var form = document.adminForm; form.filter_order.value = order; form.filter_order_Dir.value = dir; document.adminForm.submit( task ); } </script> <div id="j-sidebar-container" class="span2"> <?php echo $this->sidebar;
<?php /** * @package Windwalker.Framework * @subpackage Form.CCK * @author Simon Asika <*****@*****.**> * @copyright Copyright (C) 2013 Asikart. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; JForm::addFieldPath(AKPATH_FORM . '/fields'); JFormHelper::loadFieldType('List'); /** * Supports an HTML select list of Filter. * * @package Windwalker.Framework * @subpackage Form.CCK */ class JFormFieldFilterlist extends JFormFieldList { /** * The form field type. * * @var string */ public $type = 'Filterlist'; public $value; public $name; /** * Method to get the field input markup.
/** * Just an idea, still WIP * @param $type * @return mixed */ static function renderFormField($type) { //Get custom field JFormHelper::addFieldPath(VMPATH_ADMIN . DS . 'fields'); $types = JFormHelper::loadFieldType($type, false); return $types->getOptions(); }