Index: trunk/phase3/includes/RawPage.php |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | function __construct( Article $article, $request = false ) { |
28 | 28 | global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType, $wgGroupPermissions; |
29 | 29 | |
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' ); |
31 | 31 | $this->mArticle = $article; |
32 | 32 | $this->mTitle = $article->mTitle; |
33 | 33 | |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | break; |
59 | 59 | case 'prev': |
60 | 60 | # output previous revision, or nothing if there isn't one |
61 | | - if( ! $oldid ) { |
| 61 | + if( !$oldid ) { |
62 | 62 | # get the current revision so we can get the penultimate one |
63 | 63 | $this->mArticle->getTouched(); |
64 | 64 | $oldid = $this->mArticle->mLatest; |
— | — | @@ -76,17 +76,21 @@ |
77 | 77 | |
78 | 78 | if( $gen == 'css' ) { |
79 | 79 | $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 | + } |
82 | 86 | } else { |
83 | 87 | $this->mGen = false; |
84 | 88 | } |
85 | 89 | $this->mCharset = $wgInputEncoding; |
86 | 90 | |
87 | 91 | # 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 ) ) { |
89 | 93 | global $wgForcedRawSMaxage; |
90 | | - $this->mSmaxage = intval($wgForcedRawSMaxage); |
| 94 | + $this->mSmaxage = intval( $wgForcedRawSMaxage ); |
91 | 95 | } else { |
92 | 96 | $this->mSmaxage = intval( $smaxage ); |
93 | 97 | } |
— | — | @@ -94,13 +98,13 @@ |
95 | 99 | |
96 | 100 | # Output may contain user-specific data; |
97 | 101 | # vary generated content for open sessions and private wikis |
98 | | - if( $this->mGen or !$wgGroupPermissions['*']['read'] ) { |
| 102 | + if( $this->mGen || !$wgGroupPermissions['*']['read'] ) { |
99 | 103 | $this->mPrivateCache = $this->mSmaxage == 0 || session_id() != ''; |
100 | 104 | } else { |
101 | 105 | $this->mPrivateCache = false; |
102 | 106 | } |
103 | 107 | |
104 | | - if( $ctype == '' or ! in_array( $ctype, $allowedCTypes ) ) { |
| 108 | + if( $ctype == '' || !in_array( $ctype, $allowedCTypes ) ) { |
105 | 109 | $this->mContentType = 'text/x-wiki'; |
106 | 110 | } else { |
107 | 111 | $this->mContentType = $ctype; |
— | — | @@ -124,28 +128,28 @@ |
125 | 129 | # |
126 | 130 | # Just return a 403 Forbidden and get it over with. |
127 | 131 | wfHttpError( 403, 'Forbidden', |
128 | | - 'Invalid file extension found in PATH_INFO. ' . |
| 132 | + 'Invalid file extension found in PATH_INFO. ' . |
129 | 133 | 'Raw pages must be accessed through the primary script entry point.' ); |
130 | 134 | return; |
131 | 135 | } |
132 | 136 | |
133 | | - header( "Content-type: ".$this->mContentType.'; charset='.$this->mCharset ); |
| 137 | + header( 'Content-type: ' . $this->mContentType . '; charset=' . $this->mCharset ); |
134 | 138 | # allow the client to cache this for 24 hours |
135 | 139 | $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 | + |
138 | 142 | global $wgUseFileCache; |
139 | | - if( $wgUseFileCache and HTMLFileCache::useFileCache() ) { |
| 143 | + if( $wgUseFileCache && HTMLFileCache::useFileCache() ) { |
140 | 144 | $cache = new HTMLFileCache( $this->mTitle, 'raw' ); |
141 | 145 | if( $cache->isFileCacheGood( /* Assume up to date */ ) ) { |
142 | 146 | $cache->loadFromFileCache(); |
143 | 147 | $wgOut->disable(); |
144 | 148 | return; |
145 | 149 | } else { |
146 | | - ob_start( array(&$cache, 'saveToFileCache' ) ); |
| 150 | + ob_start( array( &$cache, 'saveToFileCache' ) ); |
147 | 151 | } |
148 | 152 | } |
149 | | - |
| 153 | + |
150 | 154 | $text = $this->getRawText(); |
151 | 155 | |
152 | 156 | if( !wfRunHooks( 'RawPageViewBeforeOutput', array( &$this, &$text ) ) ) { |
— | — | @@ -160,8 +164,9 @@ |
161 | 165 | global $wgUser, $wgOut; |
162 | 166 | if( $this->mGen ) { |
163 | 167 | $sk = $wgUser->getSkin(); |
164 | | - if( !StubObject::isRealObject( $wgOut ) ) |
| 168 | + if( !StubObject::isRealObject( $wgOut ) ) { |
165 | 169 | $wgOut->_unstub( 2 ); |
| 170 | + } |
166 | 171 | $sk->initPage( $wgOut ); |
167 | 172 | if( $this->mGen == 'css' ) { |
168 | 173 | return $sk->generateUserStylesheet(); |
— | — | @@ -180,8 +185,9 @@ |
181 | 186 | $key = $this->mTitle->getDBkey(); |
182 | 187 | $text = wfMsgForContentNoTrans( $key ); |
183 | 188 | # If the message doesn't exist, return a blank |
184 | | - if( wfEmptyMsg( $key, $text ) ) |
| 189 | + if( wfEmptyMsg( $key, $text ) ) { |
185 | 190 | $text = ''; |
| 191 | + } |
186 | 192 | $found = true; |
187 | 193 | } else { |
188 | 194 | // Get it from the DB |
— | — | @@ -190,11 +196,12 @@ |
191 | 197 | $lastmod = wfTimestamp( TS_RFC2822, $rev->getTimestamp() ); |
192 | 198 | header( "Last-modified: $lastmod" ); |
193 | 199 | |
194 | | - if( !is_null($this->mSection ) ) { |
| 200 | + if( !is_null( $this->mSection ) ) { |
195 | 201 | global $wgParser; |
196 | | - $text = $wgParser->getSection ( $rev->getText(), $this->mSection ); |
197 | | - } else |
| 202 | + $text = $wgParser->getSection( $rev->getText(), $this->mSection ); |
| 203 | + } else { |
198 | 204 | $text = $rev->getText(); |
| 205 | + } |
199 | 206 | $found = true; |
200 | 207 | } |
201 | 208 | } |
— | — | @@ -206,7 +213,7 @@ |
207 | 214 | # 404s aren't generally cached and it would create |
208 | 215 | # extra hits when user CSS/JS are on and the user doesn't |
209 | 216 | # have the pages. |
210 | | - header( "HTTP/1.0 404 Not Found" ); |
| 217 | + header( 'HTTP/1.0 404 Not Found' ); |
211 | 218 | } |
212 | 219 | |
213 | 220 | // Special-case for empty CSS/JS |
— | — | @@ -218,22 +225,24 @@ |
219 | 226 | // |
220 | 227 | // Give it a comment... |
221 | 228 | if( strlen( $text ) == 0 && |
222 | | - ($this->mContentType == 'text/css' || |
| 229 | + ( $this->mContentType == 'text/css' || |
223 | 230 | $this->mContentType == 'text/javascript' ) ) { |
224 | | - return "/* Empty */"; |
| 231 | + return '/* Empty */'; |
225 | 232 | } |
226 | 233 | |
227 | 234 | return $this->parseArticleText( $text ); |
228 | 235 | } |
229 | 236 | |
230 | 237 | function parseArticleText( $text ) { |
231 | | - if( $text === '' ) |
| 238 | + if( $text === '' ) { |
232 | 239 | return ''; |
233 | | - else |
| 240 | + } else { |
234 | 241 | if( $this->mExpandTemplates ) { |
235 | 242 | global $wgParser; |
236 | 243 | return $wgParser->preprocess( $text, $this->mTitle, new ParserOptions() ); |
237 | | - } else |
| 244 | + } else { |
238 | 245 | return $text; |
| 246 | + } |
| 247 | + } |
239 | 248 | } |
240 | 249 | } |