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


PHP Router::controller_path方法代码示例

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


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

示例1: count

 static function parse_url()
 {
     if (Router::$controller) {
         return;
     }
     // Work around problems with the CGI sapi by enforcing our default path
     if ($_SERVER["SCRIPT_NAME"] && "/" . Router::$current_uri == $_SERVER["SCRIPT_NAME"]) {
         Router::$controller_path = MODPATH . "gallery/controllers/albums.php";
         Router::$controller = "albums";
         Router::$method = 1;
         return;
     }
     $current_uri = html_entity_decode(Router::$current_uri, ENT_QUOTES);
     $item = ORM::factory("item")->where("relative_path_cache", $current_uri)->find();
     if (!$item->loaded) {
         // It's possible that the relative path cache for the item we're looking for is out of date,
         // so find it the hard way.
         $count = count(Router::$segments);
         foreach (ORM::factory("item")->where("name", html_entity_decode(Router::$segments[$count - 1], ENT_QUOTES))->where("level", $count + 1)->find_all() as $match) {
             if ($match->relative_path() == $current_uri) {
                 $item = $match;
             }
         }
     }
     if ($item && $item->loaded) {
         Router::$controller = "{$item->type}s";
         Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php";
         Router::$method = $item->id;
     }
 }
开发者ID:krgeek,项目名称:gallery3,代码行数:30,代码来源:MY_url.php

示例2: call_fallback_page

function call_fallback_page()
{
    if (Router::$controller === NULL) {
        Router::$controller = 'fallback_page';
        Router::$method = 'find_view';
        Router::$controller_path = APPPATH . 'controllers/fallback_page.php';
    }
}
开发者ID:hdragomir,项目名称:ProjectsLounge,代码行数:8,代码来源:fallback_page.php

示例3:

 /**
  * If Gallery is in maintenance mode, then force all non-admins to get routed to a "This site is
  * down for maintenance" page.
  */
 static function maintenance_mode()
 {
     $maintenance_mode = Kohana::config("core.maintenance_mode", false, false);
     if (Router::$controller != "login" && !empty($maintenance_mode) && !user::active()->admin) {
         Router::$controller = "maintenance";
         Router::$controller_path = MODPATH . "gallery/controllers/maintenance.php";
         Router::$method = "index";
     }
 }
开发者ID:Okat,项目名称:gallery3,代码行数:13,代码来源:gallery.php

示例4: count

 static function parse_url()
 {
     if (Router::$controller) {
         return;
     }
     $count = count(Router::$segments);
     foreach (ORM::factory("item")->where("name", Router::$segments[$count - 1])->where("level", $count + 1)->find_all() as $match) {
         if ($match->relative_path() == Router::$current_uri) {
             $item = $match;
         }
     }
     if (!empty($item)) {
         Router::$controller = "{$item->type}s";
         Router::$controller_path = APPPATH . "controllers/{$item->type}s.php";
         Router::$method = $item->id;
     }
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:17,代码来源:MY_url.php

示例5:

 static function parse_url()
 {
     if (Router::$controller) {
         return;
     }
     // Work around problems with the CGI sapi by enforcing our default path
     if ($_SERVER["SCRIPT_NAME"] && "/" . Router::$current_uri == $_SERVER["SCRIPT_NAME"]) {
         Router::$controller_path = MODPATH . "gallery/controllers/albums.php";
         Router::$controller = "albums";
         Router::$method = 1;
         return;
     }
     $item = self::get_item_from_uri(Router::$current_uri);
     if ($item && $item->loaded) {
         Router::$controller = "{$item->type}s";
         Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php";
         Router::$method = $item->id;
     }
 }
开发者ID:scarygary,项目名称:gallery3,代码行数:19,代码来源:MY_url.php

示例6: array

 static function parse_url()
 {
     if (Router::$controller) {
         return;
     }
     // Work around problems with the CGI sapi by enforcing our default path
     if ($_SERVER["SCRIPT_NAME"] && "/" . Router::$current_uri == $_SERVER["SCRIPT_NAME"]) {
         Router::$controller_path = MODPATH . "gallery/controllers/albums.php";
         Router::$controller = "albums";
         Router::$method = 1;
         return;
     }
     $item = item::find_by_relative_url(html_entity_decode(Router::$current_uri, ENT_QUOTES));
     if ($item && $item->loaded()) {
         Router::$controller = "{$item->type}s";
         Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php";
         Router::$method = "show";
         Router::$arguments = array($item);
     }
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:20,代码来源:MY_url.php

示例7: ReflectionClass

 /**
  * If the gallery is only available to registered users and the user is not logged in, present
  * the login page.
  */
 static function private_gallery()
 {
     if (identity::active_user()->guest && !access::user_can(identity::guest(), "view", item::root()) && php_sapi_name() != "cli") {
         try {
             $class = new ReflectionClass(ucfirst(Router::$controller) . '_Controller');
             $allowed = $class->getConstant("ALLOW_PRIVATE_GALLERY") === true;
         } catch (ReflectionClass $e) {
             $allowed = false;
         }
         if (!$allowed) {
             if (Router::$controller == "admin") {
                 // At this point we're in the admin theme and it doesn't have a themed login page, so
                 // we can't just swap in the login controller and have it work.  So redirect back to the
                 // root item where we'll run this code again with the site theme.
                 url::redirect(item::root()->abs_url());
             } else {
                 Session::instance()->set("continue_url", url::abs_current());
                 Router::$controller = "login";
                 Router::$controller_path = MODPATH . "gallery/controllers/login.php";
                 Router::$method = "html";
             }
         }
     }
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:28,代码来源:gallery.php

示例8: setup

 /**
  * Router setup routine. Automatically called during Kohana setup process.
  *
  * @return  void
  */
 public static function setup()
 {
     if (!empty($_SERVER['QUERY_STRING'])) {
         // Set the query string to the current query string
         Router::$query_string = '?' . trim($_SERVER['QUERY_STRING'], '&/');
     }
     if (Router::$routes === NULL) {
         // Load routes
         Router::$routes = Kohana::config('routes');
     }
     // Default route status
     $default_route = FALSE;
     if (Router::$current_uri === '') {
         // Make sure the default route is set
         if (!isset(Router::$routes['_default'])) {
             throw new Kohana_Exception('core.no_default_route');
         }
         // Use the default route when no segments exist
         Router::$current_uri = Router::$routes['_default'];
         // Default route is in use
         $default_route = TRUE;
     }
     // Make sure the URL is not tainted with HTML characters
     Router::$current_uri = html::specialchars(Router::$current_uri, FALSE);
     // Remove all dot-paths from the URI, they are not valid
     Router::$current_uri = preg_replace('#\\.[\\s./]*/#', '', Router::$current_uri);
     // At this point segments, rsegments, and current URI are all the same
     Router::$segments = Router::$rsegments = Router::$current_uri = trim(Router::$current_uri, '/');
     // Set the complete URI
     Router::$complete_uri = Router::$current_uri . Router::$query_string;
     // Explode the segments by slashes
     Router::$segments = ($default_route === TRUE or Router::$segments === '') ? array() : explode('/', Router::$segments);
     if ($default_route === FALSE and count(Router::$routes) > 1) {
         // Custom routing
         Router::$rsegments = Router::routed_uri(Router::$current_uri);
     }
     // The routed URI is now complete
     Router::$routed_uri = Router::$rsegments;
     // Routed segments will never be empty
     Router::$rsegments = explode('/', Router::$rsegments);
     // Prepare to find the controller
     $controller_path = '';
     $method_segment = NULL;
     // Paths to search
     $paths = Kohana::include_paths();
     foreach (Router::$rsegments as $key => $segment) {
         // Add the segment to the search path
         $controller_path .= $segment;
         $found = FALSE;
         foreach ($paths as $dir) {
             // Search within controllers only
             $dir .= 'controllers/';
             if (is_dir($dir . $controller_path) or is_file($dir . $controller_path . EXT)) {
                 // Valid path
                 $found = TRUE;
                 // The controller must be a file that exists with the search path
                 if ($c = str_replace('\\', '/', realpath($dir . $controller_path . EXT)) and is_file($c) and strpos($c, $dir) === 0) {
                     // Set controller name
                     Router::$controller = $segment;
                     // Change controller path
                     Router::$controller_path = $c;
                     // Set the method segment
                     $method_segment = $key + 1;
                     // Stop searching
                     break;
                 }
             }
         }
         if ($found === FALSE) {
             // Maximum depth has been reached, stop searching
             break;
         }
         // Add another slash
         $controller_path .= '/';
     }
     if ($method_segment !== NULL and isset(Router::$rsegments[$method_segment])) {
         // Set method
         Router::$method = Router::$rsegments[$method_segment];
         if (isset(Router::$rsegments[$method_segment + 1])) {
             // Set arguments
             Router::$arguments = array_slice(Router::$rsegments, $method_segment + 1);
         }
     }
     // Last chance to set routing before a 404 is triggered
     Event::run('system.post_routing');
     if (Router::$controller === NULL) {
         // No controller was found, so no page can be rendered
         Event::run('system.404');
     }
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:95,代码来源:Router.php

示例9: route

 /**
  * Определение запрашиваемого модуля и сегмента
  */
 public static function route()
 {
     self::parse_query();
     if (self::_check_segments()) {
         self::$segment1 = self::$parse['segment1'];
         self::$segment2 = self::$parse['segment2'];
         self::$segment3 = self::$parse['segment3'];
         if (empty(self::$segment1)) {
             if (file_exists(ROOT . 'modules/index/execute/index.php')) {
                 self::$controller_path = 'modules/index/execute/index.php';
                 self::$controller_name = 'index';
                 self::$action = '';
                 self::$page = '';
                 self::$module = 'index';
             } else {
                 self::$controller_exists = FALSE;
             }
         } elseif (!empty(self::$segment1) && !empty(self::$segment2)) {
             if (file_exists(ROOT . 'modules/' . self::$segment1 . '/execute/' . self::$segment1 . '.php')) {
                 self::$controller_path = 'modules/' . self::$segment1 . '/execute/' . self::$segment1 . '.php';
                 self::$controller_name = self::$segment1;
                 self::$action = self::$segment2;
                 self::$page = '';
                 self::$module = self::$segment1;
             } else {
                 self::$controller_exists = FALSE;
             }
         } elseif (!empty(self::$segment1)) {
             if (file_exists(ROOT . 'modules/' . self::$segment1 . '/execute/' . self::$segment1 . '.php')) {
                 self::$controller_path = 'modules/' . self::$segment1 . '/execute/' . self::$segment1 . '.php';
                 self::$controller_name = self::$segment1;
                 self::$action = '';
                 self::$page = '';
                 self::$module = self::$segment1;
             } else {
                 self::$controller_exists = FALSE;
             }
         } else {
             throw new Exception('00404');
         }
     }
     if (self::$controller_exists) {
         define('ROUTE_CONTROLLER_PATH', self::$controller_path);
         define('ROUTE_CONTROLLER_NAME', self::$controller_name);
         define('ROUTE_CONTROLLER_URL', self::$module . (self::$action ? '/' . self::$action : '') . (self::$page ? '/' . self::$page : ''));
         define('ROUTE_ACTION', self::$action);
         define('ROUTE_PAGE', self::$page);
         define('ROUTE_MODULE', self::$module);
     } elseif (!empty(self::$segment1)) {
         if (!empty(self::$segment2)) {
             if (is_numeric(self::$segment2)) {
                 if (!empty(self::$segment3)) {
                     self::$action = self::$segment3;
                 } else {
                     self::$action = "showThread";
                 }
             } else {
                 self::$action = self::$segment2;
             }
         } else {
             self::$action = "showBoard";
         }
         define('ROUTE_CONTROLLER_PATH', ROOT . 'modules/index/execute/index.php');
         define('ROUTE_CONTROLLER_NAME', 'index');
         define('ROUTE_CONTROLLER_URL', self::$segment1);
         define('ROUTE_ACTION', self::$action);
         define('ROUTE_SEGMENT', self::$segment2);
         define('ROUTE_PAGE', self::$segment3);
         define('ROUTE_MODULE', 'index');
         define('ROUTE_LOGIN', self::$segment1);
     } else {
         throw new Exception('00404');
     }
     //;
 }
开发者ID:alejes,项目名称:PrivateChan,代码行数:78,代码来源:router.php

示例10: initialize

 /**
  * Setup routine.
  * Automatically called during the core initialization process.
  * @return bool
  * @throws Exception_Exido
  * @throws Exception_Exido_404
  */
 public static function initialize()
 {
     if (self::$_routes === null) {
         // Load routes
         self::$_routes = Exido::config('route');
     }
     // Debug log
     if (Exido::$log_debug) {
         Exido::$log->add('EXIDO_DEBUG_LOG', __('Initialize routing'));
     }
     $default_route = false;
     if (self::$current_uri == Exido::config('global.core.index_file')) {
         self::$current_uri = '';
     }
     if (!isset(self::$_routes['default_method'])) {
         self::$_routes['default_method'] = self::$method;
     }
     // Remove web-root directory
     if (WEB_ROOT != '') {
         self::$web_root = trim(WEB_ROOT, '/');
         // Remove the suffix from the URL if needed
         self::$current_uri = trim(preg_replace("|^" . self::$web_root . "|", "", self::$current_uri), '/');
     }
     if (self::$current_uri == '') {
         // If default controller is not set
         if (!isset(self::$_routes['default_controller']) or self::$_routes['default_controller'] == '') {
             self::$_routes['default_controller'] = self::$default;
         }
         // Use the default route when no segments exist
         self::$current_uri = self::$_routes['default_controller'];
         // Default route is in use
         $default_route = true;
     }
     if ($default_route == false) {
         // Remove the suffix from the URL if needed
         self::$current_uri = preg_replace("|" . preg_quote(Exido::config('global.core.url_suffix')) . "\$|", "", self::$current_uri);
         // Strip arguments
         if ($argspos = strpos(self::$current_uri, '?')) {
             self::$current_uri = substr(self::$current_uri, 0, $argspos);
         }
         // Explode the segments by slashes
         foreach (explode("/", preg_replace("|/*(.+?)/*\$|", "\\1", self::$current_uri)) as $val) {
             $val = trim($val);
             // Check for allowed characters
             if (Exido::config('global.core.permitted_uri_chars') != '' and $val != '') {
                 // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards
                 // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern
                 if (!preg_match("|^[" . str_replace(array('\\-', '\\-'), '-', preg_quote(Exido::config('global.core.permitted_uri_chars'), '-')) . "]+\$|i", $val)) {
                     throw new Exception_Exido('The requested URL %s has a disallowed characters', array($val));
                 }
             }
             if ($val != '') {
                 self::$segments[] = self::$rsegments[] = $val;
             }
         }
         // Custom routing
         if (count(self::$_routes) > 0) {
             self::$rsegments = self::_getRouted(self::$segments);
         }
         //array_merge(self::_getRouted(self::$segments), self::$segments);
     }
     if ($default_route == true) {
         self::$rsegments[] = self::$current_uri;
     }
     // Prepare to find the controller
     $controller_path = '';
     $method_segment = null;
     $controller_name = array();
     // Paths to search
     $paths = Exido::getIncludePaths();
     foreach (self::$rsegments as $key => $segment) {
         // Add the segment to the search path
         $controller_path .= $segment;
         $found = false;
         // Set segment into controller name
         $controller_name[] = ucfirst($segment);
         foreach ($paths as $dir) {
             // Search within controllers only
             $dir .= 'controller/';
             if (is_dir($dir . $controller_path) or is_file($dir . $controller_path . '.php')) {
                 // Valid path
                 $found = true;
                 // The controller must be a file that exists with the search path
                 if ($c = realpath($dir . $controller_path . '.php') and is_file($c)) {
                     // Set the controller name
                     self::$controller = ucfirst(strtolower(EXIDO_ENVIRONMENT_NAME)) . '_Controller_' . implode('_', $controller_name);
                     self::$controller_view = $controller_path;
                     // Set the controller path
                     self::$controller_path = $c;
                     // Set the method
                     $method_segment = $key + 1;
                     // Stop searching
                     break;
//.........这里部分代码省略.........
开发者ID:esironal,项目名称:exidoengine,代码行数:101,代码来源:router.php


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