Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php |
— | — | @@ -15,13 +15,11 @@ |
16 | 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 | # http://www.gnu.org/copyleft/gpl.html |
18 | 18 | |
19 | | - |
20 | 19 | /* |
21 | | - todo : |
| 20 | + todo : |
22 | 21 | - check unicity of the index page : when index is saved too |
23 | 22 | */ |
24 | 23 | |
25 | | - |
26 | 24 | class ProofreadPage { |
27 | 25 | |
28 | 26 | /* Page and Index namespaces */ |
— | — | @@ -36,9 +34,9 @@ |
37 | 35 | */ |
38 | 36 | function ProofreadPage() { |
39 | 37 | global $wgParser, $wgHooks; |
40 | | - $wgParser->setHook( "pagelist", array( &$this, "renderPageList" ) ); |
41 | | - $wgParser->setHook( "pages", array( &$this, "renderPages" ) ); |
42 | | - $wgParser->setHook( "pagequality", array( &$this, "pageQuality" ) ); |
| 38 | + $wgParser->setHook( 'pagelist', array( &$this, 'renderPageList' ) ); |
| 39 | + $wgParser->setHook( 'pages', array( &$this, 'renderPages' ) ); |
| 40 | + $wgParser->setHook( 'pagequality', array( &$this, 'pageQuality' ) ); |
43 | 41 | $wgHooks['BeforePageDisplay'][] = array( &$this, 'beforePageDisplay' ); |
44 | 42 | $wgHooks['GetLinkColours'][] = array( &$this, 'getLinkColoursHook' ); |
45 | 43 | $wgHooks['ImageOpenShowImageInlineBefore'][] = array( &$this, 'imageMessage' ); |
— | — | @@ -57,70 +55,79 @@ |
58 | 56 | $this->index_namespace = preg_quote( wfMsgForContent( 'proofreadpage_index_namespace' ), '/' ); |
59 | 57 | } |
60 | 58 | |
61 | | - |
62 | 59 | public static function resourceLoaderRegisterModules() { |
| 60 | + ResourceLoader::register( |
| 61 | + 'proofreadpage.page', |
| 62 | + new ResourceLoaderFileModule( |
| 63 | + array( |
| 64 | + 'scripts' => 'extensions/ProofreadPage/proofread.js', |
| 65 | + 'messages' => array( |
| 66 | + 'proofreadpage_index', |
| 67 | + 'proofreadpage_nextpage', |
| 68 | + 'proofreadpage_prevpage', |
| 69 | + 'proofreadpage_image', |
| 70 | + 'proofreadpage_header', |
| 71 | + 'proofreadpage_body', |
| 72 | + 'proofreadpage_footer', |
| 73 | + 'proofreadpage_toggleheaders', |
| 74 | + 'proofreadpage_page_status', |
| 75 | + 'proofreadpage_quality0_category', |
| 76 | + 'proofreadpage_quality1_category', |
| 77 | + 'proofreadpage_quality2_category', |
| 78 | + 'proofreadpage_quality3_category', |
| 79 | + 'proofreadpage_quality4_category', |
| 80 | + ) |
| 81 | + ) |
| 82 | + ) |
| 83 | + ); |
63 | 84 | |
64 | | - ResourceLoader::register( 'proofreadpage.page', |
65 | | - new ResourceLoaderFileModule( |
66 | | - array( 'scripts' => 'extensions/ProofreadPage/proofread.js', |
67 | | - 'messages' => array( 'proofreadpage_index', |
68 | | - 'proofreadpage_nextpage', |
69 | | - 'proofreadpage_prevpage', |
70 | | - 'proofreadpage_image', |
71 | | - 'proofreadpage_header', |
72 | | - 'proofreadpage_body', |
73 | | - 'proofreadpage_footer', |
74 | | - 'proofreadpage_toggleheaders', |
75 | | - 'proofreadpage_page_status', |
76 | | - 'proofreadpage_quality0_category', |
77 | | - 'proofreadpage_quality1_category', |
78 | | - 'proofreadpage_quality2_category', |
79 | | - 'proofreadpage_quality3_category', |
80 | | - 'proofreadpage_quality4_category', |
81 | | - ) |
82 | | - ) ) ); |
| 85 | + ResourceLoader::register( |
| 86 | + 'proofreadpage.article', |
| 87 | + new ResourceLoaderFileModule( |
| 88 | + array( |
| 89 | + 'scripts' => 'extensions/ProofreadPage/proofread_article.js', |
| 90 | + 'messages'=> array( |
| 91 | + 'proofreadpage_source', |
| 92 | + 'proofreadpage_source_message' |
| 93 | + ) |
| 94 | + ) |
| 95 | + ) |
| 96 | + ); |
83 | 97 | |
84 | | - ResourceLoader::register( 'proofreadpage.article', |
85 | | - new ResourceLoaderFileModule( |
86 | | - array( 'scripts' => 'extensions/ProofreadPage/proofread_article.js', |
87 | | - 'messages'=> array( 'proofreadpage_source', 'proofreadpage_source_message' ) |
88 | | - ) ) ); |
| 98 | + ResourceLoader::register( |
| 99 | + 'proofreadpage.index', |
| 100 | + new ResourceLoaderFileModule( array( 'scripts' => 'extensions/ProofreadPage/proofread_index.js' ) ) |
| 101 | + ); |
89 | 102 | |
90 | | - ResourceLoader::register( 'proofreadpage.index', |
91 | | - new ResourceLoaderFileModule( array( 'scripts' => 'extensions/ProofreadPage/proofread_index.js' ) ) ); |
92 | | - |
93 | 103 | return true; |
94 | 104 | } |
95 | 105 | |
96 | | - |
97 | | - |
98 | 106 | function schema_update() { |
99 | 107 | global $wgExtNewTables; |
100 | | - $base = dirname(__FILE__); |
101 | | - $wgExtNewTables[] = array( 'pr_index', "$base/ProofreadPage.sql" ); |
| 108 | + $base = dirname( __FILE__ ); |
| 109 | + $wgExtNewTables[] = array( 'pr_index', "$base/ProofreadPage.sql" ); |
102 | 110 | return true; |
103 | 111 | } |
104 | 112 | |
105 | | - |
106 | 113 | /** |
107 | | - * Query the database to find if the current page is referred in an Index page. |
| 114 | + * Query the database to find if the current page is referred in an Index page. |
108 | 115 | */ |
109 | 116 | function load_index( $title ) { |
110 | | - |
111 | 117 | $page_namespace = $this->page_namespace; |
112 | 118 | $index_namespace = $this->index_namespace; |
113 | 119 | |
114 | 120 | $title->pr_index_title = null; |
115 | 121 | $dbr = wfGetDB( DB_SLAVE ); |
116 | 122 | $result = $dbr->select( |
117 | | - array( 'page', 'pagelinks' ), |
118 | | - array( 'page_namespace', 'page_title' ), |
119 | | - array( |
120 | | - 'pl_namespace' => $title->getNamespace(), |
121 | | - 'pl_title' => $title->getDBkey(), |
122 | | - 'pl_from=page_id' |
123 | | - ), |
124 | | - __METHOD__ ); |
| 123 | + array( 'page', 'pagelinks' ), |
| 124 | + array( 'page_namespace', 'page_title' ), |
| 125 | + array( |
| 126 | + 'pl_namespace' => $title->getNamespace(), |
| 127 | + 'pl_title' => $title->getDBkey(), |
| 128 | + 'pl_from=page_id' |
| 129 | + ), |
| 130 | + __METHOD__ |
| 131 | + ); |
125 | 132 | |
126 | 133 | while ( $x = $dbr->fetchObject( $result ) ) { |
127 | 134 | $ref_title = Title::makeTitle( $x->page_namespace, $x->page_title ); |
— | — | @@ -130,20 +137,23 @@ |
131 | 138 | } |
132 | 139 | } |
133 | 140 | $dbr->freeResult( $result ) ; |
134 | | - |
135 | | - if ( $title->pr_index_title ) return; |
136 | | - |
137 | | - /*check if we are a page of a multipage file*/ |
| 141 | + |
| 142 | + if ( $title->pr_index_title ) { |
| 143 | + return; |
| 144 | + } |
| 145 | + |
| 146 | + /* check if we are a page of a multipage file */ |
138 | 147 | if ( preg_match( "/^$page_namespace:(.*?)(\/([0-9]*)|)$/", $title->getPrefixedText(), $m ) ) { |
139 | 148 | $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] ); |
140 | 149 | } |
141 | | - if ( !$imageTitle ) return; |
| 150 | + if ( !$imageTitle ) { |
| 151 | + return; |
| 152 | + } |
142 | 153 | |
143 | 154 | $image = wfFindFile( $imageTitle ); |
144 | 155 | |
145 | 156 | // if it is multipage, we use the page order of the file |
146 | 157 | if ( $image && $image->exists() && $image->isMultiPage() ) { |
147 | | - |
148 | 158 | $name = $image->getTitle()->getText(); |
149 | 159 | $index_name = "$index_namespace:$name"; |
150 | 160 | |
— | — | @@ -154,12 +164,10 @@ |
155 | 165 | } |
156 | 166 | } |
157 | 167 | |
158 | | - |
159 | 168 | /** |
160 | 169 | * return the URLs of the index, previous and next pages. |
161 | 170 | */ |
162 | 171 | function navigation( $title ) { |
163 | | - |
164 | 172 | $page_namespace = $this->page_namespace; |
165 | 173 | $default_header = wfMsgGetKey( 'proofreadpage_default_header', true, true, false ); |
166 | 174 | $default_footer = wfMsgGetKey( 'proofreadpage_default_footer', true, true, false ); |
— | — | @@ -188,83 +196,90 @@ |
189 | 197 | $next_name = "$page_namespace:$name/" . ( $pagenr + 1 ); |
190 | 198 | $prev_url = ( $pagenr == 1 ) ? '' : Title::newFromText( $prev_name )->getFullURL(); |
191 | 199 | $next_url = ( $pagenr == $count ) ? '' : Title::newFromText( $next_name )->getFullURL(); |
192 | | - |
| 200 | + |
193 | 201 | } else { |
194 | 202 | $prev_url = ''; |
195 | 203 | $next_url = ''; |
196 | 204 | } |
197 | | - |
| 205 | + |
198 | 206 | $index_url = $index_title->getFullURL(); |
199 | | - |
| 207 | + |
200 | 208 | if ( !$index_title->exists() ) { |
201 | 209 | return array( $index_url, $prev_url, $next_url, $default_header, $default_footer ); |
202 | 210 | } |
203 | 211 | |
204 | | - //if the index page exists, find current page number, previous and next pages |
| 212 | + // if the index page exists, find current page number, previous and next pages |
205 | 213 | list( $links, $params, $attributes ) = $this->parse_index( $index_title ); |
206 | | - |
207 | | - if( $links==null ) { |
208 | | - list($pagenum, $links, $mode) = $this->pageNumber($pagenr,$params); |
209 | | - $attributes["pagenum"] = $pagenum; |
| 214 | + |
| 215 | + if( $links == null ) { |
| 216 | + list( $pagenum, $links, $mode ) = $this->pageNumber( $pagenr, $params ); |
| 217 | + $attributes['pagenum'] = $pagenum; |
210 | 218 | } else { |
211 | | - for( $i=0; $i<count( $links[1] ); $i++) { |
212 | | - $a_title = Title::newFromText( $page_namespace.":".$links[1][$i] ); |
213 | | - if(!$a_title) continue; |
| 219 | + for( $i = 0; $i < count( $links[1] ); $i++ ) { |
| 220 | + $a_title = Title::newFromText( $page_namespace . ':' . $links[1][$i] ); |
| 221 | + if( !$a_title ) { |
| 222 | + continue; |
| 223 | + } |
214 | 224 | if( $a_title->getPrefixedText() == $title->getPrefixedText() ) { |
215 | | - $attributes["pagenum"] = $links[3][$i]; |
| 225 | + $attributes['pagenum'] = $links[3][$i]; |
216 | 226 | break; |
217 | 227 | } |
218 | 228 | } |
219 | | - if( ($i>0) && ($i<count($links[1])) ){ |
220 | | - $prev_title = Title::newFromText( $page_namespace.":".$links[1][$i-1] ); |
| 229 | + if( ( $i > 0 ) && ( $i < count( $links[1] ) ) ) { |
| 230 | + $prev_title = Title::newFromText( $page_namespace . ':' . $links[1][$i - 1] ); |
221 | 231 | } |
222 | | - if( ($i>=0) && ($i+1<count($links[1])) ){ |
223 | | - $next_title = Title::newFromText( $page_namespace.":".$links[1][$i+1] ); |
| 232 | + if( ( $i >= 0 ) && ( $i + 1 < count( $links[1] ) ) ) { |
| 233 | + $next_title = Title::newFromText( $page_namespace . ':' . $links[1][$i + 1] ); |
224 | 234 | } |
225 | | - if($prev_title) $prev_url = $prev_title->getFullURL(); |
226 | | - if($next_title) $next_url = $next_title->getFullURL(); |
| 235 | + if( $prev_title ) { |
| 236 | + $prev_url = $prev_title->getFullURL(); |
| 237 | + } |
| 238 | + if( $next_title ) { |
| 239 | + $next_url = $next_title->getFullURL(); |
| 240 | + } |
227 | 241 | } |
228 | 242 | |
229 | | - // Header and Footer |
| 243 | + // Header and Footer |
230 | 244 | // use a js dictionary for style, width, header footer |
231 | | - $header = $attributes['header'] ? $attributes['header'] : $default_header; |
232 | | - $footer = $attributes['footer'] ? $attributes['footer'] : $default_footer; |
| 245 | + $header = $attributes['header'] ? $attributes['header'] : $default_header; |
| 246 | + $footer = $attributes['footer'] ? $attributes['footer'] : $default_footer; |
233 | 247 | foreach ( $attributes as $key => $val ) { |
234 | 248 | $header = str_replace( "{{{{$key}}}}", $val, $header ); |
235 | 249 | $footer = str_replace( "{{{{$key}}}}", $val, $footer ); |
236 | 250 | } |
237 | | - $css = $attributes['css'] ? $attributes['css'] : ""; |
238 | | - $edit_width = $attributes['width'] ? $attributes['width'] : ""; |
239 | | - |
| 251 | + $css = $attributes['css'] ? $attributes['css'] : ''; |
| 252 | + $edit_width = $attributes['width'] ? $attributes['width'] : ''; |
| 253 | + |
240 | 254 | return array( $index_url, $prev_url, $next_url, $header, $footer, $css, $edit_width ); |
241 | | - |
242 | 255 | } |
243 | 256 | |
244 | | - |
245 | | - /* |
| 257 | + /** |
246 | 258 | * Read metadata from an index page. |
247 | | - * Depending on whether the index uses pagelist, |
248 | | - * it will return either a list of links or a list |
| 259 | + * Depending on whether the index uses pagelist, |
| 260 | + * it will return either a list of links or a list |
249 | 261 | * of parameters to pagelist, and a list of attributes. |
250 | 262 | */ |
251 | 263 | function parse_index( $index_title ) { |
252 | 264 | $err = array( false, false, array() ); |
253 | | - if ( !$index_title ) return $err; |
254 | | - if ( !$index_title->exists() ) return $err; |
255 | | - |
| 265 | + if ( !$index_title ) { |
| 266 | + return $err; |
| 267 | + } |
| 268 | + if ( !$index_title->exists() ) { |
| 269 | + return $err; |
| 270 | + } |
| 271 | + |
256 | 272 | $rev = Revision::newFromTitle( $index_title ); |
257 | 273 | $text = $rev->getText(); |
258 | 274 | return $this->parse_index_text( $text ); |
259 | 275 | } |
260 | 276 | |
261 | | - function parse_index_text( $text ){ |
262 | | - |
| 277 | + function parse_index_text( $text ) { |
263 | 278 | $page_namespace = $this->page_namespace; |
264 | 279 | //check if it is using pagelist |
265 | 280 | preg_match_all( "/<pagelist([^<]*?)\/>/is", $text, $m, PREG_PATTERN_ORDER ); |
266 | 281 | if( $m[1] ) { |
267 | | - $params_s = ""; |
268 | | - for( $k = 0; $k < count( $m[1] ); $k++) { |
| 282 | + $params_s = ''; |
| 283 | + for( $k = 0; $k < count( $m[1] ); $k++ ) { |
269 | 284 | $params_s = $params_s . $m[1][$k]; |
270 | 285 | } |
271 | 286 | $params = Sanitizer::decodeTagAttributes( $params_s ); |
— | — | @@ -275,16 +290,15 @@ |
276 | 291 | preg_match_all( $tag_pattern, $text, $links, PREG_PATTERN_ORDER ); |
277 | 292 | } |
278 | 293 | |
279 | | - |
280 | | - //read attributes |
| 294 | + // read attributes |
281 | 295 | $attributes = array(); |
282 | | - $var_names = explode(" ", wfMsgForContent('proofreadpage_js_attributes') ); |
283 | | - for( $i = 0; $i < count($var_names); $i++ ) { |
| 296 | + $var_names = explode( ' ', wfMsgForContent( 'proofreadpage_js_attributes' ) ); |
| 297 | + for( $i = 0; $i < count( $var_names ); $i++ ) { |
284 | 298 | $tag_pattern = "/\n\|" . $var_names[$i] . "=(.*?)\n(\||\}\})/is"; |
285 | | - //$var = 'proofreadPage'.$var_names[$i]; |
| 299 | + //$var = 'proofreadPage' . $var_names[$i]; |
286 | 300 | $var = strtolower( $var_names[$i] ); |
287 | 301 | if( preg_match( $tag_pattern, $text, $matches ) ) { |
288 | | - $attributes[$var] = $matches[1]; |
| 302 | + $attributes[$var] = $matches[1]; |
289 | 303 | } else { |
290 | 304 | $attributes[$var] = ''; |
291 | 305 | } |
— | — | @@ -296,10 +310,9 @@ |
297 | 311 | /** |
298 | 312 | * Return the ordered list of links to ns-0 from an index page |
299 | 313 | */ |
300 | | - function parse_index_links( $index_title ){ |
301 | | - |
| 314 | + function parse_index_links( $index_title ) { |
302 | 315 | // Instanciate a new parser object to avoid side effects of $parser->replaceVariables |
303 | | - if( is_null($this->index_parser) ) { |
| 316 | + if( is_null( $this->index_parser ) ) { |
304 | 317 | $this->index_parser = new Parser; |
305 | 318 | } |
306 | 319 | $rev = Revision::newFromTitle( $index_title ); |
— | — | @@ -316,31 +329,31 @@ |
317 | 330 | */ |
318 | 331 | function beforePageDisplay( &$out ) { |
319 | 332 | global $wgTitle, $wgJsMimeType, $wgScriptPath, $wgRequest, $wgProofreadPageVersion; |
320 | | - |
| 333 | + |
321 | 334 | $action = $wgRequest->getVal( 'action' ); |
322 | 335 | $isEdit = ( $action == 'submit' || $action == 'edit' ) ? 1 : 0; |
323 | 336 | if ( !isset( $wgTitle ) || ( !$out->isArticle() && !$isEdit ) || isset( $out->proofreadPageDone ) ) { |
324 | 337 | return true; |
325 | 338 | } |
326 | 339 | $out->proofreadPageDone = true; |
327 | | - |
| 340 | + |
328 | 341 | $page_namespace = $this->page_namespace; |
329 | 342 | if ( preg_match( "/^$page_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText(), $m ) ) { |
330 | 343 | $this->preparePage( $out, $m, $isEdit ); |
331 | 344 | return true; |
332 | 345 | } |
333 | | - |
| 346 | + |
334 | 347 | $index_namespace = $this->index_namespace; |
335 | 348 | if ( $isEdit && ( preg_match( "/^$index_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText(), $m ) ) ) { |
336 | 349 | $this->prepareIndex( $out ); |
337 | 350 | return true; |
338 | 351 | } |
339 | | - |
| 352 | + |
340 | 353 | if( $wgTitle->getNamespace() == NS_MAIN ) { |
341 | 354 | $this->prepareArticle( $out ); |
342 | 355 | return true; |
343 | 356 | } |
344 | | - |
| 357 | + |
345 | 358 | return true; |
346 | 359 | } |
347 | 360 | |
— | — | @@ -363,7 +376,7 @@ |
364 | 377 | if ( !isset( $wgTitle->pr_index_title ) ) { |
365 | 378 | $this->load_index( $wgTitle ); |
366 | 379 | } |
367 | | - |
| 380 | + |
368 | 381 | $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] ); |
369 | 382 | if ( !$imageTitle ) { |
370 | 383 | return true; |
— | — | @@ -387,22 +400,22 @@ |
388 | 401 | } |
389 | 402 | |
390 | 403 | list( $index_url, $prev_url, $next_url, $header, $footer, $css, $edit_width ) = $this->navigation( $wgTitle ); |
391 | | - |
| 404 | + |
392 | 405 | $jsVars = array( |
393 | | - 'proofreadPageWidth' => intval( $width ), |
394 | | - 'proofreadPageHeight' => intval( $height ), |
395 | | - 'proofreadPageEditWidth' => $edit_width, |
396 | | - 'proofreadPageThumbURL' => $thumbURL, |
397 | | - 'proofreadPageIsEdit' => intval( $isEdit ), |
398 | | - 'proofreadPageIndexURL' => $index_url, |
399 | | - 'proofreadPagePrevURL' => $prev_url, |
400 | | - 'proofreadPageNextURL' => $next_url, |
401 | | - 'proofreadPageHeader' => $header, |
402 | | - 'proofreadPageFooter' => $footer, |
403 | | - 'proofreadPageAddButtons' => $wgUser->isAllowed('pagequality'), |
404 | | - 'proofreadPageUserName' => $wgUser->getName(), |
405 | | - 'proofreadPageCss' => $css, |
406 | | - ); |
| 406 | + 'proofreadPageWidth' => intval( $width ), |
| 407 | + 'proofreadPageHeight' => intval( $height ), |
| 408 | + 'proofreadPageEditWidth' => $edit_width, |
| 409 | + 'proofreadPageThumbURL' => $thumbURL, |
| 410 | + 'proofreadPageIsEdit' => intval( $isEdit ), |
| 411 | + 'proofreadPageIndexURL' => $index_url, |
| 412 | + 'proofreadPagePrevURL' => $prev_url, |
| 413 | + 'proofreadPageNextURL' => $next_url, |
| 414 | + 'proofreadPageHeader' => $header, |
| 415 | + 'proofreadPageFooter' => $footer, |
| 416 | + 'proofreadPageAddButtons' => $wgUser->isAllowed( 'pagequality' ), |
| 417 | + 'proofreadPageUserName' => $wgUser->getName(), |
| 418 | + 'proofreadPageCss' => $css, |
| 419 | + ); |
407 | 420 | $out->addInlineScript( ResourceLoader::makeConfigSetScript( $jsVars ) ); |
408 | 421 | |
409 | 422 | $out->addModules( 'proofreadpage.page' ); |
— | — | @@ -410,9 +423,8 @@ |
411 | 424 | return true; |
412 | 425 | } |
413 | 426 | |
414 | | - |
415 | 427 | /** |
416 | | - * Hook function |
| 428 | + * Hook function |
417 | 429 | */ |
418 | 430 | function getLinkColoursHook( $page_ids, &$colours ) { |
419 | 431 | global $wgTitle; |
— | — | @@ -427,10 +439,9 @@ |
428 | 440 | $this->getLinkColours( $page_ids, $colours ); |
429 | 441 | return true; |
430 | 442 | } |
431 | | - |
432 | 443 | |
433 | 444 | /** |
434 | | - * Return the quality colour codes to pages linked from an index page |
| 445 | + * Return the quality colour codes to pages linked from an index page |
435 | 446 | */ |
436 | 447 | function getLinkColours( $page_ids, &$colours ) { |
437 | 448 | $page_namespace = $this->page_namespace; |
— | — | @@ -441,7 +452,7 @@ |
442 | 453 | if ( preg_match( "/^$page_namespace:(.*?)$/", $pdbk ) ) { |
443 | 454 | $colours[$pdbk] = 'quality1'; |
444 | 455 | if ( !isset( $query ) ) { |
445 | | - $query = "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN("; |
| 456 | + $query = "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN("; |
446 | 457 | } else { |
447 | 458 | $query .= ', '; |
448 | 459 | } |
— | — | @@ -476,7 +487,7 @@ |
477 | 488 | } |
478 | 489 | } |
479 | 490 | |
480 | | - function imageMessage( &$imgpage , &$wgOut ) { |
| 491 | + function imageMessage( &$imgpage, &$out ) { |
481 | 492 | global $wgUser; |
482 | 493 | $index_namespace = $this->index_namespace; |
483 | 494 | $image = $imgpage->img; |
— | — | @@ -486,48 +497,93 @@ |
487 | 498 | $sk = $wgUser->getSkin(); |
488 | 499 | $name = $image->getTitle()->getText(); |
489 | 500 | $link = $sk->makeKnownLink( "$index_namespace:$name", wfMsg( 'proofreadpage_image_message' ) ); |
490 | | - $wgOut->addHTML( "{$link}" ); |
| 501 | + $out->addHTML( "{$link}" ); |
491 | 502 | return true; |
492 | 503 | } |
493 | 504 | |
494 | | - |
495 | 505 | // credit : http://www.mediawiki.org/wiki/Extension:RomanNumbers |
496 | 506 | function toRoman( $num ) { |
497 | 507 | if ( $num < 0 || $num > 9999 ) { |
498 | 508 | return - 1; |
499 | 509 | } |
500 | | - $romanOnes = array( 1 => "I", 2 => "II", 3 => "III", 4 => "IV", 5 => "V", 6 => "VI", 7 => "VII", 8 => "VIII", 9 => "IX" ); |
501 | | - $romanTens = array( 1 => "X", 2 => "XX", 3 => "XXX", 4 => "XL", 5 => "L", 6 => "LX", 7 => "LXX", 8 => "LXXX", 9 => "XC" ); |
502 | | - $romanHund = array( 1 => "C", 2 => "CC", 3 => "CCC", 4 => "CD", 5 => "D", 6 => "DC", 7 => "DCC", 8 => "DCCC", 9 => "CM" ); |
503 | | - $romanThou = array( 1 => "M", 2 => "MM", 3 => "MMM", 4 => "MMMM", 5 => "MMMMM", 6 => "MMMMMM", 7 => "MMMMMMM", 8 => "MMMMMMMM", 9 => "MMMMMMMMM" ); |
504 | | - |
| 510 | + $romanOnes = array( |
| 511 | + 1 => 'I', |
| 512 | + 2 => 'II', |
| 513 | + 3 => 'III', |
| 514 | + 4 => 'IV', |
| 515 | + 5 => 'V', |
| 516 | + 6 => 'VI', |
| 517 | + 7 => 'VII', |
| 518 | + 8 => 'VIII', |
| 519 | + 9 => 'IX' |
| 520 | + ); |
| 521 | + $romanTens = array( |
| 522 | + 1 => 'X', |
| 523 | + 2 => 'XX', |
| 524 | + 3 => 'XXX', |
| 525 | + 4 => 'XL', |
| 526 | + 5 => 'L', |
| 527 | + 6 => 'LX', |
| 528 | + 7 => 'LXX', |
| 529 | + 8 => 'LXXX', |
| 530 | + 9 => 'XC' |
| 531 | + ); |
| 532 | + $romanHund = array( |
| 533 | + 1 => 'C', |
| 534 | + 2 => 'CC', |
| 535 | + 3 => 'CCC', |
| 536 | + 4 => 'CD', |
| 537 | + 5 => 'D', |
| 538 | + 6 => 'DC', |
| 539 | + 7 => 'DCC', |
| 540 | + 8 => 'DCCC', |
| 541 | + 9 => 'CM' |
| 542 | + ); |
| 543 | + $romanThou = array( |
| 544 | + 1 => 'M', |
| 545 | + 2 => 'MM', |
| 546 | + 3 => 'MMM', |
| 547 | + 4 => 'MMMM', |
| 548 | + 5 => 'MMMMM', |
| 549 | + 6 => 'MMMMMM', |
| 550 | + 7 => 'MMMMMMM', |
| 551 | + 8 => 'MMMMMMMM', |
| 552 | + 9 => 'MMMMMMMMM' |
| 553 | + ); |
| 554 | + |
505 | 555 | $ones = $num % 10; |
506 | 556 | $tens = ( $num - $ones ) % 100; |
507 | 557 | $hund = ( $num - $tens - $ones ) % 1000; |
508 | 558 | $thou = ( $num - $hund - $tens - $ones ) % 10000; |
509 | | - |
| 559 | + |
510 | 560 | $tens = $tens / 10; |
511 | 561 | $hund = $hund / 100; |
512 | 562 | $thou = $thou / 1000; |
513 | | - |
514 | | - if ( $thou ) $romanNum .= $romanThou[$thou]; |
515 | | - if ( $hund ) $romanNum .= $romanHund[$hund]; |
516 | | - if ( $tens ) $romanNum .= $romanTens[$tens]; |
517 | | - if ( $ones ) $romanNum .= $romanOnes[$ones]; |
518 | | - |
| 563 | + |
| 564 | + if ( $thou ) { |
| 565 | + $romanNum .= $romanThou[$thou]; |
| 566 | + } |
| 567 | + if ( $hund ) { |
| 568 | + $romanNum .= $romanHund[$hund]; |
| 569 | + } |
| 570 | + if ( $tens ) { |
| 571 | + $romanNum .= $romanTens[$tens]; |
| 572 | + } |
| 573 | + if ( $ones ) { |
| 574 | + $romanNum .= $romanOnes[$ones]; |
| 575 | + } |
| 576 | + |
519 | 577 | return $romanNum; |
520 | 578 | } |
521 | 579 | |
522 | | - |
523 | 580 | function pageNumber( $i, $args ) { |
524 | | - |
525 | 581 | $mode = 'normal'; // default |
526 | 582 | $offset = 0; |
527 | 583 | $links = true; |
528 | 584 | foreach ( $args as $num => $param ) { |
529 | 585 | if ( ( preg_match( "/^([0-9]*)to([0-9]*)$/", $num, $m ) && ( $i >= $m[1] && $i <= $m[2] ) ) |
530 | 586 | || ( is_numeric( $num ) && ( $i == $num ) ) ) { |
531 | | - $params = explode( ";", $param ); |
| 587 | + $params = explode( ';', $param ); |
532 | 588 | foreach ( $params as $iparam ) { |
533 | 589 | switch( $iparam ) { |
534 | 590 | case 'roman': |
— | — | @@ -540,61 +596,68 @@ |
541 | 597 | $links = false; |
542 | 598 | break; |
543 | 599 | default: |
544 | | - if ( !is_numeric( $iparam ) ) |
| 600 | + if ( !is_numeric( $iparam ) ) { |
545 | 601 | $mode = $iparam; |
| 602 | + } |
546 | 603 | } |
547 | 604 | } |
548 | 605 | } |
549 | | - |
| 606 | + |
550 | 607 | if ( is_numeric( $num ) && ( $i >= $num ) ) { |
551 | | - $params = explode( ";", $param ); |
552 | | - foreach ( $params as $iparam ) |
553 | | - if ( is_numeric( $iparam ) ) |
| 608 | + $params = explode( ';', $param ); |
| 609 | + foreach ( $params as $iparam ) { |
| 610 | + if ( is_numeric( $iparam ) ) { |
554 | 611 | $offset = $num - $iparam; |
| 612 | + } |
| 613 | + } |
555 | 614 | } |
556 | | - |
| 615 | + |
557 | 616 | } |
558 | 617 | $view = ( $i - $offset ); |
559 | 618 | switch( $mode ) { |
560 | 619 | case 'highroman': |
561 | | - $view = toRoman( $view ); break; |
| 620 | + $view = toRoman( $view ); |
| 621 | + break; |
562 | 622 | case 'roman': |
563 | | - $view = strtolower( toRoman( $view ) ); break; |
| 623 | + $view = strtolower( toRoman( $view ) ); |
| 624 | + break; |
564 | 625 | case 'normal': |
565 | | - $view = '' . $view; break; |
| 626 | + $view = '' . $view; |
| 627 | + break; |
566 | 628 | case 'empty': |
567 | | - $view = '' . $view; break; |
| 629 | + $view = '' . $view; |
| 630 | + break; |
568 | 631 | default: |
569 | 632 | $view = $mode; |
570 | 633 | } |
571 | 634 | return array( $view, $links, $mode ); |
572 | 635 | } |
573 | 636 | |
574 | | - |
575 | | - /* |
576 | | - * add the pagequality category. |
577 | | - * todo : display whether page has been proofread by the user or by someone else |
| 637 | + /** |
| 638 | + * Add the pagequality category. |
| 639 | + * @todo FIXME: display whether page has been proofread by the user or by someone else |
578 | 640 | */ |
579 | 641 | function pageQuality( $input, $args, &$parser ) { |
580 | 642 | global $wgUser; |
581 | | - |
| 643 | + |
582 | 644 | $page_namespace = $this->page_namespace; |
583 | 645 | if ( !preg_match( "/^$page_namespace:(.*?)(\/([0-9]*)|)$/", $parser->Title()->getPrefixedText() ) ) { |
584 | | - return ""; |
| 646 | + return ''; |
585 | 647 | } |
586 | | - |
| 648 | + |
587 | 649 | $q = $args['level']; |
588 | | - if( ! in_array( $q, array('0','1','2','3','4') ) ) { |
589 | | - return ""; |
| 650 | + if( !in_array( $q, array( '0', '1', '2', '3', '4' ) ) ) { |
| 651 | + return ''; |
590 | 652 | } |
591 | | - $message = "<div id=\"pagequality\" width=100% class=quality$q>".wfMsgForContent( "proofreadpage_quality{$q}_message" )."</div>"; |
592 | | - $out = "__NOEDITSECTION__[[Category:".wfMsgForContent( "proofreadpage_quality{$q}_category" )."]]"; |
593 | | - return $parser->recursiveTagParse( $out . $message); |
| 653 | + $message = "<div id=\"pagequality\" width=100% class=quality$q>" . |
| 654 | + wfMsgForContent( "proofreadpage_quality{$q}_message" ) . '</div>'; |
| 655 | + $out = '__NOEDITSECTION__[[Category:' . |
| 656 | + wfMsgForContent( "proofreadpage_quality{$q}_category" ) . ']]'; |
| 657 | + return $parser->recursiveTagParse( $out . $message ); |
594 | 658 | } |
595 | 659 | |
596 | | - |
597 | | - /* |
598 | | - * Parser hook for index pages |
| 660 | + /** |
| 661 | + * Parser hook for index pages |
599 | 662 | * Display a list of coloured links to pages |
600 | 663 | */ |
601 | 664 | function renderPageList( $input, $args, $parser ) { |
— | — | @@ -603,7 +666,7 @@ |
604 | 667 | $page_namespace = $this->page_namespace; |
605 | 668 | $index_namespace = $this->index_namespace; |
606 | 669 | if ( !preg_match( "/^$index_namespace:(.*?)(\/([0-9]*)|)$/", $parser->Title()->getPrefixedText(), $m ) ) { |
607 | | - return ""; |
| 670 | + return ''; |
608 | 671 | } |
609 | 672 | |
610 | 673 | $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] ); |
— | — | @@ -612,24 +675,28 @@ |
613 | 676 | } |
614 | 677 | |
615 | 678 | $image = wfFindFile( $imageTitle ); |
616 | | - if ( ! ( $image && $image->isMultiPage() && $image->pageCount() ) ) { |
| 679 | + if ( !( $image && $image->isMultiPage() && $image->pageCount() ) ) { |
617 | 680 | return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_file' ) . '</strong>'; |
618 | | - } |
| 681 | + } |
619 | 682 | |
620 | | - $return = ""; |
621 | | - |
| 683 | + $return = ''; |
| 684 | + |
622 | 685 | $name = $imageTitle->getDBkey(); |
623 | 686 | $count = $image->pageCount(); |
624 | 687 | |
625 | 688 | $from = $args['from']; |
626 | 689 | $to = $args['to']; |
627 | | - if( !$from ) $from = 1; |
628 | | - if( !$to ) $to = $count; |
| 690 | + if( !$from ) { |
| 691 | + $from = 1; |
| 692 | + } |
| 693 | + if( !$to ) { |
| 694 | + $to = $count; |
| 695 | + } |
629 | 696 | |
630 | 697 | if( !is_numeric( $from ) || !is_numeric( $to ) ) { |
631 | 698 | return '<strong class="error">' . wfMsgForContent( 'proofreadpage_number_expected' ) . '</strong>'; |
632 | 699 | } |
633 | | - if( ($from > $to) || ($from < 1) || ($to < 1 ) || ($to > $count) ) { |
| 700 | + if( ( $from > $to ) || ( $from < 1 ) || ( $to < 1 ) || ( $to > $count ) ) { |
634 | 701 | return '<strong class="error">' . wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>'; |
635 | 702 | } |
636 | 703 | |
— | — | @@ -637,7 +704,9 @@ |
638 | 705 | $pdbk = "$page_namespace:$name" . '/' . $i ; |
639 | 706 | list( $view, $links, $mode ) = $this->pageNumber( $i, $args ); |
640 | 707 | |
641 | | - if ( $mode == 'highroman' || $mode == 'roman' ) $view = ' ' . $view; |
| 708 | + if ( $mode == 'highroman' || $mode == 'roman' ) { |
| 709 | + $view = ' ' . $view; |
| 710 | + } |
642 | 711 | |
643 | 712 | $n = strlen( $count ) - strlen( $view ); |
644 | 713 | if ( $n && ( $mode == 'normal' || $mode == 'empty' ) ) { |
— | — | @@ -650,24 +719,20 @@ |
651 | 720 | $title = Title::newFromText( $pdbk ); |
652 | 721 | |
653 | 722 | if ( $links == false ) { |
654 | | - $return .= $view . " "; |
| 723 | + $return .= $view . ' '; |
655 | 724 | } else { |
656 | | - $return .= "[[".$title->getPrefixedText()."|$view]] "; |
| 725 | + $return .= '[[' . $title->getPrefixedText() . "|$view]] "; |
657 | 726 | } |
658 | 727 | } |
659 | | - $return = $parser->recursiveTagParse($return); |
| 728 | + $return = $parser->recursiveTagParse( $return ); |
660 | 729 | return $return; |
661 | 730 | } |
662 | 731 | |
663 | | - |
664 | | - |
665 | | - |
666 | | - /* |
| 732 | + /** |
667 | 733 | * Parser hook that includes a list of pages. |
668 | 734 | * parameters : index, from, to, header |
669 | 735 | */ |
670 | 736 | function renderPages( $input, $args, &$parser ) { |
671 | | - |
672 | 737 | $page_namespace = $this->page_namespace; |
673 | 738 | $index_namespace = $this->index_namespace; |
674 | 739 | $index = $args['index']; |
— | — | @@ -677,41 +742,44 @@ |
678 | 743 | |
679 | 744 | // abort if the tag is on an index page |
680 | 745 | if ( preg_match( "/^$index_namespace:(.*?)(\/([0-9]*)|)$/", $parser->Title()->getPrefixedText() ) ) { |
681 | | - return ""; |
| 746 | + return ''; |
682 | 747 | } |
683 | 748 | // abort too if the tag is in the page namespace |
684 | 749 | if ( preg_match( "/^$page_namespace:(.*?)(\/([0-9]*)|)$/", $parser->Title()->getPrefixedText() ) ) { |
685 | | - return ""; |
| 750 | + return ''; |
686 | 751 | } |
687 | | - if( ! $index ) { |
| 752 | + if( !$index ) { |
688 | 753 | return '<strong class="error">' . wfMsgForContent( 'proofreadpage_index_expected' ) . '</strong>'; |
689 | 754 | } |
690 | 755 | $index_title = Title::newFromText( "$index_namespace:$index" ); |
691 | | - if( ! $index_title || ! $index_title->exists() ) { |
| 756 | + if( !$index_title || !$index_title->exists() ) { |
692 | 757 | return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_index' ) . '</strong>'; |
693 | 758 | } |
694 | 759 | |
695 | 760 | $parser->getOutput()->addTemplate( $index_title, $index_title->getArticleID(), $index_title->getLatestRevID() ); |
696 | | - |
| 761 | + |
697 | 762 | $out = ''; |
698 | | - |
| 763 | + |
699 | 764 | list( $links, $params, $attributes ) = $this->parse_index( $index_title ); |
700 | 765 | |
701 | 766 | if( $from || $to ) { |
702 | | - |
703 | | - if( $links==null ) { |
| 767 | + if( $links == null ) { |
704 | 768 | $imageTitle = Title::makeTitleSafe( NS_IMAGE, $index ); |
705 | 769 | if ( !$imageTitle ) { |
706 | 770 | return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_file' ) . '</strong>'; |
707 | 771 | } |
708 | 772 | $image = wfFindFile( $imageTitle ); |
709 | | - if ( ! ( $image && $image->isMultiPage() && $image->pageCount() ) ) { |
| 773 | + if ( !( $image && $image->isMultiPage() && $image->pageCount() ) ) { |
710 | 774 | return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_file' ) . '</strong>'; |
711 | 775 | } |
712 | 776 | $count = $image->pageCount(); |
713 | 777 | |
714 | | - if( !$from ) $from = 1; |
715 | | - if( !$to ) $to = $count; |
| 778 | + if( !$from ) { |
| 779 | + $from = 1; |
| 780 | + } |
| 781 | + if( !$to ) { |
| 782 | + $to = $count; |
| 783 | + } |
716 | 784 | |
717 | 785 | if( !is_numeric( $from ) || !is_numeric( $to ) ) { |
718 | 786 | return '<strong class="error">' . wfMsgForContent( 'proofreadpage_number_expected' ) . '</strong>'; |
— | — | @@ -724,10 +792,10 @@ |
725 | 793 | } |
726 | 794 | $pages = array(); |
727 | 795 | |
728 | | - for( $i=$from; $i<=$to;$i++ ) { |
729 | | - list($pagenum, $links, $mode) = $this->pageNumber( $i, $params ); |
| 796 | + for( $i = $from; $i <= $to; $i++ ) { |
| 797 | + list( $pagenum, $links, $mode ) = $this->pageNumber( $i, $params ); |
730 | 798 | $page = str_replace( ' ' , '_', "$index/" . $i ); |
731 | | - if( $i == $from ) { |
| 799 | + if( $i == $from ) { |
732 | 800 | $from_page = $page; |
733 | 801 | $from_pagenum = $pagenum; |
734 | 802 | } |
— | — | @@ -738,31 +806,31 @@ |
739 | 807 | $pages[] = array( $page, $pagenum ); |
740 | 808 | } |
741 | 809 | } else { |
742 | | - if($from) { |
| 810 | + if( $from ) { |
743 | 811 | $adding = false; |
744 | 812 | } else { |
745 | 813 | $adding = true; |
746 | 814 | $from_pagenum = $links[3][0]; |
747 | 815 | } |
748 | | - for( $i=0; $i < count( $links[1] ); $i++) { |
| 816 | + for( $i = 0; $i < count( $links[1] ); $i++ ) { |
749 | 817 | $text = $links[1][$i]; |
750 | 818 | $pagenum = $links[3][$i]; |
751 | | - if($text == $from ) { |
| 819 | + if( $text == $from ) { |
752 | 820 | $adding = true; |
753 | 821 | $from_page = $from; |
754 | 822 | $from_pagenum = $pagenum; |
755 | 823 | } |
756 | | - if($adding) { |
| 824 | + if( $adding ) { |
757 | 825 | $pages[] = array( $text, $pagenum ); |
758 | 826 | } |
759 | | - if($text == $to ) { |
| 827 | + if( $text == $to ) { |
760 | 828 | $adding = false; |
761 | 829 | $to_page = $to; |
762 | 830 | $to_pagenum = $pagenum; |
763 | 831 | } |
764 | 832 | } |
765 | 833 | if( !$to ) { |
766 | | - $to_pagenum = $links[3][ count( $links[1] ) - 1 ]; |
| 834 | + $to_pagenum = $links[3][count( $links[1] ) - 1]; |
767 | 835 | } |
768 | 836 | } |
769 | 837 | |
— | — | @@ -772,58 +840,69 @@ |
773 | 841 | list( $page, $pagenum ) = $item; |
774 | 842 | $pp[] = $page; |
775 | 843 | } |
776 | | - $pagelist = "'".implode( "', '", $pp)."'"; |
| 844 | + $pagelist = "'" . implode( "', '", $pp ) . "'"; |
777 | 845 | $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $page_namespace ) ); |
778 | 846 | $dbr = wfGetDB( DB_SLAVE ); |
779 | 847 | $cat = $dbr->strencode( str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality0_category' ) ) ); |
780 | | - $res = $dbr->select( array('page', 'categorylinks' ), |
781 | | - array("page_title"), |
782 | | - array("page_title IN ( $pagelist )", "cl_to='$cat'", "page_namespace=$page_ns_index" ), |
783 | | - __METHOD__, null, |
784 | | - array('categorylinks' => array ( 'LEFT JOIN','cl_from=page_id') ) ); |
| 848 | + $res = $dbr->select( |
| 849 | + array( 'page', 'categorylinks' ), |
| 850 | + array( 'page_title' ), |
| 851 | + array( |
| 852 | + "page_title IN ( $pagelist )", |
| 853 | + "cl_to='$cat'", |
| 854 | + "page_namespace=$page_ns_index" |
| 855 | + ), |
| 856 | + __METHOD__, |
| 857 | + null, |
| 858 | + array( 'categorylinks' => array( 'LEFT JOIN', 'cl_from=page_id' ) ) |
| 859 | + ); |
785 | 860 | |
786 | 861 | $q0_pages = array(); |
787 | | - if( $res ) { |
788 | | - while( $o = $dbr->fetchObject( $res ) ) { |
| 862 | + if( $res ) { |
| 863 | + while( $o = $dbr->fetchObject( $res ) ) { |
789 | 864 | array_push( $q0_pages, $o->page_title ); |
790 | 865 | } |
791 | 866 | } |
792 | | - |
793 | | - //write the output |
| 867 | + |
| 868 | + // write the output |
794 | 869 | foreach( $pages as $item ) { |
795 | 870 | list( $page, $pagenum ) = $item; |
796 | | - if( in_array( $page , $q0_pages ) ) { |
| 871 | + if( in_array( $page, $q0_pages ) ) { |
797 | 872 | $is_q0 = true; |
798 | 873 | } else { |
799 | 874 | $is_q0 = false; |
800 | 875 | } |
801 | 876 | $text = "$page_namespace:$page"; |
802 | 877 | if( !$is_q0 ) { |
803 | | - $out.= "<span>{{:MediaWiki:Proofreadpage_pagenum_template|page=".$text."|num=$pagenum}}</span>"; |
| 878 | + $out .= '<span>{{:MediaWiki:Proofreadpage_pagenum_template|page=' . $text . "|num=$pagenum}}</span>"; |
804 | 879 | } |
805 | | - if( $args["$i"] != null){ |
806 | | - $out.= "{{#lst:".$text."|".$args["$i"]."}}"; |
807 | | - } else if($page == $from && $args["fromsection"]){ |
808 | | - $out.= "{{#lst:".$text."|".$args["fromsection"]."}}"; |
809 | | - } else if($page == $to && $args["tosection"]){ |
810 | | - $out.= "{{#lst:".$text."|".$args["tosection"]."}}"; |
| 880 | + if( $args["$i"] != null ) { |
| 881 | + $out .= '{{#lst:' . $text . '|' . $args["$i"] . '}}'; |
| 882 | + } elseif( $page == $from && $args['fromsection'] ) { |
| 883 | + $out .= '{{#lst:' . $text . '|' . $args['fromsection'] . '}}'; |
| 884 | + } elseif( $page == $to && $args['tosection'] ) { |
| 885 | + $out .= '{{#lst:' . $text . '|' . $args['tosection'] . '}}'; |
811 | 886 | } else { |
812 | | - $out.= "{{:".$text."}}"; |
| 887 | + $out .= '{{:' . $text . '}}'; |
813 | 888 | } |
814 | 889 | if( !$is_q0 ) { |
815 | | - $out.= "\n"; |
| 890 | + $out.= "\n"; |
816 | 891 | } |
817 | 892 | } |
818 | 893 | } else { |
819 | 894 | /* table of Contents */ |
820 | | - $header = "toc"; |
821 | | - if( $links==null ) { |
| 895 | + $header = 'toc'; |
| 896 | + if( $links == null ) { |
822 | 897 | $firstpage = str_replace( ' ' , '_', "$index/1" ); |
823 | 898 | } else { |
824 | 899 | $firstpage = $links[1][0]; |
825 | 900 | } |
826 | 901 | $firstpage_title = Title::newFromText( "$page_namespace:$firstpage" ); |
827 | | - $parser->getOutput()->addTemplate( $firstpage_title, $firstpage_title->getArticleID(), $firstpage_title->getLatestRevID() ); |
| 902 | + $parser->getOutput()->addTemplate( |
| 903 | + $firstpage_title, |
| 904 | + $firstpage_title->getArticleID(), |
| 905 | + $firstpage_title->getLatestRevID() |
| 906 | + ); |
828 | 907 | $parser->getOutput()->is_toc = true; |
829 | 908 | } |
830 | 909 | |
— | — | @@ -831,29 +910,47 @@ |
832 | 911 | $text_links = $this->parse_index_links( $index_title ); |
833 | 912 | $h_out = '{{:MediaWiki:Proofreadpage_header_template'; |
834 | 913 | $h_out .= "|value=$header"; |
835 | | - //find next and previous pages in list |
836 | | - for( $i=1; $i < count( $text_links[1] ); $i++) { |
| 914 | + // find next and previous pages in list |
| 915 | + for( $i = 1; $i < count( $text_links[1] ); $i++ ) { |
837 | 916 | if( $text_links[1][$i] == $parser->Title()->getPrefixedText() ) { |
838 | 917 | $current = $text_links[0][$i]; |
839 | 918 | break; |
840 | 919 | } |
841 | 920 | } |
842 | 921 | if( ( $i > 1 ) && ( $i < count( $text_links[1] ) ) ) { |
843 | | - $prev = $text_links[0][$i-1]; |
| 922 | + $prev = $text_links[0][$i - 1]; |
844 | 923 | } |
845 | 924 | if( ( $i >= 1 ) && ( $i + 1 < count( $text_links[1] ) ) ) { |
846 | | - $next = $text_links[0][$i+1]; |
| 925 | + $next = $text_links[0][$i + 1]; |
847 | 926 | } |
848 | | - if( isset( $args["current"] ) ) $current = $args["current"]; |
849 | | - if( isset( $args["prev"] ) ) $prev = $args["prev"]; |
850 | | - if( isset( $args["next"] ) ) $next = $args["next"]; |
851 | | - if( $current ) $h_out .= "|current=$current"; |
852 | | - if( $prev ) $h_out .= "|prev=$prev"; |
853 | | - if( $next ) $h_out .= "|next=$next"; |
854 | | - if( $from_pagenum ) $h_out .= "|from=$from_pagenum"; |
855 | | - if( $to_pagenum ) $h_out .= "|to=$to_pagenum"; |
| 927 | + if( isset( $args['current'] ) ) { |
| 928 | + $current = $args['current']; |
| 929 | + } |
| 930 | + if( isset( $args['prev'] ) ) { |
| 931 | + $prev = $args['prev']; |
| 932 | + } |
| 933 | + if( isset( $args['next'] ) ) { |
| 934 | + $next = $args['next']; |
| 935 | + } |
| 936 | + if( $current ) { |
| 937 | + $h_out .= "|current=$current"; |
| 938 | + } |
| 939 | + if( $prev ) { |
| 940 | + $h_out .= "|prev=$prev"; |
| 941 | + } |
| 942 | + if( $next ) { |
| 943 | + $h_out .= "|next=$next"; |
| 944 | + } |
| 945 | + if( $from_pagenum ) { |
| 946 | + $h_out .= "|from=$from_pagenum"; |
| 947 | + } |
| 948 | + if( $to_pagenum ) { |
| 949 | + $h_out .= "|to=$to_pagenum"; |
| 950 | + } |
856 | 951 | foreach ( $attributes as $key => $val ) { |
857 | | - if( $args[$key] ) $val = $args[$key]; |
| 952 | + if( $args[$key] ) { |
| 953 | + $val = $args[$key]; |
| 954 | + } |
858 | 955 | $h_out .= "|$key=$val"; |
859 | 956 | } |
860 | 957 | $h_out .= '}}'; |
— | — | @@ -862,12 +959,11 @@ |
863 | 960 | |
864 | 961 | // wrap the output in a div, to prevent the parser from inserting pararaphs |
865 | 962 | $out = "<div>$out</div>"; |
866 | | - $out = $parser->recursiveTagParse($out); |
| 963 | + $out = $parser->recursiveTagParse( $out ); |
867 | 964 | return $out; |
868 | 965 | } |
869 | 966 | |
870 | | - |
871 | | - /* |
| 967 | + /** |
872 | 968 | * Set is_toc flag (true if page is a table of contents) |
873 | 969 | */ |
874 | 970 | function OutputPageParserOutput( $outputPage, $parserOutput ) { |
— | — | @@ -879,7 +975,7 @@ |
880 | 976 | return true; |
881 | 977 | } |
882 | 978 | |
883 | | - /* |
| 979 | + /** |
884 | 980 | * Try to parse a page. |
885 | 981 | * Return quality status of the page and username of the proofreader |
886 | 982 | * Return -1 if the page cannot be parsed |
— | — | @@ -894,7 +990,7 @@ |
895 | 991 | list( $index_url, $prev_url, $next_url, $header, $footer, $css, $edit_width ) = $this->navigation( $wgTitle ); |
896 | 992 | $new_text = "<noinclude><pagequality level=\"1\" user=\"$username\" />" |
897 | 993 | ."$header\n\n\n</noinclude>$text<noinclude>\n$footer</noinclude>"; |
898 | | - return array( -1, null, $new_text ); |
| 994 | + return array( -1, null, $new_text ); |
899 | 995 | } |
900 | 996 | |
901 | 997 | $header = $m[1]; |
— | — | @@ -912,22 +1008,19 @@ |
913 | 1009 | } |
914 | 1010 | |
915 | 1011 | $new_text = "<noinclude><pagequality level=\"1\" user=\"$username\" />" |
916 | | - ."$header\n\n\n</noinclude>$body<noinclude>\n$footer</noinclude>"; |
917 | | - return array( -1, null, $new_text ); |
918 | | - |
| 1012 | + . "$header\n\n\n</noinclude>$body<noinclude>\n$footer</noinclude>"; |
| 1013 | + return array( -1, null, $new_text ); |
919 | 1014 | } |
920 | 1015 | |
921 | | - |
922 | | - |
923 | 1016 | function importFormData( $editpage, $request ) { |
924 | 1017 | global $wgTitle; |
925 | 1018 | |
926 | 1019 | $page_namespace = $this->page_namespace; |
927 | | - //abort if we are not a page |
928 | | - if ( ! preg_match( "/^$page_namespace:(.*)$/", $wgTitle->getPrefixedText() ) ) { |
| 1020 | + // abort if we are not a page |
| 1021 | + if ( !preg_match( "/^$page_namespace:(.*)$/", $wgTitle->getPrefixedText() ) ) { |
929 | 1022 | return true; |
930 | 1023 | } |
931 | | - if ( ! $request->wasPosted() ) { |
| 1024 | + if ( !$request->wasPosted() ) { |
932 | 1025 | return true; |
933 | 1026 | } |
934 | 1027 | $editpage->quality = $request->getVal( 'quality' ); |
— | — | @@ -935,31 +1028,37 @@ |
936 | 1029 | $editpage->header = $editpage->safeUnicodeInput( $request, 'wpHeaderTextbox' ); |
937 | 1030 | $editpage->footer = $editpage->safeUnicodeInput( $request, 'wpFooterTextbox' ); |
938 | 1031 | |
939 | | - //we want to keep ordinary spaces at the end of the main textbox |
940 | | - $text = rtrim( $request->getText( 'wpTextbox1' ), "\t\n\r\0\x0B"); |
| 1032 | + // we want to keep ordinary spaces at the end of the main textbox |
| 1033 | + $text = rtrim( $request->getText( 'wpTextbox1' ), "\t\n\r\0\x0B" ); |
941 | 1034 | $editpage->textbox1 = $request->getBool( 'safemode' ) |
942 | 1035 | ? $editpage->unmakesafe( $text ) |
943 | 1036 | : $text; |
944 | 1037 | |
945 | | - if( in_array( $editpage->quality , array( "0", "1", "2", "3", "4" ) ) ) { |
946 | | - //format the page |
947 | | - $text = "<noinclude><pagequality level=\"".$editpage->quality."\" user=\"".$editpage->username."\" />" |
948 | | - ."<div class=\"pagetext\">".$editpage->header."\n\n\n</noinclude>" |
949 | | - .$editpage->textbox1 |
950 | | - ."<noinclude>\n".$editpage->footer."</div></noinclude>"; |
| 1038 | + if( in_array( $editpage->quality, array( '0', '1', '2', '3', '4' ) ) ) { |
| 1039 | + // format the page |
| 1040 | + $text = '<noinclude><pagequality level="' . $editpage->quality . '" user="' . $editpage->username . '" />' . |
| 1041 | + '<div class="pagetext">' . $editpage->header."\n\n\n</noinclude>" . |
| 1042 | + $editpage->textbox1 . |
| 1043 | + "<noinclude>\n" . $editpage->footer . '</div></noinclude>'; |
951 | 1044 | $editpage->textbox1 = $text; |
952 | 1045 | } else { |
953 | | - //replace deprecated template |
| 1046 | + // replace deprecated template |
954 | 1047 | $text = $editpage->textbox1; |
955 | | - $text = preg_replace( "/\{\{PageQuality\|(0|1|2|3|4)(|\|(.*?))\}\}/is", "<pagequality level=\"\\1\" user=\"\\3\" />", $text ); |
| 1048 | + $text = preg_replace( |
| 1049 | + "/\{\{PageQuality\|(0|1|2|3|4)(|\|(.*?))\}\}/is", |
| 1050 | + "<pagequality level=\"\\1\" user=\"\\3\" />", |
| 1051 | + $text |
| 1052 | + ); |
956 | 1053 | $editpage->textbox1 = $text; |
957 | 1054 | } |
958 | 1055 | return true; |
959 | 1056 | } |
960 | 1057 | |
961 | | - |
962 | | - /* |
963 | | - * Check the format of pages in "Page" namespace. |
| 1058 | + /** |
| 1059 | + * Check the format of pages in "Page" namespace. |
| 1060 | + * |
| 1061 | + * @param $editpage Object: EditPage object |
| 1062 | + * @return Boolean |
964 | 1063 | */ |
965 | 1064 | function attemptSave( $editpage ) { |
966 | 1065 | global $wgOut, $wgUser; |
— | — | @@ -968,53 +1067,54 @@ |
969 | 1068 | $index_namespace = $this->index_namespace; |
970 | 1069 | $title = $editpage->mTitle; |
971 | 1070 | |
972 | | - //check that pages listed on an index are unique. |
| 1071 | + // check that pages listed on an index are unique. |
973 | 1072 | if ( preg_match( "/^$index_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
974 | 1073 | $text = $editpage->textbox1; |
975 | | - list( $links, $params, $attributes ) = $this->parse_index_text($text); |
976 | | - if( $links!=null && count($links[1]) != count( array_unique($links[1]))) { |
| 1074 | + list( $links, $params, $attributes ) = $this->parse_index_text( $text ); |
| 1075 | + if( $links != null && count( $links[1] ) != count( array_unique( $links[1] ) ) ) { |
977 | 1076 | $wgOut->showErrorPage( 'proofreadpage_indexdupe', 'proofreadpage_indexdupetext' ); |
978 | 1077 | return false; |
979 | 1078 | }; |
980 | 1079 | return true; |
981 | 1080 | } |
982 | 1081 | |
983 | | - //abort if we are not a page |
984 | | - if ( ! preg_match( "/^$page_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
| 1082 | + // abort if we are not a page |
| 1083 | + if ( !preg_match( "/^$page_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
985 | 1084 | return true; |
986 | 1085 | } |
987 | 1086 | |
988 | 1087 | $text = $editpage->textbox1; |
989 | | - //parse the page |
990 | | - list( $q , $username, $ptext ) = $this->parse_page( $text ); |
| 1088 | + // parse the page |
| 1089 | + list( $q, $username, $ptext ) = $this->parse_page( $text ); |
991 | 1090 | if( $q == -1 ) { |
992 | 1091 | $editpage->textbox1 = $ptext; |
993 | 1092 | $q = 1; |
994 | 1093 | } |
995 | 1094 | |
996 | | - //read previous revision, so that I know how much I need to add to pr_index |
| 1095 | + // read previous revision, so that I know how much I need to add to pr_index |
997 | 1096 | $rev = Revision::newFromTitle( $title ); |
998 | 1097 | if( $rev ) { |
999 | 1098 | $old_text = $rev->getText(); |
1000 | | - list( $old_q , $old_username, $old_ptext ) = $this->parse_page( $old_text ); |
| 1099 | + list( $old_q, $old_username, $old_ptext ) = $this->parse_page( $old_text ); |
1001 | 1100 | if( $old_q != -1 ) { |
1002 | | - //check usernames |
1003 | | - if( ($old_q != $q) && !$wgUser->isAllowed('pagequality') ) { |
| 1101 | + // check usernames |
| 1102 | + if( ( $old_q != $q ) && !$wgUser->isAllowed( 'pagequality' ) ) { |
1004 | 1103 | $wgOut->showErrorPage( 'proofreadpage_nologin', 'proofreadpage_nologintext' ); |
1005 | 1104 | return false; |
1006 | 1105 | } |
1007 | | - if ( ( ($old_username != $username) || ($old_q != $q) ) && ($wgUser->getName() != $username) ) { |
| 1106 | + if ( ( ( $old_username != $username ) || ( $old_q != $q ) ) && ( $wgUser->getName() != $username ) ) { |
1008 | 1107 | $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' ); |
1009 | 1108 | return false; |
1010 | 1109 | } |
1011 | | - if( ( ($q == 4) && ($old_q < 3) ) || ( ($q == 4) && ($old_q == 3) && ($old_username == $username) ) ) { |
| 1110 | + if( ( ( $q == 4 ) && ( $old_q < 3 ) ) || ( ( $q == 4 ) && ( $old_q == 3 ) && ( $old_username == $username ) ) ) { |
1012 | 1111 | $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' ); |
1013 | 1112 | return false; |
1014 | 1113 | } |
| 1114 | + } else { |
| 1115 | + $old_q = 1; |
1015 | 1116 | } |
1016 | | - else $old_q = 1; |
1017 | 1117 | } else { |
1018 | | - if($q == 4) { |
| 1118 | + if( $q == 4 ) { |
1019 | 1119 | $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' ); |
1020 | 1120 | return false; |
1021 | 1121 | } |
— | — | @@ -1025,16 +1125,16 @@ |
1026 | 1126 | $editpage->mArticle->old_q = $old_q; |
1027 | 1127 | |
1028 | 1128 | return true; |
1029 | | - |
1030 | 1129 | } |
1031 | 1130 | |
1032 | | - |
1033 | | - /* |
| 1131 | + /** |
1034 | 1132 | * if I delete a page, I need to update the index table |
1035 | 1133 | * if I delete an index page too... |
| 1134 | + * |
| 1135 | + * @param $article Object: Article object |
| 1136 | + * @return Boolean: true |
1036 | 1137 | */ |
1037 | 1138 | function articleDelete( $article ) { |
1038 | | - |
1039 | 1139 | $page_namespace = $this->page_namespace; |
1040 | 1140 | $index_namespace = $this->index_namespace; |
1041 | 1141 | $title = $article->mTitle; |
— | — | @@ -1043,7 +1143,7 @@ |
1044 | 1144 | $id = $article->getID(); |
1045 | 1145 | $dbw = wfGetDB( DB_MASTER ); |
1046 | 1146 | $pr_index = $dbw->tableName( 'pr_index' ); |
1047 | | - $dbw->query ("DELETE FROM $pr_index WHERE pr_page_id=$id"); |
| 1147 | + $dbw->query( "DELETE FROM $pr_index WHERE pr_page_id=$id", __METHOD__ ); |
1048 | 1148 | $dbw->commit(); |
1049 | 1149 | return true; |
1050 | 1150 | } |
— | — | @@ -1054,30 +1154,29 @@ |
1055 | 1155 | $index_title = Title::newFromText( $title->pr_index_title ); |
1056 | 1156 | $index_title->invalidateCache(); |
1057 | 1157 | $index = new Article( $index_title ); |
1058 | | - if( $index ) $this->update_pr_index( $index, $title->getDBKey() ); |
| 1158 | + if( $index ) { |
| 1159 | + $this->update_pr_index( $index, $title->getDBKey() ); |
| 1160 | + } |
1059 | 1161 | } |
1060 | 1162 | return true; |
1061 | 1163 | } |
1062 | 1164 | |
1063 | 1165 | return true; |
1064 | | - |
1065 | 1166 | } |
1066 | 1167 | |
1067 | | - |
1068 | 1168 | function articleSaveComplete( $article ) { |
1069 | | - |
1070 | 1169 | $page_namespace = $this->page_namespace; |
1071 | 1170 | $index_namespace = $this->index_namespace; |
1072 | 1171 | $title = $article->mTitle; |
1073 | 1172 | |
1074 | | - //if it's an index, update pr_index table |
| 1173 | + // if it's an index, update pr_index table |
1075 | 1174 | if ( preg_match( "/^$index_namespace:(.*)$/", $title->getPrefixedText(), $m ) ) { |
1076 | 1175 | $this->update_pr_index( $article ); |
1077 | 1176 | return true; |
1078 | 1177 | } |
1079 | 1178 | |
1080 | | - //return if it is not a page |
1081 | | - if ( ! preg_match( "/^$page_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
| 1179 | + // return if it is not a page |
| 1180 | + if ( !preg_match( "/^$page_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
1082 | 1181 | return true; |
1083 | 1182 | } |
1084 | 1183 | |
— | — | @@ -1091,61 +1190,79 @@ |
1092 | 1191 | return true; |
1093 | 1192 | } |
1094 | 1193 | |
1095 | | - /* |
1096 | | - * invalidate the cache of the index page |
| 1194 | + /** |
| 1195 | + * invalidate the cache of the index page |
1097 | 1196 | */ |
1098 | 1197 | if ( $title->pr_index_title ) { |
1099 | 1198 | $index_title = Title::newFromText( $title->pr_index_title ); |
1100 | 1199 | $index_title->invalidateCache(); |
1101 | 1200 | } |
1102 | 1201 | |
1103 | | - /* |
| 1202 | + /** |
1104 | 1203 | * update pr_index iteratively |
1105 | 1204 | */ |
1106 | 1205 | $index = new Article( $index_title ); |
1107 | 1206 | $index_id = $index->getID(); |
1108 | 1207 | $dbr = wfGetDB( DB_SLAVE ); |
1109 | 1208 | $pr_index = $dbr->tableName( 'pr_index' ); |
1110 | | - $query = "SELECT * FROM $pr_index WHERE pr_page_id=".$index_id; |
| 1209 | + $query = "SELECT * FROM $pr_index WHERE pr_page_id=" . $index_id; |
1111 | 1210 | $res = $dbr->query( $query, __METHOD__ ); |
1112 | 1211 | if( $x = $dbr->fetchObject( $res ) ) { |
1113 | | - $n = $x->pr_count ; |
1114 | | - $n0 = $x->pr_q0 ; |
1115 | | - $n1 = $x->pr_q1 ; |
1116 | | - $n2 = $x->pr_q2 ; |
1117 | | - $n3 = $x->pr_q3 ; |
1118 | | - $n4 = $x->pr_q4 ; |
| 1212 | + $n = $x->pr_count; |
| 1213 | + $n0 = $x->pr_q0; |
| 1214 | + $n1 = $x->pr_q1; |
| 1215 | + $n2 = $x->pr_q2; |
| 1216 | + $n3 = $x->pr_q3; |
| 1217 | + $n4 = $x->pr_q4; |
1119 | 1218 | |
1120 | 1219 | switch( $article->new_q ) { |
1121 | | - case 0: $n0 = $n0 + 1; break; |
1122 | | - case 1: $n1 = $n1 + 1; break; |
1123 | | - case 2: $n2 = $n2 + 1; break; |
1124 | | - case 3: $n3 = $n3 + 1; break; |
1125 | | - case 4: $n4 = $n4 + 1; break; |
| 1220 | + case 0: |
| 1221 | + $n0 = $n0 + 1; |
| 1222 | + break; |
| 1223 | + case 1: |
| 1224 | + $n1 = $n1 + 1; |
| 1225 | + break; |
| 1226 | + case 2: |
| 1227 | + $n2 = $n2 + 1; |
| 1228 | + break; |
| 1229 | + case 3: |
| 1230 | + $n3 = $n3 + 1; |
| 1231 | + break; |
| 1232 | + case 4: |
| 1233 | + $n4 = $n4 + 1; |
| 1234 | + break; |
1126 | 1235 | } |
1127 | 1236 | |
1128 | 1237 | switch( $article->old_q ) { |
1129 | | - case 0: $n0 = $n0 - 1; break; |
1130 | | - case 1: $n1 = $n1 - 1; break; |
1131 | | - case 2: $n2 = $n2 - 1; break; |
1132 | | - case 3: $n3 = $n3 - 1; break; |
1133 | | - case 4: $n4 = $n4 - 1; break; |
| 1238 | + case 0: |
| 1239 | + $n0 = $n0 - 1; |
| 1240 | + break; |
| 1241 | + case 1: |
| 1242 | + $n1 = $n1 - 1; |
| 1243 | + break; |
| 1244 | + case 2: |
| 1245 | + $n2 = $n2 - 1; |
| 1246 | + break; |
| 1247 | + case 3: |
| 1248 | + $n3 = $n3 - 1; |
| 1249 | + break; |
| 1250 | + case 4: |
| 1251 | + $n4 = $n4 - 1; |
| 1252 | + break; |
1134 | 1253 | } |
1135 | 1254 | |
1136 | 1255 | $query = "REPLACE INTO $pr_index (pr_page_id, pr_count, pr_q0, pr_q1, pr_q2, pr_q3, pr_q4) VALUES ({$index_id},$n,$n0,$n1,$n2,$n3,$n4)"; |
1137 | | - $dbw->query ( $query ); |
| 1256 | + $dbw->query( $query, __METHOD__ ); |
1138 | 1257 | $dbw->commit(); |
1139 | 1258 | |
1140 | 1259 | } |
1141 | 1260 | $dbr->freeResult( $res ); |
1142 | | - |
| 1261 | + |
1143 | 1262 | return true; |
1144 | 1263 | } |
1145 | 1264 | |
1146 | | - |
1147 | 1265 | /* Preload text layer from multipage formats */ |
1148 | 1266 | function preloadText( $textbox1, $mTitle ) { |
1149 | | - |
1150 | 1267 | $page_namespace = $this->page_namespace; |
1151 | 1268 | if ( preg_match( "/^$page_namespace:(.*?)\/([0-9]*)$/", $mTitle->getPrefixedText(), $m ) ) { |
1152 | 1269 | $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] ); |
— | — | @@ -1155,10 +1272,10 @@ |
1156 | 1273 | |
1157 | 1274 | $image = wfFindFile( $imageTitle ); |
1158 | 1275 | if ( $image && $image->exists() ) { |
1159 | | - $text = $image->handler->getPageText($image, $m[2]); |
| 1276 | + $text = $image->handler->getPageText( $image, $m[2] ); |
1160 | 1277 | if ( $text ) { |
1161 | 1278 | $text = preg_replace( "/(\\\\n)/", "\n", $text ); |
1162 | | - $text = preg_replace( "/(\\\\\d*)/", "", $text ); |
| 1279 | + $text = preg_replace( "/(\\\\\d*)/", '', $text ); |
1163 | 1280 | $textbox1 = $text; |
1164 | 1281 | } |
1165 | 1282 | } |
— | — | @@ -1166,10 +1283,7 @@ |
1167 | 1284 | return true; |
1168 | 1285 | } |
1169 | 1286 | |
1170 | | - |
1171 | | - |
1172 | 1287 | function movePage( $form, $ot, $nt ) { |
1173 | | - |
1174 | 1288 | $page_namespace = $this->page_namespace; |
1175 | 1289 | if ( preg_match( "/^$page_namespace:(.*)$/", $ot->getPrefixedText() ) ) { |
1176 | 1290 | $this->load_index( $ot ); |
— | — | @@ -1177,30 +1291,32 @@ |
1178 | 1292 | $index_title = Title::newFromText( $ot->pr_index_title ); |
1179 | 1293 | $index_title->invalidateCache(); |
1180 | 1294 | $index = new Article( $index_title ); |
1181 | | - if( $index ) $this->update_pr_index( $index ); |
| 1295 | + if( $index ) { |
| 1296 | + $this->update_pr_index( $index ); |
| 1297 | + } |
1182 | 1298 | } |
1183 | 1299 | return true; |
1184 | 1300 | } |
1185 | 1301 | |
1186 | 1302 | if ( preg_match( "/^$page_namespace:(.*)$/", $nt->getPrefixedText() ) ) { |
1187 | 1303 | $this->load_index( $nt ); |
1188 | | - if( $nt->pr_index_title && ($nt->pr_index_title!=$ot->pr_index_title) ) { |
| 1304 | + if( $nt->pr_index_title && ( $nt->pr_index_title != $ot->pr_index_title ) ) { |
1189 | 1305 | $index_title = Title::newFromText( $nt->pr_index_title ); |
1190 | 1306 | $index_title->invalidateCache(); |
1191 | 1307 | $index = new Article( $index_title ); |
1192 | | - if( $index ) $this->update_pr_index( $index ); |
| 1308 | + if( $index ) { |
| 1309 | + $this->update_pr_index( $index ); |
| 1310 | + } |
1193 | 1311 | } |
1194 | 1312 | return true; |
1195 | 1313 | } |
1196 | 1314 | return true; |
1197 | 1315 | } |
1198 | 1316 | |
1199 | | - |
1200 | | - /* |
| 1317 | + /** |
1201 | 1318 | * When an index page is created or purged, recompute pr_index values |
1202 | 1319 | */ |
1203 | 1320 | function articlePurge( $article ) { |
1204 | | - |
1205 | 1321 | $index_namespace = $this->index_namespace; |
1206 | 1322 | $title = $article->mTitle; |
1207 | 1323 | if ( preg_match( "/^$index_namespace:(.*)$/", $title->getPrefixedText() ) ) { |
— | — | @@ -1210,10 +1326,9 @@ |
1211 | 1327 | return true; |
1212 | 1328 | } |
1213 | 1329 | |
1214 | | - |
1215 | | - function query_count( $dbr, $query, $cat ){ |
| 1330 | + function query_count( $dbr, $query, $cat ) { |
1216 | 1331 | $q = $dbr->strencode( str_replace( ' ' , '_' , wfMsgForContent( $cat ) ) ); |
1217 | | - $res = $dbr->query( str_replace( '###', $q, $query) , __METHOD__ ); |
| 1332 | + $res = $dbr->query( str_replace( '###', $q, $query ), __METHOD__ ); |
1218 | 1333 | if( $res && $dbr->numRows( $res ) > 0 ) { |
1219 | 1334 | $row = $dbr->fetchObject( $res ); |
1220 | 1335 | $n = $row->count; |
— | — | @@ -1223,57 +1338,61 @@ |
1224 | 1339 | return 0; |
1225 | 1340 | } |
1226 | 1341 | |
1227 | | - |
1228 | | - /* |
1229 | | - * update the pr_index entry of an article |
| 1342 | + /** |
| 1343 | + * Update the pr_index entry of an article |
1230 | 1344 | */ |
1231 | | - function update_pr_index( $index, $deletedpage=null ) { |
1232 | | - |
| 1345 | + function update_pr_index( $index, $deletedpage = null ) { |
1233 | 1346 | $page_namespace = $this->page_namespace; |
1234 | 1347 | $index_namespace = $this->index_namespace; |
1235 | 1348 | $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $page_namespace ) ); |
1236 | 1349 | if ( $page_ns_index == null ) { |
1237 | | - return; |
| 1350 | + return; |
1238 | 1351 | } |
1239 | 1352 | |
1240 | 1353 | $index_title = $index->mTitle; |
1241 | 1354 | $index_id = $index->getID(); |
1242 | 1355 | $dbr = wfGetDB( DB_SLAVE ); |
1243 | 1356 | |
1244 | | - //read the list of pages |
| 1357 | + // read the list of pages |
1245 | 1358 | $pages = array(); |
1246 | 1359 | list( $links, $params, $attributes ) = $this->parse_index( $index_title ); |
1247 | | - if( $links==null ) { |
| 1360 | + if( $links == null ) { |
1248 | 1361 | $imageTitle = Title::makeTitleSafe( NS_IMAGE, $index_title->getText() ); |
1249 | 1362 | if ( $imageTitle ) { |
1250 | 1363 | $image = wfFindFile( $imageTitle ); |
1251 | 1364 | if ( $image && $image->isMultiPage() && $image->pageCount() ) { |
1252 | 1365 | $n = $image->pageCount(); |
1253 | 1366 | for ( $i = 1; $i <= $n; $i++ ) { |
1254 | | - $page = $dbr->strencode( $index_title->getDBKey().'/'.$i ); |
1255 | | - if($page != $deletedpage) array_push( $pages, $page ); |
| 1367 | + $page = $dbr->strencode( $index_title->getDBKey() . '/' . $i ); |
| 1368 | + if( $page != $deletedpage ) { |
| 1369 | + array_push( $pages, $page ); |
| 1370 | + } |
1256 | 1371 | } |
1257 | 1372 | } |
1258 | 1373 | } |
1259 | 1374 | } else { |
1260 | | - $n = count($links[1]); |
| 1375 | + $n = count( $links[1] ); |
1261 | 1376 | for ( $i = 0; $i < $n; $i++ ) { |
1262 | 1377 | $page = $dbr->strencode( str_replace( ' ' , '_' , $links[1][$i] ) ); |
1263 | | - if($page != $deletedpage) array_push( $pages, $page ); |
| 1378 | + if( $page != $deletedpage ) { |
| 1379 | + array_push( $pages, $page ); |
| 1380 | + } |
1264 | 1381 | } |
1265 | 1382 | } |
1266 | 1383 | |
1267 | | - if( $n==0 ) { |
| 1384 | + if( $n == 0 ) { |
1268 | 1385 | return; |
1269 | 1386 | } |
1270 | 1387 | |
1271 | 1388 | $catlinks = $dbr->tableName( 'categorylinks' ); |
1272 | 1389 | $page = $dbr->tableName( 'page' ); |
1273 | | - $pagelist = "'".implode( "', '", $pages)."'"; |
1274 | | - $res = $dbr->select( array( 'page' ), |
1275 | | - array( 'COUNT(page_id) AS count'), |
1276 | | - array( "page_namespace=$page_ns_index", "page_title IN ( $pagelist )"), |
1277 | | - __METHOD__ ); |
| 1390 | + $pagelist = "'" . implode( "', '", $pages ) . "'"; |
| 1391 | + $res = $dbr->select( |
| 1392 | + array( 'page' ), |
| 1393 | + array( 'COUNT(page_id) AS count'), |
| 1394 | + array( "page_namespace=$page_ns_index", "page_title IN ( $pagelist )" ), |
| 1395 | + __METHOD__ |
| 1396 | + ); |
1278 | 1397 | if( $res && $dbr->numRows( $res ) > 0 ) { |
1279 | 1398 | $row = $dbr->fetchObject( $res ); |
1280 | 1399 | $total = $row->count; |
— | — | @@ -1289,32 +1408,31 @@ |
1290 | 1409 | $n3 = $this->query_count( $dbr, $query, 'proofreadpage_quality3_category' ); |
1291 | 1410 | $n4 = $this->query_count( $dbr, $query, 'proofreadpage_quality4_category' ); |
1292 | 1411 | $n1 = $total - $n0 - $n2 - $n3 - $n4; |
1293 | | - |
| 1412 | + |
1294 | 1413 | $dbw = wfGetDB( DB_MASTER ); |
1295 | 1414 | $pr_index = $dbw->tableName( 'pr_index' ); |
1296 | 1415 | $query = "REPLACE INTO $pr_index (pr_page_id, pr_count, pr_q0, pr_q1, pr_q2, pr_q3, pr_q4) VALUES ({$index_id},$n,$n0,$n1,$n2,$n3,$n4)"; |
1297 | | - $dbw->query ( $query ); |
| 1416 | + $dbw->query( $query, __METHOD__ ); |
1298 | 1417 | $dbw->commit(); |
1299 | 1418 | } |
1300 | 1419 | |
1301 | | - |
1302 | | - |
1303 | | - |
1304 | | - /* |
1305 | | - * In ns-0, display the proofreading status of transcluded pages |
| 1420 | + /** |
| 1421 | + * In main namespace, display the proofreading status of transcluded pages. |
| 1422 | + * |
| 1423 | + * @param $out Object: OutputPage object |
1306 | 1424 | */ |
1307 | 1425 | function displayProofreadingStatus( $out ) { |
1308 | 1426 | global $wgTitle, $wgUser; |
1309 | 1427 | |
1310 | 1428 | $id = $wgTitle->mArticleID; |
1311 | | - if($id == -1) { |
| 1429 | + if( $id == -1 ) { |
1312 | 1430 | return true; |
1313 | 1431 | } |
1314 | 1432 | $page_namespace = $this->page_namespace; |
1315 | 1433 | $index_namespace = $this->index_namespace; |
1316 | 1434 | $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $page_namespace ) ); |
1317 | 1435 | $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $index_namespace ) ); |
1318 | | - if( $page_ns_index==null || $index_ns_index == null){ |
| 1436 | + if( $page_ns_index == null || $index_ns_index == null ) { |
1319 | 1437 | return true; |
1320 | 1438 | } |
1321 | 1439 | |
— | — | @@ -1327,19 +1445,29 @@ |
1328 | 1446 | |
1329 | 1447 | // find the index page |
1330 | 1448 | $indextitle = null; |
1331 | | - $res = $dbr->select( array( 'templatelinks' ), |
1332 | | - array( 'tl_title AS title' ), |
1333 | | - array( "tl_from=$id", "tl_namespace=$page_ns_index" ), |
1334 | | - __METHOD__, array( 'LIMIT' => 1 ) ); |
| 1449 | + $res = $dbr->select( |
| 1450 | + array( 'templatelinks' ), |
| 1451 | + array( 'tl_title AS title' ), |
| 1452 | + array( "tl_from=$id", "tl_namespace=$page_ns_index" ), |
| 1453 | + __METHOD__, |
| 1454 | + array( 'LIMIT' => 1 ) |
| 1455 | + ); |
1335 | 1456 | if( $res && $dbr->numRows( $res ) > 0 ) { |
1336 | 1457 | $row = $dbr->fetchObject( $res ); |
1337 | 1458 | $title = $dbr->strencode( $row->title ); |
1338 | 1459 | $dbr->freeResult( $res ); |
1339 | | - $res2 = $dbr->select( array( 'pagelinks', 'page' ), |
1340 | | - array( 'page_title AS title' ), |
1341 | | - array( "pl_title='$title'","pl_namespace=$page_ns_index","page_namespace=$index_ns_index"), |
1342 | | - __METHOD__, array( 'LIMIT' => 1 ), |
1343 | | - array( 'page' => array( 'LEFT JOIN', 'page_id=pl_from' ) ) ) ; |
| 1460 | + $res2 = $dbr->select( |
| 1461 | + array( 'pagelinks', 'page' ), |
| 1462 | + array( 'page_title AS title' ), |
| 1463 | + array( |
| 1464 | + "pl_title='$title'", |
| 1465 | + "pl_namespace=$page_ns_index", |
| 1466 | + "page_namespace=$index_ns_index" |
| 1467 | + ), |
| 1468 | + __METHOD__, |
| 1469 | + array( 'LIMIT' => 1 ), |
| 1470 | + array( 'page' => array( 'LEFT JOIN', 'page_id=pl_from' ) ) |
| 1471 | + ); |
1344 | 1472 | if( $res2 && $dbr->numRows( $res2 ) > 0 ) { |
1345 | 1473 | $row = $dbr->fetchObject( $res2 ); |
1346 | 1474 | $indextitle = $row->title; |
— | — | @@ -1348,12 +1476,15 @@ |
1349 | 1477 | } |
1350 | 1478 | |
1351 | 1479 | if( isset( $out->is_toc ) && $out->is_toc ) { |
1352 | | - if ($indextitle) { |
1353 | | - $res = $dbr->select( array( 'pr_index', 'page' ), |
1354 | | - array( 'pr_count', 'pr_q0', 'pr_q1', 'pr_q2', 'pr_q3', 'pr_q4' ), |
1355 | | - array( "page_title='$indextitle'", "page_namespace=$index_ns_index" ), |
1356 | | - __METHOD__, null, |
1357 | | - array( 'page' => array( 'LEFT JOIN', 'page_id=pr_page_id' ) ) ) ; |
| 1480 | + if ( $indextitle ) { |
| 1481 | + $res = $dbr->select( |
| 1482 | + array( 'pr_index', 'page' ), |
| 1483 | + array( 'pr_count', 'pr_q0', 'pr_q1', 'pr_q2', 'pr_q3', 'pr_q4' ), |
| 1484 | + array( "page_title='$indextitle'", "page_namespace=$index_ns_index" ), |
| 1485 | + __METHOD__, |
| 1486 | + null, |
| 1487 | + array( 'page' => array( 'LEFT JOIN', 'page_id=pr_page_id' ) ) |
| 1488 | + ); |
1358 | 1489 | $row = $dbr->fetchObject( $res ); |
1359 | 1490 | if( $row ) { |
1360 | 1491 | $n0 = $row->pr_q0; |
— | — | @@ -1362,16 +1493,19 @@ |
1363 | 1494 | $n3 = $row->pr_q3; |
1364 | 1495 | $n4 = $row->pr_q4; |
1365 | 1496 | $n = $row->pr_count; |
1366 | | - $ne = $n - ($n0+$n1+$n2+$n3+$n4); |
| 1497 | + $ne = $n - ( $n0 + $n1 + $n2 + $n3 + $n4 ); |
1367 | 1498 | } |
1368 | 1499 | } |
1369 | 1500 | } else { |
1370 | 1501 | // count transclusions from page namespace |
1371 | | - $res = $dbr->select( array( 'templatelinks', 'page' ), |
1372 | | - array( 'COUNT(page_id) AS count' ), |
1373 | | - array( "tl_from=$id", "tl_namespace=$page_ns_index" ), |
1374 | | - __METHOD__, null, |
1375 | | - array( 'page' => array( 'LEFT JOIN', 'page_title=tl_title AND page_namespace=tl_namespace' ) ) ) ; |
| 1502 | + $res = $dbr->select( |
| 1503 | + array( 'templatelinks', 'page' ), |
| 1504 | + array( 'COUNT(page_id) AS count' ), |
| 1505 | + array( "tl_from=$id", "tl_namespace=$page_ns_index" ), |
| 1506 | + __METHOD__, |
| 1507 | + null, |
| 1508 | + array( 'page' => array( 'LEFT JOIN', 'page_title=tl_title AND page_namespace=tl_namespace' ) ) |
| 1509 | + ); |
1376 | 1510 | if( $res && $dbr->numRows( $res ) > 0 ) { |
1377 | 1511 | $row = $dbr->fetchObject( $res ); |
1378 | 1512 | $n = $row->count; |
— | — | @@ -1388,23 +1522,23 @@ |
1389 | 1523 | $ne = 0; |
1390 | 1524 | } |
1391 | 1525 | |
1392 | | - if($n == 0) { |
| 1526 | + if( $n == 0 ) { |
1393 | 1527 | return true; |
1394 | 1528 | } |
1395 | 1529 | |
1396 | 1530 | $indexlink = ''; |
1397 | 1531 | if( $indextitle ) { |
1398 | 1532 | $sk = $wgUser->getSkin(); |
1399 | | - $indexlink = $sk->makeKnownLink( "$index_namespace:$indextitle", "[index]" ); |
| 1533 | + $indexlink = $sk->makeKnownLink( "$index_namespace:$indextitle", '[index]' ); |
1400 | 1534 | } |
1401 | 1535 | |
1402 | | - $q0 = $n0*100/$n; |
1403 | | - $q1 = $n1*100/$n; |
1404 | | - $q2 = $n2*100/$n; |
1405 | | - $q3 = $n3*100/$n; |
1406 | | - $q4 = $n4*100/$n; |
1407 | | - $qe = $ne*100/$n; |
1408 | | - $void_cell = $ne ? "<td align=center style='border-style:dotted;border-width:1px;' width=\"{$qe}\"></td>" : ""; |
| 1536 | + $q0 = $n0 * 100 / $n; |
| 1537 | + $q1 = $n1 * 100 / $n; |
| 1538 | + $q2 = $n2 * 100 / $n; |
| 1539 | + $q3 = $n3 * 100 / $n; |
| 1540 | + $q4 = $n4 * 100 / $n; |
| 1541 | + $qe = $ne * 100 / $n; |
| 1542 | + $void_cell = $ne ? "<td align=center style='border-style:dotted;border-width:1px;' width=\"{$qe}\"></td>" : ''; |
1409 | 1543 | $output = "<table class=\"pr_quality\" style=\"line-height:40%;\" border=0 cellpadding=0 cellspacing=0 ><tr> |
1410 | 1544 | <td align=center > </td> |
1411 | 1545 | <td align=center class='quality4' width=\"$q4\"></td> |
Index: trunk/extensions/ProofreadPage/SpecialProofreadPages.php |
— | — | @@ -4,20 +4,22 @@ |
5 | 5 | * @ingroup SpecialPage |
6 | 6 | */ |
7 | 7 | |
8 | | -if ( !defined( 'MEDIAWIKI' ) ) die( 1 ); |
9 | | -global $wgHooks, $IP; |
| 8 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 9 | + die( 1 ); |
| 10 | +} |
| 11 | + |
| 12 | +global $IP; |
10 | 13 | require_once "$IP/includes/QueryPage.php"; |
11 | 14 | |
12 | | - |
13 | 15 | class ProofreadPages extends SpecialPage { |
14 | 16 | |
15 | | - function __construct() { |
| 17 | + public function __construct() { |
16 | 18 | parent::__construct( 'IndexPages' ); |
17 | 19 | wfLoadExtensionMessages( 'ProofreadPage' ); |
18 | 20 | $this->index_namespace = preg_quote( wfMsgForContent( 'proofreadpage_index_namespace' ), '/' ); |
19 | 21 | } |
20 | 22 | |
21 | | - function execute( $parameters ) { |
| 23 | + public function execute( $parameters ) { |
22 | 24 | global $wgOut, $wgRequest, $wgDisableTextSearch; |
23 | 25 | |
24 | 26 | $this->setHeaders(); |
— | — | @@ -25,7 +27,7 @@ |
26 | 28 | $wgOut->addWikiText( wfMsgForContentNoTrans( 'proofreadpage_specialpage_text' ) ); |
27 | 29 | $searchList = array(); |
28 | 30 | $searchTerm = $wgRequest->getText( 'key' ); |
29 | | - if( ! $wgDisableTextSearch ) { |
| 31 | + if( !$wgDisableTextSearch ) { |
30 | 32 | $wgOut->addHTML( |
31 | 33 | Xml::openElement( 'form' ) . |
32 | 34 | Xml::openElement( 'fieldset' ) . |
— | — | @@ -75,7 +77,7 @@ |
76 | 78 | } |
77 | 79 | |
78 | 80 | function linkParameters() { |
79 | | - return array( 'key'=> $this->searchTerm ); |
| 81 | + return array( 'key' => $this->searchTerm ); |
80 | 82 | } |
81 | 83 | |
82 | 84 | function getSQL() { |
— | — | @@ -92,7 +94,9 @@ |
93 | 95 | $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $this->index_namespace ) ); |
94 | 96 | $querylist = ''; |
95 | 97 | foreach( $this->searchList as $item ) { |
96 | | - if( $querylist ) $querylist .= ', '; |
| 98 | + if( $querylist ) { |
| 99 | + $querylist .= ', '; |
| 100 | + } |
97 | 101 | $querylist .= "'" . $dbr->strencode( $item ). "'"; |
98 | 102 | } |
99 | 103 | $query .= " WHERE page_namespace=$index_ns_index AND page_title IN ($querylist)"; |
— | — | @@ -105,7 +109,7 @@ |
106 | 110 | |
107 | 111 | function getOrder() { |
108 | 112 | return ' ORDER BY 2*pr_q4+pr_q3 ' . |
109 | | - ($this->sortDescending() ? 'DESC' : ''); |
| 113 | + ( $this->sortDescending() ? 'DESC' : '' ); |
110 | 114 | } |
111 | 115 | |
112 | 116 | function sortDescending() { |
— | — | @@ -115,13 +119,13 @@ |
116 | 120 | function formatResult( $skin, $result ) { |
117 | 121 | global $wgLang; |
118 | 122 | |
119 | | - $title = Title::newFromText( $this->index_namespace.":".$result->title ); |
| 123 | + $title = Title::newFromText( $this->index_namespace . ':' . $result->title ); |
120 | 124 | |
121 | 125 | if ( !$title ) { |
122 | | - return '<!-- Invalid title ' . htmlspecialchars( $this->index_namespace.":".$result->title ). '-->'; |
| 126 | + return '<!-- Invalid title ' . htmlspecialchars( $this->index_namespace . ':' . $result->title ) . '-->'; |
123 | 127 | } |
124 | 128 | $plink = $this->isCached() |
125 | | - ? $skin->link( $title , htmlspecialchars( $title->getText() ) ) |
| 129 | + ? $skin->link( $title , htmlspecialchars( $title->getText() ) ) |
126 | 130 | : $skin->linkKnown( $title , htmlspecialchars( $title->getText() ) ); |
127 | 131 | |
128 | 132 | if ( !$title->exists() ) { |
— | — | @@ -135,7 +139,7 @@ |
136 | 140 | $q3 = $result->pr_q3; |
137 | 141 | $q4 = $result->pr_q4; |
138 | 142 | $num_void = $size-$q1-$q2-$q3-$q4-$q0; |
139 | | - $void_cell = $num_void ? "<td align=center style='border-style:dotted;background:#ffffff;border-width:1px;' width=\"{$num_void}\"></td>" : ""; |
| 143 | + $void_cell = $num_void ? "<td align=center style='border-style:dotted;background:#ffffff;border-width:1px;' width=\"{$num_void}\"></td>" : ''; |
140 | 144 | |
141 | 145 | // FIXME: consider using $size in 'proofreadpage_pages' instead of glueing it together in $output |
142 | 146 | $pages = wfMsgExt( 'proofreadpage_pages', 'parsemag', $size ); |
Index: trunk/extensions/ProofreadPage/SpecialPagesWithoutScans.php |
— | — | @@ -1,6 +1,5 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * |
5 | 4 | * This program is free software; you can redistribute it and/or modify |
6 | 5 | * it under the terms of the GNU General Public License as published by |
7 | 6 | * the Free Software Foundation; either version 2 of the License, or |
— | — | @@ -15,33 +14,32 @@ |
16 | 15 | * with this program; if not, write to the Free Software Foundation, Inc., |
17 | 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
18 | 17 | * http://www.gnu.org/copyleft/gpl.html |
| 18 | + * |
| 19 | + * @file |
| 20 | + * @ingroup Extensions |
19 | 21 | */ |
20 | 22 | |
21 | | - /* |
22 | | - * Special page that lists the texts that have no transclusions |
23 | | - * Pages in MediaWiki:Proofreadpage_notnaked_category are excluded. |
24 | | - * |
25 | | - */ |
26 | | - |
| 23 | +/** |
| 24 | + * Special page that lists the texts that have no transclusions |
| 25 | + * Pages in MediaWiki:Proofreadpage_notnaked_category are excluded. |
| 26 | + */ |
27 | 27 | class PagesWithoutScans extends SpecialPage { |
28 | 28 | |
29 | | - function __construct() { |
| 29 | + public function __construct() { |
30 | 30 | parent::__construct( 'PagesWithoutScans' ); |
31 | 31 | } |
32 | 32 | |
33 | | - function execute( $parameters ) { |
34 | | - global $wgOut, $wgRequest, $wgDisableTextSearch; |
| 33 | + public function execute( $parameters ) { |
35 | 34 | $this->setHeaders(); |
36 | 35 | list( $limit, $offset ) = wfCheckLimits(); |
37 | | - $cnl = new PagesWithoutScansQuery( ); |
| 36 | + $cnl = new PagesWithoutScansQuery(); |
38 | 37 | $cnl->doQuery( $offset, $limit ); |
39 | 38 | } |
40 | 39 | } |
41 | 40 | |
42 | | - |
43 | 41 | class PagesWithoutScansQuery extends QueryPage { |
44 | 42 | |
45 | | - function __construct( ) { |
| 43 | + function __construct() { |
46 | 44 | wfLoadExtensionMessages( 'ProofreadPage' ); |
47 | 45 | $this->page_namespace = preg_quote( wfMsgForContent( 'proofreadpage_namespace' ), '/' ); |
48 | 46 | $this->cat = wfMsgForContent( 'proofreadpage_notnaked_category' ); |
— | — | @@ -66,7 +64,7 @@ |
67 | 65 | $page = $dbr->tableName( 'page' ); |
68 | 66 | $templatelinks = $dbr->tableName( 'templatelinks' ); |
69 | 67 | $categorylinks = $dbr->tableName( 'categorylinks' ); |
70 | | - $forceindex = $dbr->useIndexClause("page_len"); |
| 68 | + $forceindex = $dbr->useIndexClause( 'page_len' ); |
71 | 69 | $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $this->page_namespace ) ); |
72 | 70 | $cat = $dbr->strencode( str_replace( ' ' , '_' , $this->cat ) ); |
73 | 71 | $clause = "page_namespace=" . NS_MAIN . " AND page_is_redirect=0 AND page_id NOT IN ( SELECT DISTINCT tl_from FROM $templatelinks LEFT JOIN $page ON page_id=tl_from WHERE tl_namespace=$page_ns_index AND page_namespace=" . NS_MAIN . " ) AND page_id NOT IN ( SELECT DISTINCT cl_from FROM $categorylinks WHERE cl_to='$cat' )"; |
— | — | @@ -89,7 +87,7 @@ |
90 | 88 | |
91 | 89 | $title = Title::makeTitleSafe( $result->namespace, $result->title ); |
92 | 90 | if ( !$title ) { |
93 | | - return '<!-- Invalid title ' . htmlspecialchars( "{$result->namespace}:{$result->title}" ). '-->'; |
| 91 | + return '<!-- Invalid title ' . htmlspecialchars( "{$result->namespace}:{$result->title}" ) . '-->'; |
94 | 92 | } |
95 | 93 | $hlink = $skin->linkKnown( |
96 | 94 | $title, |
Index: trunk/extensions/ProofreadPage/ProofreadPage.php |
— | — | @@ -14,18 +14,11 @@ |
15 | 15 | # with this program; if not, write to the Free Software Foundation, Inc., |
16 | 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 | # http://www.gnu.org/copyleft/gpl.html |
18 | | -# |
19 | | -# |
20 | | -# |
21 | | -# |
22 | | -# |
23 | | -# |
24 | 18 | |
25 | 19 | if ( !defined( 'MEDIAWIKI' ) ) { |
26 | 20 | die( "ProofreadPage extension\n" ); |
27 | 21 | } |
28 | 22 | |
29 | | - |
30 | 23 | $wgExtensionFunctions[] = 'wfProofreadPage'; |
31 | 24 | |
32 | 25 | $dir = dirname( __FILE__ ) . '/'; |
— | — | @@ -44,12 +37,12 @@ |
45 | 38 | ); |
46 | 39 | |
47 | 40 | # special page |
48 | | -$wgAutoloadClasses['ProofreadPages'] = dirname( __FILE__ ) . '/SpecialProofreadPages.php'; |
| 41 | +$wgAutoloadClasses['ProofreadPages'] = $dir . 'SpecialProofreadPages.php'; |
49 | 42 | $wgSpecialPages['IndexPages'] = 'ProofreadPages'; |
50 | 43 | $wgSpecialPageGroups['IndexPages'] = 'pages'; |
51 | 44 | |
52 | 45 | # special page |
53 | | -$wgAutoloadClasses['PagesWithoutScans'] = dirname( __FILE__ ) . '/SpecialPagesWithoutScans.php'; |
| 46 | +$wgAutoloadClasses['PagesWithoutScans'] = $dir . 'SpecialPagesWithoutScans.php'; |
54 | 47 | $wgSpecialPages['PagesWithoutScans'] = 'PagesWithoutScans'; |
55 | 48 | $wgSpecialPageGroups['PagesWithoutScans'] = 'maintenance'; |
56 | 49 | |