Index: trunk/extensions/ProofreadPage/ProofreadPage.i18n.php |
— | — | @@ -36,6 +36,8 @@ |
37 | 37 | Image|Cover image |
38 | 38 | Pages||20 |
39 | 39 | Remarks||10', |
| 40 | + 'proofreadpage_default_header' => '<div class="pagetext">', |
| 41 | + 'proofreadpage_default_footer' => '<references/></div>', |
40 | 42 | ); |
41 | 43 | |
42 | 44 | /** Message documentation (Message documentation) |
Index: trunk/extensions/ProofreadPage/ProofreadPage.php |
— | — | @@ -228,8 +228,6 @@ |
229 | 229 | if( preg_match( $tag_pattern, $text, $matches ) ) $attributes[$var] = $matches[1]; |
230 | 230 | else $attributes[$var] = ''; |
231 | 231 | } |
232 | | - |
233 | | - |
234 | 232 | return array( $prev_title, $next_title, $attributes ); |
235 | 233 | |
236 | 234 | } |
— | — | @@ -326,6 +324,7 @@ |
327 | 325 | list( $index_url, $prev_url, $next_url, $attributes ) = pr_navigation( $image ); |
328 | 326 | |
329 | 327 | $jsFile = htmlspecialchars( "$wgScriptPath/extensions/ProofreadPage/proofread.js?$wgProofreadPageVersion" ); |
| 328 | + |
330 | 329 | $jsVars = array( |
331 | 330 | 'proofreadPageWidth' => intval( $width ), |
332 | 331 | 'proofreadPageHeight' => intval( $height ), |
— | — | @@ -336,6 +335,17 @@ |
337 | 336 | 'proofreadPagePrevURL' => $prev_url, |
338 | 337 | 'proofreadPageNextURL' => $next_url, |
339 | 338 | ) + $attributes; |
| 339 | + |
| 340 | + //Header and Footer |
| 341 | + $header = $attributes['header'] ? $attributes['header'] : wfMsgGetKey('proofreadpage_default_header',true,false,false); |
| 342 | + $footer = $attributes['footer'] ? $attributes['footer'] : wfMsgGetKey('proofreadpage_default_footer',true,false,false); |
| 343 | + foreach($attributes as $key=>$val){ |
| 344 | + $header = str_replace( "{{{{$key}}}}", $val, $header ); |
| 345 | + $footer = str_replace( "{{{{$key}}}}", $val, $footer ); |
| 346 | + } |
| 347 | + $jsVars['proofreadPageHeader'] = $header; |
| 348 | + $jsVars['proofreadPageFooter'] = $footer; |
| 349 | + |
340 | 350 | $varScript = Skin::makeVariablesScript( $jsVars ); |
341 | 351 | |
342 | 352 | $out->addScript( <<<EOT |
Index: trunk/extensions/ProofreadPage/proofread.js |
— | — | @@ -59,13 +59,13 @@ |
60 | 60 | //compare to the width of the image |
61 | 61 | if(width < proofreadPageWidth) { |
62 | 62 | thumb_url = proofreadPageThumbURL.replace('##WIDTH##',""+width); |
63 | | - self.DisplayWidth = requested_width; |
64 | | - self.DisplayHeight = requested_width*proofreadPageHeight/proofreadPageWidth; |
| 63 | + self.DisplayWidth = requested_width; |
| 64 | + self.DisplayHeight = requested_width*proofreadPageHeight/proofreadPageWidth; |
65 | 65 | } |
66 | 66 | else { |
67 | | - thumb_url = proofreadPageViewURL; |
68 | | - self.DisplayWidth = proofreadPageWidth; |
69 | | - self.DisplayHeight = proofreadPageHeight; |
| 67 | + thumb_url = proofreadPageViewURL; |
| 68 | + self.DisplayWidth = proofreadPageWidth; |
| 69 | + self.DisplayHeight = proofreadPageHeight; |
70 | 70 | } |
71 | 71 | } |
72 | 72 | return thumb_url; |
— | — | @@ -101,13 +101,41 @@ |
102 | 102 | } |
103 | 103 | } |
104 | 104 | else { |
105 | | - pageHeader = '{{PageQuality|1|}}<div class="pagetext">'; |
| 105 | + pageHeader = proofreadPageHeader; |
106 | 106 | pageBody = text; |
107 | | - pageFooter = '<references/></div>'; |
| 107 | + pageFooter = proofreadPageFooter; |
108 | 108 | document.editform.elements["wpSummary"].value="/* "+proofreadPageMessageQuality1+" */ "; |
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
| 112 | + //find the PageQuality template |
| 113 | + //we do this separately from header detection, |
| 114 | + //because the template might not be in the header |
| 115 | + var reg = /\{\{PageQuality\|(0|1|2|3|4|25%|50%|75%|100%)(\|.*?|)\}\}/g; |
| 116 | + var m4 = reg.exec(pageHeader); |
| 117 | + self.show4 = false; |
| 118 | + if(m4) { |
| 119 | + switch(m4[1]){ |
| 120 | + case "0": self.proofreadpage_quality = 0; break; |
| 121 | + case "1": self.proofreadpage_quality = 1; break; |
| 122 | + case "2": self.proofreadpage_quality = 2; break; |
| 123 | + case "3": self.proofreadpage_quality = 3; break; |
| 124 | + case "4": self.proofreadpage_quality = 4; break; |
| 125 | + //keep this for backward compatibility |
| 126 | + case "100%": self.proofreadpage_quality = 4; break; |
| 127 | + case "75%": self.proofreadpage_quality = 3; break; |
| 128 | + case "50%": self.proofreadpage_quality = 1; break; |
| 129 | + case "25%": self.proofreadpage_quality = 2; break; |
| 130 | + default: self.proofreadpage_quality = 1; |
| 131 | + } |
| 132 | + |
| 133 | + if((m4[3]!= "|"+wgUserName) && (m4[1]=="3")) self.show4 = true; |
| 134 | + if(m4[1] =="4") self.show4 = true; |
| 135 | + pageHeader = pageHeader.replace(reg,''); |
| 136 | + } |
| 137 | + else self.proofreadpage_quality = 1; |
| 138 | + |
| 139 | + |
112 | 140 | //escape & character |
113 | 141 | pageBody = pageBody.split("&").join("&") |
114 | 142 | pageHeader = pageHeader.split("&").join("&") |
— | — | @@ -275,12 +303,12 @@ |
276 | 304 | else if(zoom_status == 1) { |
277 | 305 | zoom_status = 2; |
278 | 306 | return false; |
279 | | - } |
280 | | - else if(zoom_status == 2) { |
281 | | - zoom_off(); |
| 307 | + } |
| 308 | + else if(zoom_status == 2) { |
| 309 | + zoom_off(); |
282 | 310 | return false; |
283 | | - } |
284 | | - return false; |
| 311 | + } |
| 312 | + return false; |
285 | 313 | } |
286 | 314 | |
287 | 315 | |
— | — | @@ -380,14 +408,14 @@ |
381 | 409 | zp_container.onmousemove = pr_drag; |
382 | 410 | |
383 | 411 | if(evt.pageX) { |
384 | | - countoffset(); |
385 | | - lastxx=evt.pageX - ffox; |
386 | | - lastyy=evt.pageY - ffoy; |
| 412 | + countoffset(); |
| 413 | + lastxx=evt.pageX - ffox; |
| 414 | + lastyy=evt.pageY - ffoy; |
387 | 415 | } |
388 | 416 | else { |
389 | | - countoffset(); |
390 | | - lastxx=evt.clientX - ieox; |
391 | | - lastyy=evt.clientY - ieoy; |
| 417 | + countoffset(); |
| 418 | + lastxx=evt.clientX - ieox; |
| 419 | + lastyy=evt.clientY - ieoy; |
392 | 420 | } |
393 | 421 | |
394 | 422 | init_x = lastxx; |
— | — | @@ -718,7 +746,7 @@ |
719 | 747 | var footer = form.elements["footerTextbox"]; |
720 | 748 | if(header){ |
721 | 749 | var h = header.value.replace(/(\s*(\r?\n|\r))+$/, ''); |
722 | | - if(h) h = "<noinclude>"+h+"\n\n\n</noinclude>"; |
| 750 | + if(h) h = "<noinclude>{{PageQuality|"+self.proofreadpage_quality+"|"+wgUserName+"}}"+h+"\n\n\n</noinclude>"; |
723 | 751 | var f = footer.value; |
724 | 752 | if(f) f = "<noinclude>\n"+f+"</noinclude>"; |
725 | 753 | var ph = header.parentNode; |
— | — | @@ -773,11 +801,10 @@ |
774 | 802 | |
775 | 803 | if( self.proofreadpage_setup ) { |
776 | 804 | |
777 | | - proofreadpage_setup( |
778 | | - proofreadPageWidth, |
779 | | - proofreadPageHeight, |
780 | | - proofreadPageIsEdit); |
781 | | - |
| 805 | + proofreadpage_setup( |
| 806 | + proofreadPageWidth, |
| 807 | + proofreadPageHeight, |
| 808 | + proofreadPageIsEdit); |
782 | 809 | } |
783 | 810 | else pr_setup(); |
784 | 811 | } |
— | — | @@ -806,6 +833,7 @@ |
807 | 834 | |
808 | 835 | function pr_add_quality(form,value){ |
809 | 836 | |
| 837 | + self.proofreadpage_quality = value; |
810 | 838 | var text=""; |
811 | 839 | switch(value){ |
812 | 840 | case 0: text = proofreadPageMessageQuality0; break; |
— | — | @@ -814,56 +842,33 @@ |
815 | 843 | case 3: text = proofreadPageMessageQuality3; break; |
816 | 844 | case 4: text = proofreadPageMessageQuality4; break; |
817 | 845 | } |
| 846 | + form.elements["wpSummary"].value="/* "+text+" */ "; |
818 | 847 | |
819 | | - form.elements["wpSummary"].value="/* "+text+" */ "; |
820 | | - s = form.elements["headerTextbox"].value; |
821 | | - s = s.replace(/\{\{PageQuality\|(.*?)\}\}/gi,"") |
822 | | - form.elements["headerTextbox"].value="{{PageQuality|"+value+"|"+wgUserName+"}}"+s; |
823 | | - //remove template from wpTextbox1 in case it was corrupted |
824 | | - s = form.elements["wpTextbox1"].value; |
825 | | - s = s.replace(/\{\{PageQuality\|(.*?)\}\}/gi,"") |
826 | | - form.elements["wpTextbox1"].value=s; |
827 | 848 | } |
828 | 849 | |
829 | 850 | |
830 | 851 | function pr_add_quality_buttons(){ |
831 | 852 | |
832 | | - if(self.proofreadpage_no_quality_buttons) return; |
833 | | - |
| 853 | + if(self.proofreadpage_no_quality_buttons) return; |
834 | 854 | var ig = document.getElementById("wpWatchthis"); |
835 | 855 | if(!ig) return; |
836 | | - |
837 | | - var s = document.editform.headerTextbox.value; |
838 | | - var reg = /\{\{PageQuality\|([0-9]*(%|))(\|.*?|)\}\}/g; |
839 | | - var m = reg.exec(s); |
840 | | - var show4 = false; |
841 | | - if(m) { |
842 | | - //this is for backward compatibility |
843 | | - if(m[1]=="100%") m[1]="4"; |
844 | | - if(m[1]=="75%") m[1]="3"; |
845 | | - if(m[1]=="50%") m[1]="1"; |
846 | | - if(m[1]=="25%") m[1]="2"; |
847 | | - |
848 | | - if( (m[3] != "|"+wgUserName) && (m[1]=="3")) show4 = true; |
849 | | - if(m[1] =="4") show4 = true; |
850 | | - } |
851 | 856 | var f = document.createElement("span"); |
852 | 857 | f.innerHTML = |
853 | 858 | ' <span class="quality0"> <input type="radio" name="quality" onclick="pr_add_quality(this.form,0)"> </span>' |
854 | 859 | +'<span class="quality2"> <input type="radio" name="quality" onclick="pr_add_quality(this.form,2)"> </span>' |
855 | 860 | +'<span class="quality1"> <input type="radio" name="quality" onclick="pr_add_quality(this.form,1)"> </span>' |
856 | 861 | +'<span class="quality3"> <input type="radio" name="quality" onclick="pr_add_quality(this.form,3)"> </span>'; |
857 | | - if(show4) f.innerHTML = f.innerHTML |
| 862 | + if(self.show4) f.innerHTML = f.innerHTML |
858 | 863 | + '<span class="quality4"> <input type="radio" name="quality" onclick="pr_add_quality(this.form,4)"> </span>'; |
859 | 864 | f.innerHTML = f.innerHTML + ' '+proofreadPageMessageStatus; |
860 | 865 | ig.parentNode.insertBefore(f,ig.nextSibling.nextSibling.nextSibling); |
861 | | - if(m) { |
862 | | - switch(m[1]){ |
863 | | - case "4": document.editform.quality[4].checked=true; break; |
864 | | - case "3": document.editform.quality[3].checked=true; break; |
865 | | - case "1": document.editform.quality[2].checked=true; break; |
866 | | - case "2": document.editform.quality[1].checked=true; break; |
867 | | - case "0": document.editform.quality[0].checked=true; break; |
| 866 | + if(self.proofreadpage_quality) { |
| 867 | + switch(self.proofreadpage_quality){ |
| 868 | + case 4: document.editform.quality[4].checked=true; break; |
| 869 | + case 3: document.editform.quality[3].checked=true; break; |
| 870 | + case 1: document.editform.quality[2].checked=true; break; |
| 871 | + case 2: document.editform.quality[1].checked=true; break; |
| 872 | + case 0: document.editform.quality[0].checked=true; break; |
868 | 873 | } |
869 | 874 | } |
870 | 875 | } |