summaryrefslogtreecommitdiff
path: root/includes/parser/DateFormatter.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-08-12 09:28:15 +0200
committerPierre Schmitz <pierre@archlinux.de>2013-08-12 09:28:15 +0200
commit08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (patch)
tree577a29fb579188d16003a209ce2a2e9c5b0aa2bd /includes/parser/DateFormatter.php
parentcacc939b34e315b85e2d72997811eb6677996cc1 (diff)
Update to MediaWiki 1.21.1
Diffstat (limited to 'includes/parser/DateFormatter.php')
-rw-r--r--includes/parser/DateFormatter.php54
1 files changed, 27 insertions, 27 deletions
diff --git a/includes/parser/DateFormatter.php b/includes/parser/DateFormatter.php
index 2917b4a7..a2da3074 100644
--- a/includes/parser/DateFormatter.php
+++ b/includes/parser/DateFormatter.php
@@ -22,7 +22,7 @@
*/
/**
- * Date formatter, recognises dates in plain text and formats them accoding to user preferences.
+ * Date formatter, recognises dates in plain text and formats them according to user preferences.
* @todo preferences, OutputPage
* @ingroup Parser
*/
@@ -55,7 +55,7 @@ class DateFormatter {
$this->lang = $lang;
$this->monthNames = $this->getMonthRegex();
- for ( $i=1; $i<=12; $i++ ) {
+ for ( $i = 1; $i <= 12; $i++ ) {
$this->xMonths[$this->lang->lc( $this->lang->getMonthName( $i ) )] = $i;
$this->xMonths[$this->lang->lc( $this->lang->getMonthAbbreviation( $i ) )] = $i;
}
@@ -102,11 +102,11 @@ class DateFormatter {
# Rules
# pref source target
- $this->rules[self::DMY][self::MD] = self::DM;
- $this->rules[self::ALL][self::MD] = self::MD;
- $this->rules[self::MDY][self::DM] = self::MD;
- $this->rules[self::ALL][self::DM] = self::DM;
- $this->rules[self::NONE][self::ISO2] = self::ISO1;
+ $this->rules[self::DMY][self::MD] = self::DM;
+ $this->rules[self::ALL][self::MD] = self::MD;
+ $this->rules[self::MDY][self::DM] = self::MD;
+ $this->rules[self::ALL][self::DM] = self::DM;
+ $this->rules[self::NONE][self::ISO2] = self::ISO1;
$this->preferences = array(
'default' => self::NONE,
@@ -140,12 +140,12 @@ class DateFormatter {
}
/**
- * @param $preference String: User preference
- * @param $text String: Text to reformat
- * @param $options Array: can contain 'linked' and/or 'match-whole'
+ * @param string $preference User preference
+ * @param string $text Text to reformat
+ * @param array $options can contain 'linked' and/or 'match-whole'
* @return mixed|String
*/
- function reformat( $preference, $text, $options = array('linked') ) {
+ function reformat( $preference, $text, $options = array( 'linked' ) ) {
$linked = in_array( 'linked', $options );
$match_whole = in_array( 'match-whole', $options );
@@ -154,7 +154,7 @@ class DateFormatter {
} else {
$preference = self::NONE;
}
- for ( $i=1; $i<=self::LAST; $i++ ) {
+ for ( $i = 1; $i <= self::LAST; $i++ ) {
$this->mSource = $i;
if ( isset ( $this->rules[$preference][$i] ) ) {
# Specific rules
@@ -172,21 +172,21 @@ class DateFormatter {
$regex = $this->regexes[$i];
// Horrible hack
- if (!$linked) {
+ if ( !$linked ) {
$regex = str_replace( array( '\[\[', '\]\]' ), '', $regex );
}
- if ($match_whole) {
+ if ( $match_whole ) {
// Let's hope this works
$regex = preg_replace( '!^/!', '/^', $regex );
$regex = str_replace( $this->regexTrail,
- '$'.$this->regexTrail, $regex );
+ '$' . $this->regexTrail, $regex );
}
// Another horrible hack
$this->mLinked = $linked;
$text = preg_replace_callback( $regex, array( &$this, 'replace' ), $text );
- unset($this->mLinked);
+ unset( $this->mLinked );
}
return $text;
}
@@ -200,10 +200,10 @@ class DateFormatter {
$linked = true;
if ( isset( $this->mLinked ) )
$linked = $this->mLinked;
-
+
$bits = array();
$key = $this->keys[$this->mSource];
- for ( $p=0; $p < strlen($key); $p++ ) {
+ for ( $p = 0; $p < strlen( $key ); $p++ ) {
if ( $key[$p] != ' ' ) {
$bits[$key[$p]] = $matches[$p+1];
}
@@ -219,8 +219,8 @@ class DateFormatter {
*/
function formatDate( $bits, $link = true ) {
$format = $this->targets[$this->mTarget];
-
- if (!$link) {
+
+ if ( !$link ) {
// strip piped links
$format = preg_replace( '/\[\[[^|]+\|([^\]]+)\]\]/', '$1', $format );
// strip remaining links
@@ -246,11 +246,11 @@ class DateFormatter {
}
}
- if ( !isset($bits['d']) ) {
+ if ( !isset( $bits['d'] ) ) {
$bits['d'] = sprintf( '%02d', $bits['j'] );
}
- for ( $p=0; $p < strlen( $format ); $p++ ) {
+ for ( $p = 0; $p < strlen( $format ); $p++ ) {
$char = $format[$p];
switch ( $char ) {
case 'd': # ISO day of month
@@ -263,7 +263,7 @@ class DateFormatter {
$text .= $bits['y'];
break;
case 'j': # ordinary day of month
- if ( !isset($bits['j']) ) {
+ if ( !isset( $bits['j'] ) ) {
$text .= intval( $bits['d'] );
} else {
$text .= $bits['j'];
@@ -271,7 +271,7 @@ class DateFormatter {
break;
case 'F': # long month
if ( !isset( $bits['F'] ) ) {
- $m = intval($bits['m']);
+ $m = intval( $bits['m'] );
if ( $m > 12 || $m < 1 ) {
$fail = true;
} else {
@@ -293,7 +293,7 @@ class DateFormatter {
}
$isoBits = array();
- if ( isset($bits['y']) )
+ if ( isset( $bits['y'] ) )
$isoBits[] = $bits['y'];
$isoBits[] = $bits['m'];
$isoBits[] = $bits['d'];
@@ -321,7 +321,7 @@ class DateFormatter {
/**
* Makes an ISO month, e.g. 02, from a month name
- * @param $monthName String: month name
+ * @param string $monthName month name
* @return string ISO month name
*/
function makeIsoMonth( $monthName ) {
@@ -331,7 +331,7 @@ class DateFormatter {
/**
* @todo document
- * @param $year String: Year name
+ * @param string $year Year name
* @return string ISO year name
*/
function makeIsoYear( $year ) {