mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
The "getAutoEncodedUrl" function is added
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9829 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
be6d9a096d
commit
7a9430263e
2 changed files with 29 additions and 2 deletions
|
|
@ -789,7 +789,7 @@ class Context {
|
|||
* @brief make URL with args_list upon request URL
|
||||
* @return result URL
|
||||
**/
|
||||
function getUrl($num_args=0, $args_list=array(), $domain = null, $encode = true) {
|
||||
function getUrl($num_args=0, $args_list=array(), $domain = null, $encode = true, $auto = false) {
|
||||
static $site_module_info = null;
|
||||
static $current_info = null;
|
||||
|
||||
|
|
@ -935,7 +935,25 @@ class Context {
|
|||
else $query = getScriptPath().$query;
|
||||
}
|
||||
|
||||
return $encode?htmlspecialchars($query):$query;
|
||||
if ($encode){
|
||||
if($auto){
|
||||
$parsedUrl = parse_url($query);
|
||||
parse_str($parsedUrl['query'], $output);
|
||||
$encode_queries = array();
|
||||
foreach($output as $key=>$value){
|
||||
if (!preg_match('/&[a-z]{2,};/', $value)){
|
||||
$value = htmlspecialchars($value);
|
||||
}
|
||||
$encode_queries[] = $key.'='.$value;
|
||||
}
|
||||
$encode_query = implode('&', $encode_queries);
|
||||
return $parsedUrl['path'].'?'.$encode_query;
|
||||
}
|
||||
else
|
||||
return htmlspecialchars($query);
|
||||
}else{
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -238,6 +238,15 @@
|
|||
return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url);
|
||||
}
|
||||
|
||||
function getAutoEncodedUrl() {
|
||||
$num_args = func_num_args();
|
||||
$args_list = func_get_args();
|
||||
|
||||
if($num_args) $url = Context::getUrl($num_args, $args_list, null, true, true);
|
||||
else $url = Context::getRequestUri();
|
||||
|
||||
return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url);
|
||||
}
|
||||
/**
|
||||
* @brief return the value adding request uri to getUrl()
|
||||
* to get the full url
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue