end
elseif props.url then
-- we have a local defined url-formatter string, use it as second priority
url = mw.message.newRawMessage(props.url, verified_value):plain
if props.track then
output[#output].category[#output[#output].category+1] = mw.message.newRawMessage(cmodule:getMessage(contLang:getCode, 'track-cat-local-local'), props.prop):plain
end
elseif wikidata_property then
url = verified_value:gsub(' ','_')
if props.track then
output[#output].category[#output[#output].category+1] = mw.message.newRawMessage(cmodule:getMessage(contLang:getCode, 'track-cat-wd-local'), props.prop):plain
end
else
-- no other choice, bail out
return {}
end
local this_wiki = mw.getContentLanguage
local this_wiki_code = this_wiki:getCode
local langlink = (output[#output].langcode and output[#output].langcode ~= '' and output[#output].langcode ~= this_wiki_code) and mw.message.newRawMessage(conf:g('msg-langcode'), props.langcode, mw.language.fetchLanguageName(props.langcode, this_wiki_code)) or ""
if short_links and props.short then
output[#output].text =
mw.message.newRawMessage(props.short,
getLabel(nil, props.genitive, pagetitle),
url,
langlink,
verified_value,
mw.uri.encode(verified_value, 'PATH'))
:plain
else
output[#output].text =
mw.message.newRawMessage(props.message,
getLabel(nil, props.genitive, pagetitle),
url,
langlink,
verified_value,
mw.uri.encode(verified_value, 'PATH'))
:plain
end
end
--mw.log("findSiteLinksLocal returning="..dump(output))
return output
end  
local function addLinkback(str, property)
local id = mw.wikibase.getEntityObject
if not id then
return str
end
if type(id) == 'table' then
id = id.id
end  
local
local url = ''
if property then .. string.lower(property)
url = mw.uri.fullUrl('d:' .. id .. '#' .. property)
url.fragment = property
else
url = mw.uri.fullUrl('d:' .. id )
end  
local title = conf:g('wikidata-linkback-edit')
local icon = '[%s ]'
url = tostring(url)
local v = mw.html.create('span')
:addClass(class)
:wikitext(str)
:tag('span')
:addClass('noprint plainlinks wikidata-linkback')
:css('padding-', '.3em')
:wikitext(icon:format(url, title))
:allDone
return tostring(v)
end  
local function getArgument(, argument)
local args = .args
if args[1] == nil then
local pFrame = :getParent;
args = pFrame.args;
for k,v in pairs( .args ) do
args[k] = v;
end
end
if args[argument] then
return args[argument]
end
return nil
end  
local function removeEntry(conf_claims, identifier, property)
for i, props in ipairs(conf_claims) do
if props[identifier] == property then
table.remove(conf_claims, i)
end
end
return conf_claims
end  
function p.getLinks
local configured_conf = getArgument(, conf:a('arg-conf'))
if configured_conf then
cmodule = require ('Module:External_links/conf/'..configured_conf)
else
error(mw.message.newRawMessage(conf:g('missing-conf'), configured_conf):plain)
end
local output = {}
local category = {}
local conf_claims = cmodule:getConfiguredClaims(contLang:getCode)
local limits = cmodule:getLimits
assert(limits, mw.message.newRawMessage(conf:g('missing-limits'), configured_conf):plain)
local links_shown = getArgument(, conf:a('arg-maxlink'))
local pagetitle = getArgument(, conf:a('arg-title'))
-- get a list of tracked properties from the article itself
local requested_tracking = getArgument(, conf:a('arg-track'))
if requested_tracking and requested_tracking ~= '' then
-- the properties should be written as P1234, P2345 and other
-- version corresponding to the applicable property-identifiers in the config
for track_prop in string.gmatch(requested_tracking,"([^ ,;:]+)") do
-- get the requested properties and be able to access them
-- like req_prop['P345'] to verify if it was requested
local remove_track = string.match(track_prop, "^\-(.*)")
for i,claim in ipairs ( conf_claims ) do
if remove_track == claim.prop or remove_track == conf:a('mod-filter-all') then
-- if a property starts with "-", then we'll simply remove that
-- property from the conf_claims
conf_claims[i]['track'] = false
elseif track_prop == claim.prop or track_prop == conf:a('mod-filter-all') then
conf_claims[i]['track'] = true
end
end
end
end
-- get a list of "approved" properties from the article itself
local requested_properties = getArgument(, conf:a('arg-properties'))
--mw.log("requested_properties="..dump(requested_properties))
-- assume all properties are allowed
local req_prop = {}
local no_req_prop = false -- we'll allow properties to be filtered for now
if requested_properties and requested_properties ~= '' then
-- the properties should be written as P1234, P2345 and other
-- version corresponding to the applicable property-identifiers in the config
for i in string.gmatch(requested_properties,"([^ ,;:]+)") do
-- get the requested properties and be able to access them
-- like req_prop['P345'] to verify if it was requested
if i == conf:a('mod-filter-all') then
-- this is a special modifier, saying we should ignore
-- all previous and future positive filters and remove the
-- filter (with exception of negative filters)
req_prop = {}
no_req_prop = true
end
local remove_prop = string.match(i, "^\-(.*)")
if remove_prop then
-- if a property starts with "-", then we'll simply remove that
-- property from the conf_claims
conf_claims = removeEntry(conf_claims, 'prop', remove_prop)
elseif not no_req_prop then -- only if we are allowing properties to be filtered
req_prop[i] = 1
-- cheat to make #req_prop indicate populated table
req_prop[1] = 1
end
end
end
local requested_langs = getArgument(, conf:a('arg-languages'))
--mw.log("requested_langs="..dump(requested_langs))
-- assume all languages are allowed
local req_lang = {}
local no_req_lang = false -- we'll allow languages to be filtered for now
if requested_langs and requested_langs ~= '' then
-- the languages should be written as langcodes as used in the conf_claims
for i in string.gmatch(requested_langs,"([^ ,;:]+)") do
-- get the requested languages and be able to access them
if i == conf:a('mod-filter-all') then
-- this is a special modifier, saying we should ignore
-- all previous and future positive filters and remove the
-- filter (with exception of negative filters)
req_lang = {}
no_req_lang = true
end
-- like req_lang['en'] to verify if it was requested
local remove_lang = string.match(i, "^\-(.*)")
if remove_lang then
-- if a language starts with "-", then we'll simply remove that
-- language from the conf_claims
conf_claims = removeEntry(conf_claims, 'langcode', remove_lang)
elseif not no_req_lang then -- only if we are allowing languages to be filtered
req_lang[i] = 1
-- cheat to make #req_lang indicate populated table
req_lang[1] = 1
end
end
end
local short_links = getArgument(, conf:a('arg-short'))
if short_links and short_links ~= '' then
short_links = true
else
short_links = false
end
local showinline = getArgument(, conf:a('arg-inline'))
if showinline and showinline ~= '' then
showinline = true
else
showinline = false
end
if not links_shown or links_shown == '' then
links_shown = limits['links-shown'] and limits['links-shown'] or 5
else
links_shown = tonumber(links_shown)
end
local somedataonwikidata = (short_links and false or true)
--mw.log("conf_claims="..dump(conf_claims))
--mw.log("req_prop="..dump(req_prop))
--mw.log("req_lang="..dump(req_lang))
--mw.log("short_links="..dump(short_links))
for _, props in ipairs(conf_claims) do
-- if we're called with a list of approved properties or languages, check if this one is "approved"
if (#req_prop==0 or req_prop[props.prop]) and (#req_lang==0 or req_lang[props.langcode] or string.find(props.langcode, "([pP]%d+)")) then
--mw.log("checking claim="..dump(props))
local links = {}
local checkedonwikidata = false
-- get the any local overriding value from the call
local wikivalue = getArgument(, props.prop)
--mw.log("wikivalue="..dump(wikivalue))
if (not wikivalue or wikivalue == "") and string.find(props.prop, "([pP]%d+)") then
-- the property is a Pnnn type, and therefore on Wikidata
links = findMainLinksOnWikidata(props, pagetitle, short_links)