Index: trunk/extensions/ProofreadPage/ProofreadPage.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | $wgExtensionMessagesFiles['ProofreadPage'] = dirname( __FILE__ ) . '/ProofreadPage.i18n.php'; |
11 | 11 | |
12 | 12 | $wgHooks['BeforePageDisplay'][] = 'pr_beforePageDisplay'; |
13 | | -$wgHooks['GetLinkColours'][] = 'pr_getLinkColours'; |
| 13 | +$wgHooks['GetLinkColours'][] = 'pr_getLinkColoursHook'; |
14 | 14 | $wgHooks['ImageOpenShowImageInlineBefore'][] = 'pr_imageMessage'; |
15 | 15 | $wgHooks['ArticleSaveComplete'][] = 'pr_articleSave'; |
16 | 16 | $wgHooks['EditFormPreloadText'][] = 'pr_preloadText'; |
— | — | @@ -387,10 +387,10 @@ |
388 | 388 | |
389 | 389 | |
390 | 390 | /** |
391 | | - * Return the quality colour codes to pages linked from an index page |
392 | | - * Update page counts in pr_index table |
| 391 | + * Hook function |
393 | 392 | */ |
394 | | -function pr_getLinkColours( $page_ids, &$colours ) { |
| 393 | +function pr_getLinkColoursHook( $page_ids, &$colours ) { |
| 394 | + |
395 | 395 | global $wgTitle; |
396 | 396 | |
397 | 397 | if ( !isset( $wgTitle ) ) { |
— | — | @@ -400,12 +400,26 @@ |
401 | 401 | |
402 | 402 | // abort if we are not an index page |
403 | 403 | $index_namespace = preg_quote( wfMsgForContent( 'proofreadpage_index_namespace' ), '/' ); |
404 | | - if ( !preg_match( "/^$index_namespace:(.*?)$/", $wgTitle->getPrefixedText() ) ) { |
| 404 | + if ( !preg_match( "/^$index_namespace:(.*?)$/", $wgTitle->getPrefixedText(), $m ) ) { |
405 | 405 | return true; |
406 | 406 | } |
| 407 | + // abort too if we are a djvu index |
| 408 | + $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] ); |
| 409 | + if ( $imageTitle ) { |
| 410 | + $image = wfFindFile( $imageTitle ); |
| 411 | + if ( $image && $image->isMultiPage() ) { |
| 412 | + return true; |
| 413 | + } |
| 414 | + } |
| 415 | + pr_getLinkColours( $page_ids, $colours ); |
| 416 | + return true; |
| 417 | +} |
| 418 | + |
407 | 419 | |
408 | | - // counters |
409 | | - $n = $n0 = $n1 = $n2 = $n3 = $n4 = 0; |
| 420 | +/** |
| 421 | + * Return the quality colour codes to pages linked from an index page |
| 422 | + */ |
| 423 | +function pr_getLinkColours( $page_ids, &$colours ) { |
410 | 424 | |
411 | 425 | $dbr = wfGetDB( DB_SLAVE ); |
412 | 426 | $catlinks = $dbr->tableName( 'categorylinks' ); |
— | — | @@ -414,8 +428,6 @@ |
415 | 429 | $page_namespace = preg_quote( wfMsgForContent( 'proofreadpage_namespace' ), '/' ); |
416 | 430 | if ( preg_match( "/^$page_namespace:(.*?)$/", $pdbk ) ) { |
417 | 431 | $colours[$pdbk] = 'quality1'; |
418 | | - $n++; |
419 | | - |
420 | 432 | if ( !isset( $query ) ) { |
421 | 433 | $query = "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN("; |
422 | 434 | } else { |
— | — | @@ -434,29 +446,22 @@ |
435 | 447 | switch( $x->cl_to ) { |
436 | 448 | case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality0_category' ) ): |
437 | 449 | $colours[$pdbk] = 'quality0'; |
438 | | - $n0++; |
439 | 450 | break; |
440 | 451 | case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality1_category' ) ): |
441 | 452 | $colours[$pdbk] = 'quality1'; |
442 | | - $n1++; |
443 | 453 | break; |
444 | 454 | case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality2_category' ) ): |
445 | 455 | $colours[$pdbk] = 'quality2'; |
446 | | - $n2++; |
447 | 456 | break; |
448 | 457 | case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality3_category' ) ): |
449 | 458 | $colours[$pdbk] = 'quality3'; |
450 | | - $n3++; |
451 | 459 | break; |
452 | 460 | case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality4_category' ) ): |
453 | 461 | $colours[$pdbk] = 'quality4'; |
454 | | - $n4++; |
455 | 462 | break; |
456 | 463 | } |
457 | 464 | } |
458 | 465 | } |
459 | | - |
460 | | - return true; |
461 | 466 | } |
462 | 467 | |
463 | 468 | function pr_imageMessage( &$imgpage , &$wgOut ) { |