Implement #1739 : new magickeyword REVISIONID. Give the diff / latest revision id...
authorAntoine Musso <hashar@users.mediawiki.org>
Sat, 26 Mar 2005 18:24:32 +0000 (18:24 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Sat, 26 Mar 2005 18:24:32 +0000 (18:24 +0000)
New fetchedRevId method in Article::

RELEASE-NOTES
includes/Article.php
includes/MagicWord.php
includes/Parser.php
languages/Language.php

index e229dfb..b3c8d76 100644 (file)
@@ -16,6 +16,8 @@ New exciting things! Need further work and testing...
 * New WikiSyntax: -- turns into &emdash; or &ndash; depending on context
 * (bug 15) Allow editors to view diff of their change before actually submitting an edit
 * (bug 190) Hide your own edits on the watchlist
+* (bug 1739) Magic keyword {{REVISIONID}} give you the article or diff database
+~ revision id, useful for proper citation.
 * ...and more!
 
 Need to merge:
index fe31b6c..8aff111 100644 (file)
@@ -34,6 +34,7 @@ class Article {
        var $mId, $mTable;
        var $mForUpdate;
        var $mOldId;
+       var $mRevIdFetched;
        /**#@-*/
 
        /**
@@ -68,6 +69,7 @@ class Article {
                $this->mTouched = '19700101000000';
                $this->mForUpdate = false;
                $this->mIsRedirect = false;
+               $this->mRevIdFetched = false;
        }
 
        /**
@@ -426,7 +428,9 @@ class Article {
                $this->mComment   = $revision->getComment();
                $this->mTimestamp = wfTimestamp( TS_MW, $revision->getTimestamp() );
                
+               $this->mRevIdFetched = $revision->getID();
                $this->mContentLoaded = true;
+               
                return $this->mContent;
        }
 
@@ -575,6 +579,11 @@ class Article {
                $this->loadLastEdit();
                return $this->mMinorEdit;
        }
+       
+       function getRevIdFetched() {
+               $this->loadLastEdit();
+               return $this->mRevIdFetched;
+       }
 
        function getContributors($limit = 0, $offset = 0) {
                $fname = 'Article::getContributors';
index bb4cf49..539d528 100644 (file)
@@ -9,7 +9,7 @@
  */
 $wgMagicFound = false;
 
-
+/** Actual keyword to be used is set in Language.php */
 define('MAG_REDIRECT', 0);
 define('MAG_NOTOC', 1);
 define('MAG_START', 2);
@@ -50,6 +50,7 @@ define('MAG_NOTITLECONVERT', 36);
 define('MAG_NOCONTENTCONVERT', 37);
 define('MAG_CURRENTWEEK', 38);
 define('MAG_CURRENTDOW', 39);
+define('MAG_REVISIONID', 40);
 
 $wgVariableIDs = array(
        MAG_CURRENTMONTH,
@@ -67,7 +68,8 @@ $wgVariableIDs = array(
        MAG_PAGENAMEE,
        MAG_NAMESPACE,
        MAG_CURRENTWEEK,
-       MAG_CURRENTDOW
+       MAG_CURRENTDOW,
+       MAG_REVISIONID,
 );
 
 /**
index 1b1398d..e4bd863 100644 (file)
@@ -1696,7 +1696,7 @@ class Parser
         * @access private
         */
        function getVariableValue( $index ) {
-               global $wgContLang, $wgSitename, $wgServer;
+               global $wgContLang, $wgSitename, $wgServer, $wgArticle;
                
                /**
                 * Some of these require message or data lookups and can be
@@ -1720,6 +1720,8 @@ class Parser
                                return $this->mTitle->getText();
                        case MAG_PAGENAMEE:
                                return $this->mTitle->getPartialURL();
+                       case MAG_REVISIONID:
+                               return $wgArticle->getRevIdFetched();
                        case MAG_NAMESPACE:
                                # return Namespace::getCanonicalName($this->mTitle->getNamespace());
                                return $wgContLang->getNsText($this->mTitle->getNamespace()); # Patch by Dori
index a163362..93f1bc1 100644 (file)
@@ -241,6 +241,7 @@ $wgLanguageNamesEn =& $wgLanguageNames;
        MAG_NOCONTENTCONVERT     => array( 0,    '__NOCONTENTCONVERT__', '__NOCC__'),
        MAG_CURRENTWEEK          => array( 1,    'CURRENTWEEK'            ),
        MAG_CURRENTDOW           => array( 1,    'CURRENTDOW'             ),
+       MAG_REVISIONID           => array( 1,    'REVISIONID'             ),    
 );
 
 #-------------------------------------------------------------------