/** * * gUrl * * URL模式的构建函数 * * @param controller 控制器名称,默认为配置'default_controller' * @param action 动作名称,默认为配置'default_action' * @param args 传递的参数,数组形式 * @param anchor 跳转锚点 */ function gUrl($controller = null, $action = null, $args = null, $anchor = null) { $controller = null != $controller ? $controller : $GLOBALS['G_SP']["default_controller"]; $action = null != $action ? $action : $GLOBALS['G_SP']["default_action"]; // 使用扩展点 if ($launch = spLaunch("function_url", array('controller' => $controller, 'action' => $action, 'args' => $args, 'anchor' => $anchor), TRUE)) { return $launch; } if (TRUE == $GLOBALS['G_SP']['url']["url_path_info"]) { // 使用path_info方式 $url = $GLOBALS['G_SP']['url']["url_path_base"] . "/{$controller}/{$action}"; if (null != $args) { foreach ($args as $key => $arg) { $url .= "/{$key}/{$arg}"; } } } else { $url = $GLOBALS['G_SP']['url']["url_path_base"] . "?" . $GLOBALS['G_SP']["url_controller"] . "={$controller}&"; $url .= $GLOBALS['G_SP']["url_action"] . "={$action}"; if (null != $args) { foreach ($args as $key => $arg) { $url .= "&{$key}={$arg}"; } } } if (null != $anchor) { $url .= "#" . $anchor; } return $url; }
/** * * spUrl * * URL模式的构建函数 * * @param controller 控制器名称,默认为配置'default_controller' * @param action 动作名称,默认为配置'default_action' * @param args 传递的参数,数组形式 * @param anchor 跳转锚点 * @param no_sphtml 是否应用spHtml设置,在FALSE时效果与不启用spHtml相同。 */ function spUrl($controller = null, $action = null, $args = null, $anchor = null, $no_sphtml = FALSE) { if (TRUE == $GLOBALS['G_SP']['html']["enabled"] && TRUE != $no_sphtml) { // 当开启HTML生成时,将查找HTML列表获取静态文件名称。 $realhtml = spHtml::getUrl($controller, $action, $args, $anchor); if (isset($realhtml[0])) { return $realhtml[0]; } } $controller = null != $controller ? $controller : $GLOBALS['G_SP']["default_controller"]; $action = null != $action ? $action : $GLOBALS['G_SP']["default_action"]; // 使用挂靠点 if ($launch = spLaunch("function_url", array('controller' => $controller, 'action' => $action, 'args' => $args, 'anchor' => $anchor, 'no_sphtml' => $no_sphtml), TRUE)) { return $launch; } if (TRUE == $GLOBALS['G_SP']['url']["url_path_info"]) { // 使用path_info方式 $url = $GLOBALS['G_SP']['url']["url_path_base"] . "/{$controller}/{$action}"; if (null != $args) { foreach ($args as $key => $arg) { $url .= "/{$key}/{$arg}"; } } } else { $url = $GLOBALS['G_SP']['url']["url_path_base"] . "?" . $GLOBALS['G_SP']["url_controller"] . "={$controller}&"; $url .= $GLOBALS['G_SP']["url_action"] . "={$action}"; if (null != $args) { foreach ($args as $key => $arg) { $url .= "&{$key}={$arg}"; } } } if (null != $anchor) { $url .= "#" . $anchor; } return $url; }
function spUrl($geturl = null, $controller = null, $action = null, $args = null, $anchor = null, $no_sphtml = FALSE) { if (TRUE == $GLOBALS['G_DY']['html']["enabled"] && TRUE != $no_sphtml) { $realhtml = syhtml::getUrl($geturl, $controller, $action, $args, $anchor); if (isset($realhtml[0])) { return $realhtml[0]; } } $geturl = null != $geturl ? $geturl : basename(__FILE__); $controller = null != $controller ? $controller : $GLOBALS['G_DY']["default_controller"]; $action = null != $action ? $action : $GLOBALS['G_DY']["default_action"]; if ($launch = spLaunch("function_url", array('controller' => $controller, 'action' => $action, 'args' => $args, 'anchor' => $anchor, 'no_sphtml' => $no_sphtml), TRUE)) { return $launch; } if (TRUE == $GLOBALS['G_DY']['url']["url_path_info"]) { $url = "{$controller}/{$controller}/{$action}"; if (null != $args) { foreach ($args as $key => $arg) { $url .= "/{$key}/{$arg}"; } } } else { $url = $geturl . "?" . $GLOBALS['G_DY']["url_controller"] . "={$controller}&"; $url .= $GLOBALS['G_DY']["url_action"] . "={$action}"; if (null != $args) { foreach ($args as $key => $arg) { $url .= "&{$key}={$arg}"; } } } if (null != $anchor) { $url .= "#" . $anchor; } return $url; }