Discuz rewriteoutput函数 获取rewrite字符串
/**
* 获取rewrite字符串
* @param string $type 需要获取的rewite
* @param boolean $returntype true:直接返回href, false:返回a标签
* @param string $host 可选网站域名
* @return string
*/
function rewriteoutput($type, $returntype, $host) {
global $_G;
$fextra = '';
if($type == 'forum_forumdisplay') {
list(,,, $fid, $page, $extra) = func_get_args();
$r = array(
'{fid}' => empty($_G['setting']['forumkeys'][$fid]) ? $fid : $_G['setting']['forumkeys'][$fid],
'{page}' => $page ? $page : 1,
);
} elseif($type == 'forum_viewthread') {
list(,,, $tid, $page, $prevpage, $extra) = func_get_args();
$r = array(
'{tid}' => $tid,
'{page}' => $page ? $page : 1,
'{prevpage}' => $prevpage && !IS_ROBOT ? $prevpage : 1,
);
} elseif($type == 'home_space') {
list(,,, $uid, $username, $extra) = func_get_args();
$_G['setting']['rewritecompatible'] && $username = rawurlencode($username);
$r = array(
'{user}' => $uid ? 'uid' : 'username',
'{value}' => $uid ? $uid : $username,
);
} elseif($type == 'home_blog') {
list(,,, $uid, $blogid, $extra) = func_get_args();
$r = array(
'{uid}' => $uid,
'{blogid}' => $blogid,
);
} elseif($type == 'group_group') {
list(,,, $fid, $page, $extra) = func_get_args();
$r = array(
'{fid}' => $fid,
'{page}' => $page ? $page : 1,
);
} elseif($type == 'portal_topic') {
list(,,, $name, $extra) = func_get_args();
$r = array(
'{name}' => $name,
);
} elseif($type == 'portal_article') {
list(,,, $id, $page, $extra) = func_get_args();
$r = array(
'{id}' => $id,
'{page}' => $page ? $page : 1,
);
} elseif($type == 'forum_archiver') {
list(,, $action, $value, $page, $extra) = func_get_args();
$host = '';
$r = array(
'{action}' => $action,
'{value}' => $value,
);
if($page) {
$fextra = '?page='.$page;
}
} elseif($type == 'plugin') {
list(,, $pluginid, $module,, $param, $extra) = func_get_args();
$host = '';
$r = array(
'{pluginid}' => $pluginid,
'{module}' => $module,
);
if($param) {
$fextra = '?'.$param;
}
}
$href = str_replace(array_keys($r), $r, $_G['setting']['rewriterule'][$type]).$fextra;
if(!$returntype) {
return '<a href="'.$host.$href.'"'.(!empty($extra) ? stripslashes($extra) : '').'>';
} else {
return $host.$href;
}
}
页:
[1]