Module:Cite Q: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 17:
get_name_list -- adapted from getAuthors code taken from [[Module:RexxS]]
arguments:
nl_type - type of name list to fetch: nl_type = 'aauthor' for authors; 'eeditor' for editors
args - pointer to the parameter arguments table from the template call
qid - value from |qid= parameter; the Q-id of the source (book, etc.) in qid
Line 29:
local propertyID = "P50"
if 'aauthor' == nl_type then
propertyID = 'P50'; -- for authors
elseif 'eeditor' == nl_type then
propertyID = 'P98'; -- for editors
else
Line 119:
end
-- if there's anything to return, then returninsert athe listadditions in the template arguments table
-- in the form |author1=firstname secondname |author2= ...
if #out > 0 then
for k,v in ipairs(out) do -- authorn or editorn
-- construct the list in the format we want
args[parameter_namenl_type .. k] = v
if 'a' == nl_type then
end
for k,v in ipairs(out) do
for k,v in pairs(link) do -- author-linkn or editor-linkn
local parameter_name = 'author' .. k
args[parameter_namenl_type .. '-link' .. k] = v
end
for k,v in pairs(link) do
local parameter_name = 'author-link' .. k
args[parameter_name] = v
end
elseif 'e' == nl_type then
for k,v in ipairs(out) do
local parameter_name = 'editor' .. k
args[parameter_name] = v
end
for k,v in pairs(link) do
local parameter_name = 'editor-link' .. k
args[parameter_name] = v
end
end
end
end
Line 173 ⟶ 159:
if is_set (qid) then
if not is_set (citeq_args.author) and not is_set (citeq_args.author1) then -- if neither are set, try to get authors from wikidata
get_name_list ('aauthor', citeq_args, qid, wdl); -- modify citeq_args table with authors from wikidata
end
 
if not is_set (citeq_args.editor) and not is_set (citeq_args.editor1) then -- if neither are set, try to get editors from wikidata
get_name_list ('eeditor', citeq_args, qid, wdl); -- modify citeq_args table with editors from wikidata
end
end