Modul:Classgenerator/class/doc

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

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

local name = args[1] or args.name or mw.title.getCurrentTitle().rootText
local Class = require('Module:Name/class')
local me = Class:new(name)
me:initDataFromArgs(args)
me:storeData()
me:addInfobox()
me:addPageBody()
return me:render()


Methods

Constructor

new(uid)

Creates a new Object for the class.

uid
variable, optional
used to identify the object
return
object, of the class

public methods

addInfobox()

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

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.

return
boolean, whether adding was successful or not

myArgumentProcessing(coreData)

Performs the individual argument processing in initDataFromArgs(args) right before inititializing it.

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

myPlausibilityTest(args)

Performs the individual plausibility tests in initDataFromArgs(args) 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 addError(errortext).

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

myStashAdjustments(self, stash)

Performs the adjusts the stash in storeData() right before storing it.

stash
table, mandatory
the array of data to be saved (in the form fieldname: value)
return
boolean, the new stash

static methods

ClassClassgenerator: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.

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.

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

_namespaceName (self, namespaceId)

Takes the id of a namespace and converts it to the human readable name. Normally returns mw.site.namespaces[id].canonicalName...

self
object, me
namespaceId
int; mandatory
for which namespace id the name should be returned
return
string, name of namespace

_processAttribute(self, attr, indent, name)

Takes an attribute and builds from that (and self:getCoreData()) one entry in the class's config file.

self
object, me
attr
string; mandatory
for which attribute should the entry be build
indent
string; mandatory
indentation of line
name
string; optional
normally the parameter name will be constructed out of attr. if you have special needs as a name, you can supply them via this parameter. name takes precedence, if provided.
return
string, the entry that can directly be added to the config file/string

Properties

static

See also Static Properties

ClassName.myConfiguration
this is your configuration. It is devided in several section, each a
table, holds configuration data found in Module:Name/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
      • 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
className.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 _debug(self, level, text)

Configuration Data

This class holds its control data in Module:Classgenerator/class/config.

Inheritance

Methods

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

Constructor

new(uid, superhandler)

Creates a new Object for the class.

uid
variable, suggested
used to identify the object. defaults to mw.title.getCurrentTitle().prefixedText
superhandler
object of childclass of Foundationclass, optional
supply the superhandler, if you instanciate an object within another object. the instanciated object will pass errors and warnings to the superhandler and forgo adding an object category
return
object, of the class

Static Properties

FoundationClass.globalConfig
table, holds some global configuration (data, that applies to all classes the same way). See Module:Foundationclass/globalconfig for details.
FoundationClass.myCargoUtil
table, instance of Module:CargoUtil
FoundationClass.mySwmUtil
table, instance of Module:SmwUtil
FoundationClass.myTableTools
table, instance of Module:TableTools
FoundationClass.myYesno
table, instance of Module:Yesno

Dependecies

Apart from the obvious (being all pages in Category:Class engine), we also need:

Nice to have:

Please check also Foundationclass's dependencies.

Interface messages

To generate your project's meta categories, Classgenerator makes use of the following interface messages:

You may edit them freely for your convenience to suit your needs.