本文整理汇总了PHP中route类的典型用法代码示例。如果您正苦于以下问题:PHP route类的具体用法?PHP route怎么用?PHP route使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了route类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getAllRoutes
/**
* get all routes
* get the URLs, the variables, the modules and the actions of all routes, use the "/applications/config/routes.xml" file.
* @param string current url (optionnal)
* @return array list of routes object
*/
public function getAllRoutes($currentUrl = null)
{
//get content of the file.
$xml = new \DOMDocument();
$xml->load(__DIR__ . '/../applications/config/routes.xml');
$file = $xml->getElementsByTagName('route');
//parse the content.
$varsNames = array();
$varsValues = array();
$varsList = array();
foreach ($file as $line) {
//create the route.
$varsNames = explode(',', $line->getAttribute('vars'));
//get the name of all variables
$route = new route($line->getAttribute('url'), $line->getAttribute('module'), $line->getAttribute('action'), $line->getAttribute('name'), $varsNames);
//get variables.
if ($varsValues = $route->match($currentUrl)) {
array_shift($varsValues);
// the first result contain the full captured string (cf. pregmatch manual).
foreach ($varsValues as $key => $match) {
$varsList[$varsNames[$key]] = $match;
}
$route->setVars($varsList);
}
//add the route to the router.
$this->addRoute($route);
}
//return all routes.
return $this->routes;
}
开发者ID:ThomasSchweizer,项目名称:agoraexmachina,代码行数:36,代码来源:router.class.php
示例2: get_options_fincas
function get_options_fincas()
{
$con = new con();
$msg = new messages();
$rt = new route();
$con->connect();
//consultamos fincas desde la matriz ica
if (isset($_SESSION["ses_id"])) {
$qry = 'SELECT DISTINCT codfinca, municipio, depto FROM tbl_matriz_ica ORDER BY codfinca ASC';
$res = mysql_query($qry);
$item = " ";
$script = "<script>\$(document).ready(function(){";
while ($row_res = mysql_fetch_assoc($res)) {
$item .= '
<option value="' . $row_res["codfinca"] . '">' . $row_res["codfinca"] . ' (' . $row_res["municipio"] . ' - ' . $row_res["depto"] . ')</option>
';
$script .= '';
}
$script .= '});</script>';
} else {
$rt->routing($rt->path("login"));
}
$html = '
<select class="form-control valued" id="cod">
' . $item . '
</select>
';
$con->disconnect();
return $script . $html;
}
开发者ID:alchemixt99,项目名称:STL,代码行数:30,代码来源:supervisores.php
示例3: __construct
function __construct(route $route)
{
$this->config = $route->getConfig();
unset($route);
$this->getCacheKey();
$this->getCache();
}
开发者ID:laiello,项目名称:ffphp,代码行数:7,代码来源:cacheSys.php
示例4: go
public function go()
{
$route = new route();
$path = $route->getRoute();
$this->controll = $path['controll'] . 'Ctrl';
$this->action = $path['action'];
//加载控制器和方法
include APP . '/controll/' . $this->controll . '.php';
$c = new $this->controll();
$c->{$this->action}();
}
开发者ID:kphcdr,项目名称:PPAPI,代码行数:11,代码来源:ppphp.php
示例5: start
static function start()
{
$routes = explode('/', $_GET['router']);
if ($routes[0]) {
$controller_name = "Controller" . $routes[0];
} elseif ($routes[0] == "") {
$controller_name = "Controllerindex";
}
if ($routes[1]) {
$action_name = $routes[1];
} else {
$action_name = "index";
}
$model_name = "Model" . $routes[0];
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/apps/controler/" . mb_strtolower($controller_name) . ".php")) {
include_once $_SERVER['DOCUMENT_ROOT'] . "/apps/controler/" . mb_strtolower($controller_name) . ".php";
$controller = new $controller_name();
} else {
$controller = new Controler();
}
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/apps/model/" . mb_strtolower($model_name) . ".php")) {
include_once $_SERVER['DOCUMENT_ROOT'] . "/apps/model/" . mb_strtolower($model_name) . ".php";
}
if (method_exists($controller, $action_name)) {
$controller->{$action_name}();
} else {
echo route::ErrorPage404();
}
}
开发者ID:edward1995,项目名称:micro-framework,代码行数:29,代码来源:route.php
示例6: get_fincas_list
function get_fincas_list()
{
$con = new con();
$msg = new messages();
$rt = new route();
$con->connect();
//consultamos fincas desde la tabla de fincas
if (isset($_SESSION["ses_id"])) {
$qry = 'SELECT * FROM tbl_fincas WHERE fi_estado=1 ORDER BY fi_id ASC';
$res = mysql_query($qry);
$item = " ";
$script = "<script>\$(document).ready(function(){";
while ($row_res = mysql_fetch_assoc($res)) {
$item .= '
<option value="' . $row_res["fi_id"] . '">' . $row_res["fi_codigo"] . '</option>
';
$script .= '';
}
$script .= '});</script>';
} else {
$rt->routing($rt->path("login"));
}
$html = '
<select class="form-control valued" id="cod">
<option>Seleccione</option>
' . $item . '
</select>
';
$con->disconnect();
return $script . $html;
}
开发者ID:alchemixt99,项目名称:STL,代码行数:31,代码来源:inventarios.php
示例7: getFacadeAccessor
protected static function getFacadeAccessor()
{
if (!static::$__router) {
static::$__router = kernel::single('base_routing_router', request::instance());
route::boot();
}
return static::$__router;
}
开发者ID:453111208,项目名称:bbc,代码行数:8,代码来源:route.php
示例8: getFacadeAccessor
protected static function getFacadeAccessor()
{
if (!static::$__url) {
$routes = route::getRoutes();
static::$__url = new base_routing_urlgenerator($routes, request::instance());
}
return static::$__url;
}
开发者ID:453111208,项目名称:bbc,代码行数:8,代码来源:url.php
示例9: __construct
public function __construct($param = array())
{
parent::__construct($param);
if (count($this->param->part)) {
foreach ($this->param->part as $k => $v) {
$class = 'route_' . $v->type;
$this->param->part->{$k} = class_exists($class) ? new $class($v->param) : new data($v->param);
}
}
}
开发者ID:s-kalaus,项目名称:ekernel,代码行数:10,代码来源:chain.php
示例10: get_reports
function get_reports()
{
$con = new con();
$msg = new messages();
$rt = new route();
$con->connect();
//consultamos fincas
if (isset($_SESSION["ses_id"])) {
$qry = 'SELECT * FROM tbl_reporte_consecutivo ORDER BY rp_consecutivo DESC ';
$res = mysql_query($qry);
$item = " ";
$script = "<script>\$(document).ready(function(){";
while ($row_res = mysql_fetch_assoc($res)) {
$item .= '
<tr>
<td>' . $row_res["rp_timestamp"] . '</td>
<td>' . $row_res["rp_consecutivo"] . '</td>
<td>' . $row_res["rp_causa"] . '</td>
</tr>
';
$script .= '';
}
$script .= '});</script>';
} else {
$rt->routing($rt->path("login"));
}
$html = '
<table class="table table-striped table-hover ">
<thead>
<tr>
<th>Fecha reporte</th>
<th>Consecutivo</th>
<th>Causa</th>
</tr>
</thead>
<tbody>
' . $item . '
</tbody>
</table>
';
$con->disconnect();
return $script . $html;
}
开发者ID:alchemixt99,项目名称:STL,代码行数:43,代码来源:reportar.php
示例11: theme_widget_items_category
/**
* ShopEx licence
*
* @copyright Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn)
* @license http://ecos.shopex.cn/ ShopEx License
*/
function theme_widget_items_category(&$setting)
{
// 判断是否首页
if (route::currentRouteName() == 'topc') {
$returnData['isindex'] = true;
}
if (false && base_kvstore::instance('topc_category')->fetch('category_ex_vertical_widget.data', $cat_list)) {
return $cat_list;
}
$returnData['data'] = app::get('topc')->rpcCall('category.cat.get.list', array('fields' => 'cat_id,cat_name'));
return $returnData;
}
开发者ID:453111208,项目名称:bbc,代码行数:18,代码来源:theme_widget_items_category.php
示例12: theme_widget_index_category
/**
* ShopEx licence
*
* @copyright Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn)
* @license http://ecos.shopex.cn/ ShopEx License
*/
function theme_widget_index_category(&$setting)
{
// 判断是否首页
$A = route::currentRouteName();
//var_dump($_SERVER);
if (route::currentRouteName() == 'topc' || $_SERVER["ORIG_PATH_INFO"] == "/index.php/trading" || $_SERVER["DOCUMENT_URI"] == "/index.php/trading") {
$returnData['isindex'] = true;
}
if (false && base_kvstore::instance('topc_category')->fetch('category_ex_vertical_widget.data', $cat_list)) {
return $cat_list;
}
$returnData['data'] = app::get('topc')->rpcCall('category.cat.get.list', array('fields' => 'cat_id,cat_name'));
//var_dump($returnData);
return $returnData;
}
开发者ID:453111208,项目名称:bbc,代码行数:21,代码来源:theme_widget_index_category.php
示例13: handle
public function handle($request, Clousure $next)
{
$routeAs = route::currentRouteName();
$currentPermission = shopAuth::getSellerPermission();
//$currentPermission = false 表示为店主不用判断权限
//获取当前用户的路由权限
if ($currentPermission && !in_array($routeAs, $currentPermission)) {
if (request::ajax()) {
return response::json(array('error' => true, 'message' => '无操作权限'));
} else {
return redirect::action('topshop_ctl_index@nopermission');
}
}
return $next($request);
}
开发者ID:453111208,项目名称:bbc,代码行数:15,代码来源:permission.php
示例14: match_route
/**
* match the requested route with one of the routes added to the routes array on the main maverick class
* @param string $protocol the protocol specified in the routes, either post, get, or any
* @param string $route the route string
* @param string $action the action to take, usually in the form of controller->method
* @param array $args an array of matched parameters to pass to the routing controller class
* @return boolean
*/
private static function match_route($protocol, $route, $action, $args)
{
$maverick = \maverick\maverick::getInstance();
// return if a route has already been matched
if (isset($maverick->route)) {
return false;
}
// return if the protocols don't match
if (strtolower($_SERVER['REQUEST_METHOD']) == $protocol || $protocol == 'any') {
preg_match("~^{$route}\$~", $maverick->requested_route_string, $matches);
// route match - assign the information back to the main maverick object
if (!empty($matches)) {
$maverick->controller = route::get_full_action($action, $args, $matches);
}
} else {
return false;
}
}
开发者ID:AshleyJSheridan,项目名称:tweed,代码行数:26,代码来源:route.php
示例15: init_route
/**
* 初始化路由
*
* @since 1.0.1
* @notice 主要的路径下,尽可能囊括更多的选择,诸如/join/?123
*/
private function init_route()
{
route::register('/', 'index');
route::register('/index.php', 'index');
route::register('/\\?.*', 'index', true);
route::register('/index.php\\?.*', 'index', true);
route::register('/join', 'join');
route::register('/join\\?.*', 'join', true);
route::register('/join/\\?.*', 'join', true);
route::register('/baoming', 'join');
route::register('/baoming\\?.*', 'join', true);
route::register('/baoming/\\?.*', 'join', true);
route::register('/about', 'about');
route::register('/about\\?.*', 'about', true);
route::register('/about/\\?.*', 'about', true);
route::register('/links', 'links');
route::register('/links\\?.*', 'links', true);
route::register('/links/\\?.*', 'links', true);
route::register('/contact', 'contact');
route::register('/contact\\?.*', 'contact', true);
route::register('/contact/\\?.*', 'contact', true);
route::register('/bbs', 'bbs');
route::register('/bbs\\?.*', 'bbs', true);
route::register('/bbs/\\?.*', 'bbs', true);
route::register('/dispbbs.asp', 'bbs');
route::register('/dispbbs.asp\\?.*', 'bbs', true);
route::register('/index.asp', 'bbs');
route::register('/index.asp\\?.*', 'bbs', true);
route::register('/forum', 'forum');
route::register('/forum\\?.*', 'forum', true);
route::register('/forum/\\?.*', 'forum', true);
route::register('/thread', 'forum');
route::register('/thread\\?.*', 'forum', true);
route::register('/thread/\\?.*', 'forum', true);
route::register('/home.php', 'forum');
route::register('/home.php\\?.*', 'forum', true);
route::register('/member.php', 'forum');
route::register('/member.php\\?.*', 'forum', true);
route::register('/hi-cat', 'hi_cat');
route::register('/hi-cat\\?.*', 'hi_cat', true);
route::register('.*', 'page404', true);
new Route();
}
开发者ID:venmos,项目名称:go9999.com,代码行数:49,代码来源:app.class.php
示例16: command_cache
public function command_cache()
{
if ($this->files->exists(kernel::getCachedRoutesPath())) {
$this->command_clear();
}
if (!$this->files->isWritable(dirname(kernel::getCachedRoutesPath()))) {
logger::info(sprintf('Route cache path:%s cannot write', kernel::getCachedRoutesPath()));
exit;
}
$routes = route::getRoutes();
if (count($routes) == 0) {
logger::info("Your application doesn't have any routes.");
exit;
}
foreach ($routes as $route) {
$route->prepareForSerialization();
}
$this->files->put(kernel::getCachedRoutesPath(), $this->buildRouteCacheFile($routes));
logger::info("Routes cached successfully!");
}
开发者ID:453111208,项目名称:bbc,代码行数:20,代码来源:route.php
示例17: createMethodsCache
/**
* create routing cache
*
* @return array
*/
private function createMethodsCache()
{
$routing = (include 'src/Web/routing.php');
$config = array();
foreach ($routing as $key => $route) {
if (!isset($route['methods'])) {
$config[$key] = $route;
continue;
}
if (isset($route['methods']) && !in_array(strtoupper($route['methods']), $this->methods)) {
continue;
}
if (isset($route['methods']) && $this->route->getCurrentMethod() != strtoupper($route['methods'])) {
continue;
}
$config[$key] = $route;
}
$config = ArrayToolkit::index($config, 'pattern');
return $config;
}
开发者ID:PHILIP-2014,项目名称:Group,代码行数:25,代码来源:Router.php
示例18: test_url
public static function test_url($url, $pattern, $create_get = true)
{
if (is_array($pattern)) {
$found = false;
foreach ($pattern as $p) {
$found = route::test_url($url, $p, $create_get);
if ($found) {
return $found;
}
}
return false;
}
$testPattern = preg_replace('#\\{(\\w+)\\}#isU', '(\\w+)', $pattern);
$testPattern = preg_replace('#\\{\\?(\\w+)\\}#isU', '(\\w*)', $testPattern);
$testPattern = preg_replace('#\\{\\[(\\w+)\\]\\}#isU', '(.+)', $testPattern);
$testPattern = preg_replace('#\\{\\?\\[(\\w+)\\]\\}#isU', '(.*)', $testPattern);
$testPattern = preg_replace('#/#isU', '/*', $testPattern);
if (preg_match_all('#^' . $testPattern . '$#', $url, $matches)) {
if (!$create_get) {
return true;
}
if (preg_match_all('#\\{(.+)\\}#isU', $pattern, $names)) {
unset($matches[0]);
if (count($matches) == count($names[1])) {
foreach ($names[1] as $key => $get_name) {
$name = preg_replace('#\\[(.+)\\]#isU', '$1', $get_name);
$name = ltrim($name, '?');
if ($get_name[0] == '?') {
if ($matches[$key + 1][0] != '') {
$_GET[$name] = $matches[$key + 1][0];
}
} else {
$_GET[$name] = $matches[$key + 1][0];
}
}
}
}
return true;
}
return false;
}
开发者ID:silversthem,项目名称:simPHPle,代码行数:41,代码来源:route.class.php
示例19: function
<?php
Route::get('/', function () {
return View::make('hello');
});
route::post('login/', function () {
return 0;
});
开发者ID:Arvumti,项目名称:ranked,代码行数:8,代码来源:routes.php
示例20: function
Route::get('/', 'PagesController@Index');
Route::get('/about', 'PagesController@about');
Route::post('user/{id}/feedback', 'Insertions\\FeedbacksController@create');
Route::resource('posts', 'Insertions\\PostsController');
Route::resource('adverts', 'Insertions\\AdvertsController');
Route::post('posts/{postId}/comments/', 'Insertions\\CommentsController@create');
Route::get('user/{id}', 'UsersController@show');
Route::get('dashboard', 'UsersController@edit');
Route::put('dashboard/{id}', 'UsersController@update');
Route::get('upload', function () {
return View::make('users.upload');
});
Route::post('upload', 'UploadController@upload');
//invite
Route::resource('invite', 'InvitesController');
route::resource('/auth/activate', 'InviteRegisterController');
//admin panel
Route::get('/admin', 'Admin\\AdminController@index');
Route::resource('/admin/users', 'Admin\\AdminUsersController');
Route::resource('/admin/roles', 'Admin\\RolesController');
Route::resource('/admin/permissions', 'Admin\\PermissionsController');
});
Route::post('about', 'EmailController@showForm');
Route::post('about', 'EmailController@handleFormPost');
Route::get('setlocale/{locale}', function ($locale) {
if (in_array($locale, \Config::get('app.locales'))) {
# ѕровер¤ем, что у пользовател¤ выбран доступный ¤зык
Session::put('locale', $locale);
# » устанавливаем его в сессии под именем locale
}
});
开发者ID:aArenar54rus,项目名称:bookcross,代码行数:31,代码来源:routes.php
注:本文中的route类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论