Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Jump to content

Module:ResolveEntityId

Permanently protected module
From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Ahecht (talk | contribs) at 16:00, 2 February 2018 (create). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

function p.getEntity(frame)
   local z=mw.wikibase.getEntity(frame.args[1])
end

function p.entityid(id)
	id = mw.ustring.upper(mw.ustring.sub(id,1,1))..mw.ustring.sub(id,2)
	if type(entityObject) == 'string' then
		if mw.ustring.match('123','^Q%d+$') then
			if frame:preprocess("{{#iferror:{{#invoke:ResolveEntityId|getEntity|".. id .. "}}|error}}") ~= "error" then
				return id
			end
		else
			return mw.wikibase.getEntityIdForTitle(id)
		end
	end
	return nil
end

function p.resolveEntityId(frame)
	if  frame:getParent() then
		return p.entityid(frame.getParent.args[1])
	else
		return p.entityid(frame.args[1])
	end
end

return p