/** * Fetch a calendar element * * @param string $name Element name * @param string $value Element value * @param object &$node XMLElement node object containing the settings for the element * @param string $control_name Control name * @return string */ public function fetchElement($name, $value, &$node, $control_name) { // path to images directory $path = PATH_ROOT . DS . (string) $node['directory']; $filter = (string) $node['filter']; $exclude = (string) $node['exclude']; $stripExt = (string) $node['stripext']; $files = App::get('filesystem')->files($path, $filter); $options = array(); if (!$node['hide_none']) { $options[] = Builder\Select::option('-1', App::get('language')->txt('JOPTION_DO_NOT_USE')); } if (!$node['hide_default']) { $options[] = Builder\Select::option('', App::get('language')->txt('JOPTION_USE_DEFAULT')); } if (is_array($files)) { foreach ($files as $file) { if ($exclude) { if (preg_match(chr(1) . $exclude . chr(1), $file)) { continue; } } if ($stripExt) { $file = App::get('filesystem')->extension($file); } $options[] = Builder\Select::option($file, $file); } } return Builder\Select::genericlist($options, $control_name . '[' . $name . ']', array('id' => 'param' . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value)); }
/** * Fetch a calendar element * * @param string $name Element name * @param string $value Element value * @param object &$node XMLElement node object containing the settings for the element * @param string $control_name Control name * @return string */ public function fetchElement($name, $value, &$node, $control_name) { $client = (string) $node['client']; $languages = App::get('language')->createLanguageList($value, constant('JPATH_' . strtoupper($client)), true); array_unshift($languages, Builder\Select::option('', App::get('language')->txt('JOPTION_SELECT_LANGUAGE'))); return Builder\Select::genericlist($languages, $control_name . '[' . $name . ']', array('id' => $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value)); }
/** * Method to get the field input markup for a generic list. * Use the multiple attribute to enable multiselect. * * @return string The field input markup. */ protected function getInput() { // Initialize variables. $html = array(); $attr = ''; // Initialize some field attributes. $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; // To avoid user's confusion, readonly="true" should imply disabled="true". if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') { $attr .= ' disabled="disabled"'; } $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; $attr .= $this->multiple ? ' multiple="multiple"' : ''; // Initialize JavaScript field attributes. $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; // Get the field options. $options = (array) $this->getOptions(); // Create a read-only list (no name) with a hidden input to store the value. if ((string) $this->element['readonly'] == 'true') { $html[] = Dropdown::genericlist($options, '', trim($attr), 'value', 'text', $this->value, $this->id); $html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />'; } else { $html[] = Dropdown::genericlist($options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id); if ($this->element['option_other']) { $found = false; foreach ($options as $option) { if ($option->value == $this->value) { $found = true; } } $html[] = '<input type="text" name="' . $this->getName($this->fieldname . '_other') . '" value="' . ($found ? '' : htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8')) . '" placeholder="' . App::get('language')->txt('Other...') . '" />'; } } return implode($html); }
/** * Fetch a calendar element * * @param string $name Element name * @param string $value Element value * @param object &$node XMLElement node object containing the settings for the element * @param string $control_name Control name * @return string */ public function fetchElement($name, $value, &$node, $control_name) { // compile list of the editors $query = 'SELECT `element` AS `value`, `name` AS `text` FROM `#__extensions` WHERE folder = "editors" AND type = "plugin" AND enabled = 1 ORDER BY ordering, name'; $db = \App::get('db'); $db->setQuery($query); $editors = $db->loadObjectList(); array_unshift($editors, Builder\Select::option('', \App::get('language')->txt('JOPTION_SELECT_EDITOR'))); return Builder\Select::genericlist($editors, $control_name . '[' . $name . ']', array('id' => $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value)); }
/** * Fetch a calendar element * * @param string $name Element name * @param string $value Element value * @param object &$node XMLElement node object containing the settings for the element * @param string $control_name Control name * @return string */ public function fetchElement($name, $value, &$node, $control_name) { require_once PATH_CORE . '/components/com_menus/admin/helpers/menus.php'; $menuTypes = \MenusHelper::getMenuTypes(); foreach ($menuTypes as $menutype) { $options[] = Builder\Select::option($menutype, $menutype); } array_unshift($options, Builder\Select::option(\App::get('language')->txt('JOPTION_SELECT_MENU'))); return Builder\Select::genericlist($options, $control_name . '[' . $name . ']', array('id' => $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value)); }
/** * Fetch a calendar element * * @param string $name Element name * @param string $value Element value * @param object &$node XMLElement node object containing the settings for the element * @param string $control_name Control name * @return string */ public function fetchElement($name, $value, &$node, $control_name) { $db = \App::get('db'); $query = 'SELECT * FROM `#__template_styles` ' . 'WHERE client_id = 0 ' . 'AND home = 0'; $db->setQuery($query); $data = $db->loadObjectList(); $default = Builder\Select::option(0, App::get('language')->txt('JOPTION_USE_DEFAULT'), 'id', 'description'); array_unshift($data, $default); $selected = $this->_getSelected(); $html = Builder\Select::genericlist($data, $control_name . '[' . $name . ']', 'class="inputbox" size="6"', 'id', 'description', $selected); return $html; }
/** * Fetch a calendar element * * @param string $name Element name * @param string $value Element value * @param object &$node XMLElement node object containing the settings for the element * @param string $control_name Control name * @return string */ public function fetchElement($name, $value, &$node, $control_name) { $db = \App::get('db'); $db->setQuery((string) $node['query']); $key = (string) $node['key_field']; $key = $key ?: 'value'; $val = (string) $node['value_field']; $val = $val ?: $name; $options = $db->loadObjectlist(); // Check for an error. if ($db->getErrorNum()) { throw new Exception($db->getErrorMsg(), 500); } if (!$options) { $options = array(); } return Builder\Select::genericlist($options, $control_name . '[' . $name . ']', array('id' => $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value, 'option.key' => $key, 'option.text' => $val)); }
/** * Fetch a calendar element * * @param string $name Element name * @param string $value Element value * @param object &$node XMLElement node object containing the settings for the element * @param string $control_name Control name * @return string */ public function fetchElement($name, $value, &$node, $control_name) { $ctrl = $control_name . '[' . $name . ']'; $attribs = ' '; if ($v = $node['size']) { $attribs .= 'size="' . (string) $v . '"'; } if ($v = $node['class']) { $attribs .= 'class="' . (string) $v . '"'; } else { $attribs .= 'class="inputbox"'; } if ($m = $node['multiple']) { $attribs .= 'multiple="multiple"'; $ctrl .= '[]'; } return Builder\Select::genericlist($this->_getOptions($node), $ctrl, array('id' => $control_name . $name, 'list.attr' => $attribs, 'list.select' => $value)); }
/** * Fetch a calendar element * * @param string $name Element name * @param string $value Element value * @param object &$node XMLElement node object containing the settings for the element * @param string $control_name Control name * @return string */ public function fetchElement($name, $value, &$node, $control_name) { // Initialise variables. $path = PATH_ROOT . DS . (string) $node['directory']; $filter = (string) $node['filter']; $exclude = (string) $node['exclude']; $folders = App::get('filesystem')->folders($path, $filter); $options = array(); foreach ($folders as $folder) { if ($exclude) { if (preg_match(chr(1) . $exclude . chr(1), $folder)) { continue; } } $options[] = Builder\Select::option($folder, $folder); } if (!$node['hide_none']) { array_unshift($options, Builder\Select::option('-1', App::get('language')->txt('JOPTION_DO_NOT_USE'))); } if (!$node['hide_default']) { array_unshift($options, Builder\Select::option('', App::get('language')->txt('JOPTION_USE_DEFAULT'))); } return Builder\Select::genericlist($options, $control_name . '[' . $name . ']', array('id' => 'param' . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value)); }
<li class="limit"> <label for="<?php echo $this->prefix; ?> limit"><?php echo Lang::txt('JGLOBAL_DISPLAY_NUM'); ?> </label> <?php // Build the select list. $selected = $this->viewall ? 0 : $this->limit; $attr = 'class="inputbox" size="1" onchange="this.form.submit()"'; if (App::isAdmin()) { $attr = 'class="inputbox" size="1" onchange="Joomla.submitform();"'; } echo \Hubzero\Html\Builder\Select::genericlist($limits, $this->pages->prefix . 'limit', $attr, 'value', 'text', $selected); ?> </li> <li class="pagination-start start"> <?php if ($this->pages->start->base !== null) { ?> <?php echo paginator_item_active($this->pages->start, $this->prefix); ?> <?php } else { ?> <span class="pagenav"><?php echo $this->pages->start->text; ?>
/** * Displays a Select list of the available asset groups * * @param string $name The name of the select element * @param mixed $selected The selected asset group id * @param string $attribs Optional attributes for the select field * @param array $config An array of options for the control * @return mixed An HTML string or null if an error occurs */ public static function assetgrouplist($name, $selected, $attribs = null, $config = array()) { static $count; $options = self::assetgroups(); if (isset($config['title'])) { array_unshift($options, Select::option('', $config['title'])); } return Select::genericlist($options, $name, array('id' => isset($config['id']) ? $config['id'] : 'assetgroups_' . ++$count, 'list.attr' => is_null($attribs) ? 'class="inputbox" size="3"' : $attribs, 'list.select' => (int) $selected)); }
/** * Fetch a calendar element * * @param string $name Element name * @param string $value Element value * @param object &$node XMLElement node object containing the settings for the element * @param string $control_name Control name * @return string */ public function fetchElement($name, $value, &$node, $control_name) { $helpsites = \JHelp::createSiteList(PATH_CORE . '/help/helpsites.xml', $value); array_unshift($helpsites, Builder\Select::option('', \App::get('language')->txt('local'))); return Builder\Select::genericlist($helpsites, $control_name . '[' . $name . ']', array('id' => $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value)); }
/** * Method to create a select list of states for filtering * By default the filter shows only published and unpublished items * * @param string $filter_state The initial filter state * @param string $published The Text string for published * @param string $unpublished The Text string for Unpublished * @param string $archived The Text string for Archived * @param string $trashed The Text string for Trashed * @return string */ public static function state($filter_state = '*', $published = 'Published', $unpublished = 'Unpublished', $archived = null, $trashed = null) { $state = array('' => '- ' . Lang::txt('JLIB_HTML_SELECT_STATE') . ' -', 'P' => Lang::txt($published), 'U' => Lang::txt($unpublished)); if ($archived) { $state['A'] = Lang::txt($archived); } if ($trashed) { $state['T'] = Lang::txt($trashed); } return Select::genericlist($state, 'filter_state', array('list.attr' => 'class="inputbox" size="1" onchange="Joomla.submitform();"', 'list.select' => $filter_state, 'option.key' => null)); }
/** * Method to get the field input markup. * * @return string The field input markup. */ protected function getInput() { // Initialize variables. $html = array(); // Initialize some field attributes. $class = $this->element['class'] ? ' class="radio addresses-' . $this->id . ' ' . (string) $this->element['class'] . '"' : ' class="radio addresses-' . $this->id . '"'; // Start the radio field output. $html[] = '<fieldset id="' . $this->id . '"' . $class . '>'; // Get the field options. $options = $this->getOptions(); $found = false; $values = $this->value; $values = is_array($values) ? $values : array($values); $lang = App::get('language'); // Build the radio field output. foreach ($values as $i => $value) { if (is_string($value)) { $value = json_decode((string) $value, true); } if (!$value || json_last_error() !== JSON_ERROR_NONE) { $value = array(); $value['address1'] = ''; $value['address2'] = ''; $value['postal'] = ''; $value['city'] = ''; $value['region'] = ''; $value['country'] = ''; $value['latitude'] = ''; $value['longitude'] = ''; } $html[] = '<div class="address-field-wrap">'; $html[] = '<ul class="address-field">'; $html[] = '<li>'; $html[] = '<label for="' . $this->id . $i . '">' . $lang->txt('Street') . '</label>'; $html[] = '<input type="text" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][address1]" placeholder="Street" value="' . htmlspecialchars($value['address1'], ENT_COMPAT, 'UTF-8') . '" />'; $html[] = '</li>'; $html[] = '<li>'; $html[] = '<label for="' . $this->id . $i . '">' . $lang->txt('Street 2') . '</label>'; $html[] = '<input type="text" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][address2]" placeholder="Street 2" value="' . htmlspecialchars($value['address2'], ENT_COMPAT, 'UTF-8') . '" />'; $html[] = '</li>'; $html[] = '<li>'; $html[] = '<label for="' . $this->id . $i . '">' . $lang->txt('City') . '</label>'; $html[] = '<input type="text" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][city]" placeholder="City" value="' . htmlspecialchars($value['city'], ENT_COMPAT, 'UTF-8') . '" />'; $html[] = '</li>'; $html[] = '<li>'; $html[] = '<div class="grid">'; $html[] = '<div class="col span6">'; $html[] = '<label for="' . $this->id . $i . '">' . $lang->txt('Postal code') . '</label>'; $html[] = '<input type="text" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][postal]" placeholder="Postal code" value="' . htmlspecialchars($value['postal'], ENT_COMPAT, 'UTF-8') . '" />'; $html[] = '</div>'; $html[] = '<div class="col span6 omega">'; $html[] = '<label for="' . $this->id . $i . '">' . $lang->txt('State/Region') . '</label>'; $html[] = '<input type="text" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][region]" placeholder="State/Region" value="' . htmlspecialchars($value['region'], ENT_COMPAT, 'UTF-8') . '" />'; $html[] = '</div>'; $html[] = '</div>'; $html[] = '</li>'; $html[] = '<li>'; $html[] = '<label for="' . $this->id . $i . '">' . $lang->txt('Country') . '</label>'; $html[] = Dropdown::genericlist($options, $this->name . '[' . $i . '][country]', '', 'value', 'text', $value['country'], $this->id . $i); $html[] = '<input type="hidden" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][latitude]" value="' . htmlspecialchars($value['latitude'], ENT_COMPAT, 'UTF-8') . '" />'; $html[] = '<input type="hidden" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][longitude]" value="' . htmlspecialchars($value['longitude'], ENT_COMPAT, 'UTF-8') . '" />'; $html[] = '</li>'; $html[] = '</ul>'; $html[] = '</div>'; } // End the radio field output. $html[] = '</fieldset>'; Behavior::framework(true); App::get('document')->addScriptDeclaration("\n\t\t\tfunction manageProfileAddresses() {\n\t\t\t\tif (\$('.addresses-" . $this->id . "').length > 0) {\n\t\t\t\t\tvar fieldset = \$('.addresses-" . $this->id . "');\n\t\t\t\t\tvar btn = \$('<p class=\"address-add\"><a class=\"icon-add\" href=\"#\">Add another address</a></p>').on('click', function(e){\n\t\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t\tvar grp = fieldset\n\t\t\t\t\t\t\t.find('.address-field-wrap')\n\t\t\t\t\t\t\t.last()\n\t\t\t\t\t\t\t.clone();\n\t\t\t\t\t\tgrp.find('input').each(function(){\n\t\t\t\t\t\t\tthis.name = this.name.replace(/\\[(\\d+)\\]/,function(str,p1){return '[' + (parseInt(p1,10)+1) + ']';});\n\t\t\t\t\t\t\tthis.value = '';\n\t\t\t\t\t\t});\n\t\t\t\t\t\tgrp.find('select').each(function(){\n\t\t\t\t\t\t\tthis.name = this.name.replace(/\\[(\\d+)\\]/,function(str,p1){return '[' + (parseInt(p1,10)+1) + ']';});\n\t\t\t\t\t\t\tthis.selectedIndex = 0;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!grp.find('.address-remove').length) {\n\t\t\t\t\t\t\tvar rmv = \$('<a class=\"address-remove icon-remove\" href=\"#\">Remove</a>');\n\t\t\t\t\t\t\tgrp.append(rmv);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgrp.appendTo(fieldset);\n\n\t\t\t\t\t\tfieldset.find('.address-remove').off('click').on('click', function(e){\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\$(this).parent().remove();\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t\tfieldset.after(btn);\n\t\t\t\t\tfieldset.find('.address-field-wrap').each(function(i, grp){\n\t\t\t\t\t\tif (i === 0) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgrp = \$(grp);\n\t\t\t\t\t\tif (!grp.find('.address-remove').length) {\n\t\t\t\t\t\t\tvar rmv = \$('<a class=\"address-remove icon-remove\" href=\"#\">Remove</a>').on('click', function(e){\n\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\$(this).parent().remove();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tgrp.append(rmv);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\t\t"); App::get('document')->addScriptDeclaration("jQuery(document).ready(function(\$){\nmanageProfileAddresses();\n});"); App::get('document')->addScriptDeclaration("jQuery(document).on('ajaxLoad', function(\$){\nmanageProfileAddresses();\n});"); return implode($html); }
/** * Fetch a calendar element * * @param string $name Element name * @param string $value Element value * @param object &$node XMLElement node object containing the settings for the element * @param string $control_name Control name * @return string */ public function fetchElement($name, $value, &$node, $control_name) { $db = \App::get('db'); $menuType = $this->_parent->get('menu_type'); if (!empty($menuType)) { $where = ' WHERE menutype = ' . $db->quote($menuType); } else { $where = ' WHERE 1'; } // Load the list of menu types // TODO: move query to model $query = 'SELECT menutype, title' . ' FROM #__menu_types' . ' ORDER BY title'; $db->setQuery($query); $menuTypes = $db->loadObjectList(); if ($state = $node->attributes('state')) { $where .= ' AND published = ' . (int) $state; } // load the list of menu items // TODO: move query to model $query = 'SELECT id, parent_id, title, menutype, type' . ' FROM #__menu' . $where . ' ORDER BY menutype, parent_id, ordering'; $db->setQuery($query); $menuItems = $db->loadObjectList(); // Establish the hierarchy of the menu // TODO: use node model $children = array(); if ($menuItems) { // First pass - collect children foreach ($menuItems as $v) { $pt = $v->parent_id; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; } } // Second pass - get an indent list of the items $list = Builder\Menu::treerecurse(0, '', array(), $children, 9999, 0, 0); // Assemble into menutype groups $n = count($list); $groupedList = array(); foreach ($list as $k => $v) { $groupedList[$v->menutype][] =& $list[$k]; } // Assemble menu items to the array $options = array(); $options[] = Builder\Select::option('', App::get('language')->txt('JOPTION_SELECT_MENU_ITEM')); foreach ($menuTypes as $type) { if ($menuType == '') { $options[] = Builder\Select::option('0', ' ', 'value', 'text', true); $options[] = Builder\Select::option($type->menutype, $type->title . ' - ' . App::get('language')->txt('JGLOBAL_TOP'), 'value', 'text', true); } if (isset($groupedList[$type->menutype])) { $n = count($groupedList[$type->menutype]); for ($i = 0; $i < $n; $i++) { $item =& $groupedList[$type->menutype][$i]; // If menutype is changed but item is not saved yet, use the new type in the list if (App::get('request')->getString('option', '', 'get') == 'com_menus') { $currentItemArray = App::get('request')->getVar('cid', array(0), '', 'array'); $currentItemId = (int) $currentItemArray[0]; $currentItemType = App::get('request')->getString('type', $item->type, 'get'); if ($currentItemId == $item->id && $currentItemType != $item->type) { $item->type = $currentItemType; } } $disable = strpos($node->attributes('disable'), $item->type) !== false ? true : false; $options[] = Builder\Select::option($item->id, '   ' . $item->treename, 'value', 'text', $disable); } } } return Builder\Select::genericlist($options, $control_name . '[' . $name . ']', array('id' => $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value)); }