Go to the documentation of this file.
15 protected function setUp() {
18 $router->
add(
"/wiki/$1" );
19 $this->basicRouter = $router;
26 $matches = $this->basicRouter->parse(
"/wiki/Foo" );
35 $router->
add(
"/" ); # Should be the same
as "/$1"
40 $router->
add(
"/wiki" ); # Should be the same
as /
wiki/$1
41 $matches = $router->parse(
"/wiki/Foo" );
45 $router->
add(
"/wiki/" ); # Should be the same
as /
wiki/$1
46 $matches = $router->parse(
"/wiki/Foo" );
55 $router->
add(
"/$1" );
56 $router->add(
"/a/$1" );
57 $router->add(
"/b/$1" );
58 $matches = $router->parse(
"/a/Foo" );
62 $router->
add(
"/b/$1" );
63 $router->add(
"/a/$1" );
64 $router->add(
"/$1" );
65 $matches = $router->parse(
"/a/Foo" );
74 $router->
add(
array(
'edit' =>
"/edit/$1" ),
array(
'action' =>
'$key' ) );
75 $matches = $router->parse(
"/edit/Foo" );
76 $this->assertEquals(
$matches,
array(
'title' =>
"Foo",
'action' =>
'edit' ) );
85 $router->
add(
'/$2/$1',
array(
'test' =>
'$2' ) );
86 $matches = $router->parse(
"/asdf/Foo" );
87 $this->assertEquals(
$matches,
array(
'title' =>
"Foo",
'test' =>
'asdf' ) );
95 $router->
add(
'/$2/$1',
96 array(
'test' =>
'$2' ),
99 $router->add(
'/$2/$1',
100 array(
'test2' =>
'$2' ),
103 $router->add(
'/$1' );
105 $matches = $router->parse(
"/asdf/Foo" );
106 $this->assertEquals(
$matches,
array(
'title' =>
"asdf/Foo" ) );
108 $matches = $router->parse(
"/a/Foo" );
109 $this->assertEquals(
$matches,
array(
'title' =>
"Foo",
'test' =>
'a' ) );
111 $matches = $router->parse(
"/c/Foo" );
112 $this->assertEquals(
$matches,
array(
'title' =>
"Foo",
'test2' =>
'c' ) );
123 array(
'a' =>
'b',
'data:foo' =>
'bar' ),
124 array(
'callback' =>
array( $this,
'callbackForTest' ) )
126 $matches = $router->parse(
'/Foo' );
140 $router->
add(
"/wiki/$1",
array(
'title' =>
"$1$2" ) );
141 $matches = $router->parse(
"/wiki/A" );
151 $router->add(
"/asdf-$1",
array(
'title' =>
'qwerty-$1' ) );
152 $router->add(
"/$1" );
153 $router->add(
"/qwerty-$1",
array(
'title' =>
'asdf-$1' ) );
154 $router->addStrict(
"/Baz",
array(
'marco' =>
'polo' ) );
155 $router->add(
"/a/$1" );
156 $router->add(
"/asdf/$1" );
157 $router->add(
"/$2/$1",
array(
'unrestricted' =>
'$2' ) );
158 $router->add(
array(
'qwerty' =>
"/qwerty/$1" ),
array(
'qwerty' =>
'$key' ) );
159 $router->add(
"/$2/$1",
array(
'restricted-to-y' =>
'$2' ),
array(
'$2' =>
'y' ) );
163 '/Foo' =>
array(
'title' =>
'Foo' ),
164 '/Bar' =>
array(
'ping' =>
'pong' ),
165 '/Baz' =>
array(
'marco' =>
'polo' ),
166 '/asdf-foo' =>
array(
'title' =>
'qwerty-foo' ),
167 '/qwerty-bar' =>
array(
'title' =>
'asdf-bar' ),
168 '/a/Foo' =>
array(
'title' =>
'Foo' ),
169 '/asdf/Foo' =>
array(
'title' =>
'Foo' ),
170 '/qwerty/Foo' =>
array(
'title' =>
'Foo',
'qwerty' =>
'qwerty' ),
171 '/baz/Foo' =>
array(
'title' =>
'Foo',
'unrestricted' =>
'baz' ),
172 '/y/Foo' =>
array(
'title' =>
'Foo',
'restricted-to-y' =>
'y' ),
175 $this->assertEquals( $router->parse(
$path ),
$result );
183 $matches = $this->basicRouter->parse(
"/wiki/Special:Recentchanges" );
184 $this->assertEquals(
$matches,
array(
'title' =>
"Special:Recentchanges" ) );
191 $matches = $this->basicRouter->parse(
"/wiki/Title_With%20Space" );
192 $this->assertEquals(
$matches,
array(
'title' =>
"Title_With Space" ) );
209 $matches = $this->basicRouter->parse(
"/wiki/$char" );
210 $this->assertEquals(
$matches,
array(
'title' =>
"$char" ) );
217 $matches = $this->basicRouter->parse(
"/wiki/Plus+And&Dollar\\Stuff();[]{}*" );
218 $this->assertEquals(
$matches,
array(
'title' =>
"Plus+And&Dollar\\Stuff();[]{}*" ) );
228 $matches = $this->basicRouter->parse(
"/wiki/Spécial:Modifications_récentes" );
229 $this->assertEquals(
$matches,
array(
'title' =>
"Spécial:Modifications_récentes" ) );
231 $matches = $this->basicRouter->parse(
"/wiki/Sp%C3%A9cial:Modifications_r%C3%A9centes" );
232 $this->assertEquals(
$matches,
array(
'title' =>
"Spécial:Modifications_récentes" ) );
239 $matches = $this->basicRouter->parse(
"/wiki/Lorem_ipsum_dolor_sit_amet,_consectetur_adipisicing_elit,_sed_do_eiusmod_tempor_incididunt_ut_labore_et_dolore_magna_aliqua._Ut_enim_ad_minim_veniam,_quis_nostrud_exercitation_ullamco_laboris_nisi_ut_aliquip_ex_ea_commodo_consequat._Duis_aute_irure_dolor_in_reprehenderit_in_voluptate_velit_esse_cillum_dolore_eu_fugiat_nulla_pariatur._Excepteur_sint_occaecat_cupidatat_non_proident,_sunt_in_culpa_qui_officia_deserunt_mollit_anim_id_est_laborum." );
240 $this->assertEquals(
$matches,
array(
'title' =>
"Lorem_ipsum_dolor_sit_amet,_consectetur_adipisicing_elit,_sed_do_eiusmod_tempor_incididunt_ut_labore_et_dolore_magna_aliqua._Ut_enim_ad_minim_veniam,_quis_nostrud_exercitation_ullamco_laboris_nisi_ut_aliquip_ex_ea_commodo_consequat._Duis_aute_irure_dolor_in_reprehenderit_in_voluptate_velit_esse_cillum_dolore_eu_fugiat_nulla_pariatur._Excepteur_sint_occaecat_cupidatat_non_proident,_sunt_in_culpa_qui_officia_deserunt_mollit_anim_id_est_laborum." ) );
248 $router->
add(
"/wiki/$1",
array(
'title' =>
'%20:$1' ) );
249 $matches = $router->parse(
"/wiki/Foo" );
250 $this->assertEquals(
$matches,
array(
'title' =>
'%20:Foo' ) );
258 $router->
add(
"/wiki/$1",
array(
'title' =>
array(
'value' =>
'bar%20$1' ) ) );
259 $matches = $router->parse(
"/wiki/Foo" );
260 $this->assertEquals(
$matches,
array(
'title' =>
'bar%20$1' ) );
testKeyParameter()
Test the handling of key based arrays with a url parameter.
testFail()
Test to ensure that matches are not made if a parameter expects nonexistent input.
add( $path, $params=array(), $options=array())
Add a new path pattern to the path router.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
addStrict( $path, $params=array(), $options=array())
Add a new path pattern to the path router with the strict option on.
testSpecial()
Make sure the router handles titles like Special:Recentchanges correctly.
testWeight()
Test to ensure weight of paths is handled correctly.
testOrder()
Test to ensure that path is based on specifity, not order.
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning maintenance scripts have been cleaned up to use a unified class Directory structure How to run a script How to write your own DIRECTORY STRUCTURE The maintenance directory of a MediaWiki installation contains several all of which have unique purposes HOW TO RUN A SCRIPT Ridiculously just call php someScript php that s in the top level maintenance directory if not default wiki
testRestrictedValue()
Test additional restricted value parameter.
static provideRegexpChars()
testCharacters()
Make sure the router handles characters like +&() properly.
testLoose()
Test loose path auto-$1.
Tests for the PathRouter parsing.
callbackForTest(&$matches, $data)
testRegexpChars( $char)
Make sure the router doesn't break on special characters like $ used in regexp replacements @dataProv...
testUnicode()
Make sure the router handles unicode characters correctly @depends testSpecial @depends testUrlencodi...
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
if(!defined( 'MEDIAWIKI')) if(!isset( $wgVersion)) $matches
testLength()
Ensure the router doesn't choke on long paths.
testAdditionalParameter()
Test the handling of $2 inside paths.
testUrlencoding()
Make sure the router decodes urlencoding properly.
testRawParamValue()
Ensure that raw parameter values do not have any variable replacements or urldecoding.
testPatternUrlencoding()
Ensure that the php passed site of parameter values are not urldecoded.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
testBasic()
Test basic path parsing.