Modul:RelatedSites: Porovnání verzí

Z Wikicitátů
Smazaný obsah Přidaný obsah
dočasný modul pro kontrolu odkazů do Wikipedie a Wikizdrojů, osekaná a upravená verze z w:cs:Modul:RelatedSites
(Žádný rozdíl)

Verze z 23. 6. 2014, 18:21

Dokumentaci tohoto modulu lze vytvořit na stránce Nápověda:Modul:RelatedSites

Chyba skriptu: Chyba Lua na řádku 75: unexpected symbol near '�'.

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.cswikipedia then
		cswikipedia = entity.sitelinks.cswikipedia.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 cswikipedia then
			link = link .. cswikipedia
		else return nil
		end

	-- Wikimedia Commons
	if site == "commons" then
		if commonswiki then
			if not string.find(commonswiki,"Category:") then
				link = link .. commonswiki
			elseif p935 then
				link = link .. p935
		 	end
		elseif p935 then
				link = link .. p935
		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