r109957 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109956‎ | r109957 | r109958 >
Date:21:34, 24 January 2012
Author:johnduhart
Status:reverted (Comments)
Tags:
Comment:
Add HTMLFormFields for namespaces and restriction levels. This is not a 1.19 feature and should be reverted post-branch.
Modified paths:
  • /trunk/phase3/includes/HTMLForm.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HTMLForm.php
@@ -72,6 +72,8 @@
7373 'submit' => 'HTMLSubmitField',
7474 'hidden' => 'HTMLHiddenField',
7575 'edittools' => 'HTMLEditTools',
 76+ 'namespaces' => 'HTMLNamespacesField',
 77+ 'restrictionlevels' => 'HTMLRestrictionLevelsField',
7678
7779 // HTMLTextField will output the correct type="" attribute automagically.
7880 // There are about four zillion other HTML5 input types, like url, but
@@ -2000,3 +2002,99 @@
20012003 . "</div></td></tr>\n";
20022004 }
20032005 }
 2006+
 2007+/**
 2008+ * Dropdown for namespaces
 2009+ *
 2010+ * @since 1.20
 2011+ */
 2012+class HTMLNamespacesField extends HTMLSelectField {
 2013+
 2014+ /**
 2015+ * Constructor, adds the namespaces to the options
 2016+ *
 2017+ * @param $params
 2018+ */
 2019+ function __construct( $params ) {
 2020+ global $wgContLang;
 2021+ parent::__construct( $params );
 2022+
 2023+ $namespaces = $wgContLang->getFormattedNamespaces();
 2024+
 2025+ $options = array();
 2026+ $options[ wfMessage( 'namespacesall' )->escaped() ] = ''; // TODO: Make an option
 2027+
 2028+ foreach ( $namespaces as $index => $name ) {
 2029+ // Don't include things like SpecialPages
 2030+ if ( $index < NS_MAIN ) {
 2031+ continue;
 2032+ }
 2033+
 2034+ if ( $index === 0 ) {
 2035+ $name = wfMessage( 'blanknamespace' )->escaped();
 2036+ }
 2037+
 2038+ $options[$name] = $index;
 2039+ }
 2040+
 2041+ $this->mParams['options'] = $options;
 2042+ }
 2043+}
 2044+
 2045+/**
 2046+ * Dropdown for protection levels
 2047+ *
 2048+ * @since 1.20
 2049+ */
 2050+class HTMLRestrictionLevelsField extends HTMLSelectField {
 2051+
 2052+ /**
 2053+ * Should this field be displayed? If it hits a condition where it should
 2054+ * be hidden, set this to false.
 2055+ *
 2056+ * @var bool
 2057+ */
 2058+ protected $enabled = true;
 2059+
 2060+ /**
 2061+ * Constructor, adds the restrictions to the options
 2062+ *
 2063+ * @param $params
 2064+ */
 2065+ function __construct( $params ) {
 2066+ global $wgRestrictionLevels;
 2067+ parent::__construct( $params );
 2068+
 2069+ $options = array( wfMsg('restriction-level-all') => 0 ); // Temporary array
 2070+
 2071+ // First pass to load the level names
 2072+ foreach( $wgRestrictionLevels as $type ) {
 2073+ if ( $type != '' && $type != '*' ) {
 2074+ $text = wfMsg("restriction-level-$type");
 2075+ $options[$text] = $type;
 2076+ }
 2077+ }
 2078+
 2079+ // Is there only one level (aside from "all")?
 2080+ if( count($options) <= 2 ) {
 2081+ $this->enabled = false;
 2082+ return;
 2083+ }
 2084+
 2085+ $this->mParams['options'] = $options;
 2086+ }
 2087+
 2088+ /**
 2089+ * Returns nothing if there are no restrictions to show
 2090+ *
 2091+ * @param $value
 2092+ * @return String
 2093+ */
 2094+ function getTableRow( $value ) {
 2095+ if ( $this->enabled ) {
 2096+ return parent::getTableRow( $value );
 2097+ }
 2098+
 2099+ return '';
 2100+ }
 2101+}
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r110195Reverted r109957 per slush (see CR comments)aaron00:16, 28 January 2012

Comments

#Comment by 😂 (talk | contribs)   21:38, 24 January 2012

If it's going to be reverted from the branch anyway, why commit it now during the slush?

#Comment by Johnduhart (talk | contribs)   21:53, 24 January 2012

Because I'm in the middle of rewriting a bunch of things for 1.20 and I'd rather keep this (new) stuff in separate branches to make them easier to commit later.

On second thought that's a pretty poor reason and I should probably learn how to branch new code that needed in other new branches properly. Ideas?

#Comment by MarkAHershberger (talk | contribs)   23:38, 26 January 2012

> On second thought that's a pretty poor reason and I should probably learn how to branch new code that needed in other new > branches properly. Ideas?

Use the git mirror of the code and revert this. Commit the code when we switch to git post-1.19.

Status & tagging log