[MediaWiki-commits] [Gerrit] HTMLForm: Move header formatting OOUI-specific code to OOUIH... - change (mediawiki/core)

2015-08-21 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: HTMLForm: Move header formatting OOUI-specific code to 
OOUIHTMLForm
..


HTMLForm: Move header formatting OOUI-specific code to OOUIHTMLForm

* Introduce a getter getHeaderText() and override it in OOUIHTMLForm.
* While we're at it, also introduce getFooterText() (although right
  now we have no need to override this one).
* Use both in HTMLForm where appropriate.

Change-Id: I9a7234ed75b024f24e0a087c9c000bb2024b405f
---
M includes/htmlform/HTMLForm.php
M includes/htmlform/OOUIHTMLForm.php
2 files changed, 44 insertions(+), 9 deletions(-)

Approvals:
  Jforrester: Looks good to me, approved
  Florianschmidtwelzow: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php
index 946fc72..38729a5 100644
--- a/includes/htmlform/HTMLForm.php
+++ b/includes/htmlform/HTMLForm.php
@@ -711,6 +711,21 @@
}
 
/**
+* Get header text.
+*
+* @param string|null $section The section to get the header text for
+* @since 1.26
+* @return string
+*/
+   function getHeaderText( $section = null ) {
+   if ( is_null( $section ) ) {
+   return $this-mHeader;
+   } else {
+   return isset( $this-mSectionHeaders[$section] ) ? 
$this-mSectionHeaders[$section] : '';
+   }
+   }
+
+   /**
 * Add footer text, inside the form.
 *
 * @param string $msg Complete text of message to display
@@ -748,6 +763,21 @@
}
 
return $this;
+   }
+
+   /**
+* Get footer text.
+*
+* @param string|null $section The section to get the footer text for
+* @since 1.26
+* @return string
+*/
+   function getFooterText( $section = null ) {
+   if ( is_null( $section ) ) {
+   return $this-mFooter;
+   } else {
+   return isset( $this-mSectionFooters[$section] ) ? 
$this-mSectionFooters[$section] : '';
+   }
}
 
/**
@@ -871,12 +901,11 @@
 
$html = ''
. $this-getErrors( $submitResult )
-   // In OOUI forms, we handle mHeader elsewhere. FIXME 
This is horrible.
-   . ( $this-getDisplayFormat() === 'ooui' ? '' : 
$this-mHeader )
+   . $this-getHeaderText()
. $this-getBody()
. $this-getHiddenFields()
. $this-getButtons()
-   . $this-mFooter;
+   . $this-getFooterText();
 
$html = $this-wrapForm( $html );
 
@@ -1372,12 +1401,9 @@
 
$legend = $this-getLegend( $key );
 
-   if ( isset( 
$this-mSectionHeaders[$key] ) ) {
-   $section = 
$this-mSectionHeaders[$key] . $section;
-   }
-   if ( isset( 
$this-mSectionFooters[$key] ) ) {
-   $section .= 
$this-mSectionFooters[$key];
-   }
+   $section = $this-getHeaderText( $key ) 
.
+   $section .
+   $this-getFooterText( $key );
 
$attributes = array();
if ( $fieldsetIDPrefix ) {
diff --git a/includes/htmlform/OOUIHTMLForm.php 
b/includes/htmlform/OOUIHTMLForm.php
index fed32d0..37badab 100644
--- a/includes/htmlform/OOUIHTMLForm.php
+++ b/includes/htmlform/OOUIHTMLForm.php
@@ -133,6 +133,15 @@
return '';
}
 
+   function getHeaderText( $section = null ) {
+   if ( is_null( $section ) ) {
+   // We handle $this-mHeader elsewhere, in getBody()
+   return '';
+   } else {
+   return parent::getHeaderText( $section );
+   }
+   }
+
function getBody() {
$fieldset = parent::getBody();
// FIXME This only works for forms with no subsections

-- 
To view, visit https://gerrit.wikimedia.org/r/227605
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9a7234ed75b024f24e0a087c9c000bb2024b405f
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński matma@gmail.com
Gerrit-Reviewer: Bartosz Dziewoński matma@gmail.com
Gerrit-Reviewer: Daniel Friesen dan...@nadir-seen-fire.com

[MediaWiki-commits] [Gerrit] HTMLForm: Move header formatting OOUI-specific code to OOUIH... - change (mediawiki/core)

2015-07-28 Thread Code Review
Bartosz Dziewoński has uploaded a new change for review.

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

Change subject: HTMLForm: Move header formatting OOUI-specific code to 
OOUIHTMLForm
..

HTMLForm: Move header formatting OOUI-specific code to OOUIHTMLForm

* Introduce a getter getHeaderText() and override it in OOUIHTMLForm.
* While we're at it, also introduce getFooterText() (although right
  now we have no need to override this one).
* Use both in HTMLForm where appropriate.

Change-Id: I9a7234ed75b024f24e0a087c9c000bb2024b405f
---
M includes/htmlform/HTMLForm.php
M includes/htmlform/OOUIHTMLForm.php
2 files changed, 49 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/05/227605/1

diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php
index 0678bdd..2be3144 100644
--- a/includes/htmlform/HTMLForm.php
+++ b/includes/htmlform/HTMLForm.php
@@ -713,6 +713,21 @@
}
 
/**
+* Get header text.
+*
+* @param string|null $section The section to get the header text for
+* @since 1.26
+* @return string
+*/
+   function getHeaderText( $section = null ) {
+   if ( is_null( $section ) ) {
+   return $this-mHeader;
+   } else {
+   return isset( $this-mSectionHeaders[$section] ) ? 
$this-mSectionHeaders[$section] : '';
+   }
+   }
+
+   /**
 * Add footer text, inside the form.
 *
 * @param string $msg Complete text of message to display
@@ -750,6 +765,21 @@
}
 
return $this;
+   }
+
+   /**
+* Get footer text.
+*
+* @param string|null $section The section to get the footer text for
+* @since 1.26
+* @return string
+*/
+   function getFooterText( $section = null ) {
+   if ( is_null( $section ) ) {
+   return $this-mFooter;
+   } else {
+   return isset( $this-mSectionFooters[$section] ) ? 
$this-mSectionFooters[$section] : '';
+   }
}
 
/**
@@ -873,12 +903,11 @@
 
$html = ''
. $this-getErrors( $submitResult )
-   // In OOUI forms, we handle mHeader elsewhere. FIXME 
This is horrible.
-   . ( $this-getDisplayFormat() === 'ooui' ? '' : 
$this-mHeader )
+   . $this-getHeaderText()
. $this-getBody()
. $this-getHiddenFields()
. $this-getButtons()
-   . $this-mFooter;
+   . $this-getFooterText();
 
$html = $this-wrapForm( $html );
 
@@ -1374,12 +1403,7 @@
 
$legend = $this-getLegend( $key );
 
-   if ( isset( 
$this-mSectionHeaders[$key] ) ) {
-   $section = 
$this-mSectionHeaders[$key] . $section;
-   }
-   if ( isset( 
$this-mSectionFooters[$key] ) ) {
-   $section .= 
$this-mSectionFooters[$key];
-   }
+   $section = $this-getHeaderText( $key ) 
. $section . $this-getFooterText( $key );
 
$attributes = array();
if ( $fieldsetIDPrefix ) {
diff --git a/includes/htmlform/OOUIHTMLForm.php 
b/includes/htmlform/OOUIHTMLForm.php
index ca8ca0f..3f12f1d 100644
--- a/includes/htmlform/OOUIHTMLForm.php
+++ b/includes/htmlform/OOUIHTMLForm.php
@@ -132,6 +132,22 @@
// TODO Write me!
}
 
+   /**
+* Get header text.
+*
+* @param string|null $section The section to get the header text for
+* @since 1.26
+* @return string
+*/
+   function getHeaderText( $section = null ) {
+   if ( is_null( $section ) ) {
+   // We handle $this-mHeader elsewhere, in getBody()
+   return '';
+   } else {
+   return parent::getHeaderText( $section );
+   }
+   }
+
function getBody() {
$fieldset = parent::getBody();
// FIXME This only works for forms with no subsections

-- 
To view, visit https://gerrit.wikimedia.org/r/227605
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9a7234ed75b024f24e0a087c9c000bb2024b405f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński matma@gmail.com