Pre-fill the link cache with talk page of the user performing the action, and the...
[lhc/web/wiklou.git] / includes / MagicWord.php
index e616639..60bfd0f 100644 (file)
@@ -43,6 +43,16 @@ class MagicWord {
                'currentyear',
                'currenttime',
                'currenthour',
+               'localmonth',
+               'localmonthname',
+               'localmonthnamegen',
+               'localmonthabbrev',
+               'localday',
+               'localday2',
+               'localdayname',
+               'localyear',
+               'localtime',
+               'localhour',
                'numberofarticles',
                'numberoffiles',
                'sitename',
@@ -57,7 +67,14 @@ class MagicWord {
                'namespacee',
                'currentweek',
                'currentdow',
+               'localweek',
+               'localdow',
                'revisionid',
+               'revisionday',
+               'revisionday2',
+               'revisionmonth',
+               'revisionyear',
+               'revisiontimestamp',
                'subpagename',
                'subpagenamee',
                'displaytitle',
@@ -78,11 +95,13 @@ class MagicWord {
                'basepagenamee',
                'urlencode',
                'currenttimestamp',
+               'localtimestamp',
                'directionmark',
                'language',
                'contentlanguage',
                'pagesinnamespace',
                'numberofadmins',
+               'defaultsort',
        );
 
        static public $mObjects = array();
@@ -137,6 +156,11 @@ class MagicWord {
                global $wgContLang;
                $this->mId = $id;
                $wgContLang->getMagic( $this );
+               if ( !$this->mSynonyms ) {
+                       $this->mSynonyms = array( 'dkjsagfjsgashfajsh' );
+                       #throw new MWException( "Error: invalid magic word '$id'" );
+                       wfDebugLog( 'exception', "Error: invalid magic word '$id'\n" );
+               }
        }
 
        /**
@@ -155,7 +179,7 @@ class MagicWord {
                        $escSyn[] = preg_quote( $synonym, '/' );
                $this->mBaseRegex = implode( '|', $escSyn );
                
-               $case = $this->mCaseSensitive ? '' : 'i';
+               $case = $this->mCaseSensitive ? '' : 'iu';
                $this->mRegex = "/{$this->mBaseRegex}/{$case}";
                $this->mRegexStart = "/^(?:{$this->mBaseRegex})/{$case}";
                $this->mVariableRegex = str_replace( "\\$1", "(.*?)", $this->mRegex );
@@ -182,7 +206,7 @@ class MagicWord {
                if ( $this->mRegex === '' )
                        $this->initRegex();
 
-               return $this->mCaseSensitive ? '' : 'i';
+               return $this->mCaseSensitive ? '' : 'iu';
        }
 
        /**
@@ -266,7 +290,7 @@ class MagicWord {
         * Used in matchAndRemove()
         * @private
         **/
-       function pregRemoveAndRecord( $match ) {
+       function pregRemoveAndRecord( ) {
                $this->mFound = true;
                return '';
        }
@@ -275,7 +299,7 @@ class MagicWord {
         * Replaces the word with something else
         */
        function replace( $replacement, $subject, $limit=-1 ) {
-               $res = preg_replace( $this->getRegex(), wfRegexReplacement( $replacement ), $subject, $limit );
+               $res = preg_replace( $this->getRegex(), StringUtils::escapeRegexReplacement( $replacement ), $subject, $limit );
                $this->mModified = !($res === $subject);
                return $res;
        }
@@ -355,8 +379,9 @@ class MagicWord {
         * lookup in a list of magic words
         */
        function addToArray( &$array, $value ) {
+               global $wgContLang;
                foreach ( $this->mSynonyms as $syn ) {
-                       $array[$syn] = $value;
+                       $array[$wgContLang->lc($syn)] = $value;
                }
        }