예제 #1
0
 /**
  * Finds URL for specified action.
  *
  * Returns an URL pointing to a combination of controller and action. Param
  * $url can be:
  * 	+ Empty - the method will find adress to actuall controller/action.
  * 	+ '/' - the method will find base URL of application.
  * 	+ A combination of controller/action - the method will find url for it.
  *
  * @param  mixed  $url    Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4"
  *                        or an array specifying any of the following: 'controller', 'action',
  *                        and/or 'plugin', in addition to named arguments (keyed array elements),
  *                        and standard URL arguments (indexed array elements)
  * @param boolean $full   If true, the full base URL will be prepended to the result
  * @return string  Full translated URL with base path.
  */
 public function url($url = null, $full = false, $sessionId = true)
 {
     if ($sessionId) {
         $url = addSessionId($url);
     }
     //======================================================================
     // FormHelper::createで id をキーとして使うので、ルーターでマッチしない場合がある。
     // id というキー名を除外する事で対応。
     //======================================================================
     if (is_array($url) && isset($url['id'])) {
         array_push($url, $url['id']);
         unset($url['id']);
     }
     if (is_array($url) && !isset($url['admin']) && !empty($this->request->params['admin'])) {
         $url = array_merge($url, array('admin' => true));
     }
     if (!is_array($url) && preg_match('/\\/(img|css|js|files)\\//', $url)) {
         return $this->webroot($url);
     } elseif (!is_array($url) && preg_match('/^javascript:/', $url)) {
         return $url;
     } else {
         return parent::url($url, $full);
     }
 }
예제 #2
0
 /**
  * Redirects to given $url, after turning off $this->autoRender.
  * Script execution is halted after the redirect.
  *
  * @param mixed $url A string or array-based URL pointing to another location within the app, or an absolute URL
  * @param integer $status Optional HTTP status code (eg: 404)
  * @param boolean $exit If true, exit() will be called after the redirect
  * @return mixed void if $exit = false. Terminates script if $exit = true
  * @access public
  */
 function redirect($url, $status = null, $exit = true)
 {
     $url = addSessionId($url, true);
     // 管理システムでのURLの生成が CakePHP の標準仕様と違っていたので調整
     // ※ Routing.admin を変更した場合
     if (!isset($url['admin']) && !empty($this->params['admin'])) {
         $url['admin'] = true;
     } elseif (isset($url['admin']) && !$url['admin']) {
         unset($url['admin']);
     }
     parent::redirect($url, $status, $exit);
 }
예제 #3
0
 /**
  * Redirects to given $url, after turning off $this->autoRender.
  * Script execution is halted after the redirect.
  *
  * @param mixed $url A string or array-based URL pointing to another location within the app, or an absolute URL
  * @param integer $status Optional HTTP status code (eg: 404)
  * @param boolean $exit If true, exit() will be called after the redirect
  * @return mixed void if $exit = false. Terminates script if $exit = true
  * @access public
  */
 function redirect($url, $status = null, $exit = true)
 {
     $url = addSessionId($url, true);
     parent::redirect($url, $status, $exit);
 }
예제 #4
0
 /**
  * URLにセッションIDを付加する
  */
 public function testAddSessionId()
 {
     // 初期化
     session_id('baser');
     session_name('BASERCMS');
     $_SERVER['REQUEST_URI'] = '/m/';
     $message = 'URLにセッションIDを正しく付加できません';
     $this->assertEquals('/?BASERCMS=baser', addSessionId('/', true), $message);
     $this->assertEquals('/?id=1&BASERCMS=baser', addSessionId('/?id=1', true), $message);
     $this->assertEquals('/?id=1&BASERCMS=baser', addSessionId('/?id=1&BASERCMS=1', true), $message);
     $this->assertEquals('/?id=1&BASERCMS=baser', addSessionId('/?id=1&BASERCMS=1', true), $message);
     // urlが配列の場合
     $url = array(0 => '/', '?' => array('id' => 1, 'BASERCMS' => 1));
     $expect = array(0 => '/', '?' => array('id' => 1, 'BASERCMS' => 'baser'));
     $this->assertEquals($expect, addSessionId($url, true), $message);
 }
예제 #5
0
 /**
  * Finds URL for specified action.
  *
  * Returns an URL pointing to a combination of controller and action. Param
  * $url can be:
  *	+ Empty - the method will find adress to actuall controller/action.
  *	+ '/' - the method will find base URL of application.
  *	+ A combination of controller/action - the method will find url for it.
  *
  * @param  mixed  $url    Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4"
  *                        or an array specifying any of the following: 'controller', 'action',
  *                        and/or 'plugin', in addition to named arguments (keyed array elements),
  *                        and standard URL arguments (indexed array elements)
  * @param boolean $full   If true, the full base URL will be prepended to the result
  * @return string  Full translated URL with base path.
  */
 function url($url = null, $full = false)
 {
     $url = addSessionId($url);
     //======================================================================
     // FormHelper::createで id をキーとして使うので、ルーターでマッチしない場合がある。
     // id というキー名を除外する事で対応。
     //======================================================================
     if (is_array($url) && isset($url['id'])) {
         array_push($url, $url['id']);
         unset($url['id']);
     }
     if (!isset($url['admin']) && !empty($this->params['admin'])) {
         $url['admin'] = true;
     } elseif (isset($url['admin']) && !$url['admin']) {
         unset($url['admin']);
     }
     return parent::url($url, $full);
 }
예제 #6
0
 /**
  * Finds URL for specified action.
  *
  * Returns an URL pointing to a combination of controller and action. Param
  * $url can be:
  * 	+ Empty - the method will find adress to actuall controller/action.
  * 	+ '/' - the method will find base URL of application.
  * 	+ A combination of controller/action - the method will find url for it.
  *
  * @param  mixed  $url    Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4"
  *                        or an array specifying any of the following: 'controller', 'action',
  *                        and/or 'plugin', in addition to named arguments (keyed array elements),
  *                        and standard URL arguments (indexed array elements)
  * @param boolean $full   If true, the full base URL will be prepended to the result
  * @return string  Full translated URL with base path.
  */
 public function url($url = null, $full = false, $sessionId = true)
 {
     if ($sessionId) {
         $url = addSessionId($url);
     }
     //======================================================================
     // FormHelper::createで id をキーとして使うので、ルーターでマッチしない場合がある。
     // id というキー名を除外する事で対応。
     //======================================================================
     if (is_array($url) && isset($url['id'])) {
         array_push($url, $url['id']);
         unset($url['id']);
     }
     if (is_array($url) && !isset($url['admin']) && !empty($this->request->params['admin'])) {
         $url = array_merge($url, array('admin' => true));
     }
     if (!is_array($url) && preg_match('/\\/(img|css|js|files)\\//', $url)) {
         return $this->webroot($url);
     } elseif (!is_array($url) && preg_match('/^javascript:/', $url)) {
         return $url;
     } else {
         if (!BcUtil::isAdminSystem() && !is_array($url) && !empty($this->request->params['Content'])) {
             $Content = ClassRegistry::init('Content');
             $url = $Content->getUrl($url, $full, @$this->_View->request->params['Site']['use_subdomain']);
         } else {
             $url = parent::url($url, $full);
         }
         $params = explode('?', $url);
         $url = preg_replace('/\\/index$/', '/', $params[0]);
         if (!empty($params[1])) {
             $url .= '?' . $params[1];
         }
         return $url;
     }
 }
예제 #7
0
 /**
  * Finds URL for specified action.
  *
  * Returns an URL pointing to a combination of controller and action. Param
  * $url can be:
  *	+ Empty - the method will find adress to actuall controller/action.
  *	+ '/' - the method will find base URL of application.
  *	+ A combination of controller/action - the method will find url for it.
  *
  * @param  mixed  $url    Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4"
  *                        or an array specifying any of the following: 'controller', 'action',
  *                        and/or 'plugin', in addition to named arguments (keyed array elements),
  *                        and standard URL arguments (indexed array elements)
  * @param boolean $full   If true, the full base URL will be prepended to the result
  * @return string  Full translated URL with base path.
  */
 function url($url = null, $full = false)
 {
     $url = addSessionId($url);
     return parent::url($url, $full);
 }