Index: trunk/phase3/includes/parser/CoreParserFunctions.php |
— | — | @@ -89,11 +89,17 @@ |
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | | - static function formatDate( $parser, $date ) { |
| 93 | + static function formatDate( $parser, $date, $defaultPref = null ) { |
94 | 94 | $df = DateFormatter::getInstance(); |
95 | 95 | |
| 96 | + $date = trim($date); |
| 97 | + |
96 | 98 | $pref = $parser->mOptions->getDateFormat(); |
97 | | - $date = $df->reformat( $pref, $date, false ); |
| 99 | + |
| 100 | + if ($pref == 'default' && $defaultPref) |
| 101 | + $pref = $defaultPref; |
| 102 | + |
| 103 | + $date = $df->reformat( $pref, $date, array('match-whole') ); |
98 | 104 | return $date; |
99 | 105 | } |
100 | 106 | |
Index: trunk/phase3/includes/parser/DateFormatter.php |
— | — | @@ -117,7 +117,11 @@ |
118 | 118 | * @param $preference String: User preference |
119 | 119 | * @param $text String: Text to reformat |
120 | 120 | */ |
121 | | - function reformat( $preference, $text, $linked = true ) { |
| 121 | + function reformat( $preference, $text, $options = array('linked') ) { |
| 122 | + |
| 123 | + $linked = in_array( 'linked', $options ); |
| 124 | + $match_whole = in_array( 'match-whole', $options ); |
| 125 | + |
122 | 126 | if ( isset( $this->preferences[$preference] ) ) { |
123 | 127 | $preference = $this->preferences[$preference]; |
124 | 128 | } else { |
— | — | @@ -145,6 +149,13 @@ |
146 | 150 | $regex = str_replace( array( '\[\[', '\]\]' ), '', $regex ); |
147 | 151 | } |
148 | 152 | |
| 153 | + if ($match_whole) { |
| 154 | + // Let's hope this works |
| 155 | + $regex = preg_replace( '!^/!', '/^', $regex ); |
| 156 | + $regex = str_replace( $this->regexTrail, |
| 157 | + '$'.$this->regexTrail, $regex ); |
| 158 | + } |
| 159 | + |
149 | 160 | // Another horrible hack |
150 | 161 | $this->mLinked = $linked; |
151 | 162 | $text = preg_replace_callback( $regex, array( &$this, 'replace' ), $text ); |