当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::detect_uri方法代码示例

本文整理汇总了PHP中Request::detect_uri方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::detect_uri方法的具体用法?PHP Request::detect_uri怎么用?PHP Request::detect_uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Request的用法示例。


在下文中一共展示了Request::detect_uri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load_themes

 /**
  * Load the active theme.
  *
  * This is called at bootstrap time.
  * We will only ever have one theme active for any given request.
  *
  * @uses Kohana::modules
  */
 public static function load_themes()
 {
     $config = Config::load('site');
     self::$themes = self::available(FALSE);
     //set admin theme based on path info
     $path = ltrim(Request::detect_uri(), '/');
     Theme::$is_admin = $path == "admin" || !strncmp($path, "admin/", 6);
     if (Theme::$is_admin) {
         // Load the admin theme
         Theme::$active = $config->get('admin_theme', 'cerber');
     } else {
         // Load the site theme
         Theme::$active = $config->get('theme', 'cerber');
     }
     //Set mobile theme, if enabled and mobile request
     if (Request::is_mobile() and $config->get('mobile_theme', FALSE)) {
         // Load the mobile theme
         Theme::$active = $config->get('mobile_theme', 'cerber');
     }
     // Admins can override the site theme, temporarily. This lets us preview themes.
     if (User::is_admin() and isset($_GET['theme']) and $override = Text::plain($_GET['theme'])) {
         Theme::$active = $override;
     }
     //Finally set the active theme
     Theme::set_theme();
 }
开发者ID:ultimateprogramer,项目名称:cms,代码行数:34,代码来源:theme.php

示例2: __construct

 public function __construct($template = NULL, array $partials = NULL, $alien_call = false)
 {
     // Если объект создается сторонним приложением для использования
     // определенных функция - конструктор надо освободить от выполнения
     // лишних операций
     if (!empty($alien_call)) {
         return;
     }
     // Получаем нужные настройки админ.части
     $this->site_name = $this->get_variable('site_name');
     $this->js_path = $this->get_variable('js_path');
     $this->css_path = $this->get_variable('css_path');
     $this->image_path = $this->get_variable('image_path');
     $this->packages_path = $this->get_variable('packages_path');
     // Фомируем текущую дату для использования в шаблоне
     $this->datetime = date('H:i d/m/y');
     // Получаем ID из запроса
     $this->request = new Request(Request::detect_uri());
     $this->id = $this->request->param('id');
     // Формируем пользователя
     if (empty($this->auth)) {
         $this->auth = Auth::instance();
         $this->user = $this->auth->get_user();
         if (!empty($this->user)) {
             // Узнаем роль пользователя (помимо роли Login)
             $roleuser = Sprig::factory('roleuser')->load(DB::select('*')->where('user_id', '=', $this->user->id)->and_where('role_id', '!=', '1'), NULL);
             // Вытаскиваем роль
             if (!empty($roleuser[0]->role_id)) {
                 $this->role = Sprig::factory('role', array('id' => $roleuser[0]->role_id))->load();
             }
         }
     }
     parent::__construct($template, $partials);
 }
开发者ID:bosoy83,项目名称:progtest,代码行数:34,代码来源:layout.php

示例3: instance

 public static function instance(&$uri = TRUE)
 {
     if (!Request::$instance) {
         if (!empty($_SERVER['HTTPS']) and filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN)) {
             Request::$protocol = 'https';
         }
         if (isset($_SERVER['REQUEST_METHOD'])) {
             Request::$method = $_SERVER['REQUEST_METHOD'];
         }
         if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
             Request::$is_ajax = TRUE;
         }
         Request::$client_ip = self::get_client_ip();
         if (Request::$method !== 'GET' and Request::$method !== 'POST') {
             parse_str(file_get_contents('php://input'), $_POST);
         }
         if (isset($_SERVER['HTTP_USER_AGENT'])) {
             Request::$user_agent = $_SERVER['HTTP_USER_AGENT'];
         }
         if (isset($_SERVER['HTTP_REFERER'])) {
             Request::$referrer = $_SERVER['HTTP_REFERER'];
         }
         if ($uri === TRUE) {
             $uri = Request::detect_uri();
         }
         $uri = preg_replace('#//+#', '/', $uri);
         $uri = preg_replace('#\\.[\\s./]*/#', '', $uri);
         Request::$instance = new Request($uri);
     }
     return Request::$instance;
 }
开发者ID:andygoo,项目名称:kohana,代码行数:31,代码来源:Request.php

示例4: authenticate

 protected function authenticate()
 {
     if (!Auth::instance()->logged_in()) {
         $this->session->set('redirect', Request::detect_uri());
         $this->request->redirect($this->site . "/login");
     } else {
         $this->user = Auth::instance()->get_user();
     }
 }
开发者ID:samjiks,项目名称:semedng,代码行数:9,代码来源:ccontroller.php

示例5: before

 public function before()
 {
     parent::before();
     $this->view = new View_Pages_ErrorHandler();
     $this->view->set('page', URL::site(rawurldecode(Request::detect_uri())));
     // Internal request only!
     if (Request::$initial !== $this->request) {
         if ($message = rawurldecode($this->request->param('message'))) {
             $this->view->set('raw_message', $message);
         }
     } else {
         $this->request->action(404);
     }
     $action = $this->request->action();
     $this->response->status((int) $action);
     $this->view->set('code', $action);
 }
开发者ID:andygoo,项目名称:kohana_demo,代码行数:17,代码来源:error.php

示例6: find_current

 /**
  * Finds the current language or falls back to default if no available
  * language found
  *
  * @param   string  $uri  the URI
  * @return  string
  * @uses    Request::detect_uri
  * @uses    Lang::available_languages
  * @uses    Lang::find_default()
  */
 public static function find_current($uri = NULL)
 {
     if ($uri === NULL) {
         // Get the URI
         $uri = Request::detect_uri();
     }
     // Normalize URI
     $uri = ltrim($uri, '/');
     // Set available languages
     $available_languages = Lang::available_languages();
     if (!preg_match('~^(?:' . implode('|', $available_languages) . ')(?=/|$)~i', $uri, $matches)) {
         // Find the best default language
         $matches[0] = Lang::find_default();
     }
     // Return the detected language
     return strtolower($matches[0]);
 }
开发者ID:bikramjeetbajwa,项目名称:trackddb,代码行数:27,代码来源:Lang.php

示例7: get_response

 public function get_response()
 {
     $this->template = View::factory('base');
     $config = Kohana::$config->load('main')->site;
     $base = new Model_Base();
     $options = $base->getOptions();
     $this->template->styles = $config['styles'];
     $this->template->styles[] = 'css/menu.css';
     $this->template->scripts = $config['scripts'];
     $this->template->scripts[] = 'js/errors.js';
     $this->template->title = 'Ошибка 404 - Страница не найдена';
     $this->template->description = $options['description'];
     $this->template->keywords = $options['keywords'];
     $this->template->page_title = null;
     $header = View::factory('header');
     $footer = View::factory('footer');
     $this->template->header = $header;
     $this->template->footer = $footer;
     $this->template->for_cart = null;
     $this->template->top_menu = array(Request::factory('widgets/menu/index/4')->execute());
     $this->template->left_menu = null;
     $this->template->block_left = null;
     $this->template->block_right = null;
     $this->template->pathway = null;
     $this->message = '<h1>Упс! Ошибка 404.</h1><br><p>Запрашиваемая страница не найдена. Скорее всего она была перемещена или удалена.</p>';
     // Remembering that `$this` is an instance of HTTP_Exception_404
     //проверка редиректов
     $gid = 34;
     $materials = new Model_Material('group');
     $redirects = $materials->getMaterials($gid, 1000, 0);
     $url = Request::detect_uri();
     foreach ($redirects as $redirect) {
         if ($redirect['name'] == Kohana::$base_url . substr($url, 1)) {
             $fields = $materials->getFields2($redirect['id'], TRUE);
             $this->redirect = $fields['to'];
         }
     }
     if (Kohana::$environment === Kohana::PRODUCTION) {
         $view = View::factory('errors/404')->set('message', $this->message)->set('redirect', $this->redirect)->render();
     } else {
         $view = View::factory('errors/404')->set('message', $this->message)->render();
     }
     $this->template->block_center = array($view);
     $response = Response::factory()->status(404)->body($this->template->render());
     return $response;
 }
开发者ID:chernogolov,项目名称:blank,代码行数:46,代码来源:404.php

示例8: factory

 /**
  * Detect current page url
  *
  * @param $uri
  * @return Request
  */
 public static function factory($uri)
 {
     // If this is the initial request
     if (!Request::$initial) {
         if ($uri === TRUE) {
             // Attempt to guess the proper URI
             $uri = Request::detect_uri();
             $dir = str_replace('/', '\\/', DIR);
             $uri = preg_replace('/^' . $dir . '/', '/', $uri);
         }
         // Create the instance singleton
         Request::$initial = $request = new Request($uri);
     } else {
         $request = new Request($uri);
     }
     return $request;
 }
开发者ID:DrTeamRocks,项目名称:drmvc-framework,代码行数:23,代码来源:Request.php

示例9: delParamFromUrl

 public static function delParamFromUrl($param)
 {
     $url = Request::detect_uri();
     $arr = $_GET;
     //смотрим, есть ли параметры GET
     $base = new Model_Base();
     $arr = $base->delFromArray($arr, $param);
     $cnt = count($arr);
     if ($cnt > 0) {
         $url .= '?';
         foreach ($arr as $key => $value) {
             $url .= $key . '=' . $value . '&';
         }
         $url = substr($url, 0, -1);
     }
     unset($cnt);
     return $url;
 }
开发者ID:chernogolov,项目名称:blank,代码行数:18,代码来源:Request.php

示例10: factory

 /**
  * Extension of the main request factory. If none given, the URI will
  * be automatically detected. If the URI contains no language segment, the user
  * will be redirected to the same URI with the default language prepended.
  * If the URI does contain a language segment, I18n and locale will be set.
  * Also, a cookie with the current language will be set. Finally, the language
  * segment is chopped off the URI and normal request processing continues.
  *
  * @param   string  $uri URI of the request
  * @param   Cache   $cache
  * @param   array   $injected_routes an array of routes to use, for testing
  * @return  Request
  * @uses    Lang::config
  * @uses    Request::detect_uri
  * @uses    Lang::find_current
  * @uses    Lang::$default_prepended
  * @uses    Lang::$default
  * @uses    Request::lang_redirect
  * @uses    Request::$lang
  * @uses    I18n::$lang
  * @uses    Cookie::get
  * @uses    Lang::$cookie
  * @uses    Cookie::set
  */
 public static function factory($uri = TRUE, $client_params = array(), $allow_external = TRUE, $injected_routes = array())
 {
     // Load config
     $config = Lang::config();
     if ($uri === TRUE) {
         // We need the current URI
         $uri = Request::detect_uri();
     }
     // Get current language from URI
     $current_language = Lang::find_current($uri);
     if (!Lang::$default_prepended and $current_language === Lang::$default and strpos($uri, '/' . Lang::$default) === 0) {
         // If default is not prepended and current language is the default,
         // then redirect to the same URI, but with default language removed
         Request::lang_redirect(NULL, ltrim($uri, '/' . Lang::$default));
     } elseif (Lang::$default_prepended and $current_language === Lang::$default and strpos($uri, '/' . Lang::$default) !== 0) {
         // If the current language is the default which needs to be
         // prepended, but it's missing, then redirect to same URI but with
         // language prepended
         Request::lang_redirect($current_language, $uri);
     }
     // Language found in the URI
     Request::$lang = $current_language;
     // Store target language in I18n
     I18n::$lang = $config[Request::$lang]['i18n_code'];
     // Set locale
     setlocale(LC_ALL, $config[Request::$lang]['locale']);
     if (Cookie::get(Lang::$cookie) !== Request::$lang) {
         // Update language cookie if needed
         Cookie::set(Lang::$cookie, Request::$lang);
     }
     if (Lang::$default_prepended or Request::$lang !== Lang::$default) {
         // Remove language from URI if default is prepended or the language is not the default
         $uri = (string) substr($uri, strlen(Request::$lang) + 1);
     }
     // Continue normal request processing with the URI without language
     return parent::factory($uri, $client_params, $allow_external, $injected_routes);
 }
开发者ID:bikramjeetbajwa,项目名称:trackddb,代码行数:61,代码来源:Request.php

示例11: action_index

 public function action_index($options = array())
 {
     $breadcrumbs = new Model_Widgets_Breadcrumb();
     $paths[] = array("title" => "Главная", "path" => "/");
     $uri = Request::detect_uri();
     $dirs = explode("/", $uri);
     array_shift($dirs);
     foreach ($dirs as $dir) {
         $path = $breadcrumbs->getPath($dir);
         if ($path != FALSE) {
             $paths[] = array("title" => $path["name"], "path" => $path["path"]);
         }
     }
     $cnt = count($paths) - 1;
     $paths[$cnt]["path"] = "";
     // --- Не удалять!!! --------------------------------------------------
     $node = $paths[count($paths) - 1];
     $paths[0]["path"] = "";
     unset($paths[count($paths) - 1]);
     // --- /Не удалять!!! -------------------------------------------------
     $model = array("nodes" => $paths, "node" => $node);
     PC::debug($model, "breadcrumb");
     $this->set_template("/widgets/w_breadcrumb.php", "twig")->render($model)->body();
 }
开发者ID:chernogolov,项目名称:blank,代码行数:24,代码来源:Breadcrumb.php

示例12: add

 /**
  * Adds a message to the log
  *
  * Replacement values must be passed in to be
  * replaced using [strtr](http://php.net/strtr).
  *
  * Usage:
  * ~~~
  * $log->add(Log::ERROR, 'Could not locate user: :user', array(':user' => $user->name));
  * ~~~
  *
  * @param   string  $level       Level of message
  * @param   string  $message     Message body
  * @param   array   $values      Values to replace in the message [Optional]
  * @param   array   $additional  Additional custom parameters to supply to the log writer [Optional]
  * @return  Log
  *
  * @uses    Date::formatted_time
  * @uses    Date::$timestamp_format
  * @uses    Date::$timezone
  * @uses    Request::current
  * @uses    Request::initial
  * @uses    Request::uri
  * @uses    Request::detect_uri
  * @uses    Request::$client_ip
  * @uses    Request::$user_agent
  * @uses    Text::plain
  */
 public function add($level, $message, array $values = NULL, array $additional = NULL)
 {
     if ($values) {
         // Insert the values into the message
         $message = strtr($message, $values);
     }
     if (isset($additional['exception'])) {
         $trace = $additional['exception']->getTrace();
     } else {
         // Older PHP version don't have 'DEBUG_BACKTRACE_IGNORE_ARGS',
         // so manually remove the args from the backtrace
         if (!defined('DEBUG_BACKTRACE_IGNORE_ARGS')) {
             $trace = array_map(function ($item) {
                 unset($item['args']);
                 return $item;
             }, array_slice(debug_backtrace(FALSE), 1));
         } else {
             $trace = array_slice(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), 1);
         }
     }
     is_null($additional) or $additional = array();
     $request = Request::current();
     $uri = '';
     if ($request instanceof Request) {
         $uri = Request::initial()->uri();
     } elseif (!Kohana::$is_cli) {
         $uri = Request::detect_uri();
     }
     // Create a new message and timestamp it
     $this->_messages[] = array('time' => Date::formatted_time('now', Date::$timestamp_format, Date::$timezone), 'level' => $level, 'body' => $message, 'trace' => $trace, 'file' => isset($trace[0]['file']) ? $trace[0]['file'] : NULL, 'line' => isset($trace[0]['line']) ? $trace[0]['line'] : NULL, 'class' => isset($trace[0]['class']) ? $trace[0]['class'] : NULL, 'function' => isset($trace[0]['function']) ? $trace[0]['function'] : NULL, 'additional' => $additional, 'hostname' => Request::$client_ip, 'user_agent' => Request::$user_agent, 'referer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', 'url' => Text::plain($uri));
     if (Log::$write_on_add) {
         // Write logs as they are added
         $this->write();
     }
     return $this;
 }
开发者ID:ultimateprogramer,项目名称:cms,代码行数:64,代码来源:log.php

示例13: define

$modules = "modules";
$system = "system";
define("EXT", ".php");
define("DOCROOT", realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
error_reporting(E_ALL | E_NOTICE | E_STRICT);
if (!is_dir($application) and is_dir(DOCROOT . $application)) {
    $application = DOCROOT . $application;
}
if (!is_dir($modules) and is_dir(DOCROOT . $modules)) {
    $modules = DOCROOT . $modules;
}
if (!is_dir($system) and is_dir(DOCROOT . $system)) {
    $system = DOCROOT . $system;
}
define("APPPATH", realpath($application) . DIRECTORY_SEPARATOR);
define("MODPATH", realpath($modules) . DIRECTORY_SEPARATOR);
define("SYSPATH", realpath($system) . DIRECTORY_SEPARATOR);
unset($application, $modules, $system);
if (!defined("APPLICATION_START_TIME")) {
    define("APPLICATION_START_TIME", microtime(TRUE));
}
if (!defined("APPLICATION_START_MEMORY")) {
    define("APPLICATION_START_MEMORY", memory_get_usage());
}
require APPPATH . "bootstrap" . EXT;
//JsonApiApplication::$log->add(Log::EMERGENCY,'The world will end on :time.',[':time'=>time()+60]);
try {
    echo Request::factory(TRUE, array(), FALSE)->query($_GET)->post($_POST)->method($_SERVER["REQUEST_METHOD"])->execute()->send_headers(TRUE)->body();
} catch (Exception $e) {
    echo "You tried to reach: " . Request::detect_uri();
}
开发者ID:benshez,项目名称:DreamWeddingCeremomies,代码行数:31,代码来源:index.php

示例14: before

 public function before()
 {
     // Выполняем функцию родительского класса
     parent::before();
     $base = new Model_Base();
     $config = Kohana::$config->load('main')->site;
     $positions = Kohana::$config->load('main')->positions;
     $options = $base->getOptions();
     $auth = Auth::instance();
     if (isset($options['work']) && $options['work'] == 'TRUE' && $auth->logged_in('admin') == 0) {
         $this->template = View::factory('cap');
     }
     $this->template->title = $options['title'];
     $this->template->description = $options['description'];
     $this->template->keywords = $options['keywords'];
     $this->template->page_title = null;
     $this->template->links = array();
     // $cart = Request::factory("widgets/");
     $header = Request::factory('widgets/header/index')->execute();
     // ->bind('cart', $cart);
     $footer = Request::factory('widgets/footer/index')->execute();
     foreach ($positions as $key => $value) {
         $this->template->{$key} = $value;
     }
     $this->template->header = $header;
     $this->template->footer = $footer;
     if (isset($_GET['login'])) {
         //активируем пользователя
         $vData = $_GET;
         $validation = Validation::factory($vData);
         $validation->rule('username', 'not_empty');
         $validation->rule('username', 'min_length', array(':value', '2'));
         $validation->rule('username', 'max_length', array(':value', '250'));
         $validation->rule('password', 'not_empty');
         $validation->rule('password', 'min_length', array(':value', '6'));
         $validation->rule('password', 'max_length', array(':value', '50'));
         if (!$validation->check()) {
             $errors[] = $validation->errors('registrationErrors');
         } else {
             $auth = Auth::instance();
             $username = Arr::get($_GET, 'username', '');
             $password = Arr::get($_GET, 'password', '');
             if ($auth->login($username, $password)) {
                 Controller::redirect('/user');
             } else {
                 $errors[] = 'Не верный логин или пароль.';
             }
         }
     }
     if (isset($_GET['site_version'])) {
         if ($_GET['site_version'] == 'standart') {
             Cookie::set('site_version', 'standart');
         } else {
             Cookie::set('site_version', 'adaptive');
         }
     }
     $site_version = Cookie::get('site_version', 'adaptive');
     //проверка редиректов
     $gid = 46;
     $materials = new Model_Material('group');
     $redirects = $materials->getMaterials($gid, 1000, 0);
     $url = Request::detect_uri();
     foreach ($redirects as $redirect) {
         if ($redirect['name'] == DIRECTORY_SEPARATOR . substr($url, 1)) {
             $fields = $materials->getFields2($redirect['id'], TRUE);
             Controller::redirect(Kohana::$base_url . substr($fields['to'], 1), 301);
         }
     }
     $auth = Request::factory('widgets/auth/')->execute();
     $this->template->site_version = $site_version;
     $this->template->auth = $auth;
     $this->template->styles = array();
     $this->template->scripts = $config['scripts'];
 }
开发者ID:chernogolov,项目名称:blank,代码行数:74,代码来源:Main.php

示例15: explode

<?php

$url = explode('/', Request::detect_uri());
if (count($url) > 1) {
    array_shift($url);
    if (preg_match("/page(.*)/", $url[count($url) - 1])) {
        unset($url[count($url) - 1]);
    }
    $url = implode('/', $url);
} else {
    $url = '';
}
if (count($_GET) > 0) {
    $query = '?';
    $i = 0;
    foreach ($_GET as $key => $value) {
        ++$i;
        $query .= $key . '=' . $value;
        if ($i < count($_GET)) {
            $query .= '&amp';
        }
    }
} else {
    $query = '';
}
?>
<ul class="pagination pull-right">

    <?php 
if ($first_page !== FALSE) {
    ?>
开发者ID:chernogolov,项目名称:blank,代码行数:31,代码来源:basic2.php


注:本文中的Request::detect_uri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。