Module:Infobox film/track
This module is no longer in use as it served its purpose. |
This module checks arguments passed to {{Infobox film}} and adds Category:Pages using infobox film with incorrectly placed links if a person linked in |producer(s)=
is also listed in |writer=
etc., or a person linked in |music=
is also listed in |cinematography=
or |editing=
(in the main and draft namespaces only).
It also shows suggestions like The link "[[Samuel G. Engel]]" in |producer= should be moved to |screenplay=
as preview warnings. This is done in all namespaces.
local p = {}
local function check(args, sources, targets)
local source
for _, param in ipairs(sources) do
if args[param] and args[param] ~= '' then
source = param
break
end
end
if not source then
return nil
end
local warnings = {}
for link in mw.ustring.gmatch(args[source], '%[%[[^%[%]]+%]%]') do
local name = mw.ustring.match(link, '([^%|]+)%]%]$', 3)
for _, param in ipairs(targets) do
if args[param] and args[param] ~= '' then
local match = mw.ustring.match(args[param], '.?.?%f[%w]' .. name .. '%f[%W]')
-- Eliminate duplicate links
if match and not mw.ustring.find(match, '^%[[%[:]') then
table.insert(warnings, 'The link <code>' .. mw.text.nowiki(link) .. '</code> in <code>|' .. source .. '=</code> should be moved to <code>|' .. param .. '=</code>.')
break
end
end
end
end
return warnings
end
function p.main(frame)
local args = frame:getParent().args
local warnings = check(args, {'producer', 'producers'}, {'writer', 'writers', 'screenplay', 'story', 'based_on'}) or {}
local warnings2 = check(args, {'music'}, {'cinematography', 'editing'}) or {}
for _, v in ipairs(warnings2) do
table.insert(warnings, v)
end
if #warnings ~= 0 then
local ret = require('Module:If preview')._warning({table.concat(warnings, ' ')})
local namespace = mw.title.getCurrentTitle().namespace
if namespace == 0 or namespace == 118 then
ret = ret .. '[[Category:Pages using infobox film with incorrectly placed links]]'
end
return ret
end
end
return p