本文整理汇总了PHP中JRoute::_router方法的典型用法代码示例。如果您正苦于以下问题:PHP JRoute::_router方法的具体用法?PHP JRoute::_router怎么用?PHP JRoute::_router使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JRoute
的用法示例。
在下文中一共展示了JRoute::_router方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _
/**
* Translates an internal Joomla URL to a humanly readible URL.
*
* @param string $url Absolute or Relative URI to Joomla resource.
* @param boolean $xhtml Replace & by & for XML compilance.
* @param integer $ssl Secure state for the resolved URI.
* 1: Make URI secure using global secure site URI.
* 0: Leave URI in the same secure state as it was passed to the function.
* -1: Make URI unsecure using the global unsecure site URI.
*
* @return The translated humanly readible URL.
*
* @since 11.1
*/
public static function _($url, $xhtml = true, $ssl = null)
{
if (!self::$_router) {
// Get the router.
self::$_router = JFactory::getApplication()->getRouter();
// Make sure that we have our router
if (!self::$_router) {
return null;
}
}
if (strpos($url, '&') !== 0 && strpos($url, 'index.php') !== 0) {
return $url;
}
// Build route.
$uri = self::$_router->build($url);
$url = $uri->toString(array('path', 'query', 'fragment'));
// Replace spaces.
$url = preg_replace('/\\s/u', '%20', $url);
/*
* Get the secure/unsecure URLs.
*
* If the first 5 characters of the BASE are 'https', then we are on an ssl connection over
* https and need to set our secure URL to the current request URL, if not, and the scheme is
* 'http', then we need to do a quick string manipulation to switch schemes.
*/
if ((int) $ssl) {
$uri = JURI::getInstance();
// Get additional parts.
static $prefix;
if (!$prefix) {
$prefix = $uri->toString(array('host', 'port'));
}
// Determine which scheme we want.
$scheme = (int) $ssl === 1 ? 'https' : 'http';
// Make sure our URL path begins with a slash.
if (!preg_match('#^/#', $url)) {
$url = '/' . $url;
}
// Build the URL.
$url = $scheme . '://' . $prefix . $url;
}
if ($xhtml) {
$url = htmlspecialchars($url);
}
return $url;
}
示例2: _
/**
* Translates an internal Joomla URL to a humanly readable URL.
*
* @param string $url Absolute or Relative URI to Joomla resource.
* @param boolean $xhtml Replace & by & for XML compliance.
* @param integer $ssl Secure state for the resolved URI.
* 0: (default) No change, use the protocol currently used in the request
* 1: Make URI secure using global secure site URI.
* 2: Make URI unsecure using the global unsecure site URI.
*
* @return string The translated humanly readable URL.
*
* @since 11.1
*/
public static function _($url, $xhtml = true, $ssl = null)
{
if (!self::$_router) {
// Get the router.
$app = JFactory::getApplication();
self::$_router = $app::getRouter();
// Make sure that we have our router
if (!self::$_router) {
return null;
}
}
if (!is_array($url) && strpos($url, '&') !== 0 && strpos($url, 'index.php') !== 0) {
return $url;
}
// Build route.
$uri = self::$_router->build($url);
$scheme = array('path', 'query', 'fragment');
/*
* Get the secure/unsecure URLs.
*
* If the first 5 characters of the BASE are 'https', then we are on an ssl connection over
* https and need to set our secure URL to the current request URL, if not, and the scheme is
* 'http', then we need to do a quick string manipulation to switch schemes.
*/
if ((int) $ssl || $uri->isSsl()) {
static $host_port;
if (!is_array($host_port)) {
$uri2 = JUri::getInstance();
$host_port = array($uri2->getHost(), $uri2->getPort());
}
// Determine which scheme we want.
$uri->setScheme((int) $ssl === 1 || $uri->isSsl() ? 'https' : 'http');
$uri->setHost($host_port[0]);
$uri->setPort($host_port[1]);
$scheme = array_merge($scheme, array('host', 'port', 'scheme'));
}
$url = $uri->toString($scheme);
// Replace spaces.
$url = preg_replace('/\\s/u', '%20', $url);
if ($xhtml) {
$url = htmlspecialchars($url);
}
return $url;
}