本文整理汇总了PHP中WindUrlHelper::urlToArgs方法的典型用法代码示例。如果您正苦于以下问题:PHP WindUrlHelper::urlToArgs方法的具体用法?PHP WindUrlHelper::urlToArgs怎么用?PHP WindUrlHelper::urlToArgs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindUrlHelper
的用法示例。
在下文中一共展示了WindUrlHelper::urlToArgs方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: match
/**
* 路由解析
*
* 匹配这个patten时,将试图去解析module、controller和action值,并解析二级域名。
* @see AbstractWindRoute::match()
*/
public function match($request)
{
$fullUrl = $request->getHostInfo() . $request->getRequestUri();
$_pathInfo = trim(str_replace($request->getBaseUrl(), '', $fullUrl), '/');
if (!$_pathInfo || !preg_match_all('/' . $this->pattern . '/i', trim($_pathInfo, '/'), $matches) || strpos($_pathInfo, '.php') !== false) {
return null;
}
list(, $_args) = explode('?', $_pathInfo . '?', 2);
$_args = trim($_args, '?');
$_args = WindUrlHelper::urlToArgs($_args, true, $this->separator);
foreach ($this->params as $_n => $_p) {
if (isset($_p['map']) && isset($matches[$_p['map']][0])) {
$_value = $matches[$_p['map']][0];
} else {
$_value = isset($_p['default']) ? $_p['default'] : '';
}
$this->params[$_n]['value'] = $params[$_n] = trim($_value, '-/');
unset($_args[$_n]);
//去掉参数中的m,c,a
}
$host = $request->getHostInfo();
if ($host != '' && ($pos1 = strpos($host, '://')) !== false && ($pos2 = strpos($host, '.')) !== false) {
$host = substr($host, $pos1 + 3, $pos2 - $pos1 - 3);
} else {
return null;
}
$params['p'] = $host == 'www' ? '' : $host;
unset($_args['p']);
//去掉参数中的p
$_args && ($params = array_merge($params, $_args));
return $params;
}
示例2: _resolveMca
/**
* 分析参数
*
* @param AbstractWindRouter $router
* @param string $action
* @param array $args
* @return array
*/
private function _resolveMca($router, $action, $args)
{
list($action, $_args) = explode('?', $action . '?');
$args = array_merge($args, $_args ? WindUrlHelper::urlToArgs($_args, false) : array());
$action = trim($action, '/');
$tmp = explode('/', $action . '/');
end($tmp);
if (5 === count($tmp) && !strncasecmp('app/', $action, 4)) {
list($_a, $_c, $_app_name, $_m) = array(prev($tmp), prev($tmp), prev($tmp), prev($tmp));
$args['app'] = $_app_name;
} else {
list($_a, $_c, $_m) = array(prev($tmp), prev($tmp), prev($tmp));
}
return array($_a, $_c, $_m, $args);
}
示例3: match
/**
* 路由解析
*
* 匹配这个patten时,将试图去解析module、controller和action值,并解析二级域名。
*
* @see AbstractWindRoute::match()
*/
public function match($request)
{
$_pathInfo = trim($request->getPathInfo(), '/');
if (!$_pathInfo || !preg_match($this->pattern, $_pathInfo, $matches) || strpos($_pathInfo, '.php') !== false) {
return null;
}
$params = array();
$_args = WindUrlHelper::urlToArgs($matches[4], true, $this->separator);
// 解析m,c,a
foreach ($this->params as $k => $v) {
if (isset($matches[$v])) {
$params[$k] = trim($matches[$v], '-/');
}
unset($_args[$k]);
// 去掉参数中的m,c,a
}
return $_args + $params;
}
示例4: _resolveMca
/**
* 分析参数
*
* @param AbstractWindRouter $router
* @param string $action
* @param array $args
* @return array
*/
private function _resolveMca($router, $action, $args)
{
list($action, $_args) = explode('?', $action . '?');
$args = array_merge($args, $_args ? WindUrlHelper::urlToArgs($_args, false) : array());
$action = trim($action, '/');
$tmp = explode('/', $action . '/');
end($tmp);
if (5 === count($tmp) && !strncasecmp('app/', $action, 4)) {
list($_a, $_c, $_app_name, $_m) = array(prev($tmp), prev($tmp), prev($tmp), prev($tmp));
$args['app'] = $_app_name;
} else {
list($_a, $_c, $_m) = array(prev($tmp), prev($tmp), prev($tmp));
}
$_m = $_m ? $_m : $router->getDefaultModule();
$_c = $_c ? $_c : $router->getDefaultController();
$_a = $_a ? $_a : $router->getDefaultAction();
return array($_m, $_c, $_a, $args);
}
示例5: _filterUrl
/**
* 过滤来源URL
*
* TODO
*
* @return string
*/
private function _filterUrl($returnDefault = true)
{
$url = $this->getInput('backurl');
if (!$url) {
$url = $this->getRequest()->getServer('HTTP_REFERER');
}
if ($url) {
// 排除来自注册页面/自身welcome/show的跳转
$args = WindUrlHelper::urlToArgs($url);
if ($args['m'] == 'u' && in_array($args['c'], array('register', 'login'))) {
$url = '';
}
}
if (!$url && $returnDefault) {
$url = Wekit::url()->base;
}
return $url;
}
示例6: match
public function match($request)
{
$path = $request->getPathInfo();
return WindUrlHelper::urlToArgs($path);
}