Extension:InputBox

From MediaWiki.org
(Redirected from Extension:Inputbox)
Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
InputBox

Release status: stable

Implementation Tag, Page action, Search
Description Allows users to add predefined HTML forms to wiki pages.
Author(s) Erik Möller (EloquenceTalk)
MediaWiki 1.11
License Public domain [1]
Download Download snapshot
Subversion [Help]

Browse source code

check usage (experimental)

The InputBox extension is a MediaWiki extension that adds already created HTML forms to wiki pages. Users can "complete" a form (entering text, selecting menu items, etc.) by entering text into the box.

InputBox was originally created by Erik Möller for the purpose of adding a Create an article box to Wikinews.[1] Extension:InputBox requires at least MediaWiki 1.5.

Contents

[edit] Installation

1. Create the folder InputBox in the extensions folder.

2. Download and save the files

  1. InputBox.php
  2. InputBox.i18n.php
  3. InputBox.classes.php and
  4. InputBox.hooks.php
...to the extensions/InputBox/ folder of your MediaWiki installation.
The most recent version of InputBox.php does not work on older MediaWiki installations.[2]

3. In LocalSettings.php add the following line with the other "require_once" lines:

require_once($IP.'/extensions/InputBox/InputBox.php');

[edit] Example

[edit] Wiki code

<inputbox>
type=search
width=42
buttonlabel=Go
searchbuttonlabel=Search
break=no
</inputbox>

[edit] Result

This kind was found on the main page of a Wikipedia. It could be used for starting new articles, since it doesn’t go to the edit box of articles that already exist.

[edit] General syntax

InputBoxes are constructed like this:

<inputbox>
type=
bgcolor=
width=
default=
preload=
editintro=
buttonlabel=
hidden=
searchbuttonlabel=
break=
namespaces=
prefix=
</inputbox>

The type parameter is mandatory. All other parameters are optional.

[edit] Box types

Type Example Description
type=search
Creates a search box which has a default width of 50 characters. Information added in the text box is searched for.
type=create


Creates a new page. Information added in the text box is the name of the page which is edited.
type=comment


Adds a new section to the bottom of the page specified in the text box.
type=commenttitle


Adds a new section with the section header typed into the text box. The page has to be specified with page= parameter. Added in rev:42703.
type=fulltext
Search only the fulltext search button, without the 'Go' button. Added in rev:45269.

[edit] Parameters

Parameter
Scope
Example
bgcolor=
All types
 
Sets the table background color (HTML color values). Do not use quotes.
<inputbox>
type=search
bgcolor=#eeeeff
</inputbox>
width=
All types
 
Sets the width of the InputBox in characters.
<inputbox>
type=create
width=24
</inputbox>


default=
All types
 
Default text to put in the InputBox.
<inputbox>
type=comment
default=User talk:Eloquence
</inputbox>


preload=
comment, create
 
The page under this title will be preloaded (see Manual:Creating pages with preloaded text) into the blank editbox when a new page is created.
<inputbox>
type=create
preload=Log
</inputbox>


Enter the title of a non-existent page in the example InputBox above or below, and click "Create article" or "Post a comment" respectively to test this effect.
editintro=
comment, create
 
The page which is given under this parameter will be shown, as instructions, above the editing window.
<inputbox>
type=comment
editintro=MediaWiki:Missingcommenttext
</inputbox>


buttonlabel=
All types
 
This label will be used for the main button of the form.
<inputbox>
type=comment
buttonlabel=Add new rumor
</inputbox>


hidden=
create, comment
 
This specifies that there is no inputbox.
It is used with parameter "default", now not being a default, but the fixed value of the name of the page.
<inputbox>
type=comment
editintro=Extension:InputBox/editintro comment
preload=Extension:InputBox/preload
hidden=yes
default=Extension talk:Inputbox
buttonlabel=Post a comment on the talk page
</inputbox>


searchbuttonlabel=
search, fulltext
 
This label will be used for the "Search full text" button of the search form.
<inputbox>
type=search
searchbuttonlabel=Dig deeper
</inputbox>
break=
All types
 
Whether or not to insert a line break between the input box and the button(s). Defaults to yes (use a line break).
<inputbox>
type=create
width=24
break=no
</inputbox>

namespaces=
search, fulltext
 
Support for namespace checkboxes in fulltext search.
With "Namespace**" it is checked by default.
<inputbox>
type=search
namespaces=Main**,Help
</inputbox>
prefix=
search, fulltext
 
Narrow down search to pages beginning with certain prefix. Note this only works with certain search backends, currently only latest Extension:lucene-search.
Defaults to empty string (search all pages).

Remark: underscores aren't recognised as spaces.

<inputbox>
type=search
prefix={{FULLPAGENAME}}/Archive
</inputbox>

Applying create  to an existing page simply gives the edit page. In that case preload is ignored. Applying comment  for a new page works.

The texts taken from the MediaWiki: namespace are of course only examples, any existing page can be used for editintro or preload. Unfortunately preload does not yet work for the Special:Upload summary.

Please note that variables, templates, parser functions and template parameters are not supported in InputBox parameters.

[edit] Alignment enhancement

An editor may find there is a need to define alignment each time they use an input box. One option is to just remove the div tag from the input box HTML and specified the div when posting the InputBox. Instead editors can add the following code which allows editors to change the alignment in the code, by installing an updated copy of the code then you can specify align=left, align=center, or align=right.

[edit] Using InputBox in a template

In order to create many similar input boxes, InputBox can be used in a template. However, passing template parameters to InputBox parameters only works if the <inputbox>...</inputbox> tag is written as {{#tag:inputbox | ...}} inside the template.

The following example is a template to create a new wiki page from a named template:

{{#tag:inputbox |
type=create
buttonlabel=Create new {{{1|article}}}
preload={{{2|Template:Article}}} }}

When instantiating the template, the first parameter gives the item that is created (default: article) as spelled out in the button, the second parameter gives the name of the template used to create the item (default: Template:Article).

E.g., the code for an input box to create a new project from a project template might look like this:

{{Template:CreateNew|project|Template:Project}}

[edit] Known bugs

[edit] Notes

  1. July 2, 2005
  2. Extension:InputBox version 1.17/1.18 doesn't work for MediaWiki 1.6.8, MediaWiki 1.7.1, or Mediawiki 1.9.3 (according to three users, one who upgraded to 1.11, and the extension then worked fine).

    For an older version of Extension:InputBox, see the repository folder at:
    https://svn.wikia-code.com/wikia/branches/Bartek/extensions/inputbox/

[edit] See also

Language: English  • Français • 日本語 • Русский
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Toolbox