Inputbox

来自Org
跳转至: 导航搜索

模板:H:h 模板:MoveToMediaWiki The inputbox extension is a MediaWiki extension by Erik Möller to add predefined HTML forms to wiki pages. It was originally created for the purpose of adding a Create an article box to Wikinews. It requires MediaWiki 1.5 and an extensions script (see Installation below).

General syntax

Inputboxes are constructed like this:

 <inputbox>
 type=box type
 parameter1=value
 parameter2=value
 </inputbox>

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

Box types

Type Example
type=search
Generates a search box with a default width of 50 characters. The button labels can be specified, see below; defaults MediaWiki:Tryexact and MediaWiki:Searchfulltext. The text field specifies the search criteria.
type=create

Allows creating a new page. The button label can be specified, see below; default MediaWiki:Createarticle. The text field specifies which page is to be edited.
type=comment

Add one or more sections to an existing page, or create a page, with an edit summary that is automatically the same as the (first) new section header. The button label can be specified, see below; default MediaWiki:Postcomment also used in the sidebar of the "Standard" skin. The text field specifies which page is to be edited.

模板:-

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 below) into the blank editbox when a new page is created.
<inputbox>
type=create
preload=MediaWiki:Editthispage
</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 text of the page under this title will be added, as instructions, before the submission form for new pages.
<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>

searchbuttonlabel=
search
 
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 using the line break unless set to no.
<inputbox>
type=create
width=24
break=no
</inputbox>

Applying create  to an existing page simply gives the edit page. In that case editintro and preload are ignored. Applying comment  for a new page works, if the page already exists editintro is ignored.

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.

Preload

Preloading can be done with an inputbox (see above), but also with a URL like //www.18dao.org/index.php?title=M:abc&action=edit&preload=Template:Preload_demo which links to the edit box of a new page, preloaded with 模板:Tim.

The wikitext of the preloaded page, including noinclude parts, tags and includeonly tags, is loaded into the editbox if the target page does not exist yet. If the target of the preload operation already exists then only its wikitext is loaded, the preload command is ignored.

Define Alignment

I found that there was a need to define alignment each time I use an input box. I could have just removed the div tag from the input box html and specified the div when posting the inputbox. Instead I added a parameter that allows you to define the align in the code.

To use this, get an updated copy of the code here then you can specify

align=left, align=center, or align=right with the other parameters.

I hope you find it useful.

Installation

  1. Download and save the file inputbox.php to the extensions folder of your MediaWiki installation.
  2. Open and edit the LocalSettings.php file by adding the following line near the bottom:
require_once("$IP/extensions/inputbox.php");
NOTE: Make sure that it is still above the closing php tag so that it looks like this:
require_once("$IP/extensions/inputbox.php");
?>
  1. May need to add the following User:Algorithm/actionCreate


Example

type=search width=42 buttonlabel=Go searchbuttonlabel=Search break=no

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.


模板:H:f