From: Roan Kattouw Date: Mon, 25 Apr 2011 11:39:30 +0000 (+0000) Subject: (bug 16921) Add JavaScript-based enforcing of byte limits on move and protection... X-Git-Tag: 1.31.0-rc.0~30573 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=7611624a1a1b814002ea7b880b74863a5c1060c3;p=lhc%2Fweb%2Fwiklou.git (bug 16921) Add JavaScript-based enforcing of byte limits on move and protection forms. Patch by Jan Paul Posma --- diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 6f04e97274..5f5d7c73cf 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -467,7 +467,10 @@ class ProtectionForm { " . 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 " "; # Disallow watching is user is not logged in diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 2be33d0fdf..df200a891d 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -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 { " " . 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 " " ); diff --git a/resources/Resources.php b/resources/Resources.php index 876874a464..9bf6e40bbe 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -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 index 0000000000..4ae0dac43e --- /dev/null +++ b/resources/mediawiki.special/mediawiki.special.movePage.js @@ -0,0 +1,5 @@ +/* JavaScript for Special:MovePage */ + +jQuery( function( $ ) { + $( '#wpReason' ).byteLimit( 200 ); +}); diff --git a/skins/common/protect.js b/skins/common/protect.js index a284c3f8af..b77c2e067e 100644 --- a/skins/common/protect.js +++ b/skins/common/protect.js @@ -45,6 +45,8 @@ window.ProtectionForm = { check.checked = !this.areAllTypesMatching(); this.enableUnchainedInputs( check.checked ); } + + $( '#mwProtect-reason' ).byteLimit( 180 ); this.updateCascadeCheckbox();