Beispiel #1
0
 /**
  * Get a list of filter options for the application clients.
  *
  * @return  array  An array of JHtmlOption elements.
  */
 static function getClientOptions()
 {
     $items = array();
     foreach (ClientManager::client() as $client) {
         $item = new stdClass();
         $item->value = $client->id;
         $item->text = $client->name;
         $items[] = $item;
     }
     // Build the filter options.
     return $items;
 }
 /**
  * Set the application environment for a web request.
  *
  * @param   mixed   $environments  array|string
  * @return  string
  * @todo    Base off URI instead of Joomla path constant
  */
 protected function detectWebEnvironment($environments)
 {
     $default = ClientManager::client('site', true);
     foreach ($environments as $environment => $url) {
         if ($client = ClientManager::client($environment, true)) {
             $const = 'JPATH_' . strtoupper($environment);
             // To determine the current environment, we'll simply iterate through the possible
             // environments and look for the host that matches the host for this request we
             // are currently processing here, then return back these environment's names.
             if (defined($const) && JPATH_BASE == constant($const) || $this->request->segment(1) == $url) {
                 return $client;
             }
         }
     }
     return $default;
 }
Beispiel #3
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;
 }
Beispiel #4
0
 /**
  * Method to get a list of all the files to edit in a template.
  *
  * @return	array	A nested array of relevant files.
  * @since	1.6
  */
 public function getFiles()
 {
     // Initialise variables.
     $result = array();
     if ($template = $this->getTemplate()) {
         $client = \Hubzero\Base\ClientManager::client($template->client_id);
         //JApplicationHelper::getClientInfo($template->client_id);
         $base = ($template->protected ? PATH_CORE : PATH_APP) . '/templates/' . $template->element;
         $path = Filesystem::cleanPath($base . '/');
         $lang = Lang::getRoot();
         // Load the core and/or local language file(s).
         $lang->load('tpl_' . $template->element, $path, null, false, true) || $lang->load('tpl_' . $template->element, PATH_APP . '/bootstrap/' . (isset($client->alias) ? $client->alias : $client->name), null, false, true);
         // Check if the template path exists.
         if (is_dir($path)) {
             $result['main'] = array();
             $result['css'] = array();
             $result['clo'] = array();
             $result['mlo'] = array();
             $result['html'] = array();
             // Handle the main PHP files.
             $result['main']['index'] = $this->getFile($path, 'index.php');
             $result['main']['error'] = $this->getFile($path, 'error.php');
             $result['main']['print'] = $this->getFile($path, 'component.php');
             $result['main']['offline'] = $this->getFile($path, 'offline.php');
             // Handle the CSS files.
             $files = Filesystem::files($path . '/css', '\\.css$', true, true);
             //$files = Filesystem::files($path, '\.css$', true, true);
             foreach ($files as $file) {
                 $file = str_replace($base . '/', '', $file);
                 $result['css'][] = $this->getFile($path . '/css/', $file);
             }
             $files = Filesystem::files($path . '/html', '\\.css|\\.php$', true, true);
             foreach ($files as $file) {
                 $file = str_replace($base . '/', '', $file);
                 $result['html'][] = $this->getFile($path . '/html/', $file);
             }
         } else {
             $this->setError(Lang::txt('COM_TEMPLATES_ERROR_TEMPLATE_FOLDER_NOT_FOUND'));
             return false;
         }
     }
     return $result;
 }
Beispiel #5
0
 /**
  * Method to get the client object
  *
  * @return	object
  * @since	1.6
  */
 public function &getClient()
 {
     if (is_null($this->client)) {
         $this->client = \Hubzero\Base\ClientManager::client($this->getState('filter.client_id', 0));
         $this->client->path = '/bootstrap/' . $this->client->name;
     }
     return $this->client;
 }
						<tr>
							<td>
								<?php 
            // Get user object
            $user = User::getInstance($row->username);
            // Display link if we are authorized
            if ($editAuthorized) {
                echo '<a href="' . Route::url('index.php?option=com_users&task=user.edit&id=' . $row->userid) . '" title="' . Lang::txt('MOD_WHOSONLINE_EDIT_USER') . '">' . $this->escape($user->get('name')) . ' [' . $this->escape($user->get('username')) . ']' . '</a>';
            } else {
                echo $this->escape($user->get('name')) . ' [' . $this->escape($user->get('username')) . ']';
            }
            ?>
							</td>
							<td>
								<?php 
            $clientInfo = \Hubzero\Base\ClientManager::client($row->client_id);
            echo '<span class="client client-' . $clientInfo->name . '" data-client="' . substr($clientInfo->name, 0, 1) . '">' . ucfirst($clientInfo->name) . '</span>';
            ?>
							</td>
							<td class="priority-3">
								<?php 
            echo Lang::txt('MOD_WHOSONLINE_HOURS_AGO', (time() - $row->time) / 3600.0);
            ?>
							</td>
							<?php 
            if ($editAuthorized) {
                ?>
								<td>
									<a class="force-logout" href="<?php 
                echo Route::url('index.php?option=com_login&task=logout&uid=' . $row->userid . '&' . Session::getFormToken() . '=1');
                ?>
Beispiel #7
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 '';
 }
Beispiel #8
0
 /**
  * @param	object	A form object.
  * @param	mixed	The data expected for the form.
  * @throws	Exception if there is an error in the form event.
  * @since	1.6
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     // Initialise variables.
     $clientId = $this->getState('item.client_id');
     $template = $this->getState('item.template');
     $lang = Lang::getRoot();
     $client = \Hubzero\Base\ClientManager::client($clientId);
     if (!$form->loadFile('style_' . $client->name, true)) {
         throw new Exception(Lang::txt('JERROR_LOADFILE_FAILED'));
     }
     $base = PATH_CORE;
     if (is_dir(PATH_APP . '/templates/' . $template)) {
         $base = PATH_APP;
     }
     $formFile = Filesystem::cleanPath($base . '/templates/' . $template . '/templateDetails.xml');
     // Load the core and/or local language file(s).
     $lang->load('tpl_' . $template, $base . '/bootstrap/' . $client->name, null, false, true) || $lang->load('tpl_' . $template, $base . '/templates/' . $template, null, false, true);
     if (file_exists($formFile)) {
         // Get the template form.
         if (!$form->loadFile($formFile, false, '//config')) {
             throw new Exception(Lang::txt('JERROR_LOADFILE_FAILED'));
         }
     }
     // Disable home field if it is default style
     if (is_array($data) && array_key_exists('home', $data) && $data['home'] == '1' || is_object($data) && isset($data->home) && $data->home == '1') {
         $form->setFieldAttribute('home', 'readonly', 'true');
     }
     // Attempt to load the xml file.
     if (!($xml = simplexml_load_file($formFile))) {
         throw new Exception(Lang::txt('JERROR_LOADFILE_FAILED'));
     }
     // Get the help data from the XML file if present.
     $help = $xml->xpath('/extension/help');
     if (!empty($help)) {
         $helpKey = trim((string) $help[0]['key']);
         $helpURL = trim((string) $help[0]['url']);
         $this->helpKey = $helpKey ? $helpKey : $this->helpKey;
         $this->helpURL = $helpURL ? $helpURL : $this->helpURL;
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Beispiel #9
0
 /**
  * Method to get cache instance
  *
  * @return  object
  */
 public function cache()
 {
     $handler = App::get('config')->get('cache_handler');
     $client = ClientManager::client($this->state('clientId'));
     App::get('config')->set($handler, array('cachebase' => PATH_APP . '/cache/' . (isset($client->alias) ? $client->alias : $client->name)));
     $cache = new \Hubzero\Cache\Manager(\App::getRoot());
     $cache->storage($handler);
     return $cache;
 }
Beispiel #10
0
 /**
  * Method to preprocess the form
  *
  * @param   JForm   $form   A form object.
  * @param   mixed   $data   The data expected for the form.
  * @param   string  $group  The name of the plugin group to import (defaults to "content").
  *
  * @return  void
  *
  * @since   1.6
  * @throws  Exception if there is an error loading the form.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     // Initialise variables.
     $lang = Lang::getRoot();
     $clientId = $this->getState('item.client_id');
     $module = $this->getState('item.module');
     $client = \Hubzero\Base\ClientManager::client($clientId);
     //$formFile = JPath::clean($client->path.'/modules/'.$module.'/'.$module.'.xml');
     $formFile = null;
     $patha = JPath::clean(PATH_APP . '/modules/' . $module . '/' . $module . '.xml');
     $pathc = JPath::clean(PATH_CORE . '/modules/' . $module . '/' . $module . '.xml');
     if (file_exists($patha)) {
         $formFile = $patha;
     } elseif (file_exists($pathc)) {
         $formFile = $pathc;
     }
     // Load the core and/or local language file(s).
     $lang->load($module, PATH_APP . '/bootstrap/' . $client->name, null, false, true) || $lang->load($module, PATH_APP . '/modules/' . $module, null, false, true) || $lang->load($module, PATH_CORE . '/modules/' . $module, null, false, true);
     if ($formFile) {
         // Get the module form.
         if (!$form->loadFile($formFile, false, '//config')) {
             throw new Exception(Lang::txt('JERROR_LOADFILE_FAILED'));
         }
         // Attempt to load the xml file.
         if (!($xml = simplexml_load_file($formFile))) {
             throw new Exception(Lang::txt('JERROR_LOADFILE_FAILED'));
         }
         // Get the help data from the XML file if present.
         $help = $xml->xpath('/extension/help');
         if (!empty($help)) {
             $helpKey = trim((string) $help[0]['key']);
             $helpURL = trim((string) $help[0]['url']);
             $this->helpKey = $helpKey ? $helpKey : $this->helpKey;
             $this->helpURL = $helpURL ? $helpURL : $this->helpURL;
         }
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Beispiel #11
0
 /**
  * Load a template by client
  *
  * @param   integer  $client_id  The client to load the tmeplate for
  * @return  string
  */
 public function load($client_id = null)
 {
     if (!is_null($client_id)) {
         $client = \Hubzero\Base\ClientManager::client($client_id, !is_numeric($client_id));
     } else {
         $client = $this->app['client'];
     }
     $name = $client->name;
     $method = 'get' . ucfirst($name) . 'Template';
     if (method_exists($this, $method)) {
         return $this->{$method}();
     }
     return $this->getSystemTemplate();
 }
Beispiel #12
0
 /**
  * Method to get a list of items.
  *
  * @return	mixed	An array of objects on success, false on failure.
  */
 public function getItems()
 {
     // Get the list of items from the database.
     $items = parent::getItems();
     // Initialise variables.
     $client = \Hubzero\Base\ClientManager::client($this->getState('filter.client_id', 0));
     $client->path = PATH_CORE;
     $lang = Lang::getRoot();
     // Loop through the results to add the XML metadata,
     // and load language support.
     foreach ($items as &$item) {
         $path = \Hubzero\Filesystem\Util::normalizePath($client->path . '/modules/' . $item->module . '/' . $item->module . '.xml');
         if (file_exists($path)) {
             $item->xml = simplexml_load_file($path);
         } else {
             $item->xml = null;
         }
         // 1.5 Format; Core files or language packs then
         // 1.6 3PD Extension Support
         $lang->load($item->module . '.sys', PATH_APP . DS . 'bootstrap' . DS . $client->name, null, false, true) || $lang->load($item->module . '.sys', PATH_APP . '/modules/' . $item->module, null, false, true) || $lang->load($item->module . '.sys', $client->path . '/modules/' . $item->module, null, false, true);
         $item->name = Lang::txt($item->name);
         if (isset($item->xml) && ($text = trim($item->xml->description))) {
             $item->desc = Lang::txt($text);
         } else {
             $item->desc = Lang::txt('COM_MODULES_NODESCRIPTION');
         }
     }
     $items = \Hubzero\Utility\Arr::sortObjects($items, 'name', 1, true, $lang->getLocale());
     // TODO: Use the cached XML from the extensions table?
     return $items;
 }
Beispiel #13
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 '';
 }
Beispiel #14
0
 /**
  * Load a template by client
  *
  * @param   integer  $client_id  The client to load the tmeplate for
  * @return  string
  */
 public function load($client_id = null)
 {
     if (!is_null($client_id)) {
         $client = ClientManager::client($client_id, !is_numeric($client_id));
     } else {
         $client = $this->app['client'];
     }
     return $this->getTemplate((int) $client->id, $this->style);
 }
Beispiel #15
0
 /**
  * Clean the cache
  *
  * @param   string   $group      The cache group
  * @param   integer  $client_id  The ID of the client
  *
  * @return  void
  *
  * @since   11.1
  */
 protected function cleanCache($group = null, $client_id = 0)
 {
     // Initialise variables;
     $conf = JFactory::getConfig();
     $dispatcher = JDispatcher::getInstance();
     $options = array('defaultgroup' => $group ? $group : (isset($this->option) ? $this->option : JRequest::getCmd('option')), 'cachebase' => $client_id ? PATH_APP . '/cache/admin' : $conf->get('cache_path', PATH_APP . '/cache/site'));
     /*
     [!] HUBzero - Changed to use Hubzero Cache
     
     $cache = JCache::getInstance('callback', $options);
     $cache->clean();
     */
     $handler = \App::get('config')->get('cache_handler');
     $client = \Hubzero\Base\ClientManager::client((int) $client_id);
     $app = \App::getRoot();
     $app->get('config')->set($handler, array('cachebase' => PATH_APP . '/cache/' . (isset($client->alias) ? $client->alias : $client->name)));
     $cache = new \Hubzero\Cache\Manager($app);
     $cache->storage($handler);
     $cache->clean($group);
     // Trigger the onContentCleanCache event.
     $dispatcher->trigger($this->event_clean_cache, $options);
 }