Exemplo n.º 1
0
 protected static function build()
 {
     KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     if (self::$search === false) {
         $user = KunenaUserHelper::getMyself();
         $language = JFactory::getDocument()->getLanguage();
         $cache = self::getCache();
         // FIXME: enable caching after fixing the issues
         self::$search = false;
         //unserialize($cache->get('search', "com_kunena.route.{$language}.{$user->userid}"));
         if (self::$search === false) {
             self::$search['home'] = array();
             foreach (self::$menu as $item) {
                 // Joomla! 1.5:
                 if (!is_object($item) || isset($item->published) && $item->published < 1) {
                     continue;
                 }
                 // Do not add menu items for other languages
                 if (isset($item->language) && $item->language != '*' && strtolower($item->language) != strtolower($language)) {
                     continue;
                 }
                 if ($item->type == 'alias' && !empty($item->query['Itemid']) && !empty(self::$menu[$item->query['Itemid']])) {
                     // Follow links
                     $item = self::$menu[$item->query['Itemid']];
                 } elseif ($item->type == 'component' && $item->component == 'com_kunena' && isset($item->query['view'])) {
                     // Save Kunena menu items so that we can make fast searches
                     $home = self::getHome($item);
                     self::$search[$item->query['view']][$home ? $home->id : 0][$item->id] = $item->id;
                 }
             }
             // FIXME: enable caching after fixing the issues
             //$cache->store(serialize(self::$search), 'search', "com_kunena.route.{$language}.{$user->userid}");
         }
     }
     KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
 }
Exemplo n.º 2
0
	protected static function build()
	{
		KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;

		if (self::$search === false)
		{
			$user = KunenaUserHelper::getMyself();
			$language = strtolower(JFactory::getDocument()->getLanguage());
			self::$search = false;

			if (KunenaConfig::getInstance()->get('cache_mid'))
			{
				// FIXME: Experimental caching.
				$cache = self::getCache();
				self::$search = unserialize($cache->get('search', "com_kunena.route.v1.{$language}.{$user->userid}"));
			}

			if (self::$search === false)
			{
				self::$search['home'] = array();
				foreach (self::$menu as $item)
				{
					// Skip menu items that aren't pointing to Kunena or are using wrong language.
					if (($item->component != 'com_kunena' && $item->type != 'alias')
						|| ($item->language  != '*' && strtolower($item->language) != $language))
					{
						continue;
					}

					// Follow links.
					if ($item->type == 'alias')
					{
						if (empty($item->query['Itemid']) || empty(self::$menu[$item->query['Itemid']]))
						{
							continue;
						}

						$item = self::$menu[$item->query['Itemid']];
						if ($item->component != 'com_kunena' || ($item->language  != '*' && strtolower($item->language) != $language))
						{
							continue;
						}
					}

					// Ignore legacy menu items without view in it.
					if (!isset($item->query['view']))
					{
						continue;
					}

					// Save Kunena menu items so that we can make fast searches
					$home = self::getHome($item);
					self::$search[$item->query['view']][$home ? $home->id : 0][$item->id] = $item->id;
				}

				if (isset($cache))
				{
					$cache->store(serialize(self::$search), 'search', "com_kunena.route.v1.{$language}.{$user->userid}");
				}
			}
		}
		KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
	}
Exemplo n.º 3
0
	protected static function build() {
		KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
		if (self::$search === false) {
			$cache = JFactory::getCache('_system', 'output');
			self::$search = unserialize($cache->get('search', 'com_kunena.route'));
			if (self::$search === false) {
				self::$search['home'] = array();
				foreach ( self::$menu as $item ) {
					if (! is_object ( $item ))
						continue;
					$home = self::getHome($item);
					// Follow links
					if ($item->type == 'menulink' && !empty($item->query['Itemid']) && !empty(self::$menu[$item->query['Itemid']])) {
						$item = self::$menu[$item->query['Itemid']];
					}
					// Save Kunena menu items so that we can make fast searches
					if ($item->type == 'component' && $item->component == 'com_kunena' && isset($item->query['view'])) {
						self::$search[$item->query['view']][$home ? $home->id : 0][$item->id] = $item->id;
					}
				}
				$cache->store(serialize(self::$search), 'search', 'com_kunena.route');
			}
		}
		KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
	}