/** * Get the contents of a document include * * @param string $type The type of renderer * @param string $name The name of the element to render * @param array $attribs Associative array of remaining attributes. * * @return The output of the renderer * * @since 11.1 */ public function getBuffer($type = null, $name = null, $attribs = array()) { // If no type is specified, return the whole buffer if ($type === null) { return parent::$_buffer; } $title = isset($attribs['title']) ? $attribs['title'] : null; if (isset(parent::$_buffer[$type][$name][$title])) { return parent::$_buffer[$type][$name][$title]; } $renderer = $this->loadRenderer($type); if ($this->_caching == true && $type == 'modules') { $cache = Factory::getCache('com_modules', ''); $hash = md5(serialize(array($name, $attribs, null, $renderer))); $cbuffer = $cache->get('cbuffer_' . $type); if (isset($cbuffer[$hash])) { return Cache::getWorkarounds($cbuffer[$hash], array('mergehead' => 1)); } else { $options = array(); $options['nopathway'] = 1; $options['nomodules'] = 1; $options['modulemode'] = 1; $this->setBuffer($renderer->render($name, $attribs, null), $type, $name); $data = parent::$_buffer[$type][$name][$title]; $tmpdata = Cache::setWorkarounds($data, $options); $cbuffer[$hash] = $tmpdata; $cache->store($cbuffer, 'cbuffer_' . $type); } } else { $this->setBuffer($renderer->render($name, $attribs, null), $type, $name, $title); } return parent::$_buffer[$type][$name][$title]; }
/** * Get available languages * * @param string $key Array key * * @return array An array of published languages * * @since 11.1 */ public static function getLanguages($key = 'default') { static $languages; if (empty($languages)) { // Installation uses available languages if (Factory::getApplication()->getClientId() == 2) { $languages[$key] = array(); $knownLangs = Language::getKnownLanguages(JPATH_BASE); foreach ($knownLangs as $metadata) { // Take off 3 letters iso code languages as they can't match browsers' languages and default them to en $obj = new stdClass(); $obj->lang_code = $metadata['tag']; $languages[$key][] = $obj; } } else { $cache = Factory::getCache('com_languages', ''); if (!($languages = $cache->get('languages'))) { $db = Factory::getDBO(); $query = $db->getQuery(true); $query->select('*')->from('#__languages')->where('published=1')->order('ordering ASC'); $db->setQuery($query); $languages['default'] = $db->loadObjectList(); $languages['sef'] = array(); $languages['lang_code'] = array(); if (isset($languages['default'][0])) { foreach ($languages['default'] as $lang) { $languages['sef'][$lang->sef] = $lang; $languages['lang_code'][$lang->lang_code] = $lang; } } $cache->store($languages, 'languages'); } } } return $languages[$key]; }
/** * Loads the published plugins. * * @return array An array of published plugins * * @since 11.1 */ protected static function _load() { if (self::$plugins !== null) { return self::$plugins; } $user = Factory::getUser(); $cache = Factory::getCache('com_plugins', ''); $levels = implode(',', $user->getAuthorisedViewLevels()); if (!(self::$plugins = $cache->get($levels))) { $db = Factory::getDbo(); $query = $db->getQuery(true); $query->select('folder AS type, element AS name, params')->from('#__extensions')->where('enabled >= 1')->where('type =' . $db->Quote('plugin'))->where('state >= 0')->where('access IN (' . $levels . ')')->order('ordering'); self::$plugins = $db->setQuery($query)->loadObjectList(); $cache->store(self::$plugins, $levels); } return self::$plugins; }