Extension:TemplateFormEditor

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
TemplateFormEditor

Release status: experimental

Implementation Page action, Extended syntax
Description Allows Editing template-applications using a Form. - an extended version of the extension CustomEdit
Author(s) Andreas Möller
Last version 0.3.0 (2009-05-31)
MediaWiki 1.13.2 and 1.13.3 may be others
License GNU GPL v2.0 or Later
Download [1]
Example Example
Tags
<TypeDefinition>
Hooks used
AlternateEdit

Check usage (experimental)

Language: English  • Deutsch

Contents

[edit] Introduction

(This Page describes version 0.3.0 of this Extension) This Extension is an extended version of "Extension:CustomEdit".

But it needs the Extension:CreateArticle for showing a form at article creation time (since version 0.2.1 this extension is compatible to that extension)

This editor is shown only when articles containing templates are edited, or if you use "Extension:CreateArticle" for creating a new page and the "preload" Parameter of the used "CreateArticle"-Form references a page containing an applicable template.

The only other way using this form editor at page crateion time is to execute the following steps:

  • open the default editor for creating a new article
  • write the template into the article - without parameters
    E.g.: {{name}}
  • click the button "preview".

now the form-editor provided by this extension is shown. This holds only if the "Template:name" has parameters and contains a <typedefinition> tag (see below)

[edit] Functional Specification

In the following description we asume that there is a Template called "name".

[edit] Extended Syntax

  • in the template definition page "Template:name" you can define the types of parameters enclosed in <typedefinition> tags
  • inside these typedefinition tags each line starting with an asterisk "*" is one definition.
    Syntax:
    * NAME : TYPE (PARAMS) "LABEL" // COMMENT
    where
    • NAME is the name of one of the templates parameter (e.g. "date" if a parameter "{{{date}}}" is used or "1" for the parameter {{{1}}} )
    • Type is one of the following defined types:
      • text  :   the form will offer a multiline textbox. Details see below.
      • oneof :   the form offers a dropdown list where one of the given elements can be choosen, so below.
      • someof :   the form offers several checkboxes where any number of elements can be choosen.
      • - :   the form offers a single line textfield like the Extension:CustomEdit does
    • PARAMS :   the expected paramenters for the type - depent on the selected type.
    • LABEL :   the form shows this text on the lefthandside of the input field.
    • COMMENT :   the form shows this text on the righthandside of the input field.

[edit] Page Action

This extension offers an alternative Editor for applications of templates with parameters.

  • Templates can be used as usual e.g. {{name}}
  • If you edit an article the following is done:
    • Default Editor is shown if no template is used in the article.
    • if the page uses a Template e.g. {{name}} the template definition page (e.g. "Template:name") is inspected
      • if the definition page contains a <typedefinition> tag a form for editing the parameters of that template is shown instead of the default editor.
      • if none of the used templates defines its parameters' types the default editor is shown.
      • if the article to be edited contains more than one template containing a <typedefinition> Tag the form contains fields for all parameters of all applicable templates.
  • The form-editor has a button which allows switching to the default editor, preserving the latest changes in the input fields
  • As you would expect, if you edit a section of a page only, only the templates of that section are respected.

[edit] Detailed Type Definition

If an application of a template should be edited using the editor provided by this template, the types of the template's parameters have to be defined on the template's definition page.

The are described on the page Extension:TemplateFormEditor/Types.

[edit] Installation

Extract the zip-file into the extension directory. Add the following line to the file LocalSettings.php:

require_once("$IP/extensions/TemplateFormEdit/TemplateEdit.php");

The zip file contains a folder "TemplateFormEditor" which contains four php-files:

  • clsTypeDefinition.php   - The definition of the template parameter types and the parser for reading the <typedefinition> in the templates' definition pages.
  • TemplateEdit.php   - The entrypoint of the extension
  • TemplateForm.Editor.php   - The template form editor
  • TemplateForm.hooks.php   - This class registers the extension at the wiki it is used in.
  • TemplateForm.i18n.php   - The Translations
  • TemplateForm.Parser.php   - the parser which reads the values to be written into the form
  • TemplateForm.UI.php   - The user interface of the form


[edit] Compatibility

This Extension was tested with MediaWiki Version 1.13.2 and 1.13.3. Please send me an E-Mail if you tested the extension with other versions so that i can report if it works with version 1.11 or 1.14.

The version 0.3.1 was tested with MediaWiki Version 1.15.1: It works but shows a Warning while displaying the form. But the version 0.3.1 has some bugs and I still haven't fixed them. You should still prefere version 0.3.0.

[edit] Compatibility to Mediawiki extensions

  • Extension:CreateArticle
    If the 'preload' parameter is used and references a page containing a template-usage this Template Form Editor is used for creating a new page. (Since version 0.2.1)

[edit] Known Bugs

  • Writes unnamed parameters back to the article in a wrong way: "...|1=...|2=..." instead of using (real) unnamed parameters.
  • Possibly heavy performance problems: not yet tested with da bigger database.
    • Works fine when the whole wiki does not contain more than 3000 pages and not more than 12000 revisions.
    • Works fine if only a view templates are prepared for using the TemplateFormEditor
  • Using Preload-Parameter of Extension:CreateArticle this editor handles the preload in an other way than the default editor.
  • If predefined values of the parameter types "oneof" and "someof" contain "(", ")" or """ it may happen that the Form-Editor crashes and the page using the Template can not be edited anymore!!!

[edit] Wanted features

  • a "Combobox"-type could be usefull: an extended kind of the type "oneof" where you can additionally enter a text which is not a member of the enumeration of available values. (if possible without using javascript or other client-sided scripting).
  • a Parameter type "number": a textfield, where you can only enter the following chartacters 0123456789,.-+

[edit] Versions

The Version history describes the changes between the published versions.

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox