-- Step 1: Generate a team and result list
for k,v in pairs(targs) do
if type(k) == 'string' then
if k:find('^team%d%d*$') then
teams[v] = 1
iargs[k] = 1
if targs['name_' .. v] then
-- Great!
iargs['name_' .. v] = 1
else
table.insert(missing_teams, v)
end
if targs['note_' .. v] then
iargs['note_' .. v] = 1
end
if targs['hth_' .. v] then
local multiref = 1
local hth_local_table = mw.text.split(targs['hth_' .. v], '%s*,%s*')
if (#hth_local_table > 1) then
for j, hth_loc in ipairs(hth_local_table) do
multiref = multiref * (targs['hth_' .. hth_loc] and 1 or 0)
end
else
multiref = 0
end
if multiref > 0 then
for j, hth_loc in ipairs(hth_local_table) do
iargs['hth_' .. hth_loc] = 1
end
elseif targs['hth_' .. targs['hth_' .. v]] then
iargs['hth_' .. targs['hth_' .. v]] = 1
end
iargs['hth_' .. v] = 1
end
elseif k:find('^result%d%d*$') or k:find('^.*_result%d%d*$') then
local pre = mw.ustring.gsub(k, '^(.*)result%d%d*$', '%1')
results[v] = 1
iargs[k] = 1
if targs[pre .. 'col_' .. v] or targs[pre .. 'note_res_' .. v] then -- or targs[pre .. 'text_' .. v]
-- Great!
iargs[pre .. 'col_' .. v] = 1
iargs[pre .. 'text_' .. v] = 1
iargs[pre .. 'res_col_header'] = 1
if targs[pre .. 'note_res_' .. v] then
local multiref = 1
local note_res_local_table = mw.text.split(targs[pre .. 'note_res_' .. v], '%s*,%s*')
if (#note_res_local_table > 1) then
for j, note_res_loc in ipairs(note_res_local_table) do
multiref = multiref * (targs[pre .. 'note_res_' .. note_res_loc] and 1 or 0)
end
else
multiref = 0
end
if multiref > 0 then
for j, note_res_loc in ipairs(note_res_local_table) do
iargs[pre .. 'note_res_' .. note_res_loc] = 1
end
elseif targs[pre .. 'note_res_' .. targs[pre .. 'note_res_' .. v]] then
iargs[pre .. 'note_res_' .. targs[pre .. 'note_res_' .. v]] = 1
end
iargs[pre .. 'note_res_' .. v] = 1
end
else
table.insert(missing_results, v)
end
elseif k:find('^match[%d]*_.*_.*_note$') then
local m = mw.ustring.gsub(k, '^(match[%d]*_.*_.*)_note$', '%1')
iargs[k] = 1
if targs[m] then
if targs['note_' .. v] then
iargs['note_' .. v] = 1
end
-- Great!
else
table.insert(orphaned_match_notes, m)
end
end
end
end
return {}
|