From: Antoine Musso Date: Sat, 26 Mar 2005 18:24:32 +0000 (+0000) Subject: Implement #1739 : new magickeyword REVISIONID. Give the diff / latest revision id... X-Git-Tag: 1.5.0alpha1~509 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=4caf76c1eac32db63e0c81e80d51a1b15d52e1f9;p=lhc%2Fweb%2Fwiklou.git Implement #1739 : new magickeyword REVISIONID. Give the diff / latest revision id for the article being view. Useful for proper citation. New fetchedRevId method in Article:: --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e229dfb1cb..b3c8d762d3 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -16,6 +16,8 @@ New exciting things! Need further work and testing... * New WikiSyntax: -- turns into &emdash; or – 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: diff --git a/includes/Article.php b/includes/Article.php index fe31b6c60e..8aff1110cb 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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'; diff --git a/includes/MagicWord.php b/includes/MagicWord.php index bb4cf497c4..539d528e01 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -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, ); /** diff --git a/includes/Parser.php b/includes/Parser.php index 1b1398d489..e4bd863316 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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 diff --git a/languages/Language.php b/languages/Language.php index a16336261d..93f1bc1848 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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' ), ); #-------------------------------------------------------------------