From 1d20719c7285aeee00411b874dd1a417c1a4d94b Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sat, 23 Aug 2014 22:09:15 -0700 Subject: [PATCH] includes/htmlform/: Use Config instead of globals Change-Id: Ibc798f3ee22dec0a77bab39611d490c09b3cb764 --- includes/htmlform/HTMLCheckMatrix.php | 4 +--- includes/htmlform/HTMLForm.php | 25 +++++++++++-------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/includes/htmlform/HTMLCheckMatrix.php b/includes/htmlform/HTMLCheckMatrix.php index 825552696f..6c538fdd15 100644 --- a/includes/htmlform/HTMLCheckMatrix.php +++ b/includes/htmlform/HTMLCheckMatrix.php @@ -80,8 +80,6 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable { * @return string */ function getInputHTML( $value ) { - global $wgUseMediaWikiUIEverywhere; - $html = ''; $tableContents = ''; $rows = $this->mParams['rows']; @@ -129,7 +127,7 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable { $thisAttribs['disabled'] = 1; } $chkBox = Xml::check( "{$this->mName}[]", $checked, $attribs + $thisAttribs ); - if ( $wgUseMediaWikiUIEverywhere ) { + if ( $this->mParent->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) { $chkBox = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) . $chkBox . Html::element( 'label', array( 'for' => $thisId ) ) . diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 65018908f0..3a455ab1d8 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -300,9 +300,8 @@ class HTMLForm extends ContextSource { * @return string */ public function getDisplayFormat() { - global $wgHTMLFormAllowTableFormat; $format = $this->displayFormat; - if ( !$wgHTMLFormAllowTableFormat && $format === 'table' ) { + if ( !$this->getConfig()->get( 'HTMLFormAllowTableFormat' ) && $format === 'table' ) { $format = 'div'; } return $format; @@ -845,8 +844,6 @@ class HTMLForm extends ContextSource { * @return string HTML. */ function getHiddenFields() { - global $wgArticlePath; - $html = ''; if ( $this->getMethod() == 'post' ) { $html .= Html::hidden( @@ -857,7 +854,8 @@ class HTMLForm extends ContextSource { $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; } - if ( strpos( $wgArticlePath, '?' ) !== false && $this->getMethod() == 'get' ) { + $articlePath = $this->getConfig()->get( 'ArticlePath' ); + if ( strpos( $articlePath, '?' ) !== false && $this->getMethod() == 'get' ) { $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; } @@ -874,8 +872,8 @@ class HTMLForm extends ContextSource { * @return string HTML. */ function getButtons() { - global $wgUseMediaWikiUIEverywhere; $buttons = ''; + $useMediaWikiUIEverywhere = $this->getConfig()->get( 'UseMediaWikiUIEverywhere' ); if ( $this->mShowSubmit ) { $attribs = array(); @@ -894,7 +892,7 @@ class HTMLForm extends ContextSource { $attribs['class'] = array( 'mw-htmlform-submit' ); - if ( $this->isVForm() || $wgUseMediaWikiUIEverywhere ) { + if ( $this->isVForm() || $useMediaWikiUIEverywhere ) { array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-constructive' ); } @@ -937,7 +935,7 @@ class HTMLForm extends ContextSource { $attrs['id'] = $button['id']; } - if ( $wgUseMediaWikiUIEverywhere ) { + if ( $useMediaWikiUIEverywhere ) { if ( isset( $attrs['class' ] ) ) { $attrs['class'] .= ' mw-ui-button'; } else { @@ -1438,20 +1436,19 @@ class HTMLForm extends ContextSource { * @return string */ public function getAction() { - global $wgScript, $wgArticlePath; - // If an action is alredy provided, return it if ( $this->mAction !== false ) { return $this->mAction; } - // Check whether we are in GET mode and $wgArticlePath contains a "?" + $articlePath = $this->getConfig()->get( 'ArticlePath' ); + // Check whether we are in GET mode and the ArticlePath contains a "?" // meaning that getLocalURL() would return something like "index.php?title=...". // As browser remove the query string before submitting GET forms, - // it means that the title would be lost. In such case use $wgScript instead + // it means that the title would be lost. In such case use wfScript() instead // and put title in an hidden field (see getHiddenFields()). - if ( strpos( $wgArticlePath, '?' ) !== false && $this->getMethod() === 'get' ) { - return $wgScript; + if ( strpos( $articlePath, '?' ) !== false && $this->getMethod() === 'get' ) { + return wfScript(); } return $this->getTitle()->getLocalURL(); -- 2.20.1