4 public function register() {
6 'anchorEncode' => [ $this,
'anchorEncode' ],
7 'localUrl' => [ $this,
'localUrl' ],
8 'fullUrl' => [ $this,
'fullUrl' ],
9 'canonicalUrl' => [ $this,
'canonicalUrl' ],
12 return $this->
getEngine()->registerInterface(
'mw.uri.lua', $lib, [
13 'defaultUrl' => $this->
getTitle()->getFullUrl(),
29 private function getUrl( $func, $page, $query ) {
30 $title = Title::newFromText( $page );
32 $title = Title::newFromURL( urldecode( $page ) );
35 # Convert NS_MEDIA -> NS_FILE
39 if ( $query !==
null ) {
40 $text =
$title->$func( $query );
58 return $this->
getUrl(
'getLocalURL', $page, $query );
68 public function fullUrl( $page, $query ) {
69 return $this->
getUrl(
'getFullURL', $page, $query );
80 return $this->
getUrl(
'getCanonicalURL', $page, $query );
static anchorencode( $parser, $text)
This class provides some basic services that Lua libraries will probably need.
getEngine()
Get the engine.
getParser()
Get the parser.
canonicalUrl( $page, $query)
Handler for canonicalUrl.
anchorEncode( $s)
Handler for anchorEncode.
localUrl( $page, $query)
Handler for localUrl.
fullUrl( $page, $query)
Handler for fullUrl.
getUrl( $func, $page, $query)