Content deleted Content added
update from sandbox; changes by RexxS |
+editors; |
||
Line 13:
--[=[-------------------------< G E T _ N A
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
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
-- 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
-- and table 'link' will store any links to the
local out = {}
local link = {}
Line 74 ⟶ 83:
end
if sitelink then
-- just the plain
-- 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
local parameter_name = '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[parameter_name] = v
▲ end
end
elseif 'e' == nl_type then
for k,v in ipairs(out) do
args[parameter_name] = v
end
for k,v in pairs(link) do
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 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
|