BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
PF_ParserFunctions.php File Reference

Classes

class  PFParserFunctions
 

Detailed Description

Parser functions for Page Forms.

The following parser functions are defined: #default_form, #forminput, #formlink, #formredlink, #queryformlink, #arraymap, #arraymaptemplate and #autoedit.

'#default_form' is called as: {{#default_form:formName}}

This function sets the specified form to be the default form for pages in that category. It is a substitute for the now-deprecated "Has default form" special property.

'#forminput' is called as:

{{#forminput:form=|size=|default value=|button text=|query string= |autocomplete on category=|autocomplete on namespace= |...additional query string values...}}

This function returns HTML representing a form to let the user enter the name of a page to be added or edited using a Page Forms form. All arguments are optional. 'form' is the name of the PF form to be used; if it is left empty, a dropdown will appear, letting the user chose among all existing forms. 'size' represents the size of the text input (default is 25), and 'default value' is the starting value of the input. 'button text' is the text that will appear on the "submit" button, and 'query string' is the set of values that you want passed in through the query string to the form. (Query string values can also be passed in directly as parameters.) Finally, you can can specify that the user will get autocompletion using the values from a category or namespace of your choice, using 'autocomplete on category' or 'autocomplete on namespace' (you can only use one). To autcomplete on all pages in the main (blank) namespace, specify "autocomplete on namespace=main".

Example: to create an input to add or edit a page with a form called 'User' within a namespace also called 'User', and to have the form preload with the page called 'UserStub', you could call the following:

{{#forminput:form=User|button text=Add or edit user |query string=namespace=User&preload=UserStub}}

'#formlink' is called as:

{{#formlink:form=|link text=|link type=|tooltip=|query string=|target= |popup|...additional query string values...}}

This function returns HTML representing a link to a form; given that no page name is entered by the the user, the form must be one that creates an automatic page name, or else it will display an error message when the user clicks on the link.

The first two arguments are mandatory: 'form' is the name of the PF form, and 'link text' is the text of the link. 'link type' is the type of the link: if set to 'button', the link will be a button; if set to 'post button', the link will be a button that uses the 'POST' method to send other values to the form; if set to anything else or not called, it will be a standard hyperlink. 'tooltip' sets a hovering tooltip text, if it's an actual link. 'query string' is the text to be added to the generated URL's query string (or, in the case of 'post button', to be sent as hidden inputs). 'target' is an optional value, setting the name of the page to be edited by the form.

Example: to create a link to add data with a form called 'User' within a namespace also called 'User', and to have the form preload with the page called 'UserStub', you could call the following:

{{#formlink:form=User|link text=Add a user |query string=namespace=User&preload=UserStub}}

'#formredlink' is called in a very similar way to 'formlink' - the only difference is that it lacks the 'link text', 'link type' and 'tooltip' parameters. Its behavior is quite similar to that of 'formlink' as well; the only difference is that, when the 'target' is an existing page, it creates a link directly to that page, instead of to a form to edit the page.

'#queryformlink' links to Special:RunQuery, instead of Special:FormEdit. It is called in the exact same way as 'formlink', though the 'target' parameter should not be specified, and 'link text' is now optional, since it has a default value of 'Run query' (in whatever language the wiki is in).

'#arraymap' is called as:

{{#arraymap:value|delimiter|var|formula|new_delimiter}}

This function applies the same transformation to every section of a delimited string; each such section, as dictated by the 'delimiter' value, is given the same transformation that the 'var' string is given in 'formula'. Finally, the transformed strings are joined together using the 'new_delimiter' string. Both 'delimiter' and 'new_delimiter' default to commas.

Example: to take a semicolon-delimited list, and place the attribute 'Has color' around each element in the list, you could call the following:

{{#arraymap:blue;red;yellow|;|x|[[Has color::x]]|;}}

'#arraymaptemplate' is called as:

{{#arraymaptemplate:value|template|delimiter|new_delimiter}}

This function makes the same template call for every section of a delimited string; each such section, as dictated by the 'delimiter' value, is passed as a first parameter to the template specified. Finally, the transformed strings are joined together using the 'new_delimiter' string. Both 'delimiter' and 'new_delimiter' default to commas.

Example: to take a semicolon-delimited list, and call a template named 'Beautify' on each element in the list, you could call the following:

{{#arraymaptemplate:blue;red;yellow|Beautify|;|;}}

'#autoedit' is called as:

{{#autoedit:form=|target=|link text=|link type=|tooltip=|query string= |reload}}

This function creates a link or button that, when clicked on, automatically modifies the specified page according to the values in the 'query string' variable.

The parameters of #autoedit are called in the same format as those of #formlink. The one addition, 'reload', will, if added, cause the page to reload after the user clicks the button or link.

Author
Yaron Koren
Sergey Chernyshev
Daniel Friesen
Barry Welch
Christoph Burgmer
Stephan Gambke
MWJames