Content deleted Content added
some minor rearrangements |
write initialisation code for Action objects, and start the code to get the current status object |
||
Line 28:
-------------------------------------------------------------------------------
-- Action class
-- Action objects deal with a single action in the history of the article. We
-- use getter methods rather than properties for the name and result, etc., as
-- their processing needs to be delayed until after the current status has
-- been determined. Some current statuses depend on parsing the action objects,
-- and the value of some names, etc., depends on having the current status
-- available, so this is necessary to avoid infinite loops.
-------------------------------------------------------------------------------
Line 36 ⟶ 41:
-- Properties to implement:
-- * id
-- * name▼
-- * oldid
-- * paramNum
-- * actionCfg
-- * currentTitle
function Action.new(data)
-- Valid data table keys:
-- code, result, link, paramNum,
local obj = setmetatable({}, Action)
obj.
obj.
obj.oldid = data.oldid▼
obj.paramNum = data.paramNum
-- Set the ID
obj.id = obj.cfg.actions[data.code] and obj.cfg.actions[data.code].id
if not obj.id then
-- @TODO: Error
end
-- Add a shortcut for this action's config.
obj.actionCfg = obj.cfg.actions[obj.id]
-- Set the oldid
▲ obj.oldid = tonumber(data.oldid)
if obj.oldid and not isPositiveInteger(obj.oldid) then
-- @TODO: Error
end
return obj
Line 54 ⟶ 75:
function Action:getName()
end
function Action:getLink()
end
Line 161 ⟶ 185:
local t = actionParams[num] or {}
t[suffixes[suffix]] = v
t.
actionParams[num] = t
end
Line 178 ⟶ 202:
-- Create the action objects.
for _, t in ipairs(actionParamsSorted) do
t.cfg = obj.cfg
t.currentTitle = obj.currentTitle
table.insert(obj.actions, Action.new(t))
end
Line 185 ⟶ 211:
end
function ArticleHistory:
if self.currentStatusObj then
return self.currentStatusObj
end
local statusCode = self.args.currentstatus
if not statusCode then
local latestFarObj
for i = #self.actions, 1, -1 do
local actionObj = self.actions[i]
if actionObj.id == 'FAR' and actionObj:getResult() == 'demoted' then
latestFarObj = actionObj
break
end
end
if latestFarObj then
-- @TODO: Error
end
end
end
|