}
}
- static function formatDate( $parser, $date ) {
+ static function formatDate( $parser, $date, $defaultPref = null ) {
$df = DateFormatter::getInstance();
+ $date = trim($date);
+
$pref = $parser->mOptions->getDateFormat();
- $date = $df->reformat( $pref, $date, false );
+
+ if ($pref == 'default' && $defaultPref)
+ $pref = $defaultPref;
+
+ $date = $df->reformat( $pref, $date, array('match-whole') );
return $date;
}
* @param $preference String: User preference
* @param $text String: Text to reformat
*/
- function reformat( $preference, $text, $linked = true ) {
+ function reformat( $preference, $text, $options = array('linked') ) {
+
+ $linked = in_array( 'linked', $options );
+ $match_whole = in_array( 'match-whole', $options );
+
if ( isset( $this->preferences[$preference] ) ) {
$preference = $this->preferences[$preference];
} else {
$regex = str_replace( array( '\[\[', '\]\]' ), '', $regex );
}
+ if ($match_whole) {
+ // Let's hope this works
+ $regex = preg_replace( '!^/!', '/^', $regex );
+ $regex = str_replace( $this->regexTrail,
+ '$'.$this->regexTrail, $regex );
+ }
+
// Another horrible hack
$this->mLinked = $linked;
$text = preg_replace_callback( $regex, array( &$this, 'replace' ), $text );