MediaWiki:Classengine-template-module-class-documentation-page

This is [[MediaWiki:Tagline]]. Set to <code>display:none</code> by chameleon skin.
Wechseln zu:Navigation, Suche

{{documentation subpage}} {{module rating|protected}}

This is a Class Module. It implements a class in Lua using Module:Middleclass and the template class Module:Foundationclass. This class provides methods for PURPOSE.

Usage

{{code|lang=lua|code= local name = args[1] or args.name or mw.title.getCurrentTitle().rootText local Class = require('Module:$1/class') local me = Class:new(mw.title.getCurrentTitle().prefixedText) me:initFromArgs(args) me:storeData() me:addInfobox() me:addPageBody() return me:render() }}

{{#invoke:$1|explainDataStore}}

Methods

Constructor

new(uid, superhandler)

Creates a new Object for the class.

uid
variable, optional
used to identify the object
superhandler
object of childclass of Foundationclass, optional
supply the superhandler, if you instanciate this object within another object. the instanciated object will pass errors and warnings to the superhandler and forgo adding the object category
return
object, of the class

public methods

addInfobox()

If no errors and data is present, adds an infobox to the object's output. {{small|

return
boolean, whether adding was successful or not

}}

addPageBody()

Adds a page body (all content besides the infobox) to the object's output: Errors and Warnings, sample configuration, statistics, ... Of course, only if there is data. {{small|

return
boolean, whether adding was successful or not

}}

myArgumentProcessing(coreData)

Performs the individual argument processing in right before inititializing it. {{small|

coreData
table, mandatory
the core data of the object. the one to process individually before initialization
return
table, the new core data array to be used

}}

myDataAdjustments(data)

Performs a transformation form data (coming from the datastore) into data used for argument processing. This is called by (for smw: after property to parameter conversion) and is directly passed to and subsequently plausibility test. {{small|

data
table, mandatory
a data table coming directly from the data store
return
table, the new data table suiteable for argument processing

}}

myPlausibilityTest(args)

Performs the individual plausibility tests in before entering the initialization part. NOTE: The return value will be ignored. If this finds errors, it must add them to the list of errors via . {{small|

args
table, mandatory
arguments passed to the template to be checked
return
boolean, whether the object is plausible or not.

}}

myStashAdjustments(stash, storeType)

Performs the adjusts the stash in right before storing it. {{small|

stash
table, mandatory
the array of data to be saved (in the form fieldname: value)
storeType
string, mandatory
type of storage method used with the current call (either 'cargo' or 'swm'). In case you use both stores and your stash adjustment differs with each of this methods
return
boolean, the new stash

}}

static methods

$2:mySfDynamicFieldAttribute(fieldname, attribute, value)

For some semantic form fields there are attribute values, that are not static, thus can not be provided at forehand in the configuration file. This method does the trick to adapt them at runtime shortly before the field is rendered. Essentially: the method checks, if it has a special rule for the pair fieldname:attribute and if so, calculates the new value. if not, the old value is returned. Note, that you can completely disable a form field with this when you return false on attribute "disable". {{small|

fieldname
string, mandatory
the form field's name, needed to match current paring to an existing special treatment rule
attribute
string, mandatory
the form field's attribute, needed to match current paring to an existing special treatment rule
value
variable, mandatory
the value, that is already provided in the configuration file. this will be adapted by the method, if there is a special rule for the pair fieldname:attribute.
return
string, the value to be used forthwith (which can be the old one or a freshly calculated)

}}

private methods

_debug(self, level, text)

Adds output to the internal debug log. {{small|

self
object, me
level
int; mandatory
debug level for the message
text
string; mandatory
debug message text
return
void

}}

Properties

static

See also

$2.myConfiguration
this is your configuration. It is devided in several section, each a
table, holds configuration data found in Module:$1/config
WARNING: This is a read only table and besides functions pairs() and ipairs() nothing else will work on it, especially not the functions of the table library!
    • form, table, holds data used to create the form. here are some of them:
      • formButtons, table, which buttons should be printed at the bottom
      • fieldOrder, table, in which order the form fields should appear (note: only fields listed here will be added to the form)
    • global, table, holds some global configuration data
    • parameter, table, holds all data about all parameter used in the module (be they form only, data store only or normal). The table has the form paramname = { table of paramdata }. The tables for the parameter have data as follows:
      • cardinality, string, mandatory, one of singe or list
      • cargo_type, string, optional, if the parameter is to be stored in cargo, add the field type here (one of Page, Text, Integer, Float, Date, Datetime, Boolean (which should be provided as 1 or 0), Coordinates, Wikitext, File, String, URL, or Email)
      • description, string, mandatory, a description of this parameter
      • label, string, mandatory, the label used in the form and the template documentation
      • property_name, string, optional, if the parameter is to be stored in smw, add the property name here
      • property_type, string, optional, if the parameter is to be stored in smw, add the property type here (defaults to page)
      • severity, string, optional, if provided one of mandatory, suggested
      • sf, table, optional, used to add more attributes to the semantic forms field. ref Module:SFfield/config for all possible attributes. Note that the table is of type attribute_name : value. Value can be of type string, integer, boolean, and (in case of 'show on select') a table. Please note, that the attribute name cannot contain a " " (space). Use the underscore instead.
      • td_default, string, optional, if you want a default value to be indicated in the template data section on the documentation page, add it here
      • td_type, string, optional, if the parameter should be present in the template documentation page, fill this field. all possible values are listed here
      • values, table, optional, if you want the possible values to be restricted to a specific set, fill this table
    • template, table, holds some data used only in the template
$2.publicStaticProperty
type, explanation
_privateStaticProperty
type, explanation

private

Note: all private properties are stored in table _private[self]. _private is a static array that is indexed by self, so the table _private[self] holds all properties for instance self.

dbg
object, my instance of Module:Debug/class for debugging purposes. only present afer first call of

Configuration Data

This class holds its control data in [[Module:{{BASEPAGENAME}}/config]].

Inheritance

Note: You still reference those either by self:publicMethod() or $2:staticMethod() and $2.staticProperty respectively!

Methods

{{MediaWiki:Classengine-content-documentation-methods}}

Static Properties

{{MediaWiki:Classengine-content-documentation-properties}}

<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||

}}</includeonly>