Inputbox extension

From FollowTheScore
Revision as of 14:40, 14 September 2007 by Dmb (talk | contribs) (I hope this helps...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

I wish someone would rewrite this extension! Specifically I wish they would rewrite it and merge all the existing rewrites back into the trunk! Its so messy! At least 3 versions 'in the wild'.

Here is my diff from a recent co of the original - I made these diffs to fix a rendering problem that Input box forces on you...


--- inputbox/inputbox.php       2007-09-09 12:29:26.000000000 +0200
+++ inputboxX/inputbox.php      2007-09-09 18:43:19.000000000 +0200
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * This file contains the main include file for the Inputbox extension of 
+ * This file contains the main include file for the InputboxX extension of 
  * MediaWiki. 
  *
  * Usage: require_once("path/to/inputbox.php"); in LocalSettings.php
@@ -17,11 +17,11 @@
  */
 
 /**
- * Register the Inputbox extension with MediaWiki
+ * Register the InputboxX extension with MediaWiki
  */ 
-$wgExtensionFunctions[] = 'efInputBoxSetup';
+$wgExtensionFunctions[] = 'efInputBoxXSetup';
 $wgExtensionCredits['parserhook'][] = array(
-       'name' => 'Inputbox',
+       'name' => 'InputboxX',
        'author' => array( 'Erik Moeller', 'Leonardo Pimenta', 'Rob Church' ),
        'url' => 'http://meta.wikimedia.org/wiki/Help:Inputbox',
        'description' => 'Allow inclusion of predefined HTML forms.',
@@ -30,26 +30,26 @@
 /**
  * Extension setup function
  */
-function efInputBoxSetup() {
+function efInputBoxXSetup() {
        global $wgMessageCache, $wgParser;
        require_once( dirname( __FILE__ ) . '/InputBox.i18n.php' );
-       foreach( efInputBoxMessages() as $lang => $messages )
+       foreach( efInputBoxXMessages() as $lang => $messages )
                $wgMessageCache->addMessages( $messages, $lang );
-       $wgParser->setHook( 'inputbox', 'efInputBoxRender' );
+       $wgParser->setHook( 'inputboxX', 'efInputBoxXRender' );
 }
 
-function efInputBoxRender( $input, $params, $parser ) {
-       $inputbox = new Inputbox( $parser );
-       $inputbox->extractOptions( $parser->replaceVariables( $input ) );
-       return $inputbox->render();
+function efInputBoxXRender( $input, $params, $parser ) {
+       $inputboxX = new InputboxX( $parser );
+       $inputboxX->extractOptions( $parser->replaceVariables( $input ) );
+       return $inputboxX->render();
 }
 
-class Inputbox {
+class InputboxX {
        var $type,$width,$preload,$editintro, $br;
        var $defaulttext,$bgcolor,$buttonlabel,$searchbuttonlabel;
        var $hidden, $namespaces;
 
-       function InputBox( &$parser ) {
+       function InputBoxX( &$parser ) {
                $this->parser =& $parser;
        }
 
@@ -84,12 +84,7 @@
 
                $type = $this->hidden ? 'hidden' : 'text';
                $searchform=<<<ENDFORM
-               <table border="0" width="100%" cellspacing="0" cellpadding="0">
-               <tr>
-               <td align="center" bgcolor="{$this->bgcolor}">
-               <form name="searchbox" action="{$search}" class="searchbox">
-               <input class="searchboxInput" name="search" type="{$type}"
-               value="{$this->defaulttext}" size="{$this->width}" />{$this->br}
+<div style="display:inline"><form style="display:inline" name="searchbox" action="{$search}" class="searchbox"><input class="searchboxInput" name="search" type="{$
type}" value="{$this->defaulttext}" size="{$this->width}" />{$this->br}
 ENDFORM;
 
                // disabled when namespace filter active
@@ -128,12 +123,7 @@
                        $gobutton='';
                } 
                $searchform3=<<<ENDFORM2
-               {$gobutton}
-               <input type='submit' name="fulltext" class="searchboxSearchButton" value="{$this->searchbuttonlabel}" />
-               </form>
-               </td>
-               </tr>
-               </table>
+{$gobutton}<input type='submit' name="fulltext" class="searchboxSearchButton" value="{$this->searchbuttonlabel}" /></form></div>
 ENDFORM2;
                //Return form values
                return $searchform . $searchform2 . $searchform3;
@@ -169,7 +159,7 @@
        function getCreateForm() {
                global $wgScript;
 
-               $action = htmlspecialchars( $wgScript );
+               $action = htmlspecialchars( $wgScript );
                if($this->type=="comment") {
                        $comment='<input type="hidden" name="section" value="new" />';
                        if(!$this->buttonlabel) {
@@ -183,22 +173,7 @@
                }
                $type = $this->hidden ? 'hidden' : 'text';
                $createform=<<<ENDFORM
-<table border="0" width="100%" cellspacing="0" cellpadding="0">
-<tr>
-<td align="center" bgcolor="{$this->bgcolor}">
-<form name="createbox" action="$action" method="get" class="createbox">
-       <input type='hidden' name="action" value="edit" />
-       <input type="hidden" name="preload" value="{$this->preload}" />
-       <input type="hidden" name="editintro" value="{$this->editintro}" />
-       {$comment}
-       <input class="createboxInput" name="title" type="{$type}"
-       value="{$this->defaulttext}" size="{$this->width}" />{$this->br}
-       <input type='submit' name="create" class="createboxButton"
-       value="{$this->buttonlabel}" />
-</form>
-</td>
-</tr>
-</table>
+<div style="display:inline"><form style="display:inline" name="createbox" action="$action" method="get" class="createbox"><input type='hidden' name="action" value=
"edit" /><input type="hidden" name="preload" value="{$this->preload}" /><input type="hidden" name="editintro" value="{$this->editintro}" />{$comment}<input class="c
reateboxInput" name="title" type="{$type}" value="{$this->defaulttext}" size="{$this->width}" />{$this->br}<input type='submit' name="create" class="createboxButton
" value="{$this->buttonlabel}" /></form></div>
 ENDFORM;
                return $createform;
        }