92 if ( $path[0] !==
'/' ) {
98 if (
strpos( $path,
'$1' ) ===
false ) {
99 if (
substr( $path, -1 ) !==
'/' ) {
118 foreach (
$params as $paramName => $paramData ) {
120 if (
preg_match(
'/\$(\d+|key)/u', $paramData ) ) {
121 $paramArrKey =
'pattern';
125 $paramArrKey =
'value';
135 foreach (
$options as $optionName => $optionData ) {
148 $this->patterns[] = $pattern;
160 foreach ( $path as $key => $onePath ) {
186 foreach ( $this->patterns as $key => $pattern ) {
187 $weights[$key] = $pattern->weight;
197 # Start with a weight of 0
201 $path = explode(
'/', $pattern->path );
203 # For each level of the path
204 foreach ( $path as $piece ) {
205 if (
preg_match(
'/^\$(\d+|key)$/u', $piece ) ) {
206 # For a piece that is only a $1 variable add 1 points of weight
209 # For a piece that simply contains a $1 variable add 2 points of weight
212 # For a solid piece add a full 3 points of weight
217 foreach ( $pattern->options as $key => $option ) {
219 # Add 0.5 for restrictions to values
220 # This way given two separate "/$2/$1" patterns the
221 # one with a limited set of $2 values will dominate
222 # the one that'll match more loosely
265 foreach ( $this->patterns as $pattern ) {
283 $regexp =
preg_replace(
'#\\\\\$1#u',
'(?P<par1>.*)', $regexp );
285 $regexp =
preg_replace(
'#\\\\\$(\d+)#u',
'(?P<par$1>.+?)', $regexp );
286 $regexp =
"#^{$regexp}$#";
295 foreach ( $pattern->options as $key => $option ) {
308 foreach ( $m as $matchKey => $matchValue ) {
309 if (
preg_match(
'/^par\d+$/u', $matchKey ) ) {
315 if (
isset( $pattern->key ) ) {
316 $data[
'$key'] = $pattern->key;
320 foreach ( $pattern->params as $paramName => $paramData ) {
324 if (
preg_match(
'/^data:/u', $paramName ) ) {
326 $key =
substr( $paramName, 5 );
332 if (
isset( $paramData[
'value'] ) ) {
334 $value = $paramData[
'value'];
338 $paramData[
'pattern'] );
354 if (
isset( $pattern->options[
'callback'] ) ) {
376 $replacer =
function ( $m ) use ( $pathMatches, $key, &$error ) {
377 if ( $m[1] ==
"key" ) {
387 if ( !
isset( $pathMatches[
"par$d"] ) ) {
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfRemoveDotSegments( $urlPath)
Remove all dot-segments in the provided URL path.
sortByWeight()
Protected helper to re-sort our patterns so that the most specific (most heavily weighted) patterns a...
static extractTitle( $path, $pattern)
add( $path, $params=[], $options=[])
Add a new path pattern to the path router.
static expandParamValue( $pathMatches, $key, $value)
Replace $key etc.
addStrict( $path, $params=[], $options=[])
Add a new path pattern to the path router with the strict option on.
static makeWeight( $pattern)
parse( $path)
Parse a path and return the query matches for the path.
doAdd( $path, $params, $options, $key=null)
Protected helper to do the actual bulk work of adding a single pattern.
internalParse( $path)
Match a path against each defined pattern.
An extension or a local will often add custom code to the function with or without a global variable For someone wanting email notification when an article is shown may add
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))