https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114398

Revision: 114398
Author:   catrope
Date:     2012-03-21 19:44:42 +0000 (Wed, 21 Mar 2012)
Log Message:
-----------
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
    trunk/extensions/ProofreadPage/ProofreadPage.php
    trunk/extensions/ProofreadPage/ProofreadPage_body.php
    trunk/extensions/ProofreadPage/proofread.js

Modified: trunk/extensions/ProofreadPage/ProofreadPage.i18n.php
===================================================================
--- trunk/extensions/ProofreadPage/ProofreadPage.i18n.php       2012-03-21 
19:44:27 UTC (rev 114397)
+++ trunk/extensions/ProofreadPage/ProofreadPage.i18n.php       2012-03-21 
19:44:42 UTC (rev 114398)
@@ -73,8 +73,7 @@
        'proofreadpage-button-zoom-out-label'          => 'Zoom out',
        'proofreadpage-button-reset-zoom-label'        => 'Original size',
        'proofreadpage-button-zoom-in-label'           => 'Zoom in',
-       'proofreadpage-button-toggle-layout-label'     => 'Vertical/horizontal 
layout',
-       'proofreadpage-preferences-showheaders-label'  => 'Show header and 
footer fields when editing in the Page namespace'
+       'proofreadpage-button-toggle-layout-label'     => 'Vertical/horizontal 
layout'
 );
 
 /** Message documentation (Message documentation)
@@ -140,7 +139,6 @@
        'proofreadpage-button-zoom-out-label' => 'Tooltip text in button for 
zoom out, only visible in edit mode.',
        'proofreadpage-button-zoom-in-label' => 'Tooltip text in button for 
zoom in, only visible in edit mode.',
        'proofreadpage-button-toggle-layout-label' => 'Tooltip text in button 
for horizontal or vertical layout toggle, only visible in edit mode.',
-       '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.',
 );
 
 /**    زَوُن (   زَوُن)

Modified: trunk/extensions/ProofreadPage/ProofreadPage.php
===================================================================
--- trunk/extensions/ProofreadPage/ProofreadPage.php    2012-03-21 19:44:27 UTC 
(rev 114397)
+++ trunk/extensions/ProofreadPage/ProofreadPage.php    2012-03-21 19:44:42 UTC 
(rev 114398)
@@ -83,7 +83,6 @@
                        'proofreadpage-button-reset-zoom-label',
                        'proofreadpage-button-zoom-in-label',
                        'proofreadpage-button-toggle-layout-label',
-                       'proofreadpage-preferences-showheaders-label',
                )
        ),
        'ext.proofreadpage.article' => $prpResourceTemplate + array(
@@ -108,4 +107,3 @@
 $wgHooks['EditPage::importFormData'][] = 
'ProofreadPage::onEditPageImportFormData';
 $wgHooks['OutputPageParserOutput'][] = 
'ProofreadPage::onOutputPageParserOutput';
 $wgHooks['wgQueryPages'][] = 'ProofreadPage::onwgQueryPages';
-$wgHooks['GetPreferences'][] = 'ProofreadPage::onGetPreferences';

Modified: trunk/extensions/ProofreadPage/ProofreadPage_body.php
===================================================================
--- trunk/extensions/ProofreadPage/ProofreadPage_body.php       2012-03-21 
19:44:27 UTC (rev 114397)
+++ trunk/extensions/ProofreadPage/ProofreadPage_body.php       2012-03-21 
19:44:42 UTC (rev 114398)
@@ -740,9 +740,6 @@
                $index = array_key_exists( 'index', $args ) ? $args['index'] : 
null;
                $from = array_key_exists( 'from', $args ) ? $args['from'] : 
null;
                $to = array_key_exists( 'to', $args ) ? $args['to'] : null;
-               $include = array_key_exists( 'include', $args ) ? 
$args['include'] : null;
-               $exclude = array_key_exists( 'exclude', $args ) ? 
$args['exclude'] : null;
-               $step = array_key_exists( 'step', $args ) ? $args['step'] : 
null;
                $header = array_key_exists( 'header', $args ) ? $args['header'] 
: null;
                $tosection = array_key_exists( 'tosection', $args ) ? 
$args['tosection'] : null;
                $fromsection = array_key_exists( 'fromsection', $args ) ? 
$args['fromsection'] : null;
@@ -769,9 +766,8 @@
 
                list( $links, $params, $attributes ) = self::parse_index( 
$index_title );
 
-               if( $from || $to || $include ) {
+               if( $from || $to ) {
                        $pages = array();
-
                        if( $links == null ) {
                                $imageTitle = Title::makeTitleSafe( NS_IMAGE, 
$index );
                                if ( !$imageTitle ) {
@@ -783,75 +779,36 @@
                                }
                                $count = $image->pageCount();
 
-                               if( !$step ) {
-                                       $step = 1;
+                               if( !$from ) {
+                                       $from = 1;
                                }
-                               if( !is_numeric( $step ) || $step < 1 ) {
-                                       return '<strong class="error">' . 
wfMsgForContent( 'proofreadpage_number_expected' ) . '</strong>';
+                               if( !$to ) {
+                                       $to = $count;
                                }
 
-                               $pagenums = array();
-
-                               //add page selected with $include in pagenums
-                               if( $include ) {
-                                       $list = self::parse_num_list( $include 
);
-                                       if( $list  == null ) {
-                                               return '<strong class="error">' 
. wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>';
-                                       }
-                                       $pagenums = $list;
+                               if( !is_numeric( $from ) || !is_numeric( $to ) 
) {
+                                       return '<strong class="error">' . 
wfMsgForContent( 'proofreadpage_number_expected' ) . '</strong>';
                                }
-
-                               //ad pages selected with form and to in pagenums
-                               if( $from || $to ) {
-                                       if( !$from ) {
-                                               $from = 1;
-                                       }
-                                       if( !$to ) {
-                                               $to = $count;
-                                       }
-                                       if( !is_numeric( $from ) || 
!is_numeric( $to )  || !is_numeric( $step ) ) {
-                                               return '<strong class="error">' 
. wfMsgForContent( 'proofreadpage_number_expected' ) . '</strong>';
-                                       }
-                                       if( ($from > $to) || ($from < 1) || 
($to < 1 ) || ($to > $count) ) {
-                                               return '<strong class="error">' 
. wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>';
-                                       }
-
-                                       for( $i = $from; $i <= $to; $i++ ) {
-                                               $pagenums[$i] = $i;
-                                       }
+                               if( ($from > $to) || ($from < 1) || ($to < 1 ) 
|| ($to > $count) ) {
+                                       return '<strong class="error">' . 
wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>';
                                }
-
-                               //remove excluded pages form $pagenums
-                               if( $exclude ) {
-                                       $excluded = self::parse_num_list( 
$exclude );
-                                       if( $excluded  == null ) {
-                                               return '<strong class="error">' 
. wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>';
-                                       }
-                                       $pagenums = array_diff( $pagenums, 
$excluded );
-                               }
-
-                               if( count($pagenums)/$step > 1000 ) {
+                               if( $to - $from > 1000 ) {
                                        return '<strong class="error">' . 
wfMsgForContent( 'proofreadpage_interval_too_large' ) . '</strong>';
                                }
 
-                               ksort( $pagenums ); //we must sort the array 
even if the numerical keys are in a good order. 
-                               if( reset( $pagenums ) > $count ) {
-                                       return '<strong class="error">' . 
wfMsgForContent( 'proofreadpage_invalid_interval' ) . '</strong>';
-                               }
-
-                               //Create the list of pages to translude. the 
step system start with the smaller pagenum
-                               $mod = reset( $pagenums ) % $step;
-                               foreach( $pagenums as $num ) {
-                                       if( $step == 1 || $num % $step == $mod 
) {
-                                               list( $pagenum, $links, $mode ) 
= self::pageNumber( $num, $params );
-                                               $page = str_replace( ' ' , '_', 
"$index/" . $num );
-                                               $pages[] = array($page, 
$pagenum);
+                               for( $i = $from; $i <= $to; $i++ ) {
+                                       list( $pagenum, $links, $mode ) = 
self::pageNumber( $i, $params );
+                                       $page = str_replace( ' ' , '_', 
"$index/" . $i );
+                                       if( $i == $from ) {
+                                               $from_page = $page;
+                                               $from_pagenum = $pagenum;
                                        }
+                                       if( $i == $to ) {
+                                               $to_page = $page;
+                                               $to_pagenum = $pagenum;
+                                       }
+                                       $pages[] = array( $page, $pagenum );
                                }
-
-                               list( $from_page, $from_pagenum ) = end( $pages 
);
-                               list( $to_page, $to_pagenum ) = reset( $pages );
-
                        } else {
                                if( $from ) {
                                        $adding = false;
@@ -1018,35 +975,6 @@
        }
 
        /**
-        * Parse a comma-separated list of pages. A dash indicates an interval 
of pages
-        * example: 1-10,23,38
-        * Return an array of pages, or null if the input does not comply to 
the syntax
-        */
-       private static function parse_num_list($input) {
-               $input = str_replace(array(' ', '\t', '\n'), '', $input);
-               $list = explode( ',', $input );
-               $nums = array();
-               foreach( $list as $item ) {
-                       if( is_numeric( $item ) ) {
-                               $nums[$item] = $item;
-                       } else {
-                               $interval = explode( '-', $item );
-                               if( count( $interval ) != 2
-                                       || !is_numeric( $interval[0] )
-                                       || !is_numeric( $interval[1] )
-                                       || $interval[1] < $interval[0]
-                               ) {
-                                       return null;
-                               }
-                               for( $i = $interval[0]; $i <= $interval[1]; $i 
+= 1 ) {
-                                       $nums[$i] = $i;
-                               }
-                       }
-               }
-               return $nums;
-       }
-
-       /**
         * Set is_toc flag (true if page is a table of contents)
         */
        public static function onOutputPageParserOutput( $outputPage, 
$parserOutput ) {
@@ -1644,18 +1572,4 @@
                return true;
        }
 
-       /**
-        * Add ProofreadPage preferences to the preferences menu
-        */
-       public static function onGetPreferences( $user, &$preferences ) {
- 
-               //Show header and footer fields when editing in the Page 
namespace
-               $preferences['proofreadpage-showheaders'] = array(
-                       'type'           => 'toggle',
-                       'label-message'  => 
'proofreadpage-preferences-showheaders-label',
-                       'section'        => 'editing/advancedediting',
-               );
-
-               return true;
-       }
 }

Modified: trunk/extensions/ProofreadPage/proofread.js
===================================================================
--- trunk/extensions/ProofreadPage/proofread.js 2012-03-21 19:44:27 UTC (rev 
114397)
+++ trunk/extensions/ProofreadPage/proofread.js 2012-03-21 19:44:42 UTC (rev 
114398)
@@ -754,10 +754,10 @@
                pr_make_edit_area( self.text_container, text.value );
                f.insertBefore( table, text.nextSibling ); // Inserts table 
after text
                f.removeChild( text );
-               if ( mw.user.options.get( 'proofreadpage-showheaders' ) ) {
+               if ( !self.proofreadpage_show_headers ) {
+                       hookEvent( 'load', pr_toggle_visibility );
+               } else {
                        hookEvent( 'load', pr_reset_size );
-               } else {
-                       hookEvent( 'load', pr_toggle_visibility );
                }
        } else {
                var new_text = f.removeChild( text );
@@ -843,18 +843,18 @@
                };
 
                var $edit = $( '#wpTextbox1' );
-               if( mw.user.options.get('usebetatoolbar') ) {
-                       mw.loader.using('ext.wikiEditor.toolbar', function() {
-                               $edit.wikiEditor( 'addToToolbar', {
-                                       'sections': {
-                                               'proofreadpage-tools': {
-                                                       'type': 'toolbar',
-                                                       'label': mw.msg( 
'proofreadpage-section-tools' )
-                                               }
+               if( typeof $edit.wikiEditor == 'function' ) {
+                       setTimeout(function() {
+                       $edit.wikiEditor( 'addToToolbar', {
+                               'sections': {
+                                       'proofreadpage-tools': {
+                                               'type': 'toolbar',
+                                               'label': mw.msg( 
'proofreadpage-section-tools' )
                                        }
-                               } )
-                               .wikiEditor( 'addToToolbar', tools);
-                       } );
+                               }
+                       } )
+                       .wikiEditor( 'addToToolbar', tools);
+                       }, 500);
                } else {
                        var toolbar = document.getElementById( 'toolbar' );
 
@@ -896,9 +896,18 @@
                return;
        }
 
-       if( $.inArray( mw.config.get( 'wgAction' ), ['protect', 'unprotect', 
'delete', 'undelete', 'watch', 'unwatch', 'history'] ) !== -1 ) {
+       if( document.URL.indexOf( 'action=protect' ) > 0 || 
document.URL.indexOf( 'action=unprotect' ) > 0 ) {
                return;
        }
+       if( document.URL.indexOf( 'action=delete' ) > 0 || 
document.URL.indexOf( 'action=undelete' ) > 0 ) {
+               return;
+       }
+       if( document.URL.indexOf( 'action=watch' ) > 0 || document.URL.indexOf( 
'action=unwatch' ) > 0 ) {
+               return;
+       }
+       if( document.URL.indexOf( 'action=history' ) > 0 ) {
+               return;
+       }
 
        /* check if external URL is provided */
        if( !self.proofreadPageThumbURL ) {


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to