|
|
(One intermediate revision by the same user not shown) |
Line 1: |
Line 1: |
− | 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'.
| + | {{#inputbox: |
| + | |type=create |
| + | |buttonlabel= create an article |
| + | }} |
| | | |
− | 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...
| + | == available options == |
| | | |
| + | ;type |
| + | :... |
| | | |
− | <pre>
| + | ;width |
− | --- 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 @@
| + | ;preload |
− | <?php
| + | :... |
− |
| + | |
− | /**
| + | ;editintro |
− | - * 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.
| + | ;default |
− | *
| + | :... |
− | * Usage: require_once("path/to/inputbox.php"); in LocalSettings.php
| + | |
− | @@ -17,11 +17,11 @@
| + | ;titleprefix |
− | */
| + | :... |
− |
| + | |
− | /**
| + | ;bgcolor |
− | - * Register the Inputbox extension with MediaWiki
| + | :... |
− | + * Register the InputboxX extension with MediaWiki
| + | |
− | */
| + | ;buttonlabel |
− | -$wgExtensionFunctions[] = 'efInputBoxSetup';
| + | :... |
− | +$wgExtensionFunctions[] = 'efInputBoxXSetup';
| + | |
− | $wgExtensionCredits['parserhook'][] = array(
| + | ;searchbuttonlabel |
− | - 'name' => 'Inputbox',
| + | :... |
− | + 'name' => 'InputboxX',
| + | |
− | 'author' => array( 'Erik Moeller', 'Leonardo Pimenta', 'Rob Church' ),
| + | ;namespaces |
− | 'url' => 'http://meta.wikimedia.org/wiki/Help:Inputbox',
| + | :... |
− | 'description' => 'Allow inclusion of predefined HTML forms.',
| + | |
− | @@ -30,26 +30,26 @@
| + | ;id |
− | /**
| + | :... |
− | * Extension setup function
| + | |
− | */
| + | ;labeltext |
− | -function efInputBoxSetup() {
| + | :... |
− | +function efInputBoxXSetup() {
| + | |
− | global $wgMessageCache, $wgParser;
| + | ;break |
− | require_once( dirname( __FILE__ ) . '/InputBox.i18n.php' );
| + | :... |
− | - foreach( efInputBoxMessages() as $lang => $messages )
| + | |
− | + foreach( efInputBoxXMessages() as $lang => $messages )
| + | ;hidden |
− | $wgMessageCache->addMessages( $messages, $lang );
| + | :... |
− | - $wgParser->setHook( 'inputbox', 'efInputBoxRender' );
| + | |
− | + $wgParser->setHook( 'inputboxX', 'efInputBoxXRender' );
| + | ;target |
− | }
| + | :... |
− |
| + | |
− | -function efInputBoxRender( $input, $params, $parser ) {
| + | ---- |
− | - $inputbox = new Inputbox( $parser );
| + | |
− | - $inputbox->extractOptions( $parser->replaceVariables( $input ) );
| + | === Options for copy/replace === |
− | - return $inputbox->render();
| + | |
− | +function efInputBoxXRender( $input, $params, $parser ) {
| + | ;from |
− | + $inputboxX = new InputboxX( $parser );
| + | :article name where text shall be replaced ( which shall be copied ) |
− | + $inputboxX->extractOptions( $parser->replaceVariables( $input ) );
| + | |
− | + return $inputboxX->render();
| + | ;to |
− | }
| + | :copy and save modified article under this page name (only if page does not yet exist); if missing: replace text of 'from' article |
− |
| + | |
− | -class Inputbox {
| + | ;changelinks |
− | +class InputboxX {
| + | :... |
− | var $type,$width,$preload,$editintro, $br;
| + | |
− | var $defaulttext,$bgcolor,$buttonlabel,$searchbuttonlabel;
| + | ;forced |
− | var $hidden, $namespaces;
| + | :... |
− |
| + | |
− | - function InputBox( &$parser ) {
| + | ;pattern |
− | + function InputBoxX( &$parser ) {
| + | :... |
− | $this->parser =& $parser;
| + | |
− | }
| + | ;replacement |
− |
| + | :... |
− | @@ -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;
| |
− | }
| |
− | </pre>
| |