66 for ( $i = 1; $i <= 12; $i++ ) {
67 $this->xMonths[$this->lang->lc( $this->lang->getMonthName( $i ) )] = $i;
68 $this->xMonths[$this->lang->lc( $this->lang->getMonthAbbreviation( $i ) )] = $i;
71 $this->regexTrail =
'(?![a-z])/iu';
73 # Partial regular expressions
74 $this->prxDM =
'\[\[(\d{1,2})[ _](' . $this->monthNames .
')\]\]';
75 $this->prxMD =
'\[\[(' . $this->monthNames .
')[ _](\d{1,2})\]\]';
76 $this->prxY =
'\[\[(\d{1,4}([ _]BC|))\]\]';
77 $this->prxISO1 =
'\[\[(-?\d{4})]]-\[\[(\d{2})-(\d{2})\]\]';
78 $this->prxISO2 =
'\[\[(-?\d{4})-(\d{2})-(\d{2})\]\]';
80 # Real regular expressions
81 $this->regexes[
self::DMY] =
"/{$this->prxDM}(?: *, *| +){$this->prxY}{$this->regexTrail}";
82 $this->regexes[
self::YDM] =
"/{$this->prxY}(?: *, *| +){$this->prxDM}{$this->regexTrail}";
83 $this->regexes[
self::MDY] =
"/{$this->prxMD}(?: *, *| +){$this->prxY}{$this->regexTrail}";
84 $this->regexes[
self::YMD] =
"/{$this->prxY}(?: *, *| +){$this->prxMD}{$this->regexTrail}";
85 $this->regexes[
self::DM] =
"/{$this->prxDM}{$this->regexTrail}";
86 $this->regexes[
self::MD] =
"/{$this->prxMD}{$this->regexTrail}";
87 $this->regexes[
self::ISO1] =
"/{$this->prxISO1}{$this->regexTrail}";
88 $this->regexes[
self::ISO2] =
"/{$this->prxISO2}{$this->regexTrail}";
91 # See the comments in replace() for the meaning of the letters
101 # Target date formats
102 $this->targets[
self::DMY] =
'[[F j|j F]] [[Y]]';
103 $this->targets[
self::YDM] =
'[[Y]], [[F j|j F]]';
104 $this->targets[
self::MDY] =
'[[F j]], [[Y]]';
105 $this->targets[
self::YMD] =
'[[Y]] [[F j]]';
106 $this->targets[
self::DM] =
'[[F j|j F]]';
107 $this->targets[
self::MD] =
'[[F j]]';
108 $this->targets[
self::ISO1] =
'[[Y|y]]-[[F j|m-d]]';
119 $this->preferences = [
138 $lang =
$lang ?? MediaWikiServices::getInstance()->getContentLanguage();
141 static $dateFormatter =
false;
142 if ( !$dateFormatter ) {
143 $dateFormatter =
$cache->getWithSetCallback(
144 $cache->makeKey(
'dateformatter',
$lang->getCode() ),
152 return $dateFormatter;
163 $linked = in_array(
'linked',
$options );
164 $match_whole = in_array(
'match-whole',
$options );
166 if ( isset( $this->preferences[$preference] ) ) {
167 $preference = $this->preferences[$preference];
173 if ( isset( $this->rules[$preference][$i] ) ) {
175 $this->mTarget = $this->rules[$preference][$i];
176 } elseif ( isset( $this->rules[self::ALL][$i] ) ) {
178 $this->mTarget = $this->rules[
self::ALL][$i];
179 } elseif ( $preference ) {
181 $this->mTarget = $preference;
186 $regex = $this->regexes[$i];
190 $regex = str_replace( [
'\[\[',
'\]\]' ],
'', $regex );
193 if ( $match_whole ) {
195 $regex = preg_replace(
'!^/!',
'/^', $regex );
196 $regex = str_replace( $this->regexTrail,
197 '$' . $this->regexTrail, $regex );
201 $this->mLinked = $linked;
202 $text = preg_replace_callback( $regex, [ $this,
'replace' ], $text );
203 unset( $this->mLinked );
215 # Extract information from $matches
217 if ( isset( $this->mLinked ) ) {
223 $keyLength = strlen( $key );
224 for ( $p = 0; $p < $keyLength; $p++ ) {
225 if ( $key[$p] !=
' ' ) {
245 $format = preg_replace(
'/\[\[[^|]+\|([^\]]+)\]\]/',
'$1', $format );
247 $format = str_replace( [
'[[',
']]' ],
'', $format );
255 if ( !isset( $bits[
'y'] ) && isset( $bits[
'Y'] ) ) {
258 if ( !isset( $bits[
'Y'] ) && isset( $bits[
'y'] ) ) {
262 if ( !isset( $bits[
'm'] ) ) {
264 if ( !$m || $m ==
'00' ) {
271 if ( !isset( $bits[
'd'] ) ) {
272 $bits[
'd'] = sprintf(
'%02d', $bits[
'j'] );
275 $formatLength = strlen( $format );
276 for ( $p = 0; $p < $formatLength; $p++ ) {
279 case 'd': # ISO day of month
282 case 'm': # ISO month
288 case 'j': # ordinary day of month
289 if ( !isset( $bits[
'j'] ) ) {
290 $text .= intval( $bits[
'd'] );
295 case 'F': #
long month
296 if ( !isset( $bits[
'F'] ) ) {
297 $m = intval( $bits[
'm'] );
298 if ( $m > 12 || $m < 1 ) {
301 $text .= $this->lang->getMonthName( $m );
304 $text .= ucfirst( $bits[
'F'] );
307 case 'Y': # ordinary (optional BC) year
321 if ( isset( $bits[
'y'] ) ) {
322 $isoBits[] = $bits[
'y'];
324 $isoBits[] = $bits[
'm'];
325 $isoBits[] = $bits[
'd'];
326 $isoDate = implode(
'-', $isoBits );
329 $text = Html::rawElement(
'span',
330 [
'class' =>
'mw-formatted-date',
'title' => $isoDate ], $text );
341 for ( $i = 1; $i <= 12; $i++ ) {
342 $names[] = $this->lang->getMonthName( $i );
343 $names[] = $this->lang->getMonthAbbreviation( $i );
345 return implode(
'|', $names );
354 $n = $this->xMonths[$this->lang->lc( $monthName )];
355 return sprintf(
'%02d', $n );
364 # Assumes the year is in a nice format, as enforced by the regex
365 if ( substr( $year, -2 ) ==
'BC' ) {
366 $num = intval( substr( $year, 0, -3 ) ) - 1;
367 # PHP bug note: sprintf( "%04d", -1 ) fails poorly
368 $text = sprintf(
'-%04d', $num );
371 $text = sprintf(
'%04d', $year );
383 if ( $iso[0] ==
'-' ) {
384 $text = ( intval( substr( $iso, 1 ) ) + 1 ) .
' BC';
386 $text = intval( $iso );
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
Internationalisation code.
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
usually copyright or history_copyright This message must be in HTML not wikitext & $link
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 function
CACHE_MEMCACHED $wgMainCacheType