Modul:Uses Wikidata

Vorlagenprogrammierung Diskussionen Lua Unterseiten
Modul Deutsch English

Modul: Dokumentation

Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus


--[=[ Uses Wikidata 2022-06-08
	as of en.wikipedia.org
	for use in template documentation
	
* usesProperty	show wikiData properties accessed in a template
* tuProperty	track and use properties accessed in a template
]=]

local p = {}

p.LOGO = '[[Datei:Wikidata-logo-en.svg|100px]]'

--[[
	Uses Wikidata|usesProperty|<P...>|<P...>|
	displays Wikidata logo and listed properies
	parameters:
		unnamed*:	property number, e. g. "P123", one proprty per parameter
	returns: box with logo and some information followed by a list of properties
]]
function p.usesProperty(frame)
	local args = frame.getParent(frame).args or nil
	if mw.text.trim(args[1] or '') == '' then
		args = frame.args
	end
	local result =	'<table><tr><td style="padding:0">' .. p.LOGO
				..	'</td><td>Diese Vorlage greift auf das Datenobjekt zum Arti'
				..	'kel in Wikidata zu. Sie berücksichtigt dabei nachfolgend a'
				..	'ufgeführte Eigenschaftswerte.</td></tr></table><ul>'
	for _, v in ipairs(args) do
		local p_num = mw.text.trim(v)
		if p_num ~= '' then
			local label = mw.wikibase.getLabel(p_num) or "NO LABEL"
			result = result	..	"<li><i>[[d:" .. p_num .. "|" .. label
							..	" <small>(" .. p_num
							..	")</small>]]</i> ([[d:Property talk:" .. p_num
							..	"|Diskussion]], <span class='plainlinks'>[https"
							..	"://query.wikidata.org/embed.html#SELECT%20DIST"
							..	"INCT%20%3FObjekt%20%3FObjektLabel%20(group_con"
							..	"cat(%3FWertLabel%3B%20separator%3D%22%20%2C%20"
							..	"%22)%20as%20%3F" .. p_num
							..	"_Auswahl)%20WHERE%20%7B%0A%20%20SERVICE%20wiki"
							..	"base%3Alabel%20%7B%20bd%3AserviceParam%20wikib"
							..	"ase%3Alanguage%20%22de%22.%20%7D%0A%20%20%7B%0"
							..	"A%20%20%20%20select%20%3FObjekt%20%3FWertLabel"
							..	"%20where%20%7B%0A%20%20%20%20%20%20%3FObjekt%2"
							..	"0wdt%3A" .. p_num
							..	"%20%3FWert.%0A%20%20%20%20%20%20SERVICE%20wiki"
							..	"base%3Alabel%20%7B%20bd%3AserviceParam%20wikib"
							..	"ase%3Alanguage%20%22de%22.%20%7D%0A%20%20%20%2"
							..	"0%7D%20limit%208000%0A%20%20%7D%0A%7D%0Agroup%"
							..	"20by%20%3FObjekt%20%3FObjektLabel%20%0A Beispi"
							..	"ele]</span>)</li>"
		end
	end
	result = result.."</ul>"
	return result
end

function p.tuProperty(frame)
	local parent = frame.getParent(frame)
	local result = '<ul>'
	local ii = 1
	while true do
		local p_num = mw.text.trim(parent.args[ii] or '')
		if p_num ~= '' then
			local label = mw.wikibase.getLabel(p_num) or "NO LABEL"
			result = result	..	"<li><span style='font-size:90%;line-height:1;'"
							..	">●</span>&nbsp;&nbsp;<b>[[d:Property:"
							..	p_num .. "|" .. label .. "]]</b> <span style='f"
							..	"ont-size:90%;'>([[d:Property talk:"
							..	string.upper(p_num) .. "|" .. p_num .. "]])</sp"
							..	"an></li>"
			ii = ii + 1
		else break
		end
	end
	result = result.."</ul>"
	return result
end

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.