<?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%3ASFfield%2Fclass</id>
	<title>Modul:SFfield/class - 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%3ASFfield%2Fclass"/>
	<link rel="alternate" type="text/html" href="https://www.verzauberte-welten.de/index.php?title=Modul:SFfield/class&amp;action=history"/>
	<updated>2026-04-05T22:33:11Z</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:SFfield/class&amp;diff=4425&amp;oldid=prev</id>
		<title>imported&gt;Oetterer: fixed an error with show on select for input_type checkbox</title>
		<link rel="alternate" type="text/html" href="https://www.verzauberte-welten.de/index.php?title=Modul:SFfield/class&amp;diff=4425&amp;oldid=prev"/>
		<updated>2016-02-29T08:49:45Z</updated>

		<summary type="html">&lt;p&gt;fixed an error with show on select for input_type checkbox&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local class = require('Module:Middleclass').class&lt;br /&gt;
local classSFfield = class('SFfield')&lt;br /&gt;
local classDebug = require('Module:Debug/class')&lt;br /&gt;
&lt;br /&gt;
-- ****************************************************************&lt;br /&gt;
-- *                          properties                          *&lt;br /&gt;
-- ****************************************************************&lt;br /&gt;
 &lt;br /&gt;
-- **************** initialization of table for private properties&lt;br /&gt;
local _private = setmetatable({}, {__mode = &amp;quot;k&amp;quot;})   -- weak table storing all private attributes&lt;br /&gt;
 &lt;br /&gt;
-- **************** declaration of private static properties&lt;br /&gt;
-- local _PROPERTY = require( 'Module:' )&lt;br /&gt;
local _CFG = mw.loadData( 'Module:SFfield/config' )&lt;br /&gt;
local _TT = require( 'Module:TableTools' )&lt;br /&gt;
local _defaultListInputType = 'tokens'&lt;br /&gt;
local _defaultSingleInputType = 'combobox'&lt;br /&gt;
local _defaultSize = 40&lt;br /&gt;
local _defaultTextAreaAttributes = {&lt;br /&gt;
	autogrow = true,&lt;br /&gt;
	cols = 80,&lt;br /&gt;
	editor = 'wikieditor',&lt;br /&gt;
	rows = 12&lt;br /&gt;
}&lt;br /&gt;
local _mandatoryMarker = '&amp;lt;sup&amp;gt;*&amp;lt;/sup&amp;gt;'&lt;br /&gt;
local _showOnSelectIdPrefix = _CFG.global.showOnSelectIdPrefix&lt;br /&gt;
&lt;br /&gt;
-- ***************************************************************&lt;br /&gt;
-- *                           methods                           *&lt;br /&gt;
-- ***************************************************************&lt;br /&gt;
 &lt;br /&gt;
-- **************** declaration of static methods&lt;br /&gt;
function classSFfield:initialize(fieldname)	-- constructor&lt;br /&gt;
	local fieldname = fieldname or 'no fieldname specified'&lt;br /&gt;
	local dbg = classDebug:new('SFfield_field_' .. fieldname)&lt;br /&gt;
	-- initialize all private properties&lt;br /&gt;
	_private[self] = {&lt;br /&gt;
		attributes = {},&lt;br /&gt;
		dbg = dbg,&lt;br /&gt;
		name = fieldname,&lt;br /&gt;
	}&lt;br /&gt;
	_private[self].dbg:log(11, 'Initializing field &amp;quot;' .. fieldname ..'&amp;quot;')&lt;br /&gt;
end	-- end of function classSFfield:initialize(fieldname)&lt;br /&gt;
&lt;br /&gt;
function classSFfield.static:getShowOnSelectIdPrefix()&lt;br /&gt;
	return _showOnSelectIdPrefix&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function classSFfield.static:setDefaultSize(val)&lt;br /&gt;
	if val and type(val) == 'number' then&lt;br /&gt;
		_defaultSize = val&lt;br /&gt;
		classDebug:log(13, ' classSFfield.static:setDefaultSize(): Setting _defaultSize to ' .. val, tostring(self) .. '.static')&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function classSFfield.static:setDefaultTextAreaAutogrow(val)&lt;br /&gt;
	if val and type(val) == 'boolean' then&lt;br /&gt;
		_defaultTextAreaAttributes.autogrow = val&lt;br /&gt;
		classDebug:log(13, 'classSFfield.static:setDefaultTextAreaAutogrow(): Setting _defaultTextAreaAttributes.autogrow to ' .. val,&lt;br /&gt;
			tostring(self) .. '.static')&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function classSFfield.static:setDefaultTextAreaCols(val)&lt;br /&gt;
	if val and type(val) == 'number' then&lt;br /&gt;
		_defaultTextAreaAttributes.cols = val&lt;br /&gt;
		classDebug:log(13, 'classSFfield.static:setDefaultTextAreaCols(): Setting _defaultTextAreaAttributes.cols to ' .. val,&lt;br /&gt;
			tostring(self) .. '.static')&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function classSFfield.static:setDefaultTextAreaEditor(val)&lt;br /&gt;
	if type(val) == 'boolean' then&lt;br /&gt;
		if val then&lt;br /&gt;
			_defaultTextAreaAttributes.editor = 'wikieditor'&lt;br /&gt;
			classDebug:log(13, 'classSFfield.static:setDefaultTextAreaEditor(): Setting _defaultTextAreaAttributes.editor to wikieditor',&lt;br /&gt;
				tostring(self) .. '.static')&lt;br /&gt;
		else&lt;br /&gt;
			_defaultTextAreaAttributes.editor = nil&lt;br /&gt;
			classDebug:log(13, 'classSFfield.static:setDefaultTextAreaEditor(): Setting _defaultTextAreaAttributes.editor to NIL',&lt;br /&gt;
				tostring(self) .. '.static')&lt;br /&gt;
		end&lt;br /&gt;
		return true&lt;br /&gt;
	elseif val and type(val) == 'string' then&lt;br /&gt;
		_defaultTextAreaAttributes.editor = val&lt;br /&gt;
		classDebug:log(13, 'classSFfield.static:setDefaultTextAreaEditor(): Setting _defaultTextAreaAttributes.editor to ' .. val,&lt;br /&gt;
			tostring(self) .. '.static')&lt;br /&gt;
		return true&lt;br /&gt;
	else&lt;br /&gt;
		classDebug:log(13, 'classSFfield.static:setDefaultTextAreaEditor(): doing nothing. parameter type is ' .. type(val),&lt;br /&gt;
			tostring(self) .. '.static')&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function classSFfield.static:setDefaultTextAreaRows(val)&lt;br /&gt;
	if val and type(val) == 'number' then&lt;br /&gt;
		_defaultTextAreaAttributes.rows = val&lt;br /&gt;
		classDebug:log(13, 'classSFfield.static:setDefaultTextAreaRows(): Setting _defaultTextAreaAttributes.rows to ' .. val, &lt;br /&gt;
			tostring(self) .. '.static')&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function classSFfield.static:setShowOnSelectIdPrefix(val)&lt;br /&gt;
	if val and type(val) == 'string' then&lt;br /&gt;
		_showOnSelectIdPrefix = val&lt;br /&gt;
		classDebug:log(13, 'classSFfield.static:setShowOnSelectIdPrefix(): Setting _showOnSelectIdPrefix to ' .. val,&lt;br /&gt;
			tostring(self) .. '.static')&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- **************** declaration of private methods&lt;br /&gt;
local _processAttributes = function (self)&lt;br /&gt;
	_private[self].dbg:log(11, 'entering _processAttributes() to process attributes and preparing them for printout')&lt;br /&gt;
	_private[self].dbg:log(13, ' _processAttributes(): attributes array so far looks like: &amp;lt;pre&amp;gt;' .. _TT.printTable(_private[self].attributes) .. '&amp;lt;/pre&amp;gt;')&lt;br /&gt;
	local attributes = {}&lt;br /&gt;
	if not _private[self].attributes['input type'] and not (_private[self].attributes.hidden or _private[self].attributes['holds template']) then&lt;br /&gt;
		_private[self].dbg:log(13, ' _processAttributes(): no input type set. defaulting dependant on the setting of attribute &amp;quot;list&amp;quot;')&lt;br /&gt;
		if _private[self].attributes.list then&lt;br /&gt;
			_private[self].attributes['input type'] = _defaultListInputType&lt;br /&gt;
		else&lt;br /&gt;
			_private[self].attributes['input type'] = _defaultSingleInputType&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if _private[self].attributes['input type'] and (_private[self].attributes['input type'] == 'textarea' or _private[self].attributes['input type'] == 'textarea with autocomplete') then&lt;br /&gt;
		_private[self].dbg:log(13, ' _processAttributes(): textarea input type detected. setting defaults when unset')&lt;br /&gt;
		if _private[self].attributes.autogrow == nil then&lt;br /&gt;
			_private[self].attributes.autogrow = _defaultTextAreaAttributes.autogrow&lt;br /&gt;
		end&lt;br /&gt;
		if _private[self].attributes.cols == nil then&lt;br /&gt;
			_private[self].attributes.cols = _defaultTextAreaAttributes.cols&lt;br /&gt;
		end&lt;br /&gt;
		if _private[self].attributes.editor == nil and _defaultTextAreaAttributes.editor then&lt;br /&gt;
			_private[self].attributes.editor = _defaultTextAreaAttributes.editor&lt;br /&gt;
		end&lt;br /&gt;
		if _private[self].attributes.rows == nil then&lt;br /&gt;
			_private[self].attributes.rows = _defaultTextAreaAttributes.rows&lt;br /&gt;
		end&lt;br /&gt;
	elseif _private[self].attributes.size == nil and _private[self].attributes['input type']&lt;br /&gt;
			and not _TT.inTable({'radiobutton', 'hidden', 'checkbox', 'checkboxes'}, mw.ustring.lower(_private[self].attributes['input type'])) then&lt;br /&gt;
		_private[self].attributes.size = _defaultSize&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for attr, val in pairs(_private[self].attributes) do&lt;br /&gt;
		if not _private[self].attributes['input type'] or _TT.inTable(_CFG.generalAttributes, mw.ustring.lower(attr)) or &lt;br /&gt;
				_TT.inTable(_CFG.validAttributesPerType[_private[self].attributes['input type']], mw.ustring.lower(attr)) then&lt;br /&gt;
			local line&lt;br /&gt;
			if type(val) == 'boolean' then&lt;br /&gt;
				if val then&lt;br /&gt;
					line = attr&lt;br /&gt;
				end&lt;br /&gt;
			elseif type(val) == 'table' then&lt;br /&gt;
				_private[self].dbg:log(13, ' _processAttributes(): value of type &amp;quot;table&amp;quot; detected')&lt;br /&gt;
				if attr == 'show on select' then&lt;br /&gt;
					_private[self].dbg:log(13, ' _processAttributes(): belonging to attribute &amp;quot;show on select&amp;quot;. processing table')&lt;br /&gt;
					line = attr .. '='&lt;br /&gt;
					for v, eid in pairs(val) do&lt;br /&gt;
						if type(eid) == 'table' then&lt;br /&gt;
							for _, eid_v in pairs(eid) do&lt;br /&gt;
								line = line .. v .. '=&amp;gt;' .. _showOnSelectIdPrefix .. eid_v .. ';'&lt;br /&gt;
							end&lt;br /&gt;
						else&lt;br /&gt;
							line = line .. v .. '=&amp;gt;' .. _showOnSelectIdPrefix .. eid .. ';'&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					_private[self].dbg:log(13, ' _processAttributes(): not belonging to attribute &amp;quot;show on select&amp;quot;. processing table normally')&lt;br /&gt;
					local delimiter = _private[self].attributes.delimiter or _CFG.global.defaultDelimiter or ''&lt;br /&gt;
					-- unfortunately FoundationsClass tables get represented as arrays, albeit with integers ranging from 1 - n as keys. H2IK-Y! workaround:&lt;br /&gt;
					local tmpvals = {}&lt;br /&gt;
					for _, v in pairs(val) do&lt;br /&gt;
						table.insert(tmpvals, v)&lt;br /&gt;
					end&lt;br /&gt;
					line = attr .. '=' .. table.concat(tmpvals, delimiter) -- '1,2,3,' .. #val .. '-&amp;lt;pre&amp;gt;' .. require('Module:TableTools').printTable(val) .. '&amp;lt;/pre&amp;gt;' ..table.maxn(val) --table.concat(val, '-')&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				if attr == 'show on select' then&lt;br /&gt;
					line = attr .. '=' .. _showOnSelectIdPrefix .. val&lt;br /&gt;
				else&lt;br /&gt;
					line = attr .. '=' .. val&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if line then&lt;br /&gt;
				_private[self].dbg:log(13, ' _processAttributes(): adding &amp;quot;' .. line .. '&amp;quot; to table of attributes')&lt;br /&gt;
			end&lt;br /&gt;
			table.insert(attributes, line)&lt;br /&gt;
		else&lt;br /&gt;
			_private[self].dbg:log(13, ' _processAttributes(): ignoring attribute ' .. attr .. '; reason is: ' ..&lt;br /&gt;
				(_private[self].attributes['input type'] and 'not found in tables _CFG.generalAttributes and _CFG.validAttributesPerType[&amp;quot;' .. _private[self].attributes['input type'] .. '&amp;quot;]' or 'no input type set')&lt;br /&gt;
			)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return attributes&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- **************** declaration of public methods&lt;br /&gt;
function classSFfield:__tostring()&lt;br /&gt;
	_private[self].dbg:log(11, 'entering classSFfield:__tostring() to render field output')&lt;br /&gt;
	return self:render()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function classSFfield:createTr(label, tooltip)&lt;br /&gt;
	_private[self].dbg:log(11, 'entering classSFfield:createTr() to create a table row around self:render()')&lt;br /&gt;
	_private[self].dbg:log(12, ' classSFfield:createTr() has label &amp;quot;' .. (label and label or 'NOT PROVIDED') .. '&amp;quot;')&lt;br /&gt;
	_private[self].dbg:log(12, ' classSFfield:createTr() has tooltip &amp;quot;' .. (tooltip and tooltip or 'NONE') .. '&amp;quot;')&lt;br /&gt;
	local frame = mw.getCurrentFrame()&lt;br /&gt;
	tr = mw.html.create('tr')&lt;br /&gt;
	tr:attr( 'id', _showOnSelectIdPrefix .. mw.uri.encode(_private[self].name, 'WIKI') )&lt;br /&gt;
		:tag((_private[self].attributes.mandatory and 'th' or 'td'))&lt;br /&gt;
			:wikitext((label or 'LABEL_' .. fieldname) .. &lt;br /&gt;
				(_private[self].attributes.mandatory and _mandatoryMarker or '') ..&lt;br /&gt;
				(tooltip and frame:callParserFunction(_CFG.global.tooltipParserFunction, tooltip) or ''))&lt;br /&gt;
			:done()&lt;br /&gt;
		:newline()&lt;br /&gt;
		:tag('td')&lt;br /&gt;
			:wikitext(self:render())&lt;br /&gt;
			:done()&lt;br /&gt;
		:newline()&lt;br /&gt;
		:done()&lt;br /&gt;
	return tr&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function classSFfield:get(attribute)&lt;br /&gt;
	return _private[self].attributes[attribute]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function classSFfield:render()&lt;br /&gt;
	_private[self].dbg:log(11, 'entering classSFfield:render() to render field output')&lt;br /&gt;
	local str = '{{{field|' .. _private[self].name .. '|'&lt;br /&gt;
				.. table.concat(_processAttributes(self), '|') .. '}}}'&lt;br /&gt;
	_private[self].dbg:log(11, ' classSFfield:render() renders &amp;lt;code&amp;gt;' .. mw.text.nowiki(str) .. '&amp;lt;/code&amp;gt;')&lt;br /&gt;
	return str&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function classSFfield:set(attribute, value)&lt;br /&gt;
	local attribute = (attribute and mw.ustring.lower(attribute) or 'NOT PROVIDED!')&lt;br /&gt;
	_private[self].dbg:log(11, 'entering classSFfield:set() to set attribute: ' .. attribute)&lt;br /&gt;
	local value = value&lt;br /&gt;
	if value == nil then&lt;br /&gt;
		value = true&lt;br /&gt;
	end&lt;br /&gt;
	if _TT.inTable(_CFG.validAttributes, attribute) then&lt;br /&gt;
		-- we have a valid attribute. do some plausibility check&lt;br /&gt;
		if attribute == 'input type' then&lt;br /&gt;
			value = mw.ustring.lower(value)&lt;br /&gt;
			if not _TT.inTable(_CFG.validInputTypes, value) then&lt;br /&gt;
				_private[self].dbg:log(11, ' classSFfield:set() trying to set &amp;quot;intput type&amp;quot; to invalid value: ' .. value and mw.ustring.lower(value) or 'NIL')&lt;br /&gt;
				return false&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		_private[self].attributes[attribute] = value&lt;br /&gt;
		if type(value) == 'number' or type(value) == 'string' then&lt;br /&gt;
			_private[self].dbg:log(12, ' classSFfield:set() setting attribute: &amp;quot;' .. attribute .. '&amp;quot; to value ' .. value)&lt;br /&gt;
		else&lt;br /&gt;
			_private[self].dbg:log(12, ' classSFfield:set() setting attribute: &amp;quot;' .. attribute .. '&amp;quot; to a value of type ' .. type(value))&lt;br /&gt;
		end&lt;br /&gt;
		return true&lt;br /&gt;
	else&lt;br /&gt;
		_private[self].dbg:log(11, ' classSFfield:set() called with invalid attribute: ' .. attribute)&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return classSFfield&lt;/div&gt;</summary>
		<author><name>imported&gt;Oetterer</name></author>
	</entry>
</feed>