[MediaWiki-commits] [Gerrit] Some misc cleanup to ProtectionForm - change (mediawiki/core)

2014-07-19 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Some misc cleanup to ProtectionForm
..


Some misc cleanup to ProtectionForm

- Set variables near to where they are used in buildForm()
  and put variables that only need to be set once out of loops
- Move the definition of 'wgCascadeableLevels' javascript variable
  near the inclusion of mediawiki.legacy.protect module, so that
  this doesn't need to be set as a side effect of buildCleanupScript()

Change-Id: Ifb54723e7609f6fc5a8939e4fada5c2e664a22bd
---
M includes/ProtectionForm.php
1 file changed, 22 insertions(+), 23 deletions(-)

Approvals:
  Bartosz DziewoƄski: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php
index 456e4e6..853e2cc 100644
--- a/includes/ProtectionForm.php
+++ b/includes/ProtectionForm.php
@@ -338,20 +338,12 @@
 * @return string HTML form
 */
function buildForm() {
-   global $wgUser, $wgLang, $wgOut;
-
-   $mProtectreasonother = Xml::label(
-   wfMessage( 'protectcomment' )-text(),
-   'wpProtectReasonSelection'
-   );
-   $mProtectreason = Xml::label(
-   wfMessage( 'protect-otherreason' )-text(),
-   'mwProtect-reason'
-   );
+   global $wgUser, $wgLang, $wgOut, $wgCascadingRestrictionLevels;
 
$out = '';
if ( !$this-disabled ) {
$wgOut-addModules( 'mediawiki.legacy.protect' );
+   $wgOut-addJsConfigVars( 'wgCascadeableLevels', 
$wgCascadingRestrictionLevels );
$out .= Xml::openElement( 'form', array( 'method' = 
'post',
'action' = $this-mTitle-getLocalURL( 
'action=protect' ),
'id' = 'mw-Protect-Form', 'onsubmit' = 
'ProtectionForm.enableUnchainedInputs(true)' ) );
@@ -361,6 +353,9 @@
Xml::element( 'legend', null, wfMessage( 
'protect-legend' )-text() ) .
Xml::openElement( 'table', array( 'id' = 
'mwProtectSet' ) ) .
Xml::openElement( 'tbody' );
+
+   $scExpiryOptions = wfMessage( 'protect-expiry-options' 
)-inContentLanguage()-text();
+   $showProtectOptions = $scExpiryOptions !== '-'  
!$this-disabled;
 
// Not all languages have V_x - N_x relation
foreach ( $this-mRestrictions as $action = $selected ) {
@@ -372,15 +367,6 @@
Xml::element( 'legend', null, $msg-exists() ? 
$msg-text() : $action ) .
Xml::openElement( 'table', array( 'id' = 
mw-protect-table-$action ) ) .
trtd . $this-buildSelector( $action, 
$selected ) . /td/trtrtd;
-
-   $reasonDropDown = Xml::listDropDown( 
'wpProtectReasonSelection',
-   wfMessage( 'protect-dropdown' 
)-inContentLanguage()-text(),
-   wfMessage( 'protect-otherreason-op' 
)-inContentLanguage()-text(),
-   $this-mReasonSelection,
-   'mwProtect-reason', 4 );
-   $scExpiryOptions = wfMessage( 'protect-expiry-options' 
)-inContentLanguage()-text();
-
-   $showProtectOptions = $scExpiryOptions !== '-'  
!$this-disabled;
 
$mProtectexpiry = Xml::label(
wfMessage( 'protectexpiry' )-text(),
@@ -482,6 +468,22 @@
 
# Add manual and custom reason field/selects as well as submit
if ( !$this-disabled ) {
+   $mProtectreasonother = Xml::label(
+   wfMessage( 'protectcomment' )-text(),
+   'wpProtectReasonSelection'
+   );
+
+   $mProtectreason = Xml::label(
+   wfMessage( 'protect-otherreason' )-text(),
+   'mwProtect-reason'
+   );
+
+   $reasonDropDown = Xml::listDropDown( 
'wpProtectReasonSelection',
+   wfMessage( 'protect-dropdown' 
)-inContentLanguage()-text(),
+   wfMessage( 'protect-otherreason-op' 
)-inContentLanguage()-text(),
+   $this-mReasonSelection,
+   'mwProtect-reason', 4 );
+
$out .= Xml::openElement( 'table', array( 'id' = 
'mw-protect-table3' ) ) .
Xml::openElement( 'tbody' );
$out .= 
@@ -606,9 +608,6 @@
}
 
function buildCleanupScript() {
-   global $wgCascadingRestrictionLevels, $wgOut;
-
-  

[MediaWiki-commits] [Gerrit] Some misc cleanup to ProtectionForm - change (mediawiki/core)

2014-07-06 Thread IAlex (Code Review)
IAlex has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/144372

Change subject: Some misc cleanup to ProtectionForm
..

Some misc cleanup to ProtectionForm

- Set variables near to where they are used in buildForm()
  and put variables that only need to be set once out of loops
- Move the definition of 'wgCascadeableLevels' javascript variable
  near the inclusion of mediawiki.legacy.protect module, so that
  this doesn't need to be set as a side effect of buildCleanupScript()

Change-Id: Ifb54723e7609f6fc5a8939e4fada5c2e664a22bd
---
M includes/ProtectionForm.php
1 file changed, 22 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/72/144372/1

diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php
index 456e4e6..853e2cc 100644
--- a/includes/ProtectionForm.php
+++ b/includes/ProtectionForm.php
@@ -338,20 +338,12 @@
 * @return string HTML form
 */
function buildForm() {
-   global $wgUser, $wgLang, $wgOut;
-
-   $mProtectreasonother = Xml::label(
-   wfMessage( 'protectcomment' )-text(),
-   'wpProtectReasonSelection'
-   );
-   $mProtectreason = Xml::label(
-   wfMessage( 'protect-otherreason' )-text(),
-   'mwProtect-reason'
-   );
+   global $wgUser, $wgLang, $wgOut, $wgCascadingRestrictionLevels;
 
$out = '';
if ( !$this-disabled ) {
$wgOut-addModules( 'mediawiki.legacy.protect' );
+   $wgOut-addJsConfigVars( 'wgCascadeableLevels', 
$wgCascadingRestrictionLevels );
$out .= Xml::openElement( 'form', array( 'method' = 
'post',
'action' = $this-mTitle-getLocalURL( 
'action=protect' ),
'id' = 'mw-Protect-Form', 'onsubmit' = 
'ProtectionForm.enableUnchainedInputs(true)' ) );
@@ -361,6 +353,9 @@
Xml::element( 'legend', null, wfMessage( 
'protect-legend' )-text() ) .
Xml::openElement( 'table', array( 'id' = 
'mwProtectSet' ) ) .
Xml::openElement( 'tbody' );
+
+   $scExpiryOptions = wfMessage( 'protect-expiry-options' 
)-inContentLanguage()-text();
+   $showProtectOptions = $scExpiryOptions !== '-'  
!$this-disabled;
 
// Not all languages have V_x - N_x relation
foreach ( $this-mRestrictions as $action = $selected ) {
@@ -372,15 +367,6 @@
Xml::element( 'legend', null, $msg-exists() ? 
$msg-text() : $action ) .
Xml::openElement( 'table', array( 'id' = 
mw-protect-table-$action ) ) .
trtd . $this-buildSelector( $action, 
$selected ) . /td/trtrtd;
-
-   $reasonDropDown = Xml::listDropDown( 
'wpProtectReasonSelection',
-   wfMessage( 'protect-dropdown' 
)-inContentLanguage()-text(),
-   wfMessage( 'protect-otherreason-op' 
)-inContentLanguage()-text(),
-   $this-mReasonSelection,
-   'mwProtect-reason', 4 );
-   $scExpiryOptions = wfMessage( 'protect-expiry-options' 
)-inContentLanguage()-text();
-
-   $showProtectOptions = $scExpiryOptions !== '-'  
!$this-disabled;
 
$mProtectexpiry = Xml::label(
wfMessage( 'protectexpiry' )-text(),
@@ -482,6 +468,22 @@
 
# Add manual and custom reason field/selects as well as submit
if ( !$this-disabled ) {
+   $mProtectreasonother = Xml::label(
+   wfMessage( 'protectcomment' )-text(),
+   'wpProtectReasonSelection'
+   );
+
+   $mProtectreason = Xml::label(
+   wfMessage( 'protect-otherreason' )-text(),
+   'mwProtect-reason'
+   );
+
+   $reasonDropDown = Xml::listDropDown( 
'wpProtectReasonSelection',
+   wfMessage( 'protect-dropdown' 
)-inContentLanguage()-text(),
+   wfMessage( 'protect-otherreason-op' 
)-inContentLanguage()-text(),
+   $this-mReasonSelection,
+   'mwProtect-reason', 4 );
+
$out .= Xml::openElement( 'table', array( 'id' = 
'mw-protect-table3' ) ) .
Xml::openElement( 'tbody' );
$out .= 
@@ -606,9 +608,6 @@
}
 
function buildCleanupScript() {
-   global