Ejemplo n.º 1
0
 /**
  * beforeRender
  *
  * @param Controller $controller Controller
  * @return void
  * @throws NotFoundException
  */
 public function beforeRender(Controller $controller)
 {
     //RequestActionの場合、スキップする
     if (!empty($controller->request->params['requested'])) {
         return;
     }
     $this->controller = $controller;
     $this->__prepare();
     //pathからページデータ取得
     if (isset($this->controller->viewVars['page'])) {
         $page = $this->controller->viewVars['page'];
     } else {
         $this->Page = ClassRegistry::init('Pages.Page');
         $page = $this->Page->getPageWithFrame(Current::read('Page.permalink'));
         if (empty($page)) {
             throw new NotFoundException();
         }
     }
     if (Current::hasSettingMode() && Current::isSettingMode() && Current::permission('page_editable')) {
         $this->controller->request->data['ContainersPage'] = Hash::combine($page, 'Container.{n}.type', 'Container.{n}.ContainersPage');
     }
     ////cancelUrlをセット
     //if (! isset($this->controller->viewVars['cancelUrl'])) {
     //	$this->controller->set('cancelUrl', $page['Page']['permalink']);
     //}
     //Pluginデータ取得
     $pluginsRoom = ClassRegistry::init('PluginManager.PluginsRoom');
     $plugins = $pluginsRoom->getPlugins($page['Page']['room_id'], Current::read('Language.id'));
     //ページHelperにセット
     $results = array('containers' => Hash::combine($page['Container'], '{n}.type', '{n}'), 'boxes' => Hash::combine($page['Box'], '{n}.id', '{n}', '{n}.container_id'), 'plugins' => $plugins);
     $this->controller->helpers['Pages.PageLayout'] = $results;
 }