Module:Infobox: Difference between revisions
Change subobject naming scheme
(Fix category version bug) |
(Change subobject naming scheme) |
||
Line 4:
-- <nowiki>
local editbutton = require('Module:Edit button')
local smwutils = requires('Module:SMW Utils')
local Infobox = {}
Line 231:
--]]
function Infobox:parse_versions()
function insert_version_name(version_name)
table.insert(self.version_names, version_name)
if smwutils.valid_subobject_name(version_name) == false then
table.insert(self.errors, 'Illegal version value: must not be "0" nor contain a "." in the first five characters')
end
end
-- Count the versions and setup self.version_names
local i = 1
while self.args_raw['version'..i] do
i = i + 1
end
Line 244 ⟶ 251:
-- Handle the no version case - check for a custom version_name
if self.versions == 0 then
self.versions = 1
end
Line 446 ⟶ 453:
-- Generate a subobject name
-- Reminder - subobject name cannot have a . in the first 5 characters
local subobject_name =
-- Store each param that has smw_property defined and is not nil
local subobject = {Infobox = self.infobox_name} -- Also store the current Infobox name
Line 462 ⟶ 469:
-- Save subobjects if not in mainspace
if mw.title.getCurrentTitle():inNamespace(0) then
local result =
if self.versions == 1 then
result = mw.smw.set(subobject)
else
result = mw.smw.subobject(subobject, subobject_name)
end
if result ~= true then
table.insert(self.errors, 'SMW error: '..result.error)
|