Example #1
0
 /**
  * 現在のページが固定ページかどうかを判定する
  *
  * @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);
 }
Example #2
0
 /**
  * 固定ページとして管理されているURLかチェックする
  * 
  * @param string $url URL
  * @param bool $expects true Or false
  * @return void
  * @dataProvider isPageUrlDataProvider
  */
 public function testIsPageUrl($url, $expects)
 {
     $result = $this->Page->isPageUrl($url);
     $this->assertEquals($result, $expects);
 }
Example #3
0
 /**
  * 固定ページ判定
  * 
  * @return boolean
  * @access public
  */
 function isPage()
 {
     return $this->Page->isPageUrl($this->getHere());
 }
Example #4
0
 /**
  * aタグを取得するだけのラッパー
  * 
  * @param string $title
  * @param string $url
  * @param array $htmlAttributes
  * @param boolean $confirmMessage
  * @param boolean $escapeTitle
  * @return string
  * @access public
  */
 function getLink($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = false)
 {
     $htmlAttributes = $this->executeHook('beforeBaserGetLink', $title, $url, $htmlAttributes, $confirmMessage, $escapeTitle);
     if (!empty($htmlAttributes['prefix'])) {
         if (!empty($this->params['prefix'])) {
             $url[$this->params['prefix']] = true;
         }
         unset($htmlAttributes['prefix']);
     }
     if (isset($htmlAttributes['forceTitle'])) {
         $forceTitle = $htmlAttributes['forceTitle'];
         unset($htmlAttributes['forceTitle']);
     } else {
         $forceTitle = false;
     }
     if (isset($htmlAttributes['ssl'])) {
         $ssl = true;
         unset($htmlAttributes['ssl']);
     } else {
         $ssl = false;
     }
     // 管理システムメニュー対策
     // プレフィックスが変更された場合も正常動作させる為
     // TODO メニューが廃止になったら削除
     if (!is_array($url)) {
         $url = preg_replace('/^\\/admin\\//', '/' . Configure::read('Routing.admin') . '/', $url);
     }
     $url = $this->getUrl($url);
     $_url = preg_replace('/^' . preg_quote($this->base, '/') . '\\//', '/', $url);
     $enabled = true;
     // 認証チェック
     if (isset($this->Permission) && !empty($this->_view->viewVars['user']['user_group_id'])) {
         $userGroupId = $this->_view->viewVars['user']['user_group_id'];
         if (!$this->Permission->check($_url, $userGroupId)) {
             $enabled = false;
         }
     }
     // ページ公開チェック
     if (empty($this->params['admin'])) {
         $adminPrefix = Configure::read('Routing.admin');
         if (isset($this->Page) && !preg_match('/^\\/' . $adminPrefix . '/', $_url)) {
             if ($this->Page->isPageUrl($_url) && !$this->Page->checkPublish($_url)) {
                 $enabled = false;
             }
         }
     }
     if (!$enabled) {
         if ($forceTitle) {
             return "<span>{$title}</span>";
         } else {
             return '';
         }
     }
     // 現在SSLのURLの場合、フルパスで取得
     if ($this->isSSL() || $ssl) {
         $_url = preg_replace("/^\\//", "", $_url);
         if (preg_match('/^admin\\//', $_url)) {
             $admin = true;
         } else {
             $admin = false;
         }
         if (Configure::read('App.baseUrl')) {
             $_url = 'index.php/' . $_url;
         }
         if (!$ssl && !$admin) {
             $url = Configure::read('Baser.siteUrl') . $_url;
         } else {
             $url = Configure::read('Baser.sslUrl') . $_url;
         }
     } else {
         $url = $_url;
     }
     $out = $this->HtmlEx->link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle);
     return $this->executeHook('afterBaserGetLink', $url, $out);
 }