Exemplo n.º 1
0
 /**
  * Method to get the field option groups.
  *
  * @return  array  The field option objects as a nested array in groups.
  *
  * @since   11.1
  */
 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][] = RokCommon_HTML_SelectList::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][] = RokCommon_HTML_SelectList::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;
 }
Exemplo n.º 2
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.
  *
  * @since   11.1
  */
 protected function getGroups()
 {
     // Initialize variables.
     $groups = array();
     $lang = JFactory::getLanguage();
     // Get the client and client_id.
     $clientName = $this->element['client'] ? (string) $this->element['client'] : 'site';
     $client = JApplicationHelper::getClientInfo($clientName, true);
     // Get the template.
     $template = (string) $this->element['template'];
     // Get the database object and a new query object.
     $db = JFactory::getDBO();
     $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');
     // 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', $client->path, null, false, false) || $lang->load('tpl_' . $template . '.sys', $client->path . '/templates/' . $template, null, false, false) || $lang->load('tpl_' . $template . '.sys', $client->path, $lang->getDefault(), false, false) || $lang->load('tpl_' . $template . '.sys', $client->path . '/templates/' . $template, $lang->getDefault(), false, false);
             $name = rc__($style->name);
             // Initialize the group if necessary.
             if (!isset($groups[$name])) {
                 $groups[$name] = array();
             }
             $groups[$name][] = RokCommon_HTML_SelectList::option($style->id, $style->title);
         }
     }
     // Merge any additional groups in the XML definition.
     $groups = array_merge(parent::getGroups(), $groups);
     return $groups;
 }