Module:Cite Q: Difference between revisions

Content deleted Content added
update from sandbox; changes by RexxS
+editors;
Line 13:
 
 
--[=[-------------------------< G E T _ N A UM TE H_ OL RI S T >--------------------------------------------------------
 
getAuthors -- adapted from code taken from [[Module:RexxS]]
arguments:
nl_type - type of name list to fetch: nl_tpe = 'a' for authors; 'e' 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 25 ⟶ 26:
]=]
 
local function get_authorsget_name_list (nl_type, args, qid, wdl)
local propertyID = "P50"
if 'a' == nl_type then
propertyID = 'P50'; -- for authors
elseif 'e' == nl_type then
propertyID = 'P98'; -- for editors
else
return '' -- not specified so return empty string
end
-- wdlinks is a boolean passed to enable links to Wikidata when no article exists
Line 58 ⟶ 67:
-- So now we have something to return:
-- table 'out' is going to to store the author names(s):
-- and table 'link' will store any links to the authorname's article
local out = {}
local link = {}
Line 74 ⟶ 83:
end
if sitelink then
-- just the plain author name,
-- but keep a record of the links, using the same index
out[#out + 1] = label
Line 114 ⟶ 123:
if #out > 0 then
-- construct the list in the format we want
forif k,v'a' in== ipairs(out)nl_type dothen
for k,v in pairsipairs(linkout) do
local parameter_name = 'author' .. k
args[ local parameter_name] = v'author' .. k
args[parameter_name] = v
end
end
for k,v in pairs(link) do
for k,v in pairs(link) do
local parameter_name = 'authorlink' .. k
args[ local parameter_name] = v'author-link' .. k
args[parameter_name] = v
end
end
elseif 'e' == nl_type then
for k,v in ipairs(out) do
local parameter_name = 'authoreditor' .. k
args[parameter_name] = v
end
for k,v in pairs(link) do
local parameter_name = 'authorlinkeditor-link' .. k
args[parameter_name] = v
end
end
end
end
Line 151 ⟶ 171:
end
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_authorsget_name_list ('a', citeq_args, qid, wdl); -- modify citeq_args table with authors from wikidata
if is_set (qid) then
end
get_authors (citeq_args, qid, wdl); -- modify citeq_args table with authors from wikidata
 
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 ('e', citeq_args, qid, wdl); -- modify citeq_args table with editors from wikidata
end
end