Modul:RelatedSites
Vzhled
Dokumentaci tohoto modulu lze vytvořit na stránce Nápověda:Modul:RelatedSites
function link(pid)
if entity == nil then
return nil
elseif entity.claims == nil then
return nil
elseif entity.claims[pid] == nil then
return nil
else
return entity.claims[pid][0].mainsnak.datavalue.value
end
end
local p = {}
function p.link(frame)
entity = mw.wikibase.getEntityObject()
if entity == nil then
return ''
end
p373 = link("p373")
p935 = link("p935")
link = ""
if entity.sitelinks.cswiki then
cswiki = entity.sitelinks.cswiki.title
end
if entity.sitelinks.commonswiki then
commonswiki = entity.sitelinks.commonswiki.title
end
if entity.sitelinks.cswikisource then
cswikisource = entity.sitelinks.cswikisource.title
end
local site = frame.args[1]
-- Wikipedia
if site == "wikipedia" then
if cswiki then
link = link .. cswiki
else return nil
end
-- Wikimedia Commons
elseif site == "commons" then
if commonswiki then
if string.find(commonswiki,"Category:") then
if p935 then
link = link .. p935
else return ''
end
else link = link .. commonswiki
end
elseif p935 then
link = link .. p935
else return ''
end
elseif site == "commonscat" then
if commonswiki then
if string.find(commonswiki,"Category:") then
link = link .. string.sub(commonswiki,10)
elseif p373 then
link = link .. p373
end
elseif p373 then
link = link .. p373
end
-- Wikisource
elseif site == "wikisource" then
if cswikisource then
link = link .. cswikisource
else return nil
end
end
return link
end
return p