mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-11 04:52:14 +09:00
Remove 'vid' from URL handling and clean up the remainder
This commit is contained in:
parent
e8bb0cf029
commit
0184021e73
2 changed files with 19 additions and 71 deletions
|
|
@ -1548,18 +1548,18 @@ class Context
|
||||||
*/
|
*/
|
||||||
public static function getUrl($num_args = 0, $args_list = array(), $domain = null, $encode = TRUE, $autoEncode = FALSE)
|
public static function getUrl($num_args = 0, $args_list = array(), $domain = null, $encode = TRUE, $autoEncode = FALSE)
|
||||||
{
|
{
|
||||||
|
static $current_domain = null;
|
||||||
static $site_module_info = null;
|
static $site_module_info = null;
|
||||||
static $current_info = null;
|
|
||||||
if ($site_module_info === null)
|
if ($site_module_info === null)
|
||||||
{
|
{
|
||||||
$site_module_info = self::get('site_module_info');
|
$site_module_info = self::get('site_module_info');
|
||||||
}
|
}
|
||||||
if ($current_info === null)
|
if ($current_domain === null)
|
||||||
{
|
{
|
||||||
$current_info = parse_url(Rhymix\Framework\URL::getCurrentDomainURL(RX_BASEURL));
|
$current_domain = parse_url(Rhymix\Framework\URL::getCurrentDomainURL(), PHP_URL_HOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If $domain is set, handle it (if $domain is vid type, remove $domain and handle with $vid)
|
// Find the canonical form of the domain.
|
||||||
if ($domain)
|
if ($domain)
|
||||||
{
|
{
|
||||||
if (strpos($domain, '/') !== false)
|
if (strpos($domain, '/') !== false)
|
||||||
|
|
@ -1570,49 +1570,29 @@ class Context
|
||||||
{
|
{
|
||||||
$domain = Rhymix\Framework\URL::decodeIdna($domain);
|
$domain = Rhymix\Framework\URL::decodeIdna($domain);
|
||||||
}
|
}
|
||||||
if (isSiteID($domain))
|
}
|
||||||
{
|
else
|
||||||
$vid = $domain;
|
{
|
||||||
$domain = '';
|
$domain = $site_module_info->domain;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If $domain, $vid are not set, use current site information
|
// If the domain is the same as the current domain, do not use it.
|
||||||
if(!$domain && !$vid)
|
if ($domain && $domain === $current_domain)
|
||||||
{
|
{
|
||||||
if($site_module_info->domain && isSiteID($site_module_info->domain))
|
$domain = null;
|
||||||
{
|
|
||||||
$vid = $site_module_info->domain;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$domain = $site_module_info->domain;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if $domain is set, compare current URL. If they are same, remove the domain, otherwise link to the domain.
|
// Get URL parameters. If the first argument is '', reset existing parameters.
|
||||||
if($domain)
|
if (!self::$_instance->get_vars || strval($args_list[0]) === '')
|
||||||
{
|
{
|
||||||
if($domain === $current_info['host'])
|
$get_vars = array();
|
||||||
{
|
if(is_array($args_list) && strval($args_list[0]) === '')
|
||||||
unset($domain);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$get_vars = array();
|
|
||||||
|
|
||||||
// If there is no GET variables or first argument is '' to reset variables
|
|
||||||
if(!self::$_instance->get_vars || $args_list[0] == '')
|
|
||||||
{
|
|
||||||
// rearrange args_list
|
|
||||||
if(is_array($args_list) && $args_list[0] == '')
|
|
||||||
{
|
{
|
||||||
array_shift($args_list);
|
array_shift($args_list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Otherwise, make GET variables into array
|
|
||||||
$get_vars = get_object_vars(self::$_instance->get_vars);
|
$get_vars = get_object_vars(self::$_instance->get_vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1621,7 +1601,6 @@ class Context
|
||||||
{
|
{
|
||||||
$key = $args_list[$i];
|
$key = $args_list[$i];
|
||||||
$val = trim($args_list[$i + 1]);
|
$val = trim($args_list[$i + 1]);
|
||||||
|
|
||||||
// If value is not set, remove the key
|
// If value is not set, remove the key
|
||||||
if(!isset($val) || !strlen($val))
|
if(!isset($val) || !strlen($val))
|
||||||
{
|
{
|
||||||
|
|
@ -1634,14 +1613,7 @@ class Context
|
||||||
|
|
||||||
// remove vid, rnd
|
// remove vid, rnd
|
||||||
unset($get_vars['rnd']);
|
unset($get_vars['rnd']);
|
||||||
if($vid)
|
unset($get_vars['vid']);
|
||||||
{
|
|
||||||
$get_vars['vid'] = $vid;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unset($get_vars['vid']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// for compatibility to lower versions
|
// for compatibility to lower versions
|
||||||
$act = $get_vars['act'];
|
$act = $get_vars['act'];
|
||||||
|
|
@ -1665,41 +1637,26 @@ class Context
|
||||||
{
|
{
|
||||||
$var_keys = array_keys($get_vars);
|
$var_keys = array_keys($get_vars);
|
||||||
sort($var_keys);
|
sort($var_keys);
|
||||||
|
|
||||||
$target = join('.', $var_keys);
|
$target = join('.', $var_keys);
|
||||||
|
|
||||||
$act = $get_vars['act'];
|
$act = $get_vars['act'];
|
||||||
$vid = $get_vars['vid'];
|
|
||||||
$mid = $get_vars['mid'];
|
$mid = $get_vars['mid'];
|
||||||
$key = $get_vars['key'];
|
$key = $get_vars['key'];
|
||||||
$srl = $get_vars['document_srl'];
|
$srl = $get_vars['document_srl'];
|
||||||
|
|
||||||
$tmpArray = array('rss' => 1, 'atom' => 1, 'api' => 1);
|
$tmpArray = array('rss' => 1, 'atom' => 1, 'api' => 1);
|
||||||
$is_feed = isset($tmpArray[$act]);
|
$is_feed = isset($tmpArray[$act]);
|
||||||
|
|
||||||
$target_map = array(
|
$target_map = array(
|
||||||
'vid' => $vid,
|
|
||||||
'mid' => $mid,
|
'mid' => $mid,
|
||||||
'mid.vid' => "$vid/$mid",
|
|
||||||
'category.mid' => "$mid/category/" . $get_vars['category'],
|
'category.mid' => "$mid/category/" . $get_vars['category'],
|
||||||
'entry.mid' => "$mid/entry/" . $get_vars['entry'],
|
'entry.mid' => "$mid/entry/" . $get_vars['entry'],
|
||||||
'entry.mid.vid' => "$vid/$mid/entry/" . $get_vars['entry'],
|
|
||||||
'document_srl' => $srl,
|
'document_srl' => $srl,
|
||||||
'document_srl.mid' => "$mid/$srl",
|
'document_srl.mid' => "$mid/$srl",
|
||||||
'document_srl.vid' => "$vid/$srl",
|
|
||||||
'document_srl.mid.vid' => "$vid/$mid/$srl",
|
|
||||||
'act' => ($is_feed && $act !== 'api') ? $act : '',
|
'act' => ($is_feed && $act !== 'api') ? $act : '',
|
||||||
'act.mid' => $is_feed ? "$mid/$act" : '',
|
'act.mid' => $is_feed ? "$mid/$act" : '',
|
||||||
'act.mid.vid' => $is_feed ? "$vid/$mid/$act" : '',
|
|
||||||
'act.document_srl.key' => ($act == 'trackback') ? "$srl/$key/$act" : '',
|
'act.document_srl.key' => ($act == 'trackback') ? "$srl/$key/$act" : '',
|
||||||
'act.document_srl.key.mid' => ($act == 'trackback') ? "$mid/$srl/$key/$act" : '',
|
'act.document_srl.key.mid' => ($act == 'trackback') ? "$mid/$srl/$key/$act" : '',
|
||||||
'act.document_srl.key.vid' => ($act == 'trackback') ? "$vid/$srl/$key/$act" : '',
|
|
||||||
'act.document_srl.key.mid.vid' => ($act == 'trackback') ? "$vid/$mid/$srl/$key/$act" : ''
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$query = $target_map[$target];
|
$query = $target_map[$target];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$query && count($get_vars) > 0)
|
if(!$query && count($get_vars) > 0)
|
||||||
{
|
{
|
||||||
$query = 'index.php?' . http_build_query($get_vars);
|
$query = 'index.php?' . http_build_query($get_vars);
|
||||||
|
|
|
||||||
|
|
@ -260,15 +260,6 @@ class ModuleHandler extends Handler
|
||||||
//if($this->module && $module_info->module != $this->module) unset($module_info);
|
//if($this->module && $module_info->module != $this->module) unset($module_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
// redirect, if module_site_srl and site_srl are different
|
|
||||||
if(!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0)
|
|
||||||
{
|
|
||||||
Context::setCacheControl(0);
|
|
||||||
$site_info = $oModuleModel->getSiteInfo($site_module_info->module_site_srl);
|
|
||||||
header('location: ' . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid), true, 301);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If module_info is not set still, and $module does not exist, find the default module
|
// If module_info is not set still, and $module does not exist, find the default module
|
||||||
if(!$module_info && !$this->module && !$this->mid)
|
if(!$module_info && !$this->module && !$this->mid)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue