Index: trunk/extensions/ProofreadPage/ProofreadPage.php |
— | — | @@ -18,6 +18,8 @@ |
19 | 19 | $wgDjvutxt = null; |
20 | 20 | |
21 | 21 | |
| 22 | + |
| 23 | + |
22 | 24 | $wgExtensionCredits['other'][] = array( |
23 | 25 | 'name' => 'ProofreadPage', |
24 | 26 | 'author' => 'ThomasV', |
— | — | @@ -28,6 +30,8 @@ |
29 | 31 | |
30 | 32 | |
31 | 33 | $wgExtensionFunctions[] = "pr_main"; |
| 34 | +$wgAjaxExportList[] = "pr_fetch_djvutxt"; |
| 35 | + |
32 | 36 | function pr_main() { |
33 | 37 | global $wgParser; |
34 | 38 | $wgParser->setHook( "pagelist", "pr_renderPageList" ); |
— | — | @@ -35,8 +39,30 @@ |
36 | 40 | } |
37 | 41 | |
38 | 42 | |
| 43 | +/* |
| 44 | + * Fetch Djvu text with curl |
| 45 | + */ |
| 46 | +function pr_fetch_djvutxt( $url ) { |
39 | 47 | |
| 48 | + if($url[0]=='/') $url = "http://localhost" . $url; |
40 | 49 | |
| 50 | + $ch = curl_init( $url ); |
| 51 | + curl_setopt( $ch, CURLOPT_HEADER, false ); |
| 52 | + curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true); |
| 53 | + $text = curl_exec( $ch ); |
| 54 | + |
| 55 | + $errno = curl_errno( $ch ); |
| 56 | + $httpCode = curl_getinfo( $ch, CURLINFO_HTTP_CODE ); |
| 57 | + //$contentType = curl_getinfo( $ch, CURLINFO_CONTENT_TYPE ); |
| 58 | + |
| 59 | + curl_close($ch); |
| 60 | + if($errno==0 && ( $httpCode==200 || $httpCode==404 ) ) { |
| 61 | + return $text; |
| 62 | + } |
| 63 | + return ""; |
| 64 | +} |
| 65 | + |
| 66 | + |
41 | 67 | # Bump the version number every time you change proofread.js |
42 | 68 | $wgProofreadPageVersion = 18; |
43 | 69 | |
Index: trunk/extensions/ProofreadPage/proofread.js |
— | — | @@ -47,6 +47,7 @@ |
48 | 48 | |
49 | 49 | |
50 | 50 | |
| 51 | + |
51 | 52 | function pr_image_url(requested_width){ |
52 | 53 | var image_url; |
53 | 54 | |
— | — | @@ -316,7 +317,7 @@ |
317 | 318 | table.style.cssText = "width:100%;"; |
318 | 319 | |
319 | 320 | //fill table |
320 | | - if(self.proofreadpage_default_layout=='horizontal') |
| 321 | + if(self.proofreadpage_default_layout=='horizontal') |
321 | 322 | pr_fill_table(true); |
322 | 323 | else |
323 | 324 | pr_fill_table(false); |
— | — | @@ -493,18 +494,41 @@ |
494 | 495 | addOnloadHook(pr_init_tabs); |
495 | 496 | |
496 | 497 | |
497 | | -function pr_initzoom(){ |
498 | | - if(document.getElementById("wpTextbox1")){ |
| 498 | +/*fetch djvu content with ajax*/ |
| 499 | +function pr_fetch_djvutxt(){ |
| 500 | + var text_url = proofreadPageThumbURL.replace('##WIDTH##px',"djvutxt").replace(".jpg",".txt"); |
| 501 | + sajax_do_call( 'pr_fetch_djvutxt', [ text_url ], pr_init_textbox ); |
| 502 | +} |
| 503 | + |
| 504 | + |
| 505 | +function pr_init_textbox(xmlhttp) { |
| 506 | + if (xmlhttp == null) return; |
| 507 | + if (xmlhttp.readyState == 4) { |
| 508 | + document.getElementById("wpTextbox1").value = xmlhttp.responseText; |
| 509 | + } |
| 510 | +} |
| 511 | + |
| 512 | + |
| 513 | +function pr_onload(){ |
| 514 | + |
| 515 | + if(self.proofreadPageIsEdit){ |
| 516 | + if(!document.getElementById("wpTextbox1") ) return; |
499 | 517 | if(self.pr_horiz) |
500 | 518 | document.getElementById("wpTextbox1").style.cssText = "height:"+self.vertHeight+"px"; |
501 | 519 | else |
502 | 520 | document.getElementById("wpTextbox1").style.cssText = "height:"+(self.TextBoxHeight-7)+"px"; |
503 | 521 | pr_zoom(0); |
| 522 | + |
| 523 | + //to enable, set proofreadpage_djvutxt=1 |
| 524 | + if(self.proofreadpage_djvutxt) { |
| 525 | + if( document.getElementById("wpTextbox1").value == "" ) pr_fetch_djvutxt(); |
| 526 | + } |
504 | 527 | } |
505 | 528 | } |
506 | | -hookEvent("load", pr_initzoom ); |
| 529 | +hookEvent("load", pr_onload ); |
507 | 530 | |
508 | 531 | |
| 532 | + |
509 | 533 | /*Quality buttons*/ |
510 | 534 | |
511 | 535 | function pr_add_quality(form,value){ |