Add a PHP implementation of TitleInputWidget
authorRoan Kattouw <roan.kattouw@gmail.com>
Mon, 25 May 2015 09:54:29 +0000 (11:54 +0200)
committerJforrester <jforrester@wikimedia.org>
Tue, 30 Jun 2015 00:03:27 +0000 (00:03 +0000)
From the PHP side it's really just an infusable TextInputWidget.

Change-Id: I607339c2e967e502f85164c9b1ea79dc0a17c9cc

autoload.php
includes/widget/AUTHORS.txt [new file with mode: 0644]
includes/widget/LICENSE.txt [new file with mode: 0644]
includes/widget/TitleInputWidget.php [new file with mode: 0644]

index dcd8727..284da46 100644 (file)
@@ -754,6 +754,7 @@ $wgAutoloadLocalClasses = array(
        'MediaWiki\\Logger\\Monolog\\WikiProcessor' => __DIR__ . '/includes/debug/logger/monolog/WikiProcessor.php',
        'MediaWiki\\Logger\\NullSpi' => __DIR__ . '/includes/debug/logger/NullSpi.php',
        'MediaWiki\\Logger\\Spi' => __DIR__ . '/includes/debug/logger/Spi.php',
+       'MediaWiki\\Widget\\TitleInputWidget' => __DIR__ . '/includes/widget/TitleInputWidget.php',
        'MemCachedClientforWiki' => __DIR__ . '/includes/objectcache/MemcachedClient.php',
        'MemcLockManager' => __DIR__ . '/includes/filebackend/lockmanager/MemcLockManager.php',
        'MemcachedBagOStuff' => __DIR__ . '/includes/objectcache/MemcachedBagOStuff.php',
diff --git a/includes/widget/AUTHORS.txt b/includes/widget/AUTHORS.txt
new file mode 100644 (file)
index 0000000..10064b2
--- /dev/null
@@ -0,0 +1,10 @@
+Authors (alphabetically)
+
+Alex Monk <krenair@wikimedia.org>
+Bartosz Dziewoński <bdziewonski@wikimedia.org>
+Ed Sanders <esanders@wikimedia.org>
+James D. Forrester <jforrester@wikimedia.org>
+Roan Kattouw <roan@wikimedia.org>
+Sucheta Ghoshal <sghoshal@wikimedia.org>
+Timo Tijhof <timo@wikimedia.org>
+Trevor Parscal <trevor@wikimedia.org>
diff --git a/includes/widget/LICENSE.txt b/includes/widget/LICENSE.txt
new file mode 100644 (file)
index 0000000..b03ca80
--- /dev/null
@@ -0,0 +1,25 @@
+Copyright (c) 2011-2015 MediaWiki Widgets Team and others under the
+terms of The MIT License (MIT), as follows:
+
+This software consists of voluntary contributions made by many
+individuals (AUTHORS.txt) For exact contribution history, see the
+revision history and logs, available at https://gerrit.wikimedia.org
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/includes/widget/TitleInputWidget.php b/includes/widget/TitleInputWidget.php
new file mode 100644 (file)
index 0000000..173dbb0
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+/**
+ * MediaWiki Widgets – TitleInputWidget class.
+ *
+ * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+namespace MediaWiki\Widget;
+
+use OOUI\TextInputWidget;
+
+/**
+ * Title input widget.
+ */
+class TitleInputWidget extends TextInputWidget {
+
+       protected $namespace = null;
+
+       /**
+        * @param array $config Configuration options
+        * @param number|null $config['namespace'] Namespace to prepend to queries
+        */
+       public function __construct( array $config = array() ) {
+               // Parent constructor
+               parent::__construct( array_merge( $config, array( 'infusable' => true ) ) );
+
+               // Properties
+               if ( isset( $config['namespace'] ) ) {
+                       // Actually ignored in PHP, we just ship it back to JS
+                       $this->namespace = $config['namespace'];
+               }
+
+               // Initialization
+               $this->addClasses( array( 'mw-widget-TitleInputWidget' ) );
+       }
+
+       public function getConfig( &$config ) {
+               if ( $this->namespace !== null ) {
+                       $config['namespace'] = $this->namespace;
+               }
+               return parent::getConfig( $config );
+       }
+}