示例#1
0
 protected function loadData()
 {
     $manager = UpdateManager::instance();
     $this->vars['inMaintenance'] = MaintenanceSettings::get('is_enabled');
     $this->vars['showUpdates'] = $this->controller->user->hasAccess('system.manage_updates');
     $this->vars['updates'] = $manager->check();
 }
示例#2
0
 protected function loadData()
 {
     $manager = UpdateManager::instance();
     $manager->requestUpdateList();
     $this->vars['inMaintenance'] = MaintenanceSettings::get('is_enabled');
     $this->vars['updates'] = DB::table('system_parameters')->where('item', 'count')->pluck('value');
     $this->vars['plugins'] = DB::table('system_plugin_versions')->count();
     $themes = 0;
     if ($handle = opendir('themes')) {
         while (false !== ($entry = readdir($handle))) {
             if ($entry != '.' && $entry != '..' && !is_file($entry)) {
                 $themes++;
             }
         }
         closedir($handle);
     }
     $this->vars['themes'] = $themes;
 }
示例#3
0
 /**
  * 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);
 }
示例#4
0
 /**
  * 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()) {
         return $ajaxResponse;
     }
     /*
      * Execute postback handler
      */
     if (($handler = post('_handler')) && ($handlerResponse = $this->runAjaxHandler($handler)) && $handlerResponse !== true) {
         return $handlerResponse;
     }
     /*
      * Execute page lifecycle
      */
     if ($cycleResponse = $this->execPageCycle()) {
         return $cycleResponse;
     }
     /*
      * Extensibility
      */
     if (($event = $this->fireEvent('page.beforeRenderPage', [$page], true)) || ($event = Event::fire('cms.page.beforeRenderPage', [$this, $page], true))) {
         $this->pageContents = $event;
     } else {
         /*
          * Render the page
          */
         CmsException::mask($this->page, 400);
         $this->loader->setObject($this->page);
         $template = $this->twig->loadTemplate($this->page->getFullPath());
         $this->pageContents = $template->render($this->vars);
         CmsException::unmask();
     }
     /*
      * Render the layout
      */
     CmsException::mask($this->layout, 400);
     $this->loader->setObject($this->layout);
     $template = $this->twig->loadTemplate($this->layout->getFullPath());
     $result = $template->render($this->vars);
     CmsException::unmask();
     /*
      * 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);
 }