當前位置: 首頁>>代碼示例>>PHP>>正文


PHP KunenaForumCategoryHelper::_instances方法代碼示例

本文整理匯總了PHP中KunenaForumCategoryHelper::_instances方法的典型用法代碼示例。如果您正苦於以下問題:PHP KunenaForumCategoryHelper::_instances方法的具體用法?PHP KunenaForumCategoryHelper::_instances怎麽用?PHP KunenaForumCategoryHelper::_instances使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在KunenaForumCategoryHelper的用法示例。


在下文中一共展示了KunenaForumCategoryHelper::_instances方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: initialize

	/**
	 * Initialize class.
	 */
	static public function initialize()
	{
		KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;

		if (KunenaConfig::getInstance()->get('cache_cat'))
		{
			// FIXME: Experimental caching.
			/** @var JCache|JCacheControllerCallback $cache */
			$cache = JFactory::getCache('com_kunena', 'callback');
			$cache->setLifeTime(180);
			self::$_instances = $cache->call(array('KunenaForumCategoryHelper', 'loadCategories'));
		}
		else
		{
			self::$_instances = self::loadCategories();
		}

		if (is_null(self::$_tree))
		{
			self::buildTree(self::$_instances);
		}

		self::$allowed = KunenaAccess::getInstance()->getAllowedCategories();
		KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
	}
開發者ID:BillVGN,項目名稱:PortalPRP,代碼行數:28,代碼來源:helper.php

示例2: loadCategories

 protected static function loadCategories()
 {
     KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     $db = JFactory::getDBO();
     $query = "SELECT * FROM #__kunena_categories ORDER BY ordering, name";
     $db->setQuery($query);
     $results = (array) $db->loadAssocList();
     KunenaError::checkDatabaseError();
     self::$_instances = array();
     self::$_tree = array();
     if (empty($results)) {
         KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
         return;
     }
     foreach ($results as $category) {
         $instance = new KunenaForumCategory($category);
         $instance->exists(true);
         self::$_instances[$instance->id] = $instance;
         if (!isset(self::$_tree[(int) $instance->id])) {
             self::$_tree[$instance->id] = array();
         }
         self::$_tree[$instance->parent_id][$instance->id] =& self::$_tree[(int) $instance->id];
     }
     unset($results);
     // TODO: remove this by adding level into table
     $heap = array(0);
     while (($parent = array_shift($heap)) !== null) {
         foreach (self::$_tree[$parent] as $id => $children) {
             if (!empty($children)) {
                 array_push($heap, $id);
             }
             self::$_instances[$id]->level = $parent ? self::$_instances[$parent]->level + 1 : 0;
         }
     }
     KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
 }
開發者ID:proyectoseb,項目名稱:University,代碼行數:36,代碼來源:helper.php


注:本文中的KunenaForumCategoryHelper::_instances方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。