r70766 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70765‎ | r70766 | r70767 >
Date:15:00, 9 August 2010
Author:thomasv
Status:ok
Tags:
Comment:
make the page container configurable from the index page, and hide it during edition
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
@@ -57,8 +57,8 @@
5858 Image|Cover image
5959 Pages||20
6060 Remarks||10',
61 - 'proofreadpage_default_header' => '<div class="pagetext">',
62 - 'proofreadpage_default_footer' => '<references/></div>',
 61+ 'proofreadpage_default_header' => '',
 62+ 'proofreadpage_default_footer' => '<references/>',
6363 'proofreadpage_quality_message' => "<table style=\"line-height:40%;\" border=0 cellpadding=0 cellspacing=0 ><tr>
6464 <td align=center >&nbsp;</td>
6565 <td align=center class='quality4' width=\"$5\"></td>
Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -162,7 +162,7 @@
163163 $default_header = wfMsgGetKey( 'proofreadpage_default_header', true, true, false );
164164 $default_footer = wfMsgGetKey( 'proofreadpage_default_footer', true, true, false );
165165
166 - $err = array( '', '', '', '', '' );
 166+ $err = array( '', '', '', '', '', '' );
167167 $index_title = Title::newFromText( $title->pr_index_title );
168168 if ( !$index_title ) {
169169 return $err;
@@ -224,14 +224,16 @@
225225 }
226226
227227 // Header and Footer
 228+ // use a js dictionary for style, width, header footer
228229 $header = $attributes['header'] ? $attributes['header'] : $default_header;
229230 $footer = $attributes['footer'] ? $attributes['footer'] : $default_footer;
230231 foreach ( $attributes as $key => $val ) {
231232 $header = str_replace( "{{{{$key}}}}", $val, $header );
232233 $footer = str_replace( "{{{{$key}}}}", $val, $footer );
233234 }
 235+ $css = $attributes['css'] ? $attributes['css'] : "";
234236
235 - return array( $index_url, $prev_url, $next_url, $header, $footer );
 237+ return array( $index_url, $prev_url, $next_url, $header, $footer, $css );
236238
237239 }
238240
@@ -415,7 +417,7 @@
416418 $thumbURL = '';
417419 }
418420
419 - list( $index_url, $prev_url, $next_url, $header, $footer ) = pr_navigation( $wgTitle );
 421+ list( $index_url, $prev_url, $next_url, $header, $footer, $css ) = pr_navigation( $wgTitle );
420422
421423 $jsFile = htmlspecialchars( "$wgScriptPath/extensions/ProofreadPage/proofread.js?$wgProofreadPageVersion" );
422424
@@ -432,6 +434,7 @@
433435 'proofreadPageFooter' => $footer,
434436 'proofreadPageAddButtons' => $wgUser->isAllowed('pagequality'),
435437 'proofreadPageUserName' => $wgUser->getName(),
 438+ 'proofreadPageCss' => $css,
436439 );
437440 $varScript = Skin::makeVariablesScript( $jsVars );
438441
@@ -886,7 +889,7 @@
887890 $page_regexp = "/^<noinclude>(.*?)<\/noinclude>(.*?)<noinclude>(.*?)<\/noinclude>$/s";
888891 if( !preg_match( $page_regexp, $text, $m ) ) {
889892 pr_load_index( $wgTitle );
890 - list( $index_url, $prev_url, $next_url, $header, $footer ) = pr_navigation( $wgTitle );
 893+ list( $index_url, $prev_url, $next_url, $header, $footer, $css ) = pr_navigation( $wgTitle );
891894 $new_text = "<noinclude><pagequality level=\"1\" user=\"$username\" />"
892895 ."$header\n\n\n</noinclude>$text<noinclude>\n$footer</noinclude>";
893896 return array( -1, null, $new_text );
@@ -939,9 +942,9 @@
940943 if( in_array( $editpage->quality , array( "0", "1", "2", "3", "4" ) ) ) {
941944 //format the page
942945 $text = "<noinclude><pagequality level=\"".$editpage->quality."\" user=\"".$editpage->username."\" />"
943 - .$editpage->header."\n\n\n</noinclude>"
 946+ ."<div class=\"pagetext\">".$editpage->header."\n\n\n</noinclude>"
944947 .$editpage->textbox1
945 - ."<noinclude>\n".$editpage->footer."</noinclude>";
 948+ ."<noinclude>\n".$editpage->footer."</div></noinclude>";
946949 $editpage->textbox1 = $text;
947950 } else {
948951 //replace deprecated template
Index: trunk/extensions/ProofreadPage/proofread.js
@@ -150,6 +150,11 @@
151151 self.proofreadpage_quality = 1;
152152 self.proofreadpage_username = "";
153153 }
 154+ //detect the container div
 155+ if( pageHeader.match("^<div class=\"pagetext\">") && pageFooter.match("</div>$") ) {
 156+ pageHeader = pageHeader.substr(22,pageHeader.length);
 157+ pageFooter = pageFooter.substr(0,pageFooter.length-6);
 158+ }
154159
155160 //escape & character
156161 pageBody = pageBody.split("&").join("&amp;")
@@ -870,6 +875,15 @@
871876 proofreadPageIsEdit);
872877 }
873878 else pr_setup();
 879+
 880+ //add css classes to the container div
 881+ var c = document.getElementById("pagequality");
 882+ if(c) {
 883+ c = c.nextSibling;
 884+ if(c.className=="pagetext") {
 885+ c.className += " "+self.proofreadPageCss;
 886+ }
 887+ }
874888 }
875889
876890

Status & tagging log