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


PHP waSystem::getCache方法代碼示例

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


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

示例1: pages

 public function pages($parent_id = 0, $with_params = true)
 {
     if (is_bool($parent_id)) {
         $with_params = $parent_id;
         $parent_id = 0;
     }
     try {
         $page_model = $this->getPageModel();
         $domain = wa()->getRouting()->getDomain(null, true);
         if ($this->wa->getConfig()->getApplication() == wa()->getRouting()->getRoute('app')) {
             $route = wa()->getRouting()->getRoute('url');
             $url = $this->wa->getAppUrl(null, true);
         } else {
             $routes = wa()->getRouting()->getByApp($this->wa->getConfig()->getApplication(), $domain);
             if ($routes) {
                 $route = end($routes);
                 $route = $route['url'];
                 $url = wa()->getRootUrl(false, true) . waRouting::clearUrl($route);
             } else {
                 return array();
             }
         }
         $pages = null;
         $cache_key = $domain . '/' . waRouting::clearUrl($route);
         if ($cache = $this->wa->getCache()) {
             $pages = $cache->get($cache_key, 'pages');
         }
         if ($pages === null) {
             $pages = $page_model->getPublishedPages($domain, $route);
             if ($with_params && $pages) {
                 $page_params_model = $page_model->getParamsModel();
                 $data = $page_params_model->getByField('page_id', array_keys($pages), true);
                 foreach ($data as $row) {
                     if (isset($pages[$row['page_id']])) {
                         $pages[$row['page_id']][$row['name']] = $row['value'];
                     }
                 }
             }
             foreach ($pages as &$page) {
                 $page['url'] = $url . $page['full_url'];
                 if (!isset($page['title']) || !$page['title']) {
                     $page['title'] = $page['name'];
                 }
                 foreach ($page as $k => $v) {
                     if ($k != 'content') {
                         $page[$k] = htmlspecialchars($v);
                     }
                 }
             }
             unset($page);
             foreach ($pages as $page_id => $page) {
                 if ($page['parent_id'] && isset($pages[$page['parent_id']])) {
                     $pages[$page['parent_id']]['childs'][] =& $pages[$page_id];
                 }
             }
             if ($cache) {
                 $cache->set($cache_key, $pages, 3600, 'pages');
             }
         }
         if ($parent_id) {
             return isset($pages[$parent_id]['childs']) ? $pages[$parent_id]['childs'] : array();
         }
         foreach ($pages as $page_id => $page) {
             if ($page['parent_id']) {
                 unset($pages[$page_id]);
             }
         }
         return $pages;
     } catch (Exception $e) {
         return array();
     }
 }
開發者ID:cjmaximal,項目名稱:webasyst-framework,代碼行數:72,代碼來源:waAppViewHelper.class.php


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