示例#1
0
 /**
  * Main request singleton instance. If no URI is provided, the URI will
  * be automatically detected using PATH_INFO, REQUEST_URI, or PHP_SELF.
  *
  * @param   string   URI of the request
  * @return  Request
  */
 public static function instance(&$uri = TRUE)
 {
     $instance = parent::instance($uri);
     $index_page = Kohana::$index_file;
     $lang_uri_abbr = Kohana::config('appconf.lang_uri_abbr');
     $default_lang = Kohana::config('appconf.language_abbr');
     $lang_ignore = Kohana::config('appconf.lang_ignore');
     /* get the lang_abbr from uri segments */
     $segments = explode('/', $instance->uri);
     $lang_abbr = isset($segments[0]) ? $segments[0] : '';
     /* get current language */
     $cur_lang = $instance->param('lang', $default_lang);
     /* check for invalid abbreviation */
     if (!isset($lang_uri_abbr[$lang_abbr])) {
         /* check for abbreviation to be ignored */
         if ($cur_lang != $lang_ignore) {
             /* check and set the default uri identifier */
             $index_page .= empty($index_page) ? $default_lang : "/{$default_lang}";
             /* redirect after inserting language id */
             header('Location: ' . Url::base() . $index_page . '/' . $instance->uri);
             die;
         }
     }
     return $instance;
 }
示例#2
0
 public static function instance(&$uri = true)
 {
     if (!self::$instance) {
         self::$raw_req_body = @file_get_contents('php://input');
     }
     return parent::instance($uri);
 }
示例#3
0
 public static function instance(&$uri = TRUE)
 {
     if (!Request::$instance and !Kohana::$is_cli) {
         // Detect mobile environment from HTTP HOST
         Request::$is_mobile = !!strstr(URL::base(TRUE, TRUE), '//mobile.');
     }
     return parent::instance($uri);
 }