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


PHP URI::instance方法代码示例

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


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

示例1: redirect

 public function redirect()
 {
     $uri = URI::instance()->string();
     $routed_uri = false;
     $bounces = Kohana::config('redirect_301');
     if (is_null(Router::$controller) and is_array($bounces)) {
         foreach ($bounces as $key => $val) {
             // Trim slashes
             $key = trim($key, '/');
             $val = trim($val, '/');
             if (preg_match('#^' . $key . '$#u', $uri)) {
                 if (strpos($val, '$') !== FALSE) {
                     // Use regex routing
                     $routed_uri = preg_replace('#^' . $key . '$#u', $val, $uri);
                 } else {
                     // Standard routing
                     $routed_uri = $val;
                 }
                 // A valid route has been found
                 break;
             }
         }
     }
     if ($routed_uri !== false) {
         url::redirect($routed_uri, '301');
     }
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:27,代码来源:redirect_301.php

示例2: prepare_connection

 /**
  * Hook to prepare the database connection. Performs 2 tasks.
  *   1) Initialises the search path, unless configured not to do this (e.g. if this is set at db level).
  *   2) If this is a report request, sets the connection to read only.
  */
 public static function prepare_connection()
 {
     $uri = URI::instance();
     // we havent to proceed futher if a setup call was made
     if ($uri->segment(1) == 'setup_check') {
         return;
     }
     // continue to init the system
     //
     // add schema to the search path
     //
     $_schema = Kohana::config('database.default.schema');
     $query = '';
     if (!empty($_schema) && kohana::config('indicia.apply_schema') !== false) {
         $query = "SET search_path TO {$_schema}, public, pg_catalog;\n";
     }
     // Force a read only connection for reporting.
     if ($uri->segment(1) == 'services' && $uri->segment(2) == 'report') {
         $query .= "SET default_transaction_read_only TO true;\n";
     }
     if (!empty($query)) {
         $db = Database::instance();
         $db->query($query);
     }
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:30,代码来源:init.php

示例3: __construct

 /**
  * Loads URI, and Input into this controller.
  *
  * @return  void
  */
 public function __construct()
 {
     if (Kohana::$instance == NULL) {
         // Set the instance to the first controller loaded
         Kohana::$instance = $this;
     }
     // URI should always be available
     $this->uri = URI::instance();
     // Input should always be available
     $this->input = Input::instance();
     $this->db = new Database();
     $this->user_model = ORM::factory('user');
     $this->supplier_model = ORM::factory('supplier');
     $this->category_model = ORM::factory('category');
     $this->item_model = ORM::factory('item');
     $this->item_stock_model = ORM::factory('item_stock');
     $this->district_model = ORM::factory('district');
     $this->office_model = ORM::factory('office');
     $this->budget_model = ORM::factory('office_budget');
     $this->purchase_model = ORM::factory('purchase');
     $this->request_model = ORM::factory('request');
     $this->transaction_model = ORM::factory('transaction');
     $this->setting_model = ORM::factory('setting');
     $this->log_model = ORM::factory('log');
     $this->email_model = ORM::factory('email');
 }
开发者ID:humbleBeginner,项目名称:inventory-pho2,代码行数:31,代码来源:Controller.php

示例4: container

 public function container()
 {
     $id = URI::instance()->segment(3, false);
     $p = ORM::factory('plugin_instance', $id);
     if ($p->loaded) {
         echo PluginManager::instance()->get_plugin($p)->render();
     }
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:8,代码来源:plug.php

示例5: _setup_check

 /**
  * If not in the setup pages, but the indicia config file is missing, go to system setup.
  */
 public static function _setup_check()
 {
     $uri = URI::instance();
     $isOk = $uri->segment(1) == 'setup' || $uri->segment(1) == 'setup_check' || kohana::config('indicia.private_key', false, false) !== null;
     if (!$isOk) {
         url::redirect('setup_check');
     }
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:11,代码来源:setup_check.php

示例6: error_404

function error_404()
{
    if (Kohana::$instance == NULL) {
        Kohana::$instance = new Errors_Controller();
    }
    Kohana::log('error', 'Error 404 (steam.core.hooks): ' . URI::instance()->string());
    Kohana::show_404(null, 'common/error_404');
}
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:8,代码来源:errors.php

示例7: __construct

 /**
  * constructor, set up col data
  *
  * @author Andy Bennett
  */
 function __construct()
 {
     $this->container_blocks = array();
     $this->col_data = array('leftcolumn' => '', 'rightcolumn' => '', 'header' => '', 'footer' => '', 'history' => array(), 'show' => array(), 'extraHeadContent' => '', 'page_id' => URI::instance()->segment(1));
     $this->col_data['cssfiles'] = array();
     $this->col_data['jsfiles'] = array();
     // Singleton instance
     self::$instance = $this;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:14,代码来源:Display.php

示例8: get_type

 /**
  * return type
  *
  * @return string
  * @author Andy Bennett
  */
 public static function get_type()
 {
     $types = Kohana::config('sitemap.types');
     $type = URI::instance()->segment(1, 'page');
     if (!in_array($type, $types)) {
         $type = 'page';
     }
     return $type;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:15,代码来源:sitemap_helper.php

示例9: determine_current_page

 /**
  * Determines the current page, and sets the SQL offsets, in exactly
  * the same way as the original pagination library, except that this
  * method can be run **before** we know the total number of pages.
  * 
  * @return   void
  */
 public function determine_current_page()
 {
     if ($this->query_string !== '') {
         $this->current_page = isset($_GET[$this->query_string]) ? (int) $_GET[$this->query_string] : 1;
     } else {
         $this->current_page = (int) URI::instance()->segment($this->uri_segment);
     }
     $this->current_page = $current_page = max(1, $this->current_page);
     // Reset the sql offset based on current page
     $this->sql_offset = (int) ($this->current_page - 1) * $this->items_per_page;
 }
开发者ID:evansd-archive,项目名称:kohana-module--utilities,代码行数:18,代码来源:MY_Pagination.php

示例10: __construct

 /**
  * Loads URI, and Input into this controller.
  *
  * @return  void
  */
 public function __construct()
 {
     if (Lemon::$instance == NULL) {
         // Set the instance to the first controller loaded
         Lemon::$instance = $this;
     }
     // URI should always be available
     $this->uri = URI::instance();
     // Input should always be available
     $this->input = Input::instance();
 }
开发者ID:BGCX261,项目名称:zr4u-svn-to-git,代码行数:16,代码来源:Controller.php

示例11: index

 public function index()
 {
     $name = URI::instance()->segment(3, '');
     if (!strlen($name)) {
         exit('0');
     }
     $f = Kohana::find_file('page_tpl', $name);
     include $f;
     $r = json_encode($template);
     echo $r;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:11,代码来源:pagetpl.php

示例12: redirect

 public function redirect()
 {
     $bounces = Kohana::config('redirect_301');
     if (is_null(Router::$controller) and is_array($bounces)) {
         foreach ($bounces as $k => $v) {
             if (preg_match('#^' . $k . '$#u', URI::instance()->string())) {
                 header('HTTP/1.1 301 Moved Permanently');
                 url::redirect($v);
             }
         }
     }
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:12,代码来源:redirect_301.php

示例13: decode_url

 public static function decode_url()
 {
     $uri = URI::instance();
     $array = array();
     $array['class'] = urldecode($uri->segment(3));
     $array['where'] = urldecode($uri->segment(4));
     $array['orderby'] = urldecode($uri->segment(5));
     $array['limit'] = urldecode($uri->segment(6));
     foreach ($array as $key => $val) {
         $array[$key] = arr::strtoarray($val);
     }
     return $array;
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:13,代码来源:json.php

示例14: __upgrade

 public static function __upgrade()
 {
     $uri = URI::instance();
     // we havent to proceed futher if a setup call was made
     if ($uri->segment(1) == 'setup_check' || $uri->segment(2) == 'upgrade') {
         return;
     }
     // also do not proceed when responding to a web service call
     // as we may not have update permission on the database
     if ($uri->segment(1) == 'services') {
         return;
     }
     // Invoke the upgrader
     $upgrader = new Upgrade_Model();
     $upgrader->run();
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:16,代码来源:dev.php

示例15: get_list

 /**
  * return list
  *
  * @param object $lc 
  * @return array
  * @author Andy Bennett
  */
 public function get_list()
 {
     $data = array('action' => 'list', 'name' => $this->name, 'role' => User::instance()->get_role());
     Event::run('steamcore.aclcheck', $data);
     $tdata = array();
     $limit = 10;
     $page_num = $this->input->get('page', 1);
     $offset = ($page_num - 1) * $limit;
     $model = ORM::factory($this->setup['model'], null);
     $role = inflector::singular(URI::instance()->segment(1));
     $data['query'] = $model->where('role', $role)->find_all($limit, $offset);
     $data['controller'] = Kohana::instance()->uri->segment(1);
     $data['pagination'] = Pagination::factory(array('style' => 'digg', 'items_per_page' => $limit, 'query_string' => 'page', 'total_items' => $model->count_last_query()));
     // merge any passed data and the data returned from the model
     $tdata = array_merge($tdata, $data);
     // return the result
     return $tdata;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:25,代码来源:Authadmin.php


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