MediaWiki
master
Toggle main menu visibility
WikiReference.php
Go to the documentation of this file.
1
<?php
6
7
namespace
MediaWiki\WikiMap;
8
14
class
WikiReference
{
16
private
string
$mCanonicalServer;
18
private
string
$mServer;
20
private
string
$mPath;
21
27
public
function
__construct
(
string
$canonicalServer,
string
$path
, ?
string
$server =
null
) {
28
$this->mCanonicalServer = $canonicalServer;
29
$this->mPath =
$path
;
30
$this->mServer = $server ?? $canonicalServer;
31
}
32
38
public
function
getCanonicalServer
() {
39
return
$this->mCanonicalServer;
40
}
41
47
public
function
getDisplayName
() {
48
// If the server spec is invalid, there's no sensible thing to do here,
49
// so just return the canonical server as-is.
50
return
parse_url( $this->mCanonicalServer, PHP_URL_HOST ) ?: $this->mCanonicalServer;
51
}
52
60
public
function
getCanonicalUrl
( $page, $fragmentId =
null
) {
61
return
$this->mCanonicalServer . $this->getLocalUrl( $page, $fragmentId );
62
}
63
71
public
function
getUrl
( $page, $fragmentId =
null
) {
72
return
$this->
getCanonicalUrl
( $page, $fragmentId );
73
}
74
86
public
function
getFullUrl
( $page, $fragmentId =
null
) {
87
return
$this->mServer . $this->getLocalUrl( $page, $fragmentId );
88
}
89
100
private
function
getLocalUrl( $page, $fragmentId =
null
) {
101
$page =
wfUrlencode
( str_replace(
' '
,
'_'
, $page ) );
102
103
if
( is_string( $fragmentId ) && $fragmentId !==
''
) {
104
$page .=
'#'
.
wfUrlencode
( $fragmentId );
105
}
106
107
return
str_replace(
'$1'
, $page, $this->mPath );
108
}
109
}
wfUrlencode
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
Definition
GlobalFunctions.php:201
$path
$path
Definition
NoLocalSettings.php:14
MediaWiki\WikiMap\WikiReference
Reference to a locally-hosted wiki.
Definition
WikiReference.php:14
MediaWiki\WikiMap\WikiReference\getCanonicalServer
getCanonicalServer()
Get the canonical server (i.e.
Definition
WikiReference.php:38
MediaWiki\WikiMap\WikiReference\getDisplayName
getDisplayName()
Extract the server name from wgCanonicalServer.
Definition
WikiReference.php:47
MediaWiki\WikiMap\WikiReference\__construct
__construct(string $canonicalServer, string $path, ?string $server=null)
Definition
WikiReference.php:27
MediaWiki\WikiMap\WikiReference\getFullUrl
getFullUrl( $page, $fragmentId=null)
Create a full URL like Title\getFullURL() to a page, based on $wgServer.
Definition
WikiReference.php:86
MediaWiki\WikiMap\WikiReference\getUrl
getUrl( $page, $fragmentId=null)
Alias for getCanonicalUrl(), for backwards compatibility.
Definition
WikiReference.php:71
MediaWiki\WikiMap\WikiReference\getCanonicalUrl
getCanonicalUrl( $page, $fragmentId=null)
Create a full canonical URL to a page on the given wiki.
Definition
WikiReference.php:60
includes
WikiMap
WikiReference.php
Generated on
for MediaWiki by
1.18.0