Esempio n. 1
0
 /**
  * Method to get the field option groups.
  *
  * @return  array  The field option objects as a nested array in groups.
  */
 protected function getGroups()
 {
     // Initialize variables.
     $groups = array();
     // Initialize some field attributes.
     $menuType = (string) $this->element['menu_type'];
     $published = $this->element['published'] ? explode(',', (string) $this->element['published']) : array();
     $disable = $this->element['disable'] ? explode(',', (string) $this->element['disable']) : array();
     $language = $this->element['language'] ? explode(',', (string) $this->element['language']) : array();
     // Get the menu items.
     $items = \MenusHelper::getMenuLinks($menuType, 0, 0, $published, $language);
     // Build group for a specific menu type.
     if ($menuType) {
         // Initialize the group.
         $groups[$menuType] = array();
         // Build the options array.
         foreach ($items as $link) {
             $groups[$menuType][] = Dropdown::option($link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
         }
     } else {
         // Build the groups arrays.
         foreach ($items as $menu) {
             // Initialize the group.
             $groups[$menu->menutype] = array();
             // Build the options array.
             foreach ($menu->links as $link) {
                 $groups[$menu->menutype][] = Dropdown::option($link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
             }
         }
     }
     // Merge any additional groups in the XML definition.
     $groups = array_merge(parent::getGroups(), $groups);
     return $groups;
 }
Esempio n. 2
0
 /**
  * Method to get the custom field options.
  * Use the query attribute to supply a query to generate the list.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Initialize some field attributes.
     $key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value';
     $value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name'];
     $translate = $this->element['translate'] ? (string) $this->element['translate'] : false;
     $query = (string) $this->element['query'];
     // Get the database object.
     $db = App::get('db');
     // Set the query and get the result list.
     $db->setQuery($query);
     $items = $db->loadObjectlist();
     // Check for an error.
     if ($db->getErrorNum()) {
         return $options;
     }
     // Build the field options.
     if (!empty($items)) {
         foreach ($items as $item) {
             if ($translate == true) {
                 $options[] = Dropdown::option($item->{$key}, App::get('language')->txt($item->{$value}));
             } else {
                 $options[] = Dropdown::option($item->{$key}, $item->{$value});
             }
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Esempio n. 3
0
 /**
  * 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));
 }
Esempio n. 4
0
 /**
  * Method to get the user group field input markup.
  *
  * @return  string  The field input markup.
  */
 protected function getInput()
 {
     // Initialize variables.
     $options = array();
     $attr = '';
     // Initialize some field attributes.
     $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     $attr .= (string) $this->element['disabled'] == 'true' ? ' 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'] . '"' : '';
     // Iterate through the children and build an array of options.
     foreach ($this->element->children() as $option) {
         // Only add <option /> elements.
         if ($option->getName() != 'option') {
             continue;
         }
         // Create a new option object based on the <option /> element.
         $tmp = Dropdown::option((string) $option['value'], trim((string) $option), 'value', 'text', (string) $option['disabled'] == 'true');
         // Set some option attributes.
         $tmp->class = (string) $option['class'];
         // Set some JavaScript option attributes.
         $tmp->onclick = (string) $option['onclick'];
         // Add the option object to the result set.
         $options[] = $tmp;
     }
     return Access::usergroup($this->name, $this->value, $attr, $options, $this->id);
 }
Esempio n. 5
0
 /**
  * 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));
 }
Esempio n. 6
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Initialize some field attributes.
     $first = (int) $this->element['first'];
     $last = (int) $this->element['last'];
     $step = (int) $this->element['step'];
     // Sanity checks.
     if ($step == 0) {
         // Step of 0 will create an endless loop.
         return $options;
     } elseif ($first < $last && $step < 0) {
         // A negative step will never reach the last number.
         return $options;
     } elseif ($first > $last && $step > 0) {
         // A position step will never reach the last number.
         return $options;
     }
     // Build the options array.
     for ($i = $first; $i <= $last; $i += $step) {
         $options[] = Dropdown::option($i);
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Esempio n. 7
0
 /**
  * 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));
 }
Esempio n. 8
0
 /**
  * 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)
 {
     $options = array();
     foreach ($node->children() as $option) {
         $val = (string) $option['value'];
         $text = (string) $option;
         $options[] = Builder\Select::option($val, $text);
     }
     return Builder\Select::radiolist($options, '' . $control_name . '[' . $name . ']', 'class="option"', 'value', 'text', $value, $control_name . $name, true) . '</fieldset>';
 }
Esempio n. 9
0
 /**
  * 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));
 }
Esempio n. 10
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Convert to name => name array.
     foreach (Manager::getStores() as $store) {
         $options[] = Dropdown::option($store, App::get('language')->txt('JLIB_FORM_VALUE_CACHE_' . $store), 'value', 'text');
     }
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Esempio n. 11
0
 /**
  * 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;
 }
Esempio n. 12
0
 /**
  * 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));
 }
Esempio n. 13
0
 /**
  * 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));
 }
Esempio n. 14
0
 /**
  * Method to get the time zone field option groups.
  *
  * @return  array  The field option objects as a nested array in groups.
  */
 protected function getGroups()
 {
     // Initialize variables.
     $groups = array();
     $keyField = $this->element['key_field'] ? (string) $this->element['key_field'] : 'id';
     $keyValue = $this->form->getValue($keyField);
     // If the timezone is not set use the server setting.
     if (strlen($this->value) == 0 && empty($keyValue)) {
         $this->value = \App::get('config')->get('offset');
     }
     // Get the list of time zones from the server.
     $zones = \DateTimeZone::listIdentifiers();
     // Build the group lists.
     foreach ($zones as $zone) {
         // Time zones not in a group we will ignore.
         if (strpos($zone, '/') === false) {
             continue;
         }
         // Get the group/locale from the timezone.
         list($group, $locale) = explode('/', $zone, 2);
         // Only use known groups.
         if (in_array($group, self::$zones)) {
             // Initialize the group if necessary.
             if (!isset($groups[$group])) {
                 $groups[$group] = array();
             }
             // Only add options where a locale exists.
             if (!empty($locale)) {
                 $groups[$group][$zone] = Dropdown::option($zone, str_replace('_', ' ', $locale), 'value', 'text', false);
             }
         }
     }
     // Sort the group lists.
     ksort($groups);
     foreach ($groups as $zone => &$location) {
         sort($location);
     }
     // Merge any additional groups in the XML definition.
     $groups = array_merge(parent::getGroups(), $groups);
     return $groups;
 }
Esempio n. 15
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Initialize some field attributes.
     $filter = (string) $this->element['filter'];
     $exclude = (string) $this->element['exclude'];
     $hideNone = (string) $this->element['hide_none'];
     $hideDefault = (string) $this->element['hide_default'];
     // Get the path in which to search for file options.
     $path = (string) $this->element['directory'];
     if (!is_dir($path)) {
         $path = PATH_ROOT . '/' . $path;
     }
     // Prepend some default options based on field attributes.
     if (!$hideNone) {
         $options[] = Dropdown::option('-1', App::get('language')->alt('JOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)));
     }
     if (!$hideDefault) {
         $options[] = Dropdown::option('', App::get('language')->alt('JOPTION_USE_DEFAULT', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)));
     }
     // Get a list of folders in the search path with the given filter.
     $folders = App::get('filesystem')->directories($path, $filter);
     // Build the options list from the list of folders.
     if (is_array($folders)) {
         foreach ($folders as $folder) {
             // Check to see if the file is in the exclude mask.
             if ($exclude) {
                 if (preg_match(chr(1) . $exclude . chr(1), $folder)) {
                     continue;
                 }
             }
             $options[] = Dropdown::option($folder, $folder);
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Esempio n. 16
0
 /**
  * Get the options for the list.
  *
  * @param   object  &$node  XMLElement node object containing the settings for the element
  * @return  array
  */
 protected function _getOptions(&$node)
 {
     $options = array();
     $path1 = null;
     $path2 = null;
     // Load template entries for each menuid
     $db = \App::get('db');
     $query = 'SELECT template' . ' FROM #__template_styles' . ' WHERE client_id = 0 AND home = 1';
     $db->setQuery($query);
     $template = $db->loadResult();
     $view = (string) $node['view'];
     $extn = (string) $node['extension'];
     if ($view && $extn) {
         $view = preg_replace('#\\W#', '', $view);
         $extn = preg_replace('#\\W#', '', $extn);
         $path1 = PATH_CORE . '/components/' . $extn . '/site/views/' . $view . '/tmpl';
         $path2 = PATH_ROOT . '/templates/' . $template . '/html/' . $extn . '/' . $view;
         $options[] = Builder\Select::option('', App::get('language')->txt('JOPTION_USE_MENU_REQUEST_SETTING'));
     }
     if ($path1 && $path2) {
         $path1 = Util::normalizePath($path1);
         $path2 = Util::normalizePath($path2);
         $files = App::get('filesystem')->files($path1, '^[^_]*\\.php$');
         foreach ($files as $file) {
             $options[] = Builder\Select::option(App::get('filesystem')->extension($file));
         }
         if (is_dir($path2) && ($files = App::get('filesystem')->files($path2, '^[^_]*\\.php$'))) {
             $options[] = Builder\Select::optgroup(App::get('language')->txt('JOPTION_FROM_DEFAULT_TEMPLATE'));
             foreach ($files as $file) {
                 $options[] = Builder\Select::option(App::get('filesystem')->extension($file));
             }
             $options[] = Builder\Select::optgroup(App::get('language')->txt('JOPTION_FROM_DEFAULT_TEMPLATE'));
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::_getOptions($node), $options);
     return $options;
 }
Esempio n. 17
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     if (!self::$countries) {
         self::$countries = array();
         $countries = Geocode::countries();
         if ($countries && !empty($countries)) {
             self::$countries = $countries;
         }
     }
     if ($this->element['option_blank']) {
         $options[] = Dropdown::option('', App::get('language')->txt('- Select -'), 'value', 'text');
     }
     foreach (self::$countries as $option) {
         // Create a new option object based on the <option /> element.
         $tmp = Dropdown::option((string) $option->code, App::get('language')->alt(trim((string) $option->name), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text');
         // Add the option object to the result set.
         $options[] = $tmp;
     }
     reset($options);
     return $options;
 }
Esempio n. 18
0
 /**
  * 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));
 }
Esempio n. 19
0
 /**
  * Returns an array of categories for the given extension.
  *
  * @param   string  $extension  The extension option.
  * @param   array   $config     An array of configuration options. By default, only published and unpublished categories are returned.
  * @return  array   Categories for the extension
  */
 public static function categories($extension, $config = array('filter.published' => array(0, 1)))
 {
     $hash = md5($extension . '.' . serialize($config));
     if (!isset(self::$items[$hash])) {
         $config = (array) $config;
         $db = \App::get('db');
         $query = $db->getQuery(true);
         $query->select('a.id, a.title, a.level, a.parent_id');
         $query->from('#__categories AS a');
         $query->where('a.parent_id > 0');
         // Filter on extension.
         $query->where('extension = ' . $db->quote($extension));
         // Filter on the published state
         if (isset($config['filter.published'])) {
             if (is_numeric($config['filter.published'])) {
                 $query->where('a.published = ' . (int) $config['filter.published']);
             } elseif (is_array($config['filter.published'])) {
                 Arr::toInteger($config['filter.published']);
                 $query->where('a.published IN (' . implode(',', $config['filter.published']) . ')');
             }
         }
         $query->order('a.lft');
         $db->setQuery($query);
         $items = $db->loadObjectList();
         // Assemble the list options.
         self::$items[$hash] = array();
         foreach ($items as &$item) {
             $repeat = $item->level - 1 >= 0 ? $item->level - 1 : 0;
             $item->title = str_repeat('- ', $repeat) . $item->title;
             self::$items[$hash][] = Select::option($item->id, $item->title);
         }
         // Special "Add to root" option:
         self::$items[$hash][] = Select::option('1', Lang::txt('JLIB_HTML_ADD_TO_ROOT'));
     }
     return self::$items[$hash];
 }
Esempio n. 20
0
 /**
  * Method to get the field input for module layouts.
  *
  * @return  string  The field input.
  */
 protected function getInput()
 {
     // Get the client id.
     $clientId = $this->element['client_id'];
     if (is_null($clientId) && $this->form instanceof Form) {
         $clientId = $this->form->getValue('client_id');
     }
     $clientId = (int) $clientId;
     $client = ClientManager::client($clientId);
     // Get the module.
     $module = (string) $this->element['module'];
     if (empty($module) && $this->form instanceof Form) {
         $module = $this->form->getValue('module');
     }
     $module = preg_replace('#\\W#', '', $module);
     // Get the template.
     $template = (string) $this->element['template'];
     $template = preg_replace('#\\W#', '', $template);
     // Get the style.
     if ($this->form instanceof Form) {
         $template_style_id = $this->form->getValue('template_style_id');
     }
     $template_style_id = preg_replace('#\\W#', '', $template_style_id);
     // If an extension and view are present build the options.
     if ($module && $client) {
         // Load language file
         $lang = App::get('language');
         $lang->load($module . '.sys', $client->path, null, false, true) || $lang->load($module . '.sys', $client->path . '/modules/' . $module, null, false, true);
         // Get the database object and a new query object.
         $db = App::get('db');
         $query = $db->getQuery(true);
         // Build the query.
         $query->select('element, name');
         $query->from('#__extensions as e');
         $query->where('e.client_id = ' . (int) $clientId);
         $query->where('e.type = ' . $db->quote('template'));
         $query->where('e.enabled = 1');
         if ($template) {
             $query->where('e.element = ' . $db->quote($template));
         }
         if ($template_style_id) {
             $query->join('LEFT', '#__template_styles as s on s.template=e.element');
             $query->where('s.id=' . (int) $template_style_id);
         }
         // Set the query and load the templates.
         $db->setQuery($query);
         $templates = $db->loadObjectList('element');
         // Check for a database error.
         if ($db->getErrorNum()) {
             App::abort(500, $db->getErrorMsg());
         }
         // Build the search paths for module layouts.
         $module_path = Util::normalizePath($client->path . '/modules/' . $module . '/tmpl');
         // Prepare array of component layouts
         $module_layouts = array();
         // Prepare the grouped list
         $groups = array();
         // Add the layout options from the module path.
         if (is_dir($module_path) && ($module_layouts = App::get('filesystem')->files($module_path, '^[^_]*\\.php$'))) {
             // Create the group for the module
             $groups['_'] = array();
             $groups['_']['id'] = $this->id . '__';
             $groups['_']['text'] = $lang->txt('JOPTION_FROM_MODULE');
             $groups['_']['items'] = array();
             foreach ($module_layouts as $file) {
                 // Add an option to the module group
                 $value = App::get('filesystem')->name($file);
                 $text = $lang->hasKey($key = strtoupper($module . '_LAYOUT_' . $value)) ? JText::_($key) : $value;
                 $groups['_']['items'][] = Dropdown::option('_:' . $value, $text);
             }
         }
         // Loop on all templates
         if ($templates) {
             foreach ($templates as $template) {
                 // Load language file
                 $lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, true) || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, true);
                 $template_path = Util::normalizePath($client->path . '/templates/' . $template->element . '/html/' . $module);
                 // Add the layout options from the template path.
                 if (is_dir($template_path) && ($files = App::get('filesystem')->files($template_path, '^[^_]*\\.php$'))) {
                     foreach ($files as $i => $file) {
                         // Remove layout that already exist in component ones
                         if (in_array($file, $module_layouts)) {
                             unset($files[$i]);
                         }
                     }
                     if (count($files)) {
                         // Create the group for the template
                         $groups[$template->element] = array();
                         $groups[$template->element]['id'] = $this->id . '_' . $template->element;
                         $groups[$template->element]['text'] = $lang->txt('JOPTION_FROM_TEMPLATE', $template->name);
                         $groups[$template->element]['items'] = array();
                         foreach ($files as $file) {
                             // Add an option to the template group
                             $value = App::get('filesystem')->name($file);
                             $text = $lang->hasKey($key = strtoupper('TPL_' . $template->element . '_' . $module . '_LAYOUT_' . $value)) ? $lang->txt($key) : $value;
                             $groups[$template->element]['items'][] = Dropdown::option($template->element . ':' . $value, $text);
                         }
                     }
                 }
             }
         }
         // Compute attributes for the grouped list
         $attr = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
         // Prepare HTML code
         $html = array();
         // Compute the current selected values
         $selected = array($this->value);
         // Add a grouped list
         $html[] = Dropdown::groupedlist($groups, $this->name, array('id' => $this->id, 'group.id' => 'id', 'list.attr' => $attr, 'list.select' => $selected));
         return implode($html);
     }
     return '';
 }
Esempio n. 21
0
 /**
  * Get the options for the list.
  *
  * @param   object  &$node  XMLElement node object containing the settings for the element
  * @return  string
  */
 protected function _getOptions(&$node)
 {
     $v = (int) $node['client_id'];
     $clientId = $v ? $v : 0;
     $options = array();
     $path1 = null;
     $path2 = null;
     // Load template entries for each menuid
     $db = \App::get('db');
     $query = $db->getQuery(true);
     $query->select('template');
     $query->from('#__template_styles');
     $query->where('client_id = ' . (int) $clientId);
     $query->where('home = 1');
     $db->setQuery($query);
     $template = $db->loadResult();
     if ($module = (string) $node['module']) {
         $base = $clientId == 1 ? JPATH_ADMINISTRATOR : JPATH_SITE;
         $module = preg_replace('#\\W#', '', $module);
         $path1 = $base . '/modules/' . $module . '/tmpl';
         $path2 = $base . '/templates/' . $template . '/html/' . $module;
         $options[] = Builder\Select::option('', '');
     }
     if ($path1 && $path2) {
         $path1 = Util::normalizePath($path1);
         $path2 = Util::normalizePath($path2);
         $files = App::get('filesystem')->files($path1, '^[^_]*\\.php$');
         foreach ($files as $file) {
             $options[] = Builder\Select::option(App::get('filesystem')->extension($file));
         }
         if (is_dir($path2) && ($files = App::get('filesystem')->files($path2, '^[^_]*\\.php$'))) {
             $options[] = Builder\Select::optgroup(App::get('language')->txt('JOPTION_FROM_DEFAULT'));
             foreach ($files as $file) {
                 $options[] = Builder\Select::option(App::get('filesystem')->extension($file));
             }
             $options[] = Builder\Select::optgroup(App::get('language')->txt('JOPTION_FROM_DEFAULT'));
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::_getOptions($node), $options);
     return $options;
 }
Esempio n. 22
0
 /**
  * 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));
 }
Esempio n. 23
0
 /**
  * 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));
 }
Esempio n. 24
0
 /**
  * Method to get the field input markup fora grouped list.
  * Multiselect is enabled by using the multiple attribute.
  *
  * @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'] . '"' : '';
     $attr .= (string) $this->element['disabled'] == 'true' ? ' 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 groups.
     $groups = (array) $this->getGroups();
     // Create a read-only list (no name) with a hidden input to store the value.
     if ((string) $this->element['readonly'] == 'true') {
         $html[] = Dropdown::groupedlist($groups, null, array('list.attr' => $attr, 'id' => $this->id, 'list.select' => $this->value, 'group.items' => null, 'option.key.toHtml' => false, 'option.text.toHtml' => false));
         $html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"/>';
     } else {
         $html[] = Dropdown::groupedlist($groups, $this->name, array('list.attr' => $attr, 'id' => $this->id, 'list.select' => $this->value, 'group.items' => null, 'option.key.toHtml' => false, 'option.text.toHtml' => false));
     }
     return implode($html);
 }
Esempio n. 25
0
 /**
  * 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));
 }
Esempio n. 26
0
 /**
  * Method to get the field input for a component layout field.
  *
  * @return  string  The field input.
  */
 protected function getInput()
 {
     // Initialize variables.
     // Get the client id.
     $clientId = $this->element['client_id'];
     if (is_null($clientId) && $this->form instanceof Form) {
         $clientId = $this->form->getValue('client_id');
     }
     $clientId = (int) $clientId;
     $client = ClientManager::client($clientId);
     // Get the extension.
     $extn = (string) $this->element['extension'];
     if (empty($extn) && $this->form instanceof Form) {
         $extn = $this->form->getValue('extension');
     }
     $extn = preg_replace('#\\W#', '', $extn);
     // Get the template.
     $template = (string) $this->element['template'];
     $template = preg_replace('#\\W#', '', $template);
     // Get the style.
     if ($this->form instanceof Form) {
         $template_style_id = $this->form->getValue('template_style_id');
     }
     $template_style_id = preg_replace('#\\W#', '', $template_style_id);
     // Get the view.
     $view = (string) $this->element['view'];
     $view = preg_replace('#\\W#', '', $view);
     // If a template, extension and view are present build the options.
     if ($extn && $view && $client) {
         // Load language file
         $lang = App::get('language');
         $lang->load($extn . '.sys', App::get('component')->path($extn) . '/admin', null, false, true);
         // Get the database object and a new query object.
         $db = App::get('db');
         $query = $db->getQuery(true);
         // Build the query.
         $query->select('e.element, e.name');
         $query->from('#__extensions as e');
         $query->where('e.client_id = ' . (int) $clientId);
         $query->where('e.type = ' . $db->quote('template'));
         $query->where('e.enabled = 1');
         if ($template) {
             $query->where('e.element = ' . $db->quote($template));
         }
         if ($template_style_id) {
             $query->join('LEFT', '#__template_styles as s on s.template=e.element');
             $query->where('s.id=' . (int) $template_style_id);
         }
         // Set the query and load the templates.
         $db->setQuery($query);
         $templates = $db->loadObjectList('element');
         // Check for a database error.
         if ($db->getErrorNum()) {
             throw new Exception(500, $db->getErrorMsg());
         }
         $filesystem = App::get('filesystem');
         // Build the search paths for component layouts.
         $component_path = Util::normalizePath($client->path . '/components/' . $extn . '/views/' . $view . '/tmpl');
         // Prepare array of component layouts
         $component_layouts = array();
         // Prepare the grouped list
         $groups = array();
         // Add a Use Global option if useglobal="true" in XML file
         if ($this->element['useglobal'] == 'true') {
             $groups[$lang->txt('JOPTION_FROM_STANDARD')]['items'][] = Dropdown::option('', $lang->txt('JGLOBAL_USE_GLOBAL'));
         }
         // Add the layout options from the component path.
         if (is_dir($component_path) && ($component_layouts = $filesystem->files($component_path, '^[^_]*\\.xml$', false, true))) {
             // Create the group for the component
             $groups['_'] = array();
             $groups['_']['id'] = $this->id . '__';
             $groups['_']['text'] = $lang->txt('JOPTION_FROM_COMPONENT');
             $groups['_']['items'] = array();
             foreach ($component_layouts as $i => $file) {
                 // Attempt to load the XML file.
                 if (!($xml = simplexml_load_file($file))) {
                     unset($component_layouts[$i]);
                     continue;
                 }
                 // Get the help data from the XML file if present.
                 if (!($menu = $xml->xpath('layout[1]'))) {
                     unset($component_layouts[$i]);
                     continue;
                 }
                 $menu = $menu[0];
                 // Add an option to the component group
                 $value = $filesystem->name($file);
                 $component_layouts[$i] = $value;
                 $text = isset($menu['option']) ? $lang->txt($menu['option']) : (isset($menu['title']) ? $lang->txt($menu['title']) : $value);
                 $groups['_']['items'][] = Dropdown::option('_:' . $value, $text);
             }
         }
         // Loop on all templates
         if ($templates) {
             foreach ($templates as $template) {
                 // Load language file
                 $lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, true) || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, true);
                 $template_path = Util::normalizePath($client->path . '/templates/' . $template->element . '/html/' . $extn . '/' . $view);
                 // Add the layout options from the template path.
                 if (is_dir($template_path) && ($files = $filesystem->files($template_path, '^[^_]*\\.php$', false, true))) {
                     // Files with corresponding XML files are alternate menu items, not alternate layout files
                     // so we need to exclude these files from the list.
                     $xml_files = $filesystem->files($template_path, '^[^_]*\\.xml$', false, true);
                     for ($j = 0, $count = count($xml_files); $j < $count; $j++) {
                         $xml_files[$j] = $filesystem->name($xml_files[$j]);
                     }
                     foreach ($files as $i => $file) {
                         // Remove layout files that exist in the component folder or that have XML files
                         if (in_array($filesystem->name($file), $component_layouts) || in_array($filesystem->name($file), $xml_files)) {
                             unset($files[$i]);
                         }
                     }
                     if (count($files)) {
                         // Create the group for the template
                         $groups[$template->name] = array();
                         $groups[$template->name]['id'] = $this->id . '_' . $template->element;
                         $groups[$template->name]['text'] = $lang->txt('JOPTION_FROM_TEMPLATE', $template->name);
                         $groups[$template->name]['items'] = array();
                         foreach ($files as $file) {
                             // Add an option to the template group
                             $value = $filesystem->name($file);
                             $text = $lang->hasKey($key = strtoupper('TPL_' . $template->name . '_' . $extn . '_' . $view . '_LAYOUT_' . $value)) ? $lang->txt($key) : $value;
                             $groups[$template->name]['items'][] = Dropdown::option($template->element . ':' . $value, $text);
                         }
                     }
                 }
             }
         }
         // Compute attributes for the grouped list
         $attr = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
         // Prepare HTML code
         $html = array();
         // Compute the current selected values
         $selected = array($this->value);
         // Add a grouped list
         $html[] = Dropdown::groupedlist($groups, $this->name, array('id' => $this->id, 'group.id' => 'id', 'list.attr' => $attr, 'list.select' => $selected));
         return implode($html);
     }
     return '';
 }
Esempio n. 27
0
		<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;
    ?>
Esempio n. 28
0
 /**
  * Method to get the field options for radio buttons.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     foreach ($this->element->children() as $option) {
         // Only add <option /> elements.
         if ($option->getName() != 'option') {
             continue;
         }
         $label = isset($option[0]) ? $option[0] : $option['label'];
         // Create a new option object based on the <option /> element.
         $tmp = Dropdown::option((string) $option['value'], trim((string) $label), 'value', 'text', (string) $option['disabled'] == 'true');
         // Set some option attributes.
         $tmp->class = (string) $option['class'];
         // Set some JavaScript option attributes.
         $tmp->onclick = (string) $option['onclick'];
         // Add the option object to the result set.
         $options[] = $tmp;
     }
     reset($options);
     return $options;
 }
Esempio n. 29
0
 /**
  * Method to get the field options for category
  * Use the extension attribute in a form to specify the.specific extension for
  * which categories should be displayed.
  * Use the show_root attribute to specify whether to show the global category root in the list.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     // Initialise variables.
     $options = array();
     $extension = $this->element['extension'] ? (string) $this->element['extension'] : (string) $this->element['scope'];
     $published = (string) $this->element['published'];
     $name = (string) $this->element['name'];
     // Load the category options for a given extension.
     if (!empty($extension)) {
         // Filter over published state or not depending upon if it is present.
         if ($published) {
             $options = Cat::options($extension, array('filter.published' => explode(',', $published)));
         } else {
             $options = Cat::options($extension);
         }
         // Verify permissions.  If the action attribute is set, then we scan the options.
         if ((string) $this->element['action']) {
             // Get the current user object.
             $user = App::get('user')->getInstance();
             // For new items we want a list of categories you are allowed to create in.
             if (!$this->form->getValue($name)) {
                 foreach ($options as $i => $option) {
                     // To take save or create in a category you need to have create rights for that category
                     // unless the item is already in that category.
                     // Unset the option if the user isn't authorised for it. In this field assets are always categories.
                     if ($user->authorise('core.create', $extension . '.category.' . $option->value) != true) {
                         unset($options[$i]);
                     }
                 }
             } else {
                 $categoryOld = $this->form->getValue($name);
                 foreach ($options as $i => $option) {
                     // If you are only allowed to edit in this category but not edit.state, you should not get any
                     // option to change the category.
                     if ($user->authorise('core.edit.state', $extension . '.category.' . $categoryOld) != true) {
                         if ($option->value != $categoryOld) {
                             unset($options[$i]);
                         }
                     } elseif ($user->authorise('core.create', $extension . '.category.' . $option->value) != true && $option->value != $categoryOld) {
                         unset($options[$i]);
                     }
                 }
             }
         }
         if (isset($this->element['show_root'])) {
             array_unshift($options, Dropdown::option('0', App::get('language')->txt('JGLOBAL_ROOT')));
         }
     } else {
         App::abort(500, App::get('language')->txt('JLIB_FORM_ERROR_FIELDS_CATEGORY_ERROR_EXTENSION_EMPTY'));
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Esempio n. 30
0
 /**
  * Method to get the list of template style options
  * grouped by template.
  * Use the client attribute to specify a specific client.
  * Use the template attribute to specify a specific template
  *
  * @return  array  The field option objects as a nested array in groups.
  */
 protected function getGroups()
 {
     // Initialize variables.
     $groups = array();
     $lang = App::get('language');
     // Get the client and client_id.
     $clientName = $this->element['client'] ? (string) $this->element['client'] : 'site';
     $client = ClientManager::client($clientName, true);
     // Get the template.
     $template = (string) $this->element['template'];
     // Get the database object and a new query object.
     $db = App::get('db');
     $query = $db->getQuery(true);
     // Build the query.
     $query->select('s.id, s.title, e.name as name, s.template');
     $query->from('#__template_styles as s');
     $query->where('s.client_id = ' . (int) $client->id);
     $query->order('template');
     $query->order('title');
     if ($template) {
         $query->where('s.template = ' . $db->quote($template));
     }
     $query->join('LEFT', '#__extensions as e on e.element=s.template');
     $query->where('e.enabled=1');
     $query->where($db->quoteName('e.type') . '=' . $db->quote('template'));
     // Set the query and load the styles.
     $db->setQuery($query);
     $styles = $db->loadObjectList();
     // Build the grouped list array.
     if ($styles) {
         foreach ($styles as $style) {
             $template = $style->template;
             $lang->load('tpl_' . $template . '.sys', PATH_APP . '/templates/' . $template, null, false, true) || $lang->load('tpl_' . $template . '.sys', PATH_CORE . '/templates/' . $template, null, false, true);
             $name = $lang->txt($style->name);
             // Initialize the group if necessary.
             if (!isset($groups[$name])) {
                 $groups[$name] = array();
             }
             $groups[$name][] = Dropdown::option($style->id, $style->title);
         }
     }
     // Merge any additional groups in the XML definition.
     $groups = array_merge(parent::getGroups(), $groups);
     return $groups;
 }