Index: trunk/extensions/ProofreadPage/ProofreadPage.php |
— | — | @@ -12,7 +12,11 @@ |
13 | 13 | $wgHooks['GetLinkColours'][] = 'pr_getLinkColours'; |
14 | 14 | $wgHooks['ImageOpenShowImageInlineBefore'][] = 'pr_imageMessage'; |
15 | 15 | $wgHooks['ArticleSaveComplete'][] = 'pr_articleSave'; |
| 16 | +$wgHooks['EditFormPreloadText'][] = 'pr_preloadText'; |
16 | 17 | |
| 18 | +$wgDjvutxt = 'djvutxt'; |
| 19 | + |
| 20 | + |
17 | 21 | $wgExtensionCredits['other'][] = array( |
18 | 22 | 'name' => 'ProofreadPage', |
19 | 23 | 'author' => 'ThomasV', |
— | — | @@ -648,3 +652,32 @@ |
649 | 653 | |
650 | 654 | } |
651 | 655 | |
| 656 | + |
| 657 | + |
| 658 | +function pr_preloadText( $textbox1, $mTitle ) { |
| 659 | + global $wgDjvutxt; |
| 660 | + |
| 661 | + $page_namespace = preg_quote( wfMsgForContent( 'proofreadpage_namespace' ), '/' ); |
| 662 | + |
| 663 | + if ( preg_match( "/^$page_namespace:(.*?)\/([0-9]*)$/", $mTitle->getPrefixedText(), $m ) ) { |
| 664 | + |
| 665 | + $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] ); |
| 666 | + if ( !$imageTitle ) { |
| 667 | + return true; |
| 668 | + } |
| 669 | + |
| 670 | + $image = Image::newFromTitle( $imageTitle ); |
| 671 | + if ( $image->exists() ) { |
| 672 | + $srcPath = $image->getPath(); |
| 673 | + $cmd = "( " .wfEscapeShellArg( $wgDjvutxt ); |
| 674 | + $cmd .= " --page={$m[2]} ". wfEscapeShellArg( $srcPath )." )"; |
| 675 | + wfProfileIn( 'ProofreadPage' ); |
| 676 | + wfDebug( __METHOD__.": $cmd\n" ); |
| 677 | + $err = wfShellExec( $cmd, $retval ); |
| 678 | + wfProfileOut( 'ProofreadPage' ); |
| 679 | + |
| 680 | + if($retval==0) $textbox1 = $err; |
| 681 | + } |
| 682 | + } |
| 683 | + return true; |
| 684 | +} |