r12145 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12144‎ | r12145 | r12146 >
Date:01:04, 19 December 2005
Author:avar
Status:old
Tags:
Comment:
* (bug 1436) &templates=expand now expands templates
Modified paths:
  • /trunk/phase3/includes/RawPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/RawPage.php
@@ -19,6 +19,9 @@
2020 */
2121 class RawPage {
2222 var $mArticle, $mTitle, $mRequest;
 23+ var $mOldId, $mGen, $mCharset;
 24+ var $mSmaxage, $mMaxage;
 25+ var $mContentType, $mExpandTemplates;
2326
2427 function RawPage( &$article, $request = false ) {
2528 global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType;
@@ -36,9 +39,11 @@
3740 $ctype = $this->mRequest->getText( 'ctype' );
3841 $smaxage = $this->mRequest->getInt( 'smaxage', $wgSquidMaxage );
3942 $maxage = $this->mRequest->getInt( 'maxage', $wgSquidMaxage );
 43+ $this->mExpandTemplates = $this->mRequest->getText( 'templates' ) === 'expand';
4044 $this->mOldId = $this->mRequest->getInt( 'oldid' );
4145 # special case for 'generated' raw things: user css/js
4246 $gen = $this->mRequest->getText( 'gen' );
 47+
4348 if($gen == 'css') {
4449 $this->mGen = $gen;
4550 if($smaxage == '') $smaxage = $wgSquidMaxage;
@@ -53,7 +58,7 @@
5459 $this->mCharset = $wgInputEncoding;
5560 $this->mSmaxage = $smaxage;
5661 $this->mMaxage = $maxage;
57 - if(empty($ctype) or !in_array($ctype, $allowedCTypes)) {
 62+ if ( $ctype == '' or ! in_array( $ctype, $allowedCTypes ) ) {
5863 $this->mContentType = 'text/x-wiki';
5964 } else {
6065 $this->mContentType = $ctype;
@@ -118,21 +123,27 @@
119124 }
120125 }
121126
122 - function getArticleText () {
 127+ function getArticleText() {
 128+ global $wgParser;
 129+
123130 if( $this->mTitle ) {
124 - # Special case for MediaWiki: messages; we can hit the message cache.
125 - if( $this->mTitle->getNamespace() == NS_MEDIAWIKI) {
126 - $rawtext = wfMsgForContent( $this->mTitle->getDbkey() );
127 - return $rawtext;
 131+ $text = '';
 132+
 133+ // If it's a MediaWiki message we can just hit the message cache
 134+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI )
 135+ $text = wfMsgForContentNoTrans( $this->mTitle->getDbkey() );
 136+ else {
 137+ // Get it from the DB
 138+ $rev = Revision::newFromTitle( $this->mTitle, $this->mOldId );
 139+ if ( $rev ) {
 140+ $lastmod = wfTimestamp( TS_RFC2822, $rev->getTimestamp() );
 141+ header( "Last-modified: $lastmod" );
 142+ $text = $rev->isDeleted() ? '' : $rev->getText();
 143+ } else
 144+ $text = '';
128145 }
129 -
130 - # else get it from the DB
131 - $rev = Revision::newFromTitle( $this->mTitle, $this->mOldId );
132 - if( $rev ) {
133 - $lastmod = wfTimestamp( TS_RFC2822, $rev->getTimestamp() );
134 - header( 'Last-modified: ' . $lastmod );
135 - return $rev->getText();
136 - }
 146+
 147+ return $this->parseArticleText( $text );
137148 }
138149
139150 # Bad title or page does not exist
@@ -145,5 +156,22 @@
146157 }
147158 return '';
148159 }
 160+
 161+ function parseArticleText( $text ) {
 162+ if ( $text === '' )
 163+ return '';
 164+ else
 165+ if ( $this->mExpandTemplates ) {
 166+ global $wgTitle;
 167+
 168+ $parser = new Parser();
 169+ $parser->Options( new ParserOptions() ); // We don't want this to be user-specific
 170+ $parser->Title( $wgTitle );
 171+ $parser->OutputType( OT_HTML );
 172+
 173+ return $parser->replaceVariables( $text );
 174+ } else
 175+ return $text;
 176+ }
149177 }
150178 ?>

Follow-up revisions

RevisionCommit summaryAuthorDate
r34693Partial revert of r12145. Bug 12145 Kazakh message updates did not mention/mo...siebrand21:13, 12 May 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r12144* (bug 1436) Accessors required for RawPage.phpavar01:02, 19 December 2005

Status & tagging log