当前位置: 首页>>代码示例>>PHP>>正文


PHP Page::loadCached方法代码示例

本文整理汇总了PHP中Cms\Classes\Page::loadCached方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::loadCached方法的具体用法?PHP Page::loadCached怎么用?PHP Page::loadCached使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cms\Classes\Page的用法示例。


在下文中一共展示了Page::loadCached方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 /**
  * Initialize.
  *
  * @return void
  * @throws \Krisawzm\DemoManager\Classes\DemoManagerException
  */
 protected function init()
 {
     $backendUser = BackendAuth::getUser();
     $baseTheme = $this->theme = Config::get('krisawzm.demomanager::base_theme', null);
     if ($backendUser) {
         if ($backendUser->login == Config::get('krisawzm.demomanager::admin.login', 'admin')) {
             $this->theme = $baseTheme;
         } else {
             $this->theme = $backendUser->login;
         }
     } else {
         if (UserCounter::instance()->limit()) {
             $action = Config::get('krisawzm.demomanager::limit_action', 'reset');
             if ($action == 'reset') {
                 DemoManager::instance()->resetEverything();
                 // @todo queue/async?
                 $this->theme = $this->newDemoUser()->login;
             } elseif ($action == 'maintenance') {
                 $theme = Theme::load($baseTheme);
                 Event::listen('cms.page.beforeDisplay', function ($controller, $url, $page) use($theme) {
                     return Page::loadCached($theme, 'maintenance');
                 });
             } elseif ($action == 'nothing') {
                 $this->theme = $baseTheme;
             } else {
                 throw new DemoManagerException('User limit is reached, but an invalid action is defined.');
             }
         } else {
             $this->theme = $this->newDemoUser()->login;
             // @todo Remember the username after signing out.
             //       Could prove useful as some plugins may
             //       have some different offline views.
         }
     }
 }
开发者ID:janusnic,项目名称:demomanager-plugin,代码行数:41,代码来源:DemoAuth.php

示例2: getBlogTagRenderUrls

 private static function getBlogTagRenderUrls($theme, $item, $alltags = false)
 {
     $page = CmsPage::loadCached($theme, $item->cmsPage);
     $result = [];
     $tags = Tag::lists('slug', 'name');
     $pages = [];
     if ($item->nesting > 0) {
         foreach ($tags as $slug => $name) {
             if ($alltags) {
                 $url = CmsPage::url($page->getBaseFileName(), ['filter' => 'tag', 'slug' => $slug], false);
                 $url = URL::to(Str::lower($url)) . '/';
                 $pages[] = array('title' => $name, 'url' => $url);
             } else {
                 $category = Tag::whereRaw("LOWER(slug) = '{$slug}'")->first();
                 $tagPages = Post::filterByCategory($category->id)->get();
                 $pageUrl = CmsPage::url($page->getBaseFileName(), ['slug' => $slug], false);
                 $pageUrl = str_replace('/default', '', Str::lower($pageUrl) . '/');
                 foreach ($tagPages as $cpage) {
                     $pages[] = array('title' => $cpage->title, 'url' => Str::lower($pageUrl) . $cpage->slug . '/');
                 }
             }
         }
     }
     return $pages;
 }
开发者ID:fuunnx,项目名称:loveandzucchini,代码行数:25,代码来源:Tag.php

示例3: getUrl

 /**
  *
  * Generates url for the item to be resolved
  *
  * @param int $year - year number
  * @param string $pageCode - page code to be used
  * @param $theme
  * @return string
  */
 protected static function getUrl($year, $pageCode, $theme)
 {
     $page = CmsPage::loadCached($theme, $pageCode);
     if (!$page) {
         return '';
     }
     $properties = $page->getComponentProperties('blogArchive');
     if (!isset($properties['yearParam'])) {
         return '';
     }
     $paramName = $properties['yearParam'];
     $url = CmsPage::url($page->getBaseFileName(), [$paramName => $year]);
     return $url;
 }
开发者ID:graker,项目名称:blogarchive,代码行数:23,代码来源:SitemapProvider.php

示例4: run

 /**
  * Finds and serves the requested page.
  * If the page cannot be found, returns the page with the URL /404.
  * If the /404 page doesn't exist, returns the system 404 page.
  * @param string $url Specifies the requested page URL.
  * If the parameter is omitted, the current URL used.
  * @return string Returns the processed page content.
  */
 public function run($url = '/')
 {
     if ($url === null) {
         $url = Request::path();
     }
     if (!strlen($url)) {
         $url = '/';
     }
     /*
      * Hidden page
      */
     $page = $this->router->findByUrl($url);
     if ($page && $page->is_hidden) {
         if (!BackendAuth::getUser()) {
             $page = null;
         }
     }
     /*
      * Maintenance mode
      */
     if (MaintenanceSettings::isConfigured() && MaintenanceSettings::get('is_enabled', false) && !BackendAuth::getUser()) {
         $page = Page::loadCached($this->theme, MaintenanceSettings::get('cms_page'));
     }
     /*
      * Extensibility
      */
     if (($event = $this->fireEvent('page.beforeDisplay', [$url, $page], true)) || ($event = Event::fire('cms.page.beforeDisplay', [$this, $url, $page], true))) {
         if ($event instanceof Page) {
             $page = $event;
         } else {
             return $event;
         }
     }
     /*
      * If the page was not found, render the 404 page - either provided by the theme or the built-in one.
      */
     if (!$page) {
         $this->setStatusCode(404);
         // Log the 404 request
         if (!App::runningUnitTests()) {
             RequestLog::add();
         }
         if (!($page = $this->router->findByUrl('/404'))) {
             return Response::make(View::make('cms::404'), $this->statusCode);
         }
     }
     /*
      * Run the page
      */
     $result = $this->runPage($page);
     /*
      * Post-processing
      */
     $result = $this->postProcessResult($page, $url, $result);
     /*
      * Extensibility
      */
     if (($event = $this->fireEvent('page.display', [$url, $page, $result], true)) || ($event = Event::fire('cms.page.display', [$this, $url, $page, $result], true))) {
         return $event;
     }
     if (!is_string($result)) {
         return $result;
     }
     return Response::make($result, $this->statusCode);
 }
开发者ID:Tripplefix,项目名称:pfadiorion,代码行数:73,代码来源:Controller.php

示例5: findByUrl

 /**
  * Finds a page by its URL. Returns the page object and sets the $parameters property.
  * @param string $url The requested URL string.
  * @return \Cms\Classes\Page Returns \Cms\Classes\Page object or null if the page cannot be found.
  */
 public function findByUrl($url)
 {
     $url = RouterHelper::normalizeUrl($url);
     $apiResult = Event::fire('cms.router.beforeRoute', [$url], true);
     if ($apiResult !== null) {
         return $apiResult;
     }
     for ($pass = 1; $pass <= 2; $pass++) {
         $fileName = null;
         $urlList = [];
         $cacheable = Config::get('cms.enableRoutesCache') && in_array(Config::get('cache.driver'), ['apc', 'memcached', 'redis', 'array']);
         if ($cacheable) {
             $fileName = $this->getCachedUrlFileName($url, $urlList);
         }
         /*
          * Find the page by URL and cache the route
          */
         if (!$fileName) {
             $router = $this->getRouterObject();
             if ($router->match($url)) {
                 $this->parameters = $router->getParameters();
                 $fileName = $router->matchedRoute();
                 if ($cacheable) {
                     if (!$urlList || !is_array($urlList)) {
                         $urlList = [];
                     }
                     $urlList[$url] = $fileName;
                     $key = $this->getUrlListCacheKey();
                     Cache::put($key, serialize($urlList), Config::get('cms.urlCacheTtl', 1));
                 }
             }
         }
         /*
          * Return the page
          */
         if ($fileName) {
             if (($page = Page::loadCached($this->theme, $fileName)) === null) {
                 /*
                  * If the page was not found on the disk, clear the URL cache
                  * and repeat the routing process.
                  */
                 if ($pass == 1) {
                     $this->clearCache();
                     continue;
                 }
                 return null;
             }
             return $page;
         }
         return null;
     }
 }
开发者ID:nnmer,项目名称:october,代码行数:57,代码来源:Router.php

示例6: getCategoryPageUrl

 /**
  * Returns URL of a category page.
  */
 protected static function getCategoryPageUrl($pageCode, $category, $theme)
 {
     $page = CmsPage::loadCached($theme, $pageCode);
     if (!$page) {
         return;
     }
     $paramName = 'category';
     $url = CmsPage::url($page->getBaseFileName(), [$paramName => $category['slug']]);
     return $url;
 }
开发者ID:chrisvidal,项目名称:oc-theater-plugin,代码行数:13,代码来源:Performance.php

示例7: getPostPageUrl

 /**
  * Returns URL of a post page.
  */
 protected static function getPostPageUrl($pageCode, $category, $theme)
 {
     $page = CmsPage::loadCached($theme, $pageCode);
     if (!$page) {
         return;
     }
     $properties = $page->getComponentProperties('blogPost');
     if (!isset($properties['slug'])) {
         return;
     }
     /*
      * Extract the routing parameter name from the category filter
      * eg: {{ :someRouteParam }}
      */
     if (!preg_match('/^\\{\\{([^\\}]+)\\}\\}$/', $properties['slug'], $matches)) {
         return;
     }
     $paramName = substr(trim($matches[1]), 1);
     $url = CmsPage::url($page->getBaseFileName(), [$paramName => $category->slug]);
     return $url;
 }
开发者ID:richlove1,项目名称:avc-october,代码行数:24,代码来源:Post.php

示例8: boot

 public function boot()
 {
     /*
      * Set the page context for translation caching.
      * Adds language suffixes to page files.
      */
     Event::listen('cms.page.beforeDisplay', function ($controller, $url, $page) {
         if (!$page) {
             return;
         }
         $translator = Translator::instance();
         $translator->loadLocaleFromSession();
         Message::setContext($translator->getLocale(), $page->url);
         $defaultLocale = $translator->getDefaultLocale();
         $locale = $translator->getLocale();
         $fileName = $page->getFileName();
         $fileName = str_replace(strstr($fileName, "."), '', $fileName);
         if (!strlen(File::extension($fileName))) {
             $fileName .= '.htm';
         }
         /*
          * Splice the active locale in to the filename
          * - page.htm -> page.en.htm
          */
         if ($locale != $defaultLocale) {
             $fileName = substr_replace($fileName, '.' . $locale, strrpos($fileName, '.'), 0);
             $page->setFileName($fileName);
         }
         $page = Page::loadCached($controller->getTheme(), $fileName);
         return $page;
     });
     /*
      * Adds language suffixes to content files.
      */
     Event::listen('cms.page.beforeRenderContent', function ($controller, $fileName) {
         if (!strlen(File::extension($fileName))) {
             $fileName .= '.htm';
         }
         /*
          * Splice the active locale in to the filename
          * - content.htm -> content.en.htm
          */
         $locale = Translator::instance()->getLocale();
         $fileName = substr_replace($fileName, '.' . $locale, strrpos($fileName, '.'), 0);
         if (($content = Content::loadCached($controller->getTheme(), $fileName)) !== null) {
             return $content;
         }
     });
     /*
      * Automatically replace form fields for multi lingual equivalents
      */
     Event::listen('backend.form.extendFieldsBefore', function ($widget) {
         if (!($model = $widget->model)) {
             return;
         }
         if (!method_exists($model, 'isClassExtendedWith')) {
             return;
         }
         if (!$model->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel')) {
             return;
         }
         if (!is_array($model->translatable)) {
             return;
         }
         if (!empty($widget->config->fields)) {
             $widget->config->fields = $this->processFormMLFields($widget->config->fields, $model);
         }
         if (!empty($widget->config->tabs['fields'])) {
             $widget->config->tabs['fields'] = $this->processFormMLFields($widget->config->tabs['fields'], $model);
         }
         if (!empty($widget->config->secondaryTabs['fields'])) {
             $widget->config->secondaryTabs['fields'] = $this->processFormMLFields($widget->config->secondaryTabs['fields'], $model);
         }
     });
 }
开发者ID:janusnic,项目名称:OctoberCMS,代码行数:75,代码来源:Plugin.php

示例9: getCategoryPageUrl

 /**
  * Returns URL of a category page.
  */
 protected static function getCategoryPageUrl($pageCode, $category, $theme)
 {
     $page = CmsPage::loadCached($theme, $pageCode);
     if (!$page) {
         return;
     }
     $properties = $page->getComponentProperties('blogPosts');
     if (!isset($properties['categoryFilter'])) {
         return;
     }
     $filter = substr($properties['categoryFilter'], 1);
     $url = CmsPage::url($page->getBaseFileName(), [$filter => $category->slug], false);
     return Str::lower(RouterHelper::normalizeUrl($url));
 }
开发者ID:janusnic,项目名称:OctoberCMS,代码行数:17,代码来源:Category.php

示例10: run

 /**
  * Finds and serves the requested page.
  * If the page cannot be found, returns the page with the URL /404.
  * If the /404 page doesn't exist, returns the system 404 page.
  * @param string $url Specifies the requested page URL.
  * If the parameter is omitted, the current URL used.
  * @return string Returns the processed page content.
  */
 public function run($url = '/')
 {
     if ($url === null) {
         $url = Request::path();
     }
     if (!strlen($url)) {
         $url = '/';
     }
     /*
      * Hidden page
      */
     $page = $this->router->findByUrl($url);
     if ($page && $page->hidden) {
         if (!BackendAuth::getUser()) {
             $page = null;
         }
     }
     /*
      * Maintenance mode
      */
     if (MaintenanceSettings::isConfigured() && MaintenanceSettings::get('is_enabled', false) && !BackendAuth::getUser()) {
         $page = Page::loadCached($this->theme, MaintenanceSettings::get('cms_page'));
     }
     /*
      * Extensibility
      */
     if (($event = $this->fireEvent('page.beforeDisplay', [$url, $page], true)) || ($event = Event::fire('cms.page.beforeDisplay', [$this, $url, $page], true))) {
         if ($event instanceof Page) {
             $page = $event;
         } else {
             return $event;
         }
     }
     /*
      * If the page was not found, render the 404 page - either provided by the theme or the built-in one.
      */
     if (!$page) {
         $this->setStatusCode(404);
         // Log the 404 request
         if (!App::runningUnitTests()) {
             RequestLog::add();
         }
         if (!($page = $this->router->findByUrl('/404'))) {
             return Response::make(View::make('cms::404'), $this->statusCode);
         }
     }
     $this->page = $page;
     /*
      * If the page doesn't refer any layout, create the fallback layout.
      * Otherwise load the layout specified in the page.
      */
     if (!$page->layout) {
         $layout = Layout::initFallback($this->theme);
     } elseif (($layout = Layout::loadCached($this->theme, $page->layout)) === null) {
         throw new CmsException(Lang::get('cms::lang.layout.not_found', ['name' => $page->layout]));
     }
     $this->layout = $layout;
     /*
      * The 'this' variable is reserved for default variables.
      */
     $this->vars['this'] = ['page' => $this->page, 'layout' => $this->layout, 'theme' => $this->theme, 'param' => $this->router->getParameters(), 'controller' => $this, 'environment' => App::environment(), 'session' => App::make('session')];
     /*
      * Check for the presence of validation errors in the session.
      */
     $this->vars['errors'] = Config::get('session.driver') && Session::has('errors') ? Session::get('errors') : new \Illuminate\Support\ViewErrorBag();
     /*
      * Handle AJAX requests and execute the life cycle functions
      */
     $this->initCustomObjects();
     $this->initComponents();
     /*
      * Give the layout and page an opportunity to participate
      * after components are initialized and before AJAX is handled.
      */
     if ($this->layoutObj) {
         CmsException::mask($this->layout, 300);
         $this->layoutObj->onInit();
         CmsException::unmask();
     }
     CmsException::mask($this->page, 300);
     $this->pageObj->onInit();
     CmsException::unmask();
     /*
      * Extensibility
      */
     if (($event = $this->fireEvent('page.init', [$url, $page], true)) || ($event = Event::fire('cms.page.init', [$this, $url, $page], true))) {
         return $event;
     }
     /*
      * Execute AJAX event
      */
     if ($ajaxResponse = $this->execAjaxHandlers()) {
//.........这里部分代码省略.........
开发者ID:janusnic,项目名称:23copperleaf,代码行数:101,代码来源:Controller.php

示例11: boot

 public function boot()
 {
     $backendUri = Config::get('cms.backendUri');
     $requestUrl = Request::url();
     $currentHostUrl = Request::getHost();
     /*
      * Get domain to theme bindings from cache, if it's not there, load them from database,
      * save to cache and use for theme selection.
      */
     $binds = Cache::rememberForever('julius_multidomain_settings', function () {
         try {
             $cacheableRecords = Setting::generateCacheableRecords();
         } catch (\Illuminate\Database\QueryException $e) {
             if (BackendAuth::check()) {
                 Flash::error(trans('julius.multidomain:lang.flash.db-error'));
             }
             return null;
         }
         return $cacheableRecords;
     });
     /*
      * Oooops something went wrong, abort.
      */
     if ($binds === null) {
         return;
     }
     /*
      * If current request is in backend scope, do not continue
      */
     if (preg_match('/\\' . $backendUri . '/', $requestUrl)) {
         return;
     }
     /*
      * Check if this request is in backend scope and is using domain,
      * that is protected from using backend
      */
     foreach ($binds as $domain => $bind) {
         if (preg_match('/\\' . $backendUri . '/', $requestUrl) && preg_match('/' . $currentHostUrl . '/i', $domain) && $bind['is_protected']) {
             return App::abort(401, 'Unauthorized.');
         }
     }
     /*
      * Overide the rainlab pages with custom domain ones
      *
      */
     $menuItemsToOveride = [];
     foreach ($binds as $domain => $value) {
         if (isset($value['page_url'])) {
             $menuItemsToOveride[] = ['domain' => $domain, 'url' => $value['page_url'], 'type' => $value['type']];
         }
     }
     Event::listen('cms.router.beforeRoute', function () use($menuItemsToOveride, $currentHostUrl, $requestUrl) {
         $url = null;
         $type = null;
         $domain = null;
         foreach ($menuItemsToOveride as $key => $value) {
             $configuredDomain = $value['domain'];
             $currentHostUrl = Request::url();
             if ($currentHostUrl === $configuredDomain) {
                 $url = $value['url'];
                 $domain = $value['domain'];
                 $type = $value['type'];
             }
         }
         if (!is_null($url)) {
             if ($type === 'pages_plugin') {
                 return Controller::instance()->initCmsPage($url);
             } elseif ($type === 'cms_pages') {
                 $theme = Theme::getEditTheme();
                 $router = new Router(Theme::getEditTheme());
                 for ($pass = 1; $pass <= 2; $pass++) {
                     $fileName = null;
                     $urlList = [];
                     /*
                      * Find the page by URL
                      */
                     if (!$fileName) {
                         if ($router->match($url)) {
                             $fileName = $router->matchedRoute();
                         }
                     }
                     /*
                      * Return the page
                      */
                     if ($fileName) {
                         if (($page = Page::loadCached($theme, $fileName)) === null) {
                             /*
                              * If the page was not found on the disk, clear the URL cache
                              * and repeat the routing process.
                              */
                             if ($pass == 1) {
                                 continue;
                             }
                             return null;
                         }
                         return $page;
                     }
                     return null;
                 }
             }
//.........这里部分代码省略.........
开发者ID:Kabangi,项目名称:subdomainlandingpages,代码行数:101,代码来源:Plugin.php


注:本文中的Cms\Classes\Page::loadCached方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。