Ignore:
Timestamp:
2011/01/06 07:00:09 (15 years ago)
Author:
Seasoft
Message:

#714(パス指定によるリダイレクトの記述を簡潔にする)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/SC_Response.php

    r19832 r19834  
    132132 
    133133    /** 
    134      * @param string $location 「アプリケーションルートからの相対パス」「現在のURLからの相対パス」「URL」のいずれか 
     134     * @param string $location 「url-path」「現在のURLからのパス」「URL」のいずれか 
    135135     * @return void 
    136136     * @static 
     
    138138    function sendRedirect($location, $arrQueryString = array(), $inheritQueryString = false, $useSsl = null) { 
    139139 
    140         // アプリケーションルートからの相対パス 
     140        // url-path → URL 変換 
    141141        if ($location[0] === '/') { 
    142             if (!is_bool($useSsl)) { 
    143                 $useSsl = SC_Utils_Ex::sfIsHTTPS(); 
    144             } 
    145             $url = ($useSsl ? HTTPS_URL : HTTP_URL) . substr($location, 1); 
    146         } 
     142            $netUrl = new Net_URL(); 
     143            $netUrl->path = $location; 
     144            $location = $netUrl->getUrl(); 
     145        } 
     146 
    147147        // URL の場合 
    148         elseif (preg_match('/^https?:/', $location)) { 
     148        if (preg_match('/^https?:/', $location)) { 
    149149            $url = $location; 
    150150            if (is_bool($useSsl)) { 
     
    161161            } 
    162162        } 
    163         // 現在のURLからの相対パス 
     163        // 現在のURLからのパス 
    164164        else { 
    165165            if (!is_bool($useSsl)) { 
     
    171171        } 
    172172 
    173         $netUrl = new Net_URL($url); 
    174         $arrQueryString = array_merge($netUrl->querystring, $arrQueryString); 
    175  
    176         if ($inheritQueryString) { 
    177             if (!empty($_SERVER['QUERY_STRING'])) { 
    178                 $netUrl->addRawQueryString($_SERVER['QUERY_STRING']); 
    179             } 
    180         } 
    181  
    182         foreach ($arrQueryString as $key => $val) { 
    183             $netUrl->addQueryString($key, $val); 
    184         } 
    185  
    186         $url = $netUrl->getURL(); 
    187  
     173        // アプリケーション内での遷移時の処理 
    188174        $pattern = '/^(' . preg_quote(HTTP_URL, '/') . '|' . preg_quote(HTTPS_URL, '/') . ')/'; 
    189175        if (preg_match($pattern, $url)) { 
     176            $netUrl = new Net_URL($url); 
     177            $arrQueryString = array_merge($netUrl->querystring, $arrQueryString); 
     178            $netUrl->querystring = array(); 
     179 
     180            if ($inheritQueryString) { 
     181                if (!empty($_SERVER['QUERY_STRING'])) { 
     182                    $netUrl->addRawQueryString($_SERVER['QUERY_STRING']); 
     183                } 
     184            } 
     185 
     186            foreach ($arrQueryString as $key => $val) { 
     187                $netUrl->addQueryString($key, $val); 
     188            } 
     189 
     190            $url = $netUrl->getURL(); 
     191 
    190192            $session = SC_SessionFactory::getInstance(); 
    191193            if (SC_MobileUserAgent::isMobile() || $session->useCookie() == false) { 
     
    202204 
    203205    /** 
     206     * HTML_PATH からのパスを指定してリダイレクトする 
     207     * 
     208     * @param string $location /html/ からの相対パス 
     209     * @return void 
     210     * @static 
     211     */ 
     212    function sendRedirectFromUrlPath($location, $arrQueryString = array(), $inheritQueryString = false, $useSsl = null) { 
     213        $location = URL_PATH . $location; 
     214        SC_Response_Ex::sendRedirect($location, $arrQueryString, $inheritQueryString, $useSsl); 
     215    } 
     216 
     217    /** 
    204218     * @static 
    205219     */ 
     
    213227        $netUrl->querystring = array(); 
    214228 
    215         $this->sendRedirect($netUrl->getURL(), $arrQueryString); 
     229        SC_Response_Ex::sendRedirect($netUrl->getURL(), $arrQueryString); 
    216230    } 
    217231 
Note: See TracChangeset for help on using the changeset viewer.