本文整理汇总了PHP中WindUrlHelper::argsToUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP WindUrlHelper::argsToUrl方法的具体用法?PHP WindUrlHelper::argsToUrl怎么用?PHP WindUrlHelper::argsToUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindUrlHelper
的用法示例。
在下文中一共展示了WindUrlHelper::argsToUrl方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAction
/**
* 添加创始人
*/
public function addAction()
{
$username = $this->getInput('username', 'post');
if ($this->loadFounderService()->isFounder($username)) {
$this->showError('ADMIN:founder.add.fail.username.duplicate');
}
$args = array('username' => $username);
$this->showMessage('success', 'founder/show?' . WindUrlHelper::argsToUrl($args));
}
示例2: send
public function send($method = 'GET', $options = array())
{
if ($this->data) {
switch (strtoupper($method)) {
case 'GET':
$_url = WindUrlHelper::argsToUrl($this->data);
$url = parse_url($this->url);
$this->url .= (isset($url['query']) ? '&' : '?') . $_url;
break;
case 'POST':
$this->request(CURLOPT_POST, 1);
$_url = WindUrlHelper::argsToUrl($this->data, false);
$this->request(CURLOPT_POSTFIELDS, $_url);
break;
default:
break;
}
}
$this->request(CURLOPT_HEADER, $this->_header);
$this->request(CURLOPT_NOBODY, !$this->_body);
$this->request(CURLOPT_TIMEOUT, $this->timeout);
$this->request(CURLOPT_FOLLOWLOCATION, 0);
$this->request(CURLOPT_RETURNTRANSFER, 1);
if ($options && is_array($options)) {
curl_setopt_array($this->httpHandler, $options);
}
$_cookie = '';
foreach ($this->cookie as $key => $value) {
$_cookie .= ($_cookie !== '' ? "" : "; ") . $key . "=" . $value;
}
$this->request(CURLOPT_COOKIE, $_cookie);
$this->setHeader('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1)', 'User-Agent');
$_header = array();
foreach ($this->header as $key => $value) {
$_header[] = $key . ": " . $value;
}
$_header && $this->request(CURLOPT_HTTPHEADER, $_header);
$this->request(CURLOPT_URL, $this->url);
if (isset($options[CURLOPT_FOLLOWLOCATION])) {
$this->_redirects = $options[CURLOPT_FOLLOWLOCATION];
}
if (isset($options[CURLOPT_MAXREDIRS])) {
$this->_maxRedirs = intval($options[CURLOPT_MAXREDIRS]);
}
$this->followLocation();
$this->execute();
if ($this->isReturn) {
return $this->response();
} else {
return true;
}
}
示例3: build
public function build($router, $action, $args = array())
{
list($_a, $_c, $_m, $args) = $this->_resolveMca($router, $action, $args);
if ($_m && $_m !== $router->getDefaultModule()) {
$args[$router->getModuleKey()] = $_m;
}
if ($_c && $_c !== $router->getDefaultController()) {
$args[$router->getControllerKey()] = $_c;
}
if ($_a && $_a !== $router->getDefaultAction()) {
$args[$router->getActionKey()] = $_a;
}
$_url = Wind::getApp()->getRequest()->getScript() . '?' . WindUrlHelper::argsToUrl($args);
return $_url;
}
示例4: build
public function build($router, $action, $args = array())
{
list($_a, $_c, $_m, $args) = WindUrlHelper::resolveAction($action, $args);
if ($_m && $_m !== $router->getDefaultModule()) {
$args[$router->getModuleKey()] = $_m;
}
if ($_c && $_c !== $router->getDefaultController()) {
$args[$router->getControllerKey()] = $_c;
}
if ($_a && $_a !== $router->getDefaultAction()) {
$args[$router->getActionKey()] = $_a;
}
$_url = 'index.php?' . WindUrlHelper::argsToUrl($args);
return $_url;
}
示例5: assemble
public function assemble($action, $args = array(), $route = null)
{
$route || ($route = $this->defaultRoute);
if ($route && null !== ($route = $this->getRoute($route))) {
$_url = $route->build($this, $action, $args);
} else {
list($_a, $_c, $_m, $args) = WindUrlHelper::resolveAction($action, $args);
if ($_m && $_m !== $this->_module) {
$args[$this->moduleKey] = $_m;
}
if ($_c && $_c !== $this->_controller) {
$args[$this->controllerKey] = $_c;
}
if ($_a && $_a !== $this->_action) {
$args[$this->actionKey] = $_a;
}
$_url = $this->request->getScript() . '?' . WindUrlHelper::argsToUrl($args);
}
return $_url;
}
示例6: build
/**
* 在此路由协议的基础上组装url
*
* @param AbstractWindRouter $router
* @param string $action
* 格式为app/module/controller/action
* @param array $args
* 附带的参数
* @return string
* @see AbstractWindRoute::build()
*/
public function build($router, $action, $args = array())
{
list($_a, $_c, $_m, $_p, $args) = WindUrlHelper::resolveAction($action, $args);
foreach ($this->params as $key => $val) {
if ($key === $router->getModuleKey()) {
$_m || ($_m = $router->getModule());
$_args[$val] = $_m;
} elseif ($key === $router->getControllerKey()) {
$_c || ($_c = $router->getController());
$_args[$val] = $_c;
} elseif ($key === $router->getActionKey()) {
$_a || ($_a = $router->getAction());
$_args[$val] = $_a;
}
unset($args[$key]);
}
$_args[0] = $this->reverse;
ksort($_args);
$url = call_user_func_array("sprintf", $_args);
$args && ($url .= '/' . WindUrlHelper::argsToUrl($args, true, $this->separator));
return trim($url, '/');
}
示例7: send
public function send($method = 'GET', $options = array())
{
$method = strtoupper($method);
if ($this->data) {
switch ($method) {
case 'GET':
$_url = WindUrlHelper::argsToUrl($this->data);
$this->url .= ($this->query ? '&' : '?') . $_url;
break;
case 'POST':
$data = WindUrlHelper::argsToUrl($this->data, false);
$_header['Content-Type'] = 'application/x-www-form-urlencoded';
$_header['Content-Length'] = strlen($data);
$_body = $data;
break;
default:
break;
}
}
$this->setHeader($this->host, "Host");
!empty($_header) && $this->setHeader($_header);
$this->setHeader('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1)', 'User-Agent');
$this->setHeader('Close', 'Connection');
if ($options) {
$this->setHeader($options);
}
if ($this->cookie) {
$_cookie = WindUrlHelper::argsToUrl($this->cookie, false, ';=');
$this->setHeader($_cookie, "Cookie");
}
$_header = '';
foreach ($this->header as $key => $value) {
$_header .= $key . ': ' . $value . "\r\n";
}
$_header && $this->request('header', $_header);
$this->request('follow_location', $this->_redirects);
$this->request('max_redirects', $this->_maxRedirs);
$this->request('method', $method);
$this->request('timeout', $this->timeout);
isset($_body) && $this->request('content', $_body);
$this->httpHandler = fopen($this->url, 'r', false, $this->context);
return $this->_waitResponse ? $this->response() : true;
}
示例8: send
public function send($method = 'GET', $options = array())
{
$this->followLocation();
$method = strtoupper($method);
if ($this->data) {
switch ($method) {
case 'GET':
$_url = WindUrlHelper::argsToUrl($this->data);
$getData = ($this->query ? '&' : '?') . $_url;
$this->path .= $getData;
break;
case 'POST':
$postData = WindUrlHelper::argsToUrl($this->data, false);
$_header['Content-Type'] = 'application/x-www-form-urlencoded';
$_header['Content-Length'] = strlen($postData);
$_body = $postData;
break;
default:
break;
}
}
$this->setHeader($method . " " . $this->path . " HTTP/1.1");
$this->setHeader($this->host, "Host");
!empty($_header) && $this->setHeader($_header);
$this->setHeader('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1)', 'User-Agent');
$this->setHeader('Close', 'Connection');
if ($this->cookie) {
$_cookit = WindUrlHelper::argsToUrl($this->cookie, false, ';=');
$this->setHeader($_cookit, "Cookie");
}
$options && $this->setHeader($options);
$_request = '';
foreach ($this->header as $key => $value) {
if (is_string($key)) {
$_request .= $key . ': ' . $value;
} elseif (is_int($key)) {
$_request .= $value;
}
$_request .= "\r\n";
}
$_request && $this->request($_request . "\r\n");
isset($_body) && $this->request($_body);
return $this->_waitResponse ? $this->response() : true;
}
示例9: _buildUrl
/**
* 生成url串
*
* @param string $_m
* @param string $_c
* @param string $_a
* @param WindRouter $router
* @param array $args
* @return string
*/
private function _buildUrl($_m, $_c, $_a, $router, $args)
{
if ($this->rewrite_special) {
$rule = $this->_getRule();
if (!empty($rule)) {
$_args = $args;
foreach ($rule as $v) {
if ($v['route'] == "{$_m}/{$_c}/{$_a}") {
$format = array();
preg_match_all('/\\{(\\w+)\\}/', $v['format'], $matches);
//if (empty($matches[1])) continue;
$is_fname = strpos($v['format'], '{fname}') !== false;
if (1 === count($matches[1]) && !$is_fname) {
if (!isset($_args[$matches[1][0]])) {
continue;
}
}
if ($is_fname) {
if ($this->dynamicDomain) {
continue;
}
if (!isset($_args['fid'])) {
continue;
}
$domain = $this->_getDomain('id', 'domain');
$this->dynamic[] = '<?php $__route_rewrite=' . var_export($domain, true) . ';';
$this->dynamic[] = $_args['fid'] ? '($__route_rewrite[' . $_args['fid'] . '] ? $__route_rewrite[' . $_args['fid'] . '] : \'fname\')' : '\'fname\'';
if (is_numeric($_args['fid'])) {
if (!$domain[$_args['fid']]) {
continue;
}
$format['{fname}'] = $domain[$_args['fid']];
}
}
if ($pos = strpos($v['format'], '{page}')) {
if (!isset($_args['page'])) {
$v['format'] = str_replace($v['format'][$pos - 1] . '{page}', '', $v['format']);
}
}
foreach ($matches[1] as $code) {
if ($code != 'fname') {
$format['{' . $code . '}'] = isset($_args[$code]) ? rawurlencode($_args[$code]) : '';
unset($_args[$code]);
}
}
if ('forum' == $this->_getType("{$_m}/{$_c}/{$_a}")) {
unset($_args['fid']);
}
return '/' . trim(strtr($v['format'], $format), '/-.*') . ($_args ? '?' . WindUrlHelper::argsToUrl($_args) : '');
}
}
}
}
if ($this->rewrite_common) {
return $this->_buildCommon($router, array('m' => $_m, 'c' => $_c, 'a' => $_a), $args);
} else {
/* 非rewrite时获取脚本文件 */
$script = $this->_buildScript($_m, $_c, $_a, $args);
$url = '';
if ($this->omit_mca) {
$url = $args ? $script . '?' . WindUrlHelper::argsToUrl($args) : $script;
} else {
$_args = array();
if ($_m !== $router->getDefaultModule()) {
$_args['m'] = $_m;
}
if ($_c !== $router->getDefaultController()) {
$_args['c'] = $_c;
}
if ($_a !== $router->getDefaultAction()) {
$_args['a'] = $_a;
}
$args = array_merge($_args, $args);
$url = $args ? $script . '?' . WindUrlHelper::argsToUrl($args) : '';
}
return $url;
}
}
示例10: build
/**
* 在此路由协议的基础上组装url
*
* @param AbstractWindRouter $router
* @param string $action 格式为app/module/controller/action
* @param array $args 附带的参数
* @return string
* @see AbstractWindRoute::build()
*/
public function build($router, $action, $args = array())
{
list($_a, $_c, $_m, $_p, $args) = WindUrlHelper::resolveAction($action, $args);
$flag = 0;
foreach ($this->params as $key => $val) {
if (!isset($val['map'])) {
continue;
}
if ($key === $router->getModuleKey()) {
$m = $_m ? $_m : $router->getModule();
if ($m === $router->getDefaultModule() && $flag & 2) {
$flag = 7;
} else {
$_args[$val['map']] = $m;
}
} elseif ($key === $router->getControllerKey()) {
$c = $_c ? $_c : $router->getController();
if ($c === $router->getDefaultController() && $flag & 1) {
$flag = 3;
} else {
$_args[$val['map']] = $c;
}
} elseif ($key === $router->getActionKey()) {
$a = $_a ? $_a : $router->getAction();
if ($a === $router->getDefaultAction()) {
$flag = 1;
} else {
$_args[$val['map']] = $a;
}
} else {
if (isset($args[$key])) {
$_args[$val['map']] = $args[$key];
} elseif (isset($val['value'])) {
$_args[$val['map']] = $val['value'];
} else {
$_args[$val['map']] = '';
}
}
unset($args[$key]);
}
$mulitipyTime = count($_args);
$_args[0] = str_repeat($this->reverse, $mulitipyTime);
ksort($_args);
$url = call_user_func_array("sprintf", $_args);
$args && ($url .= '?' . WindUrlHelper::argsToUrl($args, true, $this->separator));
$baseUrl = Wind::getApp()->getRequest()->getBaseUrl(true);
$_baseUrl = $_p ? $this->replaceStr($baseUrl, $_p) : $baseUrl;
return trim($_baseUrl, '/') . '/' . trim($url, '/');
}