יחידה:פרמטרים: הבדלים בין גרסאות בדף

אין תקציר עריכה
אין תקציר עריכה
שורה 1: שורה 1:
kipod = {"אלבום", "תותח", "סינגל", "טבלת אירוויזיון", "חומצת אמינו"}
kipod = {"אלבום", "תותח", "סינגל", "טבלת אירוויזיון", "חומצת אמינו"}
sg = {["סרט"] = true, ["מידע דגל"] = true, ["סדרת טלוויזיה"] = true, }
un = {}


-- This is the main module function
-- This is the main module function
שורה 14: שורה 12:
local template = pframe:getTitle() -- template full name
local template = pframe:getTitle() -- template full name
templatename = template -- template name to remove namespace
templatename = template -- template name to remove namespace
local havesug = "" -- not enough suggestions error message
needsug = false -- is there a need to add suggestions
if find1(templatename, namespace) == 1 --remove namespace from template name
if find1(templatename, namespace) == 1 --remove namespace from template name
then templatename = mw.ustring.sub(templatename, len1(namespace) + 1) end
then templatename = mw.ustring.sub(templatename, len1(namespace) + 1) end
שורה 37: שורה 33:
end
end
if frame.args[1] then
if frame.args[1] then
data[2][#data[2] + 1] = frame.args[1]
table.insert(data[2], frame.args[1])
end
end


sugind = ''
if data and mw.title.makeTitle( 0, subpageName ).exists then
copydata = mw.loadData(subpageName) -- read template variables data
copyunnamed = copydata[1]
if copyunnamed > 0 and not un[templatename] then sugind = '[[קטגוריה:תבניות עם הצעות]]' end
end
local numbered = 0 -- real nonnamed parameters counter
local numbered = 0 -- real nonnamed parameters counter
local parnum = 0 -- template data parameters counter
local parnum = 0 -- template data parameters counter
local sugnum = 0 -- template data suggestions counter
local mustnum = data[1] -- template data maximum unnamed parameters number
local mustnum = data[1] -- template data maximum unnamed parameters number
parameters = data[2] -- template data parameters list
parameters = data[2] -- template data parameters list
שורה 54: שורה 43:
local suggestionslist = require( 'Module:פרמטרים/הצעות' )
local suggestionslist = require( 'Module:פרמטרים/הצעות' )
suggestions = suggestionslist[templatename] -- template data suggestions table
suggestions = suggestionslist[templatename] -- template data suggestions table
if suggestions then
for c, cc in pairs(suggestions) do -- count suggestions
sugnum = sugnum + 1
end
end
if sugnum == 0 then -- noone
havesug = "אין הצעות בהגדרת התבנית"
else for c, cc in pairs(parameters) do -- count parameters
parnum = parnum + 1 end
if sugnum < parnum / 2 then -- not enough suggestions
havesug = "אין מספיק הצעות בהגדרת התבנית" end end
for tt, t in pairs(must) do -- check all must parameters indeed here
for tt, t in pairs(must) do -- check all must parameters indeed here
checkmust(t) end
checkmust(t) end
שורה 83: שורה 61:


if ans == "" -- no problems
if ans == "" -- no problems
then return sugind end
then return ans end
if needsug -- need to print not enough parameters message
then ans = havesug .. "<br/>" .. ans end
if errors > 1 -- plural
if errors > 1 -- plural
then errors = "ו"
then errors = "ו"
שורה 91: שורה 67:
return '<div class="error parameters"><small>' .. " '''שגיא" .. errors .. "ת פרמטרים ב[["
return '<div class="error parameters"><small>' .. " '''שגיא" .. errors .. "ת פרמטרים ב[["
.. template .. "]]:<br/>" .. ans .. "'''</td></tr></table></small></div>" -- answer
.. template .. "]]:<br/>" .. ans .. "'''</td></tr></table></small></div>" -- answer
.. "[[קטגוריה:שגיאות פרמטריות]][[קטגוריה:שגיאות פרמטריות בתבנית " .. templatename .. "]]" .. sugind
.. "[[קטגוריה:שגיאות פרמטריות]][[קטגוריה:שגיאות פרמטריות בתבנית " .. templatename .. "]]"
end
end