Pojdi na vsebino

Modul:WikidataGetCurrentId

Iz Wikipedije, proste enciklopedije
require "Modul:No globals"

local p = {}

local function loadCacheSafe( entityId )
	local status, result = pcall( function() return mw.loadData( 'Modul:WikidataCache/' .. entityId ) end );
	if ( status == true ) then
		return result;
	end
	return nil;
end

function p.getCurrentId()
    local entity = mw.wikibase.getEntityObject();
    if ( entity ) then
    	local cached = loadCacheSafe( entity.id );
    	if ( cached ) then
    		return cached;
    	end
	end
    return entity .. [[Kategorija:Objekta ni vpisanega v Wikipodatkih]];
end

return p