/** * 現在のページが固定ページかどうかを判定する * * @return bool 固定ページの場合は true を返す */ public function isPage() { $here = $this->getHere(); /** * ページ連携していた場合prefixを除外する */ $here = preg_replace('/^\\/' . Configure::read('BcRequest.agentAlias') . '\\//', '/' . Configure::read('BcRequest.agentPrefix') . '/', $here); if ($this->_View->name == 'Pages' && preg_match('/(.+)_display$/', $this->request->params['action'], $maches)) { if ($this->_Page->isLinked($maches[1], $here)) { $here = preg_replace('/^\\/' . Configure::read('BcRequest.agentPrefix') . '\\//', '/', $here); } } return $this->_Page->isPageUrl($here); }
/** * 固定ページのコンテンツを出力する * * @return void */ public function content() { $agent = ''; if (Configure::read('BcRequest.agentPrefix')) { $agent = Configure::read('BcRequest.agentPrefix'); } $path = $this->_View->getVar('pagePath'); if ($agent) { $url = '/' . implode('/', $this->request->params['pass']); $linked = $this->Page->isLinked($agent, $url); if (!$linked) { $path = $agent . DS . $path; } } echo $this->_View->evaluate(getViewPath() . 'Pages' . DS . $path . '.php', $this->_View->viewVars); }
/** * 連携チェック * * @param string $agentPrefix * @param string $url * @param array $expected 期待値 * @param string $message テストが失敗した時に表示されるメッセージ * @dataProvider isLinkedDataProvider */ public function testIsLinked($agentPrefix, $url, $expected, $message = null) { Configure::write('BcApp', array('mobile' => true, 'smartphone' => true)); $result = $this->Page->isLinked($agentPrefix, $url); $this->assertEquals($expected, $result, $message); }