r50307 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50306‎ | r50307 | r50308 >
Date:14:51, 7 May 2009
Author:thomasv
Status:ok
Tags:
Comment:
make header and footer fields configurable from index page; do not show PageQuality in textbox
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.i18n.php (modified) (history)
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)
  • /trunk/extensions/ProofreadPage/proofread.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage.i18n.php
@@ -36,6 +36,8 @@
3737 Image|Cover image
3838 Pages||20
3939 Remarks||10',
 40+ 'proofreadpage_default_header' => '<div class="pagetext">',
 41+ 'proofreadpage_default_footer' => '<references/></div>',
4042 );
4143
4244 /** Message documentation (Message documentation)
Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -228,8 +228,6 @@
229229 if( preg_match( $tag_pattern, $text, $matches ) ) $attributes[$var] = $matches[1];
230230 else $attributes[$var] = '';
231231 }
232 -
233 -
234232 return array( $prev_title, $next_title, $attributes );
235233
236234 }
@@ -326,6 +324,7 @@
327325 list( $index_url, $prev_url, $next_url, $attributes ) = pr_navigation( $image );
328326
329327 $jsFile = htmlspecialchars( "$wgScriptPath/extensions/ProofreadPage/proofread.js?$wgProofreadPageVersion" );
 328+
330329 $jsVars = array(
331330 'proofreadPageWidth' => intval( $width ),
332331 'proofreadPageHeight' => intval( $height ),
@@ -336,6 +335,17 @@
337336 'proofreadPagePrevURL' => $prev_url,
338337 'proofreadPageNextURL' => $next_url,
339338 ) + $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+
340350 $varScript = Skin::makeVariablesScript( $jsVars );
341351
342352 $out->addScript( <<<EOT
Index: trunk/extensions/ProofreadPage/proofread.js
@@ -59,13 +59,13 @@
6060 //compare to the width of the image
6161 if(width < proofreadPageWidth) {
6262 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;
6565 }
6666 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;
7070 }
7171 }
7272 return thumb_url;
@@ -101,13 +101,41 @@
102102 }
103103 }
104104 else {
105 - pageHeader = '{{PageQuality|1|}}<div class="pagetext">';
 105+ pageHeader = proofreadPageHeader;
106106 pageBody = text;
107 - pageFooter = '<references/></div>';
 107+ pageFooter = proofreadPageFooter;
108108 document.editform.elements["wpSummary"].value="/* "+proofreadPageMessageQuality1+" */ ";
109109 }
110110 }
111111
 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+
112140 //escape & character
113141 pageBody = pageBody.split("&").join("&amp;")
114142 pageHeader = pageHeader.split("&").join("&amp;")
@@ -275,12 +303,12 @@
276304 else if(zoom_status == 1) {
277305 zoom_status = 2;
278306 return false;
279 - }
280 - else if(zoom_status == 2) {
281 - zoom_off();
 307+ }
 308+ else if(zoom_status == 2) {
 309+ zoom_off();
282310 return false;
283 - }
284 - return false;
 311+ }
 312+ return false;
285313 }
286314
287315
@@ -380,14 +408,14 @@
381409 zp_container.onmousemove = pr_drag;
382410
383411 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;
387415 }
388416 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;
392420 }
393421
394422 init_x = lastxx;
@@ -718,7 +746,7 @@
719747 var footer = form.elements["footerTextbox"];
720748 if(header){
721749 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>";
723751 var f = footer.value;
724752 if(f) f = "<noinclude>\n"+f+"</noinclude>";
725753 var ph = header.parentNode;
@@ -773,11 +801,10 @@
774802
775803 if( self.proofreadpage_setup ) {
776804
777 - proofreadpage_setup(
778 - proofreadPageWidth,
779 - proofreadPageHeight,
780 - proofreadPageIsEdit);
781 -
 805+ proofreadpage_setup(
 806+ proofreadPageWidth,
 807+ proofreadPageHeight,
 808+ proofreadPageIsEdit);
782809 }
783810 else pr_setup();
784811 }
@@ -806,6 +833,7 @@
807834
808835 function pr_add_quality(form,value){
809836
 837+ self.proofreadpage_quality = value;
810838 var text="";
811839 switch(value){
812840 case 0: text = proofreadPageMessageQuality0; break;
@@ -814,56 +842,33 @@
815843 case 3: text = proofreadPageMessageQuality3; break;
816844 case 4: text = proofreadPageMessageQuality4; break;
817845 }
 846+ form.elements["wpSummary"].value="/* "+text+" */ ";
818847
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;
827848 }
828849
829850
830851 function pr_add_quality_buttons(){
831852
832 - if(self.proofreadpage_no_quality_buttons) return;
833 -
 853+ if(self.proofreadpage_no_quality_buttons) return;
834854 var ig = document.getElementById("wpWatchthis");
835855 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 - }
851856 var f = document.createElement("span");
852857 f.innerHTML =
853858 ' <span class="quality0"> <input type="radio" name="quality" onclick="pr_add_quality(this.form,0)"> </span>'
854859 +'<span class="quality2"> <input type="radio" name="quality" onclick="pr_add_quality(this.form,2)"> </span>'
855860 +'<span class="quality1"> <input type="radio" name="quality" onclick="pr_add_quality(this.form,1)"> </span>'
856861 +'<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
858863 + '<span class="quality4"> <input type="radio" name="quality" onclick="pr_add_quality(this.form,4)"> </span>';
859864 f.innerHTML = f.innerHTML + '&nbsp;'+proofreadPageMessageStatus;
860865 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;
868873 }
869874 }
870875 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r50308Follow-up r50307: Define new message keys as to be ignored in translatewikiraymond15:31, 7 May 2009

Status & tagging log