/** * basically a test action for development puposes only * * @menuLabel Profiling test page * @menuIcon <i class="fa fa-cogs"></i> * @functionalRight cmsBackendRead * * @return \yii\web\Response|string */ public function actionProfiling() { SettingsAndMaintenanceController::$iterationCounter = 0; Yii::beginProfile(__METHOD__, 'simplecms'); $results = DefaultController::getMenuTree(1, 999, false); Yii::endProfile(__METHOD__, 'simplecms'); return $this->render('profiling', ['data' => DefaultController::$iterationCounter]); }
/** * * @param unknown $currentLanguageId * @param string $hideMissingLanguages * @param string $removeHierarchyItemsWithNoContent * @return \schallschlucker\simplecms\models\SimpleHierarchyItem */ public static function getRootHierarchyItemCached($currentLanguageId, $hideMissingLanguages = true, $removeHierarchyItemsWithNoContent = true) { Yii::beginProfile(__METHOD__, 'CMS-NAVIGATION'); $cacheKey = NavigationController::$BASE_CACHE_KEY_FRONTEND_NAVIGATION . $currentLanguageId . '-' . $hideMissingLanguages . '-' . $removeHierarchyItemsWithNoContent; $simpleHierarchyItem = Yii::$app->getModule('simplecms_frontend')->getCachedValue($cacheKey, false); if ($simpleHierarchyItem === false) { Yii::info('no cached page tree found for given parameters, will rebuild tree from database'); $simpleHierarchyItem = DefaultController::getMenuTree($currentLanguageId, 9999, $hideMissingLanguages, $removeHierarchyItemsWithNoContent, [CmsHierarchyItem::DISPLAYSTATE_PUBLISHED_VISIBLE_IN_NAVIGATION]); $simpleHierarchyItem->finalizeForOutput(); Yii::$app->getModule('simplecms_frontend')->setCacheValue($cacheKey, $simpleHierarchyItem, NavigationController::$FRONTEND_NAVIGATION_CACHE_LIVETIME_SECONDS); } Yii::endProfile(__METHOD__); return $simpleHierarchyItem; }
/** * generate a menu (page) tree of all menus (for admin reasons only, since all items will be displayed including fallback language and all display types, even hidden ones). * The result is returned as a json encoded hierarchy * * @menuLabel __HIDDEN__ * @menuIcon <span class="glyphicon glyphicon-list-alt"></span> * @functionalRight cmsBackendRead * * @param * integer language the language id for which to display the page tree (as primary language) * @param * integer expandLevel the level depth, until which the folders should be marked as expanded ($expanded = true) */ public function actionPageTreeJson($language, $hideMissingLanguages = false, $expandLevel = 9999) { $rootItem = DefaultController::getMenuTree($language, $expandLevel, $hideMissingLanguages, []); $rootItem->finalizeForOutput(); Yii::$app->response->format = \yii\web\Response::FORMAT_RAW; $headers = Yii::$app->response->headers; $headers->add('Content-Type', 'application/json; charset=utf-8'); Yii::$app->response->charset = 'UTF-8'; return json_encode([$rootItem], JSON_PRETTY_PRINT); }