64 for ( $i = 1; $i <= 12; $i++ ) {
65 $this->xMonths[$this->lang->lc( $this->lang->getMonthName( $i ) )] = $i;
66 $this->xMonths[$this->lang->lc( $this->lang->getMonthAbbreviation( $i ) )] = $i;
69 $this->regexTrail =
'(?![a-z])/iu';
71 # Partial regular expressions
72 $this->prxDM =
'\[\[(\d{1,2})[ _](' . $this->monthNames .
')\]\]';
73 $this->prxMD =
'\[\[(' . $this->monthNames .
')[ _](\d{1,2})\]\]';
74 $this->prxY =
'\[\[(\d{1,4}([ _]BC|))\]\]';
75 $this->prxISO1 =
'\[\[(-?\d{4})]]-\[\[(\d{2})-(\d{2})\]\]';
76 $this->prxISO2 =
'\[\[(-?\d{4})-(\d{2})-(\d{2})\]\]';
78 # Real regular expressions
79 $this->regexes[
self::DMY] =
"/{$this->prxDM}(?: *, *| +){$this->prxY}{$this->regexTrail}";
80 $this->regexes[
self::YDM] =
"/{$this->prxY}(?: *, *| +){$this->prxDM}{$this->regexTrail}";
81 $this->regexes[
self::MDY] =
"/{$this->prxMD}(?: *, *| +){$this->prxY}{$this->regexTrail}";
82 $this->regexes[
self::YMD] =
"/{$this->prxY}(?: *, *| +){$this->prxMD}{$this->regexTrail}";
83 $this->regexes[
self::DM] =
"/{$this->prxDM}{$this->regexTrail}";
84 $this->regexes[
self::MD] =
"/{$this->prxMD}{$this->regexTrail}";
85 $this->regexes[
self::ISO1] =
"/{$this->prxISO1}{$this->regexTrail}";
86 $this->regexes[
self::ISO2] =
"/{$this->prxISO2}{$this->regexTrail}";
89 # See the comments in replace() for the meaning of the letters
100 $this->targets[
self::DMY] =
'[[F j|j F]] [[Y]]';
101 $this->targets[
self::YDM] =
'[[Y]], [[F j|j F]]';
102 $this->targets[
self::MDY] =
'[[F j]], [[Y]]';
103 $this->targets[
self::YMD] =
'[[Y]] [[F j]]';
104 $this->targets[
self::DM] =
'[[F j|j F]]';
105 $this->targets[
self::MD] =
'[[F j]]';
106 $this->targets[
self::ISO1] =
'[[Y|y]]-[[F j|m-d]]';
117 $this->preferences = [
136 if ( is_string(
$lang ) ) {
137 wfDeprecated( __METHOD__ .
' with type string for $lang',
'1.31' );
142 static $dateFormatter =
false;
143 if ( !$dateFormatter ) {
144 $dateFormatter =
$cache->getWithSetCallback(
145 $cache->makeKey(
'dateformatter',
$lang->getCode() ),
153 return $dateFormatter;
164 $linked = in_array(
'linked',
$options );
165 $match_whole = in_array(
'match-whole',
$options );
167 if ( isset( $this->preferences[$preference] ) ) {
168 $preference = $this->preferences[$preference];
174 if ( isset( $this->rules[$preference][$i] ) ) {
176 $this->mTarget = $this->rules[$preference][$i];
177 } elseif ( isset( $this->rules[self::ALL][$i] ) ) {
179 $this->mTarget = $this->rules[
self::ALL][$i];
180 } elseif ( $preference ) {
182 $this->mTarget = $preference;
187 $regex = $this->regexes[$i];
191 $regex = str_replace( [
'\[\[',
'\]\]' ],
'', $regex );
194 if ( $match_whole ) {
196 $regex = preg_replace(
'!^/!',
'/^', $regex );
197 $regex = str_replace( $this->regexTrail,
198 '$' . $this->regexTrail, $regex );
202 $this->mLinked = $linked;
203 $text = preg_replace_callback( $regex, [ $this,
'replace' ], $text );
204 unset( $this->mLinked );
216 # Extract information from $matches
218 if ( isset( $this->mLinked ) ) {
224 $keyLength = strlen( $key );
225 for ( $p = 0; $p < $keyLength; $p++ ) {
226 if ( $key[$p] !=
' ' ) {
246 $format = preg_replace(
'/\[\[[^|]+\|([^\]]+)\]\]/',
'$1', $format );
248 $format = str_replace( [
'[[',
']]' ],
'', $format );
256 if ( !isset( $bits[
'y'] ) && isset( $bits[
'Y'] ) ) {
259 if ( !isset( $bits[
'Y'] ) && isset( $bits[
'y'] ) ) {
263 if ( !isset( $bits[
'm'] ) ) {
265 if ( !$m || $m ==
'00' ) {
272 if ( !isset( $bits[
'd'] ) ) {
273 $bits[
'd'] = sprintf(
'%02d', $bits[
'j'] );
276 $formatLength = strlen( $format );
277 for ( $p = 0; $p < $formatLength; $p++ ) {
280 case 'd': # ISO day of month
283 case 'm': # ISO month
289 case 'j': # ordinary day of month
290 if ( !isset( $bits[
'j'] ) ) {
291 $text .= intval( $bits[
'd'] );
296 case 'F': #
long month
297 if ( !isset( $bits[
'F'] ) ) {
298 $m = intval( $bits[
'm'] );
299 if ( $m > 12 || $m < 1 ) {
302 $text .= $this->lang->getMonthName( $m );
305 $text .= ucfirst( $bits[
'F'] );
308 case 'Y': # ordinary (optional BC) year
322 if ( isset( $bits[
'y'] ) ) {
323 $isoBits[] = $bits[
'y'];
325 $isoBits[] = $bits[
'm'];
326 $isoBits[] = $bits[
'd'];
327 $isoDate = implode(
'-', $isoBits );
330 $text = Html::rawElement(
'span',
331 [
'class' =>
'mw-formatted-date',
'title' => $isoDate ], $text );
342 for ( $i = 1; $i <= 12; $i++ ) {
343 $names[] = $this->lang->getMonthName( $i );
344 $names[] = $this->lang->getMonthAbbreviation( $i );
346 return implode(
'|', $names );
355 $n = $this->xMonths[$this->lang->lc( $monthName )];
356 return sprintf(
'%02d', $n );
365 # Assumes the year is in a nice format, as enforced by the regex
366 if ( substr( $year, -2 ) ==
'BC' ) {
367 $num = intval( substr( $year, 0, -3 ) ) - 1;
368 # PHP bug note: sprintf( "%04d", -1 ) fails poorly
369 $text = sprintf(
'-%04d', $num );
372 $text = sprintf(
'%04d', $year );
384 if ( $iso[0] ==
'-' ) {
385 $text = ( intval( substr( $iso, 1 ) ) + 1 ) .
' BC';
387 $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
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Internationalisation code.
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
when a variable name is used in a function
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
CACHE_MEMCACHED $wgMainCacheType