本文整理汇总了PHP中wfAssembleUrl函数的典型用法代码示例。如果您正苦于以下问题:PHP wfAssembleUrl函数的具体用法?PHP wfAssembleUrl怎么用?PHP wfAssembleUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfAssembleUrl函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: onCentralAuthSilentLoginRedirect
/**
* CentralAuthSilentLoginRedirect hook handler
* Points redirects from CentralAuth wiki to mobile domain if user has logged in from it
* @see SpecialCentralLogin in CentralAuth extension
* @param CentralAuthUser $centralUser
* @param string $url to redirect to
* @param array $info token information
*
* @return bool
*/
public static function onCentralAuthSilentLoginRedirect($centralUser, &$url, $info)
{
if (isset($info['mobileServer'])) {
$mobileUrlParsed = wfParseUrl($info['mobileServer']);
$urlParsed = wfParseUrl($url);
$urlParsed['host'] = $mobileUrlParsed['host'];
$url = wfAssembleUrl($urlParsed);
}
return true;
}
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:20,代码来源:MobileFrontend.hooks.php
示例2: wfExpandUrl
/**
* Expand a potentially local URL to a fully-qualified URL. Assumes $wgServer
* is correct.
*
* The meaning of the PROTO_* constants is as follows:
* PROTO_HTTP: Output a URL starting with http://
* PROTO_HTTPS: Output a URL starting with https://
* PROTO_RELATIVE: Output a URL starting with // (protocol-relative URL)
* PROTO_CURRENT: Output a URL starting with either http:// or https:// , depending
* on which protocol was used for the current incoming request
* PROTO_CANONICAL: For URLs without a domain, like /w/index.php , use $wgCanonicalServer.
* For protocol-relative URLs, use the protocol of $wgCanonicalServer
* PROTO_INTERNAL: Like PROTO_CANONICAL, but uses $wgInternalServer instead of $wgCanonicalServer
*
* @todo this won't work with current-path-relative URLs
* like "subdir/foo.html", etc.
*
* @param string $url Either fully-qualified or a local path + query
* @param string $defaultProto One of the PROTO_* constants. Determines the
* protocol to use if $url or $wgServer is protocol-relative
* @return string Fully-qualified URL, current-path-relative URL or false if
* no valid URL can be constructed
*/
function wfExpandUrl($url, $defaultProto = PROTO_CURRENT)
{
global $wgServer, $wgCanonicalServer, $wgInternalServer, $wgRequest, $wgHttpsPort;
if ($defaultProto === PROTO_CANONICAL) {
$serverUrl = $wgCanonicalServer;
} elseif ($defaultProto === PROTO_INTERNAL && $wgInternalServer !== false) {
// Make $wgInternalServer fall back to $wgServer if not set
$serverUrl = $wgInternalServer;
} else {
$serverUrl = $wgServer;
if ($defaultProto === PROTO_CURRENT) {
$defaultProto = $wgRequest->getProtocol() . '://';
}
}
// Analyze $serverUrl to obtain its protocol
$bits = wfParseUrl($serverUrl);
$serverHasProto = $bits && $bits['scheme'] != '';
if ($defaultProto === PROTO_CANONICAL || $defaultProto === PROTO_INTERNAL) {
if ($serverHasProto) {
$defaultProto = $bits['scheme'] . '://';
} else {
// $wgCanonicalServer or $wgInternalServer doesn't have a protocol.
// This really isn't supposed to happen. Fall back to HTTP in this
// ridiculous case.
$defaultProto = PROTO_HTTP;
}
}
$defaultProtoWithoutSlashes = substr($defaultProto, 0, -2);
if (substr($url, 0, 2) == '//') {
$url = $defaultProtoWithoutSlashes . $url;
} elseif (substr($url, 0, 1) == '/') {
// If $serverUrl is protocol-relative, prepend $defaultProtoWithoutSlashes,
// otherwise leave it alone.
$url = ($serverHasProto ? '' : $defaultProtoWithoutSlashes) . $serverUrl . $url;
}
$bits = wfParseUrl($url);
// ensure proper port for HTTPS arrives in URL
// https://bugzilla.wikimedia.org/show_bug.cgi?id=65184
if ($defaultProto === PROTO_HTTPS && $wgHttpsPort != 443) {
$bits['port'] = $wgHttpsPort;
}
if ($bits && isset($bits['path'])) {
$bits['path'] = wfRemoveDotSegments($bits['path']);
return wfAssembleUrl($bits);
} elseif ($bits) {
# No path to expand
return $url;
} elseif (substr($url, 0, 1) != '/') {
# URL is a relative path
return wfRemoveDotSegments($url);
}
# Expanded URL is not valid.
return false;
}
开发者ID:D66Ha,项目名称:mediawiki,代码行数:77,代码来源:GlobalFunctions.php
示例3: testWfAssembleUrl
/**
* @dataProvider provideURLParts
*/
public function testWfAssembleUrl($parts, $output)
{
$partsDump = print_r($parts, true);
$this->assertEquals($output, wfAssembleUrl($parts), "Testing {$partsDump} assembles to {$output}");
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:8,代码来源:wfAssembleUrlTest.php
示例4: wfExpandUrl
/**
* Expand a potentially local URL to a fully-qualified URL. Assumes $wgServer
* is correct.
*
* The meaning of the PROTO_* constants is as follows:
* PROTO_HTTP: Output a URL starting with http://
* PROTO_HTTPS: Output a URL starting with https://
* PROTO_RELATIVE: Output a URL starting with // (protocol-relative URL)
* PROTO_CURRENT: Output a URL starting with either http:// or https:// , depending on which protocol was used for the current incoming request
* PROTO_CANONICAL: For URLs without a domain, like /w/index.php , use $wgCanonicalServer. For protocol-relative URLs, use the protocol of $wgCanonicalServer
* PROTO_INTERNAL: Like PROTO_CANONICAL, but uses $wgInternalServer instead of $wgCanonicalServer
*
* @todo this won't work with current-path-relative URLs
* like "subdir/foo.html", etc.
*
* @param $url String: either fully-qualified or a local path + query
* @param $defaultProto Mixed: one of the PROTO_* constants. Determines the
* protocol to use if $url or $wgServer is
* protocol-relative
* @return string Fully-qualified URL, current-path-relative URL or false if
* no valid URL can be constructed
*/
function wfExpandUrl($url, $defaultProto = PROTO_CURRENT)
{
global $wgServer, $wgCanonicalServer, $wgInternalServer;
$serverUrl = $wgServer;
if ($defaultProto === PROTO_CANONICAL) {
$serverUrl = $wgCanonicalServer;
}
// Make $wgInternalServer fall back to $wgServer if not set
if ($defaultProto === PROTO_INTERNAL && $wgInternalServer !== false) {
$serverUrl = $wgInternalServer;
}
if ($defaultProto === PROTO_CURRENT) {
$defaultProto = WebRequest::detectProtocol() . '://';
}
// Analyze $serverUrl to obtain its protocol
$bits = wfParseUrl($serverUrl);
$serverHasProto = $bits && $bits['scheme'] != '';
if ($defaultProto === PROTO_CANONICAL || $defaultProto === PROTO_INTERNAL) {
if ($serverHasProto) {
$defaultProto = $bits['scheme'] . '://';
} else {
// $wgCanonicalServer or $wgInternalServer doesn't have a protocol. This really isn't supposed to happen
// Fall back to HTTP in this ridiculous case
$defaultProto = PROTO_HTTP;
}
}
$defaultProtoWithoutSlashes = substr($defaultProto, 0, -2);
if (substr($url, 0, 2) == '//') {
$url = $defaultProtoWithoutSlashes . $url;
} elseif (substr($url, 0, 1) == '/') {
// If $serverUrl is protocol-relative, prepend $defaultProtoWithoutSlashes, otherwise leave it alone
$url = ($serverHasProto ? '' : $defaultProtoWithoutSlashes) . $serverUrl . $url;
}
$bits = wfParseUrl($url);
if ($bits && isset($bits['path'])) {
$bits['path'] = wfRemoveDotSegments($bits['path']);
return wfAssembleUrl($bits);
} elseif ($bits) {
# No path to expand
return $url;
} elseif (substr($url, 0, 1) != '/') {
# URL is a relative path
return wfRemoveDotSegments($url);
}
# Expanded URL is not valid.
return false;
}
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:69,代码来源:GlobalFunctions.php
示例5: getDesktopUrl
/**
* Take a URL and return a copy that removes any mobile tokens
* @param string $url
* @return string
*/
public function getDesktopUrl($url)
{
$parsedUrl = wfParseUrl($url);
$this->updateDesktopUrlHost($parsedUrl);
$this->updateDesktopUrlQuery($parsedUrl);
$desktopUrl = wfAssembleUrl($parsedUrl);
return $desktopUrl;
}
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:13,代码来源:MobileContext.php
示例6: testUpdateMobileUrlPath
public function testUpdateMobileUrlPath()
{
$this->setMwGlobals(array('wgScriptPath' => '/wiki', 'wgMobileUrlTemplate' => "/mobile/%p"));
$updateMobileUrlHost = self::getMethod("updateMobileUrlPath");
// check for constructing a templated URL
$parsedUrl = wfParseUrl("http://en.wikipedia.org/wiki/Gustavus_Airport");
$updateMobileUrlHost->invokeArgs($this->makeContext(), array(&$parsedUrl));
$this->assertEquals("http://en.wikipedia.org/wiki/mobile/Gustavus_Airport", wfAssembleUrl($parsedUrl));
// check for maintaining an already templated URL
$parsedUrl = wfParseUrl("http://en.wikipedia.org/wiki/mobile/Gustavus_Airport");
$updateMobileUrlHost->invokeArgs($this->makeContext(), array(&$parsedUrl));
$this->assertEquals("http://en.wikipedia.org/wiki/mobile/Gustavus_Airport", wfAssembleUrl($parsedUrl));
}
开发者ID:negati-ve,项目名称:openshift-mediawiki,代码行数:13,代码来源:MobileContextTest.php
注:本文中的wfAssembleUrl函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论