<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://www.verzauberte-welten.de/index.php?action=history&amp;feed=atom&amp;title=Modul%3AFoundationclass%2Fdoc</id>
	<title>Modul:Foundationclass/doc - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://www.verzauberte-welten.de/index.php?action=history&amp;feed=atom&amp;title=Modul%3AFoundationclass%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://www.verzauberte-welten.de/index.php?title=Modul:Foundationclass/doc&amp;action=history"/>
	<updated>2026-04-06T00:52:36Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Verzauberte Welten e.V.</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://www.verzauberte-welten.de/index.php?title=Modul:Foundationclass/doc&amp;diff=4421&amp;oldid=prev</id>
		<title>imported&gt;Oetterer: /* Dependencies */</title>
		<link rel="alternate" type="text/html" href="https://www.verzauberte-welten.de/index.php?title=Modul:Foundationclass/doc&amp;diff=4421&amp;oldid=prev"/>
		<updated>2016-01-15T19:26:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Dependencies&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{documentation subpage}}&lt;br /&gt;
{{module rating|protected}}&lt;br /&gt;
&amp;lt;!-- Categories go at the bottom of this page and interwikis go in Wikidata. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a Template for Class Modules. It implements a class in Lua using [[Module:Middleclass]] and provides serveral static and public methods, commonly used in the typical form&amp;gt;page&amp;gt;store process.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
This is in a way an abstract class. It provides some static and public methods for resuse, and also maintains a store of private properties. If can be used to fast and easily create a typical class module that can handle:&lt;br /&gt;
* creating an appropriate form&lt;br /&gt;
* supplying your respective template with functionalities for&lt;br /&gt;
** object initialization via template parameters, arguments, and datastore (self initialization)&lt;br /&gt;
** general data assesment (basic plausibility tests)&lt;br /&gt;
** data storage (supported are ''cargo'' and ''semantic media wiki'')&lt;br /&gt;
** error and warnings management&lt;br /&gt;
** output and rendering&lt;br /&gt;
* creating a template documentation&lt;br /&gt;
&lt;br /&gt;
You can and should adjust the module in this methods:&lt;br /&gt;
* individual attribute adjustment for the semantic forms fields&lt;br /&gt;
* individual plausibility testing&lt;br /&gt;
* individual data initialization&lt;br /&gt;
* individual data store adjustments before stashing&lt;br /&gt;
&lt;br /&gt;
You can access the objects core data store with [[#getCoreData()|getCoreData()]] and its uid with [[#getUid()|getUid()]].&lt;br /&gt;
&lt;br /&gt;
=== How-To ===&lt;br /&gt;
This is, what you have to do (see [[#Useful templates|Useful templates]] for content of the corresponding pages):&lt;br /&gt;
# create your base module ''Module:Name''&lt;br /&gt;
# create your class module ''Module:Name/class''. For this, copy lua sample code below this list and apply the following changes:&lt;br /&gt;
## change all occurences of ''className'' into your class name&lt;br /&gt;
## change the highlighted lines and replace 'Name' with the Name of your module&lt;br /&gt;
## implement the abstract methods:&lt;br /&gt;
### myAgumentProcessing(coreData)&lt;br /&gt;
### myDataAdjustments(data)&lt;br /&gt;
### myPlausibilityTest(args)&lt;br /&gt;
### myStashAdjustments(stash)&lt;br /&gt;
### static:mySfDynamicFieldAttribute(fieldname, attribute, value)&lt;br /&gt;
## for the usual output generation, implement (shells given in sample code)&lt;br /&gt;
### addInfobox()&lt;br /&gt;
### addPageBody()&lt;br /&gt;
# create and fill your configuration ''Module:Name/config''&lt;br /&gt;
# create your template ''Template:Name''&lt;br /&gt;
# create your form ''Form:Name''&lt;br /&gt;
# if applicable, create your category page ''Category:Name''&lt;br /&gt;
# fill in documentation:&lt;br /&gt;
## of your base module (place one invoke below the first comment and before the includeonly)&lt;br /&gt;
## of your class module (new docu for your own public, static and private methods (which you can probably copy from other classes) and one invoke to show the inheritance. Sample code provided in [[#Useful templates|Useful templates]]&lt;br /&gt;
## of your class module's configuration (just copy content)&lt;br /&gt;
## of your template (one invoke below the first comment and before the includeonly)&lt;br /&gt;
&lt;br /&gt;
=== Useful templates ===&lt;br /&gt;
{{Collapse top|title=base module:}}&lt;br /&gt;
{{code|lang=lua|line=1|code=&lt;br /&gt;
{{#invoke:Foundationclass/classDoc|base}}&lt;br /&gt;
}}&lt;br /&gt;
{{Collapse bottom}}&lt;br /&gt;
{{Collapse top|title=base module's documentation page:}}&lt;br /&gt;
{{pre2|1=&lt;br /&gt;
{{#invoke:Foundationclass/classDoc|baseDoc}}&lt;br /&gt;
}}&lt;br /&gt;
{{Collapse bottom}}&lt;br /&gt;
{{Collapse top|title=class module:}}&lt;br /&gt;
{{code|lang=lua|line=1|start=1|highlight=7,9|code=&lt;br /&gt;
{{#invoke:Foundationclass/classDoc|class}}&lt;br /&gt;
}}&lt;br /&gt;
{{Collapse bottom}}&lt;br /&gt;
{{Collapse top|title=class module's documentation page:}}&lt;br /&gt;
{{pre2|1=&lt;br /&gt;
{{#invoke:Foundationclass/classDoc|classDoc}}&lt;br /&gt;
}}&lt;br /&gt;
{{Collapse bottom}}&lt;br /&gt;
{{Collapse top|title=class configuration (sample file):}}&lt;br /&gt;
{{code|lang=lua|code=&lt;br /&gt;
{{Module:Foundationclass/config}}&lt;br /&gt;
}}&lt;br /&gt;
{{Collapse bottom}}&lt;br /&gt;
{{Collapse top|title=configuration documentation page:}}&lt;br /&gt;
{{pre2|1=&lt;br /&gt;
{{#invoke:Foundationclass/classDoc|configDoc}}&lt;br /&gt;
}}&lt;br /&gt;
{{Collapse bottom}}&lt;br /&gt;
{{Collapse top|title=template:}}&lt;br /&gt;
{{pre2|1=&lt;br /&gt;
{{#invoke:Foundationclass/classDoc|template}}&lt;br /&gt;
}}&lt;br /&gt;
{{Collapse bottom}}&lt;br /&gt;
{{Collapse top|title=template documentation page:}}&lt;br /&gt;
{{pre2|1=&lt;br /&gt;
{{#invoke:Foundationclass/classDoc|templateDoc}}&lt;br /&gt;
}}&lt;br /&gt;
{{Collapse bottom}}&lt;br /&gt;
{{Collapse top|title=form:}}&lt;br /&gt;
{{ombox|type=content|text='''Note:''' If you have a display error on your form in a way that your fieldset and your label (the blue box) does not include your form but instead is displayed above it, add a line break before and after the #invoke-statement, having it stand alone in line.}}&lt;br /&gt;
{{pre2|1=&lt;br /&gt;
{{#invoke:Foundationclass/classDoc|form}}&lt;br /&gt;
}}&lt;br /&gt;
{{Collapse bottom}}&lt;br /&gt;
{{Collapse top|title=category:}}&lt;br /&gt;
{{pre2|1=&lt;br /&gt;
{{#invoke:Foundationclass/classDoc|category}}&lt;br /&gt;
}}&lt;br /&gt;
{{Collapse bottom}}&lt;br /&gt;
{{Collapse top|title=gardening category:}}&lt;br /&gt;
{{pre2|1=&lt;br /&gt;
{{#invoke:Foundationclass/classDoc|gardeningCategory}}&lt;br /&gt;
}}&lt;br /&gt;
{{Collapse bottom}}&lt;br /&gt;
&lt;br /&gt;
=== private, public, class or instance ===&lt;br /&gt;
{|&lt;br /&gt;
|+ Zugriffsmatrix&lt;br /&gt;
|-&lt;br /&gt;
! -&lt;br /&gt;
! public&lt;br /&gt;
! private&lt;br /&gt;
|-&lt;br /&gt;
! instance&lt;br /&gt;
| &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function MyClass:publicMethod()&lt;br /&gt;
MyClass.publicProperty&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local _privateMethod = function (self, var)&lt;br /&gt;
_private[self]._privateProperty&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! class&lt;br /&gt;
| &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function MyClass.static:staticMethod()&lt;br /&gt;
MyClass.static.staticProperty&lt;br /&gt;
-- accessing&lt;br /&gt;
MyClass.staticProperty&lt;br /&gt;
-- being &amp;quot;outside&amp;quot;:&lt;br /&gt;
MyClass:staticMethod()&lt;br /&gt;
-- being inside a static method&lt;br /&gt;
self:staticMethod()&lt;br /&gt;
-- being inside a public method&lt;br /&gt;
self.class:staticMethod()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local _privateMethod = function (self, var)&lt;br /&gt;
local _privateProperty&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== private ====&lt;br /&gt;
===== property =====&lt;br /&gt;
you can declare a property private in one of two ways:&lt;br /&gt;
# anywhere, preferably before your constructor, declare a &amp;lt;code&amp;gt;local var&amp;lt;/code&amp;gt; to have a private propery, this is not recommended, but it allows you to declare a private property, that can be used by your static methods. thus being somewhat private static&lt;br /&gt;
# for your instances, you can use the table _private[self] as a private store. it is available after your construrctor has been called (since this is an instance attribute)&lt;br /&gt;
&lt;br /&gt;
===== method =====&lt;br /&gt;
a private method is declared thus: {{code snippet|lang=lua|code=local _privateMethod = function(self, var)}}. If you want to use the method in an public/static/other private method before it is declared (aka: the calling method is on a lower line number than your private method's declaration), decare it ahead and define it later:&lt;br /&gt;
{{code|lang=lua|code=&lt;br /&gt;
local _privateImportantMethod&lt;br /&gt;
..&lt;br /&gt;
privateImportantMethod = function(self, var)&lt;br /&gt;
}}&lt;br /&gt;
private class and instance methods are basically the same.&lt;br /&gt;
&lt;br /&gt;
==== public ====&lt;br /&gt;
===== property =====&lt;br /&gt;
can be dclared via class.property. DONT DO THIS. It is bad style!&lt;br /&gt;
===== method =====&lt;br /&gt;
Declare them class:publicMethod(var). They are, after all, public&lt;br /&gt;
&lt;br /&gt;
NOTE: public methods can be called by an instance, but also as static method:&lt;br /&gt;
{{code|lang=lua|code=&lt;br /&gt;
function Class:public()&lt;br /&gt;
	return 'public: ' .. tostring(self)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local me = Class:new()&lt;br /&gt;
me.public()	-- returns &amp;quot;public: Instance of class Class&amp;quot;&lt;br /&gt;
Class:public()	-- returns &amp;quot;public: class Class&amp;quot;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== static ====&lt;br /&gt;
===== property =====&lt;br /&gt;
Declare a static property like this: &amp;lt;code&amp;gt;class.static.myProperty = 'Hello World'&amp;lt;/code&amp;gt;. This produces a public property, that can be accessed by the class, childclasses or instances via *.myProperty (replace * with class, object, childclass, ...)&lt;br /&gt;
&lt;br /&gt;
===== method =====&lt;br /&gt;
Much the same as static properties, but you should use the colon operator: {{code snippet|lang=lua|code=function Class.static:staticMethod()}} when definig the method. On accessig this method, you should use the dot-notation: {{code snippet|lang=lua|code=function Class.staticMethod(self)}}&lt;br /&gt;
&lt;br /&gt;
NOTE: Other than public methods, they can only be called by the class, but not by an instance:&lt;br /&gt;
{{code|lang=lua|code=&lt;br /&gt;
function Class.static:static()&lt;br /&gt;
	return 'static: ' .. tostring(self)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local me = Class:new()&lt;br /&gt;
me.static()	-- returns &amp;quot;error:  attempt to call method 'static' (a nil value)&amp;quot;&lt;br /&gt;
Class:static()	-- returns &amp;quot;static: class Class&amp;quot;&lt;br /&gt;
Class.static(self)	-- this is not called via colon (:) operator as to preserve the childClass's scope when inheriting from this class&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
{{MediaWiki:Classengine-content-documentation-methods}}&lt;br /&gt;
&lt;br /&gt;
=== private methods ===&lt;br /&gt;
These private Methods can not be used by child classes!&lt;br /&gt;
&lt;br /&gt;
==== _amIPlausible(self) ====&lt;br /&gt;
Returs true or false, whether the object is plausible or not (i.e. has no errors or 1+)&lt;br /&gt;
{{small|&lt;br /&gt;
;self&lt;br /&gt;
:object, me&lt;br /&gt;
;return&lt;br /&gt;
:boolean, whether the object is plausible or not &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== _debug(self, level, text) ====&lt;br /&gt;
Adds output to the internal debug log.&lt;br /&gt;
{{small|&lt;br /&gt;
;self&lt;br /&gt;
:object, me&lt;br /&gt;
;level&lt;br /&gt;
:int; mandatory&lt;br /&gt;
:debug level for the message&lt;br /&gt;
;text&lt;br /&gt;
:string; mandatory&lt;br /&gt;
:debug message text&lt;br /&gt;
;return&lt;br /&gt;
:void&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== _plausibilityTest(self, args) ====&lt;br /&gt;
Checks, if input provided via template is plausible enough, to represent the object (to be stored and displayed). Also fills the [[#private|list of errors]] and does some argument preparation.&lt;br /&gt;
{{small|&lt;br /&gt;
;self&lt;br /&gt;
:object, me&lt;br /&gt;
;args&lt;br /&gt;
:table, mandatory&lt;br /&gt;
:arguments passed to the template to be checked&lt;br /&gt;
;return&lt;br /&gt;
:boolean, whether the object is plausible or not &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
=== static ===&lt;br /&gt;
{{MediaWiki:Classengine-content-documentation-properties}}&lt;br /&gt;
=== private ===&lt;br /&gt;
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''.&lt;br /&gt;
;categories&lt;br /&gt;
:table, holds the objects categories&lt;br /&gt;
;coreData&lt;br /&gt;
:table, holds the objects data ofter initializing&lt;br /&gt;
;dbg&lt;br /&gt;
:object, my instance of [[Module:Debug/class]] for debugging purposes&lt;br /&gt;
;errors&lt;br /&gt;
:table, a list of errors that occurred&lt;br /&gt;
;fullpagename&lt;br /&gt;
:string, name of currentpage including namespace&lt;br /&gt;
;initialized&lt;br /&gt;
:boolean, is this object properly initialized&lt;br /&gt;
;loadedDataFromDataStore &lt;br /&gt;
:boolean, did this object get its data from the data store&lt;br /&gt;
;output&lt;br /&gt;
:object of type mw.html, holds all output to be rendered()&lt;br /&gt;
;pagename&lt;br /&gt;
:string, name of current page (or current page's super page) w/o namespace&lt;br /&gt;
;uid&lt;br /&gt;
:string, uinique identifier ('NIL' if unset)&lt;br /&gt;
;warnings&lt;br /&gt;
:table, a list of warnings that came up&lt;br /&gt;
&lt;br /&gt;
== Configuration Data ==&lt;br /&gt;
This class holds gets its control data from the child class. Also, there is some global configuration data in [[Module:Foundationclass/globalconfig]], that applies to all classes.&lt;br /&gt;
&lt;br /&gt;
== Dependencies ==&lt;br /&gt;
If you want to use [[Module:Foundationclass]], you also need the following items (and their doc pages!):&lt;br /&gt;
* [[Module:Middleclass]]&lt;br /&gt;
* [[Module:Foundationclass/config]]&lt;br /&gt;
* [[Module:Foundationclass/classDoc]]&lt;br /&gt;
* [[Module:Foundationclass/globalconfig]]&lt;br /&gt;
* [[Module:CargoUtil]] and [https://www.mediawiki.org/wiki/Extension:Cargo Extension:Cargo] if you want to use it as a data store&lt;br /&gt;
* [[Module:SmwUtil]] and [https://www.mediawiki.org/wiki/Extension:Semantic_MediaWiki Extension:Semantic MediaWiki] if you want to use it as a data store&lt;br /&gt;
also&lt;br /&gt;
* [[Module:Arguments]]&lt;br /&gt;
* [[Module:Collapse]]&lt;br /&gt;
* [[Module:Debug/class]]&lt;br /&gt;
* [[Module:Error]]&lt;br /&gt;
* [[Module:Infobox]]&lt;br /&gt;
* [[Module:Lua banner]]&lt;br /&gt;
* [[Module:Message box]]&lt;br /&gt;
* [[Module:SFfield]]&lt;br /&gt;
* [[Module:SFfield]]&lt;br /&gt;
* [[Module:TableTools]]&lt;br /&gt;
* [[Module:Yesno]]&lt;br /&gt;
* {{tl|code}}&lt;br /&gt;
* [https://www.mediawiki.org/wiki/Extension:TemplateData Extension:TemplateData]&lt;br /&gt;
and of course [https://www.mediawiki.org/wiki/Extension:Semantic_Forms Extension:Semantic Forms]&lt;br /&gt;
&lt;br /&gt;
Also, have a look at the extended functionality of the [[:Category:Class engine|Class engine]].&lt;br /&gt;
&lt;br /&gt;
=== Interface messages ===&lt;br /&gt;
To generate the [[#Useful_templates|Useful_templates]], Foundationclass makes use of the following interface messages:&lt;br /&gt;
* [[MediaWiki:Classengine-content-documentation-methods]]&lt;br /&gt;
* [[MediaWiki:Classengine-content-documentation-properties]]&lt;br /&gt;
* [[MediaWiki:Classengine-template-module-page]]&lt;br /&gt;
* [[MediaWiki:Classengine-template-module-documentation-page]]&lt;br /&gt;
* [[MediaWiki:Classengine-template-module-class-page]]&lt;br /&gt;
* [[MediaWiki:Classengine-template-module-class-documentation-page]]&lt;br /&gt;
* [[MediaWiki:Classengine-template-module-config-documentation-page]]&lt;br /&gt;
* [[MediaWiki:Classengine-template-template-page]]&lt;br /&gt;
* [[MediaWiki:Classengine-template-template-documentation-page]]&lt;br /&gt;
* [[MediaWiki:Classengine-template-form-page]]&lt;br /&gt;
* [[MediaWiki:Classengine-template-category-page]]&lt;br /&gt;
* [[MediaWiki:Classengine-template-gardeningcategory-page]]&lt;br /&gt;
* [[MediaWiki:Classengine-template-property-page]]&lt;br /&gt;
&lt;br /&gt;
== Next in dev queue ==&lt;br /&gt;
# have foundation class try to detect integer inputs (by td_type or cargo_type) and run a regexp in _plausibilityTest&lt;br /&gt;
# have foundationclass use mw message system for printouts instead of hardcoded text&lt;br /&gt;
# a template or page, that #autogenerates all categories, defined in [[Module:Foundationclass/globalconfig]]&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Foundationclass/classDoc|categorize}}&amp;lt;includeonly&amp;gt;{{#ifeq:{{SUBPAGENAME}}|sandbox||&lt;br /&gt;
&amp;lt;!-- Note: The class engine sets this category automatically in function methods: Lua class modules --&amp;gt;&lt;br /&gt;
&amp;lt;!-- Categories go here if you wish an additional category to that set in {{module rating}} above automatically. --&amp;gt;&lt;br /&gt;
[[Category:Lua metamodules]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Oetterer</name></author>
	</entry>
</feed>