(bug 16921) Add JavaScript-based enforcing of byte limits on move and protection...
authorRoan Kattouw <catrope@users.mediawiki.org>
Mon, 25 Apr 2011 11:39:30 +0000 (11:39 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Mon, 25 Apr 2011 11:39:30 +0000 (11:39 +0000)
includes/ProtectionForm.php
includes/specials/SpecialMovepage.php
resources/Resources.php
resources/mediawiki.special/mediawiki.special.movePage.js [new file with mode: 0644]
skins/common/protect.js

index 6f04e97..5f5d7c7 100644 (file)
@@ -467,7 +467,10 @@ class ProtectionForm {
                                        </td>
                                        <td class='mw-input'>" .
                                                Xml::input( 'mwProtect-reason', 60, $this->mReason, array( 'type' => 'text',
-                                                       'id' => 'mwProtect-reason', 'maxlength' => 255 ) ) .
+                                                       'id' => 'mwProtect-reason', 'maxlength' => 180 ) ) .
+                                                       // Limited maxlength as the database trims at 255 bytes and other texts
+                                                       // chosen by dropdown menus on this page are also included in this database field.
+                                                       // The byte limit of 180 bytes is enforced in javascript
                                        "</td>
                                </tr>";
                        # Disallow watching is user is not logged in
index 2be33d0..df200a8 100644 (file)
@@ -113,6 +113,8 @@ class MovePageForm extends UnlistedSpecialPage {
 
                $wgOut->setPagetitle( wfMsg( 'move-page', $this->oldTitle->getPrefixedText() ) );
                $skin->setRelevantTitle( $this->oldTitle );
+               
+               $wgOut->addModules( 'mediawiki.special.movePage' );
 
                $newTitle = $this->newTitle;
 
@@ -237,7 +239,7 @@ class MovePageForm extends UnlistedSpecialPage {
                                "</td>
                                <td class='mw-input'>" .
                                        Html::element( 'textarea', array( 'name' => 'wpReason', 'id' => 'wpReason', 'cols' => 60, 'rows' => 2,
-                                       'maxlength' => 200 ), $this->reason ) .
+                                       'maxlength' => 200 ), $this->reason ) . // maxlength byte limit is enforce in mediawiki.special.movePage.js
                                "</td>
                        </tr>"
                );
index 876874a..9bf6e40 100644 (file)
@@ -455,6 +455,10 @@ return array(
        'mediawiki.special.block' => array(
                'scripts' => 'resources/mediawiki.special/mediawiki.special.block.js',
        ),
+       'mediawiki.special.movePage' => array(
+               'scripts' => 'resources/mediawiki.special/mediawiki.special.movePage.js',
+               'dependencies' => 'jquery.byteLimit',
+       ),
        'mediawiki.special.upload' => array(
                // @TODO: merge in remainder of mediawiki.legacy.upload
                'scripts' => 'resources/mediawiki.special/mediawiki.special.upload.js',
@@ -586,7 +590,10 @@ return array(
                'scripts' => 'common/protect.js',
                'remoteBasePath' => $GLOBALS['wgStylePath'],
                'localBasePath' => "{$GLOBALS['IP']}/skins",
-               'dependencies' => 'mediawiki.legacy.wikibits',
+               'dependencies' => array(
+                       'mediawiki.legacy.wikibits',
+                       'jquery.byteLimit',
+               ),
        ),
        'mediawiki.legacy.search' => array(
                'scripts' => 'common/search.js',
diff --git a/resources/mediawiki.special/mediawiki.special.movePage.js b/resources/mediawiki.special/mediawiki.special.movePage.js
new file mode 100644 (file)
index 0000000..4ae0dac
--- /dev/null
@@ -0,0 +1,5 @@
+/* JavaScript for Special:MovePage */
+
+jQuery( function( $ ) {
+       $( '#wpReason' ).byteLimit( 200 );
+});
index a284c3f..b77c2e0 100644 (file)
@@ -45,6 +45,8 @@ window.ProtectionForm = {
                        check.checked = !this.areAllTypesMatching();
                        this.enableUnchainedInputs( check.checked );
                }
+               
+               $( '#mwProtect-reason' ).byteLimit( 180 );
 
                this.updateCascadeCheckbox();