Moduł:Wikidane
Przejdź do nawigacji
Przejdź do wyszukiwania
Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:Wikidane/opis
local moduleData = mw.loadData("Module:Wikidane/data") local function loadArg(frame,id) local result = frame.args[id] if not result or (#result == 0) then result = frame.getParent and frame:getParent().args[id] or nil; if not result or (#result == 0) then return nil end end return result end local function getEntityData(frame) local qid = loadArg(frame, "id") local data = mw.wikibase.getEntity(qid) if not data then return end local f = frame.args[1] and frame or frame:getParent() local i = 1 if f.args[1] == "bestclaims" then local pid = f.args[2] if not pid then return f, {}, 2 end local sd = require("Module:Wikidane/select") local _, qid, prop = sd.selectProperty(pid, sd.prepareFilters(frame), qid) if not qid then return nil end data = prop i = 3 end return f, data, i end return { T = function(frame) local qid = loadArg(frame, "id") local pid = loadArg(frame, 1) if not pid then return moduleData.errorMissingPropertyId end local sd = require("Module:Wikidane/select") local pid, qid, prop = sd.selectProperty(pid, sd.prepareFilters(frame), qid, false, loadArg(frame, "ranga")) if qid then return #prop end end, P = function(frame) local qid = loadArg(frame, "id") local pid = loadArg(frame, 1) if not pid then return moduleData.errorMissingPropertyId end local sd = require("Module:Wikidane/select") local pid, qid, prop = sd.selectProperty(pid, sd.prepareFilters(frame), qid, tonumber(loadArg(frame, "ile")), loadArg(frame, "ranga")) if qid then return require("Moduł:Wikidane/format").run(frame, pid, prop) end end, etykieta = function(frame) local qid = loadArg(frame, "id") local entity = mw.wikibase.getEntity(qid) if entity then local i = 1 local lang = true while lang do lang = frame.args[i] local result = entity:getLabel(lang) if result and (#result > 0) then return result end i = i + 1 end end return mw.title.getCurrentTitle().text .. moduleData.itemWithoutLabelCat end, id = function(frame) local title = loadArg(frame, 1) if(title)then return mw.wikibase.getEntityIdForTitle(mw.getContentLanguage():ucfirst(title), loadArg(frame, "idwiki") or mw.wikibase.getGlobalSiteId()) else return mw.wikibase.getEntityIdForCurrentPage() end; end, label = function(frame) local id = loadArg(frame, 1) if id and string.match(id, "^[PQ]%d+$") then return mw.wikibase.getLabel(id) end end, page = function(frame) local id = loadArg(frame, 1) if id then return mw.wikibase.getSitelink(id, loadArg(frame, "site")) else return nil end end, V = function(frame) local f, data, i = getEntityData(frame) if not data then return nil end while true do local index = f.args[i] if not index then return tostring(data) end data = data[index] or data[tonumber(index)] if not data then return end i = i + 1 end end, Dump = function(frame) local f, data, i = getEntityData(frame) if not data then return moduleData.warnDump end while true do local index = f.args[i] if not index then return "<pre>"..mw.dumpObject(data).."</pre>"..moduleData.warnDump end data = data[index] or data[tonumber(index)] if not data then return moduleData.warnDump end i = i + 1 end end, }