r114398 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114397‎ | r114398 | r114399 >
Date:19:44, 21 March 2012
Author:catrope
Status:ok
Tags:
Comment:
Revert r113358, r113461, r114004, r114122. Unreviewed revs in ProofreadPage.

All of these revisions are tagged with 'gerritmigration' and will be resubmitted into Gerrit after the Gerrit switchover. See also http://lists.wikimedia.org/pipermail/wikitech-l/2012-March/059124.html
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.i18n.php (modified) (history)
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)
  • /trunk/extensions/ProofreadPage/ProofreadPage_body.php (modified) (history)
  • /trunk/extensions/ProofreadPage/proofread.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php
@@ -740,9 +740,6 @@
741741 $index = array_key_exists( 'index', $args ) ? $args['index'] : null;
742742 $from = array_key_exists( 'from', $args ) ? $args['from'] : null;
743743 $to = array_key_exists( 'to', $args ) ? $args['to'] : null;
744 - $include = array_key_exists( 'include', $args ) ? $args['include'] : null;
745 - $exclude = array_key_exists( 'exclude', $args ) ? $args['exclude'] : null;
746 - $step = array_key_exists( 'step', $args ) ? $args['step'] : null;
747744 $header = array_key_exists( 'header', $args ) ? $args['header'] : null;
748745 $tosection = array_key_exists( 'tosection', $args ) ? $args['tosection'] : null;
749746 $fromsection = array_key_exists( 'fromsection', $args ) ? $args['fromsection'] : null;
@@ -769,9 +766,8 @@
770767
771768 list( $links, $params, $attributes ) = self::parse_index( $index_title );
772769
773 - if( $from || $to || $include ) {
 770+ if( $from || $to ) {
774771 $pages = array();
775 -
776772 if( $links == null ) {
777773 $imageTitle = Title::makeTitleSafe( NS_IMAGE, $index );
778774 if ( !$imageTitle ) {
@@ -783,75 +779,36 @@
784780 }
785781 $count = $image->pageCount();
786782
787 - if( !$step ) {
788 - $step = 1;
 783+ if( !$from ) {
 784+ $from = 1;
789785 }
790 - if( !is_numeric( $step ) || $step < 1 ) {
791 - return '<strong class="error">' . wfMsgForContent( 'proofreadpage_number_expected' ) . '</strong>';
 786+ if( !$to ) {
 787+ $to = $count;
792788 }
793789
794 - $pagenums = array();
795 -
796 - //add page selected with $include in pagenums
797 - if( $include ) {
798 - $list = self::parse_num_list( $include );
799 - if( $list == null ) {
800 - return '<strong class="error">' . wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>';
801 - }
802 - $pagenums = $list;
 790+ if( !is_numeric( $from ) || !is_numeric( $to ) ) {
 791+ return '<strong class="error">' . wfMsgForContent( 'proofreadpage_number_expected' ) . '</strong>';
803792 }
804 -
805 - //ad pages selected with form and to in pagenums
806 - if( $from || $to ) {
807 - if( !$from ) {
808 - $from = 1;
809 - }
810 - if( !$to ) {
811 - $to = $count;
812 - }
813 - if( !is_numeric( $from ) || !is_numeric( $to ) || !is_numeric( $step ) ) {
814 - return '<strong class="error">' . wfMsgForContent( 'proofreadpage_number_expected' ) . '</strong>';
815 - }
816 - if( ($from > $to) || ($from < 1) || ($to < 1 ) || ($to > $count) ) {
817 - return '<strong class="error">' . wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>';
818 - }
819 -
820 - for( $i = $from; $i <= $to; $i++ ) {
821 - $pagenums[$i] = $i;
822 - }
 793+ if( ($from > $to) || ($from < 1) || ($to < 1 ) || ($to > $count) ) {
 794+ return '<strong class="error">' . wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>';
823795 }
824 -
825 - //remove excluded pages form $pagenums
826 - if( $exclude ) {
827 - $excluded = self::parse_num_list( $exclude );
828 - if( $excluded == null ) {
829 - return '<strong class="error">' . wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>';
830 - }
831 - $pagenums = array_diff( $pagenums, $excluded );
832 - }
833 -
834 - if( count($pagenums)/$step > 1000 ) {
 796+ if( $to - $from > 1000 ) {
835797 return '<strong class="error">' . wfMsgForContent( 'proofreadpage_interval_too_large' ) . '</strong>';
836798 }
837799
838 - ksort( $pagenums ); //we must sort the array even if the numerical keys are in a good order.
839 - if( reset( $pagenums ) > $count ) {
840 - return '<strong class="error">' . wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>';
841 - }
842 -
843 - //Create the list of pages to translude. the step system start with the smaller pagenum
844 - $mod = reset( $pagenums ) % $step;
845 - foreach( $pagenums as $num ) {
846 - if( $step == 1 || $num % $step == $mod ) {
847 - list( $pagenum, $links, $mode ) = self::pageNumber( $num, $params );
848 - $page = str_replace( ' ' , '_', "$index/" . $num );
849 - $pages[] = array($page, $pagenum);
 800+ for( $i = $from; $i <= $to; $i++ ) {
 801+ list( $pagenum, $links, $mode ) = self::pageNumber( $i, $params );
 802+ $page = str_replace( ' ' , '_', "$index/" . $i );
 803+ if( $i == $from ) {
 804+ $from_page = $page;
 805+ $from_pagenum = $pagenum;
850806 }
 807+ if( $i == $to ) {
 808+ $to_page = $page;
 809+ $to_pagenum = $pagenum;
 810+ }
 811+ $pages[] = array( $page, $pagenum );
851812 }
852 -
853 - list( $from_page, $from_pagenum ) = end( $pages );
854 - list( $to_page, $to_pagenum ) = reset( $pages );
855 -
856813 } else {
857814 if( $from ) {
858815 $adding = false;
@@ -1018,35 +975,6 @@
1019976 }
1020977
1021978 /**
1022 - * Parse a comma-separated list of pages. A dash indicates an interval of pages
1023 - * example: 1-10,23,38
1024 - * Return an array of pages, or null if the input does not comply to the syntax
1025 - */
1026 - private static function parse_num_list($input) {
1027 - $input = str_replace(array(' ', '\t', '\n'), '', $input);
1028 - $list = explode( ',', $input );
1029 - $nums = array();
1030 - foreach( $list as $item ) {
1031 - if( is_numeric( $item ) ) {
1032 - $nums[$item] = $item;
1033 - } else {
1034 - $interval = explode( '-', $item );
1035 - if( count( $interval ) != 2
1036 - || !is_numeric( $interval[0] )
1037 - || !is_numeric( $interval[1] )
1038 - || $interval[1] < $interval[0]
1039 - ) {
1040 - return null;
1041 - }
1042 - for( $i = $interval[0]; $i <= $interval[1]; $i += 1 ) {
1043 - $nums[$i] = $i;
1044 - }
1045 - }
1046 - }
1047 - return $nums;
1048 - }
1049 -
1050 - /**
1051979 * Set is_toc flag (true if page is a table of contents)
1052980 */
1053981 public static function onOutputPageParserOutput( $outputPage, $parserOutput ) {
@@ -1644,18 +1572,4 @@
16451573 return true;
16461574 }
16471575
1648 - /**
1649 - * Add ProofreadPage preferences to the preferences menu
1650 - */
1651 - public static function onGetPreferences( $user, &$preferences ) {
1652 -
1653 - //Show header and footer fields when editing in the Page namespace
1654 - $preferences['proofreadpage-showheaders'] = array(
1655 - 'type' => 'toggle',
1656 - 'label-message' => 'proofreadpage-preferences-showheaders-label',
1657 - 'section' => 'editing/advancedediting',
1658 - );
1659 -
1660 - return true;
1661 - }
16621576 }
Index: trunk/extensions/ProofreadPage/ProofreadPage.i18n.php
@@ -73,8 +73,7 @@
7474 'proofreadpage-button-zoom-out-label' => 'Zoom out',
7575 'proofreadpage-button-reset-zoom-label' => 'Original size',
7676 'proofreadpage-button-zoom-in-label' => 'Zoom in',
77 - 'proofreadpage-button-toggle-layout-label' => 'Vertical/horizontal layout',
78 - 'proofreadpage-preferences-showheaders-label' => 'Show header and footer fields when editing in the Page namespace'
 77+ 'proofreadpage-button-toggle-layout-label' => 'Vertical/horizontal layout'
7978 );
8079
8180 /** Message documentation (Message documentation)
@@ -140,7 +139,6 @@
141140 'proofreadpage-button-zoom-out-label' => 'Tooltip text in button for zoom out, only visible in edit mode.',
142141 'proofreadpage-button-zoom-in-label' => 'Tooltip text in button for zoom in, only visible in edit mode.',
143142 'proofreadpage-button-toggle-layout-label' => 'Tooltip text in button for horizontal or vertical layout toggle, only visible in edit mode.',
144 - 'proofreadpage-preferences-showheaders-label' => 'Description of the checkbox preference to show/hide the header and footer fields in the edit form of the Page namespace.',
145143 );
146144
147145 /** زَوُن ( زَوُن)
Index: trunk/extensions/ProofreadPage/proofread.js
@@ -754,10 +754,10 @@
755755 pr_make_edit_area( self.text_container, text.value );
756756 f.insertBefore( table, text.nextSibling ); // Inserts table after text
757757 f.removeChild( text );
758 - if ( mw.user.options.get( 'proofreadpage-showheaders' ) ) {
 758+ if ( !self.proofreadpage_show_headers ) {
 759+ hookEvent( 'load', pr_toggle_visibility );
 760+ } else {
759761 hookEvent( 'load', pr_reset_size );
760 - } else {
761 - hookEvent( 'load', pr_toggle_visibility );
762762 }
763763 } else {
764764 var new_text = f.removeChild( text );
@@ -843,18 +843,18 @@
844844 };
845845
846846 var $edit = $( '#wpTextbox1' );
847 - if( mw.user.options.get('usebetatoolbar') ) {
848 - mw.loader.using('ext.wikiEditor.toolbar', function() {
849 - $edit.wikiEditor( 'addToToolbar', {
850 - 'sections': {
851 - 'proofreadpage-tools': {
852 - 'type': 'toolbar',
853 - 'label': mw.msg( 'proofreadpage-section-tools' )
854 - }
 847+ if( typeof $edit.wikiEditor == 'function' ) {
 848+ setTimeout(function() {
 849+ $edit.wikiEditor( 'addToToolbar', {
 850+ 'sections': {
 851+ 'proofreadpage-tools': {
 852+ 'type': 'toolbar',
 853+ 'label': mw.msg( 'proofreadpage-section-tools' )
855854 }
856 - } )
857 - .wikiEditor( 'addToToolbar', tools);
858 - } );
 855+ }
 856+ } )
 857+ .wikiEditor( 'addToToolbar', tools);
 858+ }, 500);
859859 } else {
860860 var toolbar = document.getElementById( 'toolbar' );
861861
@@ -896,9 +896,18 @@
897897 return;
898898 }
899899
900 - if( $.inArray( mw.config.get( 'wgAction' ), ['protect', 'unprotect', 'delete', 'undelete', 'watch', 'unwatch', 'history'] ) !== -1 ) {
 900+ if( document.URL.indexOf( 'action=protect' ) > 0 || document.URL.indexOf( 'action=unprotect' ) > 0 ) {
901901 return;
902902 }
 903+ if( document.URL.indexOf( 'action=delete' ) > 0 || document.URL.indexOf( 'action=undelete' ) > 0 ) {
 904+ return;
 905+ }
 906+ if( document.URL.indexOf( 'action=watch' ) > 0 || document.URL.indexOf( 'action=unwatch' ) > 0 ) {
 907+ return;
 908+ }
 909+ if( document.URL.indexOf( 'action=history' ) > 0 ) {
 910+ return;
 911+ }
903912
904913 /* check if external URL is provided */
905914 if( !self.proofreadPageThumbURL ) {
Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -83,7 +83,6 @@
8484 'proofreadpage-button-reset-zoom-label',
8585 'proofreadpage-button-zoom-in-label',
8686 'proofreadpage-button-toggle-layout-label',
87 - 'proofreadpage-preferences-showheaders-label',
8887 )
8988 ),
9089 'ext.proofreadpage.article' => $prpResourceTemplate + array(
@@ -108,4 +107,3 @@
109108 $wgHooks['EditPage::importFormData'][] = 'ProofreadPage::onEditPageImportFormData';
110109 $wgHooks['OutputPageParserOutput'][] = 'ProofreadPage::onOutputPageParserOutput';
111110 $wgHooks['wgQueryPages'][] = 'ProofreadPage::onwgQueryPages';
112 -$wgHooks['GetPreferences'][] = 'ProofreadPage::onGetPreferences';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r113358Bug 34689zaran10:37, 8 March 2012
r113461Bug 34737 - Patch from ThomasPT (Tpt)zaran09:33, 9 March 2012
r114004Bug 34942 - Add a show Headers preference. Apply ThomasPT's patchzaran09:08, 16 March 2012
r114122Follow-up to r114004 - Use tabs instead of spaceszaran02:30, 19 March 2012

Status & tagging log