58 for ( $i = 1; $i <= 12; $i++ ) {
59 $this->xMonths[$this->lang->lc( $this->lang->getMonthName( $i ) )] = $i;
60 $this->xMonths[$this->lang->lc( $this->lang->getMonthAbbreviation( $i ) )] = $i;
63 $this->regexTrail =
'(?![a-z])/iu';
65 # Partial regular expressions
66 $this->prxDM =
'\[\[(\d{1,2})[ _](' . $this->monthNames .
')\]\]';
67 $this->prxMD =
'\[\[(' . $this->monthNames .
')[ _](\d{1,2})\]\]';
68 $this->prxY =
'\[\[(\d{1,4}([ _]BC|))\]\]';
69 $this->prxISO1 =
'\[\[(-?\d{4})]]-\[\[(\d{2})-(\d{2})\]\]';
70 $this->prxISO2 =
'\[\[(-?\d{4})-(\d{2})-(\d{2})\]\]';
72 # Real regular expressions
73 $this->regexes[self::DMY] =
"/{$this->prxDM}(?: *, *| +){$this->prxY}{$this->regexTrail}";
74 $this->regexes[self::YDM] =
"/{$this->prxY}(?: *, *| +){$this->prxDM}{$this->regexTrail}";
75 $this->regexes[self::MDY] =
"/{$this->prxMD}(?: *, *| +){$this->prxY}{$this->regexTrail}";
76 $this->regexes[self::YMD] =
"/{$this->prxY}(?: *, *| +){$this->prxMD}{$this->regexTrail}";
77 $this->regexes[self::DM] =
"/{$this->prxDM}{$this->regexTrail}";
78 $this->regexes[self::MD] =
"/{$this->prxMD}{$this->regexTrail}";
79 $this->regexes[self::ISO1] =
"/{$this->prxISO1}{$this->regexTrail}";
80 $this->regexes[self::ISO2] =
"/{$this->prxISO2}{$this->regexTrail}";
83 # See the comments in replace() for the meaning of the letters
84 $this->keys[self::DMY] =
'jFY';
85 $this->keys[self::YDM] =
'Y jF';
86 $this->keys[self::MDY] =
'FjY';
87 $this->keys[self::YMD] =
'Y Fj';
88 $this->keys[self::DM] =
'jF';
89 $this->keys[self::MD] =
'Fj';
90 $this->keys[self::ISO1] =
'ymd'; # y
means ISO year
91 $this->keys[self::ISO2] =
'ymd';
94 $this->targets[self::DMY] =
'[[F j|j F]] [[Y]]';
95 $this->targets[self::YDM] =
'[[Y]], [[F j|j F]]';
96 $this->targets[self::MDY] =
'[[F j]], [[Y]]';
97 $this->targets[self::YMD] =
'[[Y]] [[F j]]';
98 $this->targets[self::DM] =
'[[F j|j F]]';
99 $this->targets[self::MD] =
'[[F j]]';
100 $this->targets[self::ISO1] =
'[[Y|y]]-[[F j|m-d]]';
101 $this->targets[self::ISO2] =
'[[y-m-d]]';
105 $this->rules[self::DMY][self::MD] = self::DM;
106 $this->rules[self::ALL][self::MD] = self::MD;
107 $this->rules[self::MDY][self::DM] = self::MD;
108 $this->rules[self::ALL][self::DM] = self::DM;
109 $this->rules[self::NONE][self::ISO2] = self::ISO1;
111 $this->preferences = [
112 'default' => self::NONE,
116 'ISO 8601' => self::ISO1,
133 static $dateFormatter =
false;
134 if ( !$dateFormatter ) {
135 $dateFormatter =
$cache->getWithSetCallback(
136 $cache->makeKey(
'dateformatter',
$lang->getCode() ),
144 return $dateFormatter;
155 $linked = in_array(
'linked',
$options );
156 $match_whole = in_array(
'match-whole',
$options );
158 if ( isset( $this->preferences[$preference] ) ) {
159 $preference = $this->preferences[$preference];
161 $preference = self::NONE;
163 for ( $i = 1; $i <= self::LAST; $i++ ) {
165 if ( isset( $this->rules[$preference][$i] ) ) {
167 $this->mTarget = $this->rules[$preference][$i];
168 } elseif ( isset( $this->rules[self::ALL][$i] ) ) {
170 $this->mTarget = $this->rules[self::ALL][$i];
171 } elseif ( $preference ) {
173 $this->mTarget = $preference;
178 $regex = $this->regexes[$i];
182 $regex = str_replace( [
'\[\[',
'\]\]' ],
'', $regex );
185 if ( $match_whole ) {
187 $regex = preg_replace(
'!^/!',
'/^', $regex );
188 $regex = str_replace( $this->regexTrail,
189 '$' . $this->regexTrail, $regex );
193 $this->mLinked = $linked;
194 $text = preg_replace_callback( $regex, [ $this,
'replace' ], $text );
195 unset( $this->mLinked );
205 # Extract information from $matches
207 if ( isset( $this->mLinked ) ) {
213 $keyLength = strlen(
$key );
214 for ( $p = 0; $p < $keyLength; $p++ ) {
215 if (
$key[$p] !=
' ' ) {
233 $format = preg_replace(
'/\[\[[^|]+\|([^\]]+)\]\]/',
'$1', $format );
235 $format = str_replace( [
'[[',
']]' ],
'', $format );
243 if ( !isset( $bits[
'y'] ) && isset( $bits[
'Y'] ) ) {
246 if ( !isset( $bits[
'Y'] ) && isset( $bits[
'y'] ) ) {
250 if ( !isset( $bits[
'm'] ) ) {
252 if ( !$m || $m ==
'00' ) {
259 if ( !isset( $bits[
'd'] ) ) {
260 $bits[
'd'] = sprintf(
'%02d', $bits[
'j'] );
263 $formatLength = strlen( $format );
264 for ( $p = 0; $p < $formatLength; $p++ ) {
267 case 'd': # ISO day
of month
270 case 'm': # ISO month
276 case 'j': # ordinary day
of month
277 if ( !isset( $bits[
'j'] ) ) {
278 $text .= intval( $bits[
'd'] );
283 case 'F': #
long month
284 if ( !isset( $bits[
'F'] ) ) {
285 $m = intval( $bits[
'm'] );
286 if ( $m > 12 || $m < 1 ) {
289 $text .= $this->lang->getMonthName( $m );
292 $text .= ucfirst( $bits[
'F'] );
295 case 'Y': # ordinary (optional BC) year
308 if ( isset( $bits[
'y'] ) ) {
309 $isoBits[] = $bits[
'y'];
311 $isoBits[] = $bits[
'm'];
312 $isoBits[] = $bits[
'd'];
313 $isoDate = implode(
'-', $isoBits );
317 [
'class' =>
'mw-formatted-date',
'title' => $isoDate ], $text );
328 for ( $i = 1; $i <= 12; $i++ ) {
329 $names[] = $this->lang->getMonthName( $i );
330 $names[] = $this->lang->getMonthAbbreviation( $i );
332 return implode(
'|', $names );
341 $n = $this->xMonths[$this->lang->lc( $monthName )];
342 return sprintf(
'%02d', $n );
351 # Assumes the year is in a nice format, as enforced by the regex
352 if ( substr( $year, -2 ) ==
'BC' ) {
353 $num = intval( substr( $year, 0, -3 ) ) - 1;
354 # PHP bug note: sprintf( "%04d", -1 ) fails poorly
355 $text = sprintf(
'-%04d', $num );
358 $text = sprintf(
'%04d', $year );
370 if ( $iso[0] ==
'-' ) {
371 $text = ( intval( substr( $iso, 1 ) ) + 1 ) .
' BC';
373 $text = intval( $iso );
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
database rows
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control means(i) the power
when a variable name is used in a it is silently declared as a new local masking the global
the value to return A Title object or null for latest to be modified or replaced by the hook handler or if authentication is not possible after cache objects are set for highlighting & $link
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
CACHE_MEMCACHED $wgMainCacheType
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static getLocalServerInstance($fallback=CACHE_NONE)
Factory function for CACHE_ACCEL (referenced from DefaultSettings.php)
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
wfGetLangObj($langcode=false)
Return a Language object from $langcode.