From: Roan Kattouw Date: Tue, 25 Sep 2007 18:36:25 +0000 (+0000) Subject: API: (bug 11405) Expand templates implementation in the API X-Git-Tag: 1.31.0-rc.0~51290 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=50e029c17e42baf56e4e1cce41cabe62bed2a453;p=lhc%2Fweb%2Fwiklou.git API: (bug 11405) Expand templates implementation in the API Modified patch by Bryan Tongh Minh --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a2244e89d8..7437a0fcc2 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -79,6 +79,7 @@ Full API documentation is available at http://www.mediawiki.org/wiki/API * (bug 11308) Allow the API to output the image metadata * (bug 11296) Temporary fix for escaping of ampersands inside links in pretty-printed help document. +* (bug 11405) Expand templates implementation in the API === Languages updated in 1.12 === diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index dc63c20e99..b8af8cae32 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -105,7 +105,10 @@ class ApiQueryRevisions extends ApiQueryBase { $this->addFields('old_id'); $this->addFields('old_text'); $this->addFields('old_flags'); + $this->fld_content = true; + + $this->expandTemplates = $expandtemplates; } $userMax = ($this->fld_content ? 50 : 500); @@ -245,7 +248,12 @@ class ApiQueryRevisions extends ApiQueryBase { } if ($this->fld_content) { - ApiResult :: setContent($vals, Revision :: getRevisionText($row)); + $text = Revision :: getRevisionText($row); + if ($this->expandTemplates) { + global $wgParser; + $text = $wgParser->preprocess( $text, Title::newFromID($row->rev_page), new ParserOptions() ); + } + ApiResult :: setContent($vals, $text); } return $vals; @@ -296,7 +304,9 @@ class ApiQueryRevisions extends ApiQueryBase { ), 'excludeuser' => array( ApiBase :: PARAM_TYPE => 'user' - ) + ), + + 'expandtemplates' => false, ); } @@ -311,6 +321,7 @@ class ApiQueryRevisions extends ApiQueryBase { 'dir' => 'direction of enumeration - towards "newer" or "older" revisions (enum)', 'user' => 'only include revisions made by user', 'excludeuser' => 'exclude revisions made by user', + 'expandtemplates' => 'expand templates in revision content' ); }