20.601
Bearbeitungen
(Export function mit setmetatable eingeführt) Markierung: Zurückgesetzt |
(Verschiebung Kalender-Funktionen zu Modul:Kalender, - obsolete Funktionen) |
||
| (52 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
local p = {} | local p = {} | ||
function p. | function p.attributeTable(args) | ||
-- Draws a simple Table that contains all arguments that are fed from the | -- Draws a simple Table that contains all arguments that are fed from the | ||
-- template to the scribunto-model. For debugging only! | -- template to the scribunto-model. For debugging only! | ||
| Zeile 14: | Zeile 13: | ||
end | end | ||
function | function p.getPageName(frame) | ||
-- This is for unlinking semantic attributes with datatype site. | -- This is for unlinking semantic attributes with datatype site. | ||
local p = frame.args[1] or "" | local p = frame.args[1] or "" | ||
| Zeile 61: | Zeile 25: | ||
end | end | ||
function p. | function p.isEmpty(a) | ||
if type(a) == "table" then | |||
for _ in pairs(a) do | |||
return false | |||
return | |||
end | end | ||
return true | |||
else | |||
return a == '' or a == nil | |||
end | end | ||
end | end | ||
| Zeile 118: | Zeile 62: | ||
end | end | ||
function p.get_key_for_value( t, value ) | function p.get_key_for_value(t, value) | ||
for k, v in pairs(t) do | for k, v in pairs(t) do | ||
if v==value then return k end | if v == value then | ||
return k | |||
end | |||
end | end | ||
end | end | ||
| Zeile 137: | Zeile 82: | ||
end | end | ||
function | function p.append_tables(t1, t2) | ||
-- append indexed/keyed table to another | |||
-- indexes/keys gonna lost! | |||
-- the result is table with new indexes | |||
-- also see p.merge_tables() | |||
local result={} | |||
for _, v in pairs(t1) do | |||
table.insert(result, v) | |||
end | |||
for _, v in pairs(t2) do | |||
table.insert(result, v) | |||
end | |||
return result | |||
end | |||
function p.spaces(frame) | |||
local n = tonumber(frame.args[1]) | local n = tonumber(frame.args[1]) | ||
local s = "" | local s = "" | ||
| Zeile 144: | Zeile 104: | ||
end | end | ||
return s | return s | ||
end | end | ||
function p.shallowcopy(orig) | function p.shallowcopy(orig) | ||
-- real-copy of a table | |||
local orig_type = type(orig) | local orig_type = type(orig) | ||
local copy | local copy | ||
| Zeile 186: | Zeile 121: | ||
end | end | ||
-- | function p.isTrue(s) | ||
-- testet String auf True-Werte verschiedenster Schreibweisen | |||
local result = false | |||
if s ~= nil then | |||
if type(s) == "boolean" then | |||
result = s | |||
elseif type(s) == "number" then | |||
result = (s ~= 0) | |||
else | |||
s = tostring(s) | |||
result = (s == "Ja" or s == "ja" or s == "Wahr" or s == "wahr" or s == "true") | |||
end | |||
end | |||
return result | |||
end | |||
return p | |||