r75083 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75082‎ | r75083 | r75084 >
Date:12:00, 20 October 2010
Author:ashley
Status:ok
Tags:
Comment:
coding style tweaks
Modified paths:
  • /trunk/phase3/includes/RawPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/RawPage.php
@@ -26,7 +26,7 @@
2727 function __construct( Article $article, $request = false ) {
2828 global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType, $wgGroupPermissions;
2929
30 - $allowedCTypes = array('text/x-wiki', $wgJsMimeType, 'text/css', 'application/x-zope-edit');
 30+ $allowedCTypes = array( 'text/x-wiki', $wgJsMimeType, 'text/css', 'application/x-zope-edit' );
3131 $this->mArticle = $article;
3232 $this->mTitle = $article->mTitle;
3333
@@ -57,7 +57,7 @@
5858 break;
5959 case 'prev':
6060 # output previous revision, or nothing if there isn't one
61 - if( ! $oldid ) {
 61+ if( !$oldid ) {
6262 # get the current revision so we can get the penultimate one
6363 $this->mArticle->getTouched();
6464 $oldid = $this->mArticle->mLatest;
@@ -76,17 +76,21 @@
7777
7878 if( $gen == 'css' ) {
7979 $this->mGen = $gen;
80 - if( is_null( $smaxage ) ) $smaxage = $wgSquidMaxage;
81 - if($ctype == '') $ctype = 'text/css';
 80+ if( is_null( $smaxage ) ) {
 81+ $smaxage = $wgSquidMaxage;
 82+ }
 83+ if( $ctype == '' ) {
 84+ $ctype = 'text/css';
 85+ }
8286 } else {
8387 $this->mGen = false;
8488 }
8589 $this->mCharset = $wgInputEncoding;
8690
8791 # Force caching for CSS and JS raw content, default: 5 minutes
88 - if( is_null($smaxage) and ($ctype=='text/css' or $ctype==$wgJsMimeType) ) {
 92+ if( is_null( $smaxage ) && ( $ctype == 'text/css' || $ctype == $wgJsMimeType ) ) {
8993 global $wgForcedRawSMaxage;
90 - $this->mSmaxage = intval($wgForcedRawSMaxage);
 94+ $this->mSmaxage = intval( $wgForcedRawSMaxage );
9195 } else {
9296 $this->mSmaxage = intval( $smaxage );
9397 }
@@ -94,13 +98,13 @@
9599
96100 # Output may contain user-specific data;
97101 # vary generated content for open sessions and private wikis
98 - if( $this->mGen or !$wgGroupPermissions['*']['read'] ) {
 102+ if( $this->mGen || !$wgGroupPermissions['*']['read'] ) {
99103 $this->mPrivateCache = $this->mSmaxage == 0 || session_id() != '';
100104 } else {
101105 $this->mPrivateCache = false;
102106 }
103107
104 - if( $ctype == '' or ! in_array( $ctype, $allowedCTypes ) ) {
 108+ if( $ctype == '' || !in_array( $ctype, $allowedCTypes ) ) {
105109 $this->mContentType = 'text/x-wiki';
106110 } else {
107111 $this->mContentType = $ctype;
@@ -124,28 +128,28 @@
125129 #
126130 # Just return a 403 Forbidden and get it over with.
127131 wfHttpError( 403, 'Forbidden',
128 - 'Invalid file extension found in PATH_INFO. ' .
 132+ 'Invalid file extension found in PATH_INFO. ' .
129133 'Raw pages must be accessed through the primary script entry point.' );
130134 return;
131135 }
132136
133 - header( "Content-type: ".$this->mContentType.'; charset='.$this->mCharset );
 137+ header( 'Content-type: ' . $this->mContentType . '; charset=' . $this->mCharset );
134138 # allow the client to cache this for 24 hours
135139 $mode = $this->mPrivateCache ? 'private' : 'public';
136 - header( 'Cache-Control: '.$mode.', s-maxage='.$this->mSmaxage.', max-age='.$this->mMaxage );
137 -
 140+ header( 'Cache-Control: ' . $mode . ', s-maxage=' . $this->mSmaxage . ', max-age=' . $this->mMaxage );
 141+
138142 global $wgUseFileCache;
139 - if( $wgUseFileCache and HTMLFileCache::useFileCache() ) {
 143+ if( $wgUseFileCache && HTMLFileCache::useFileCache() ) {
140144 $cache = new HTMLFileCache( $this->mTitle, 'raw' );
141145 if( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
142146 $cache->loadFromFileCache();
143147 $wgOut->disable();
144148 return;
145149 } else {
146 - ob_start( array(&$cache, 'saveToFileCache' ) );
 150+ ob_start( array( &$cache, 'saveToFileCache' ) );
147151 }
148152 }
149 -
 153+
150154 $text = $this->getRawText();
151155
152156 if( !wfRunHooks( 'RawPageViewBeforeOutput', array( &$this, &$text ) ) ) {
@@ -160,8 +164,9 @@
161165 global $wgUser, $wgOut;
162166 if( $this->mGen ) {
163167 $sk = $wgUser->getSkin();
164 - if( !StubObject::isRealObject( $wgOut ) )
 168+ if( !StubObject::isRealObject( $wgOut ) ) {
165169 $wgOut->_unstub( 2 );
 170+ }
166171 $sk->initPage( $wgOut );
167172 if( $this->mGen == 'css' ) {
168173 return $sk->generateUserStylesheet();
@@ -180,8 +185,9 @@
181186 $key = $this->mTitle->getDBkey();
182187 $text = wfMsgForContentNoTrans( $key );
183188 # If the message doesn't exist, return a blank
184 - if( wfEmptyMsg( $key, $text ) )
 189+ if( wfEmptyMsg( $key, $text ) ) {
185190 $text = '';
 191+ }
186192 $found = true;
187193 } else {
188194 // Get it from the DB
@@ -190,11 +196,12 @@
191197 $lastmod = wfTimestamp( TS_RFC2822, $rev->getTimestamp() );
192198 header( "Last-modified: $lastmod" );
193199
194 - if( !is_null($this->mSection ) ) {
 200+ if( !is_null( $this->mSection ) ) {
195201 global $wgParser;
196 - $text = $wgParser->getSection ( $rev->getText(), $this->mSection );
197 - } else
 202+ $text = $wgParser->getSection( $rev->getText(), $this->mSection );
 203+ } else {
198204 $text = $rev->getText();
 205+ }
199206 $found = true;
200207 }
201208 }
@@ -206,7 +213,7 @@
207214 # 404s aren't generally cached and it would create
208215 # extra hits when user CSS/JS are on and the user doesn't
209216 # have the pages.
210 - header( "HTTP/1.0 404 Not Found" );
 217+ header( 'HTTP/1.0 404 Not Found' );
211218 }
212219
213220 // Special-case for empty CSS/JS
@@ -218,22 +225,24 @@
219226 //
220227 // Give it a comment...
221228 if( strlen( $text ) == 0 &&
222 - ($this->mContentType == 'text/css' ||
 229+ ( $this->mContentType == 'text/css' ||
223230 $this->mContentType == 'text/javascript' ) ) {
224 - return "/* Empty */";
 231+ return '/* Empty */';
225232 }
226233
227234 return $this->parseArticleText( $text );
228235 }
229236
230237 function parseArticleText( $text ) {
231 - if( $text === '' )
 238+ if( $text === '' ) {
232239 return '';
233 - else
 240+ } else {
234241 if( $this->mExpandTemplates ) {
235242 global $wgParser;
236243 return $wgParser->preprocess( $text, $this->mTitle, new ParserOptions() );
237 - } else
 244+ } else {
238245 return $text;
 246+ }
 247+ }
239248 }
240249 }

Status & tagging log