Modulis:Ārējās saites identifikators

Dokumentācijas ikona Moduļa dokumentācija[izveidot]
local p = {}
local entity = mw.wikibase.getEntityObject()
if entity then
	claims = entity.claims
end

local function trim(s)
	if s == nil then
		return nil
	end
	return s:match('^%s*(.-)%s*$')
end

local function isnotempty(s)
	return s and trim(s) ~= ''
end

function p.main(frame)
	local args = frame.args
	local para = trim(frame.args['param'] or nil)
	local prop = frame.args['property']
	
	local fval = frame.args['format']
	if fval and isnotempty(para) and para~= nil then
		result = mw.ustring.match( para, fval )
		if result == nil then
			result=para
			checkF = ' neatbilst formātam '
		end
	else
		result=para
	end

	if claims then
		if claims[prop] and claims[prop][1] and claims[prop][1].mainsnak.datavalue then
			local snaktype = claims[prop][1].mainsnak.snaktype
			local propValue = claims[prop][1].mainsnak.datavalue.value
				if propValue and not isnotempty(para) and snaktype == 'value' then
					result = propValue
				else
					if isnotempty(para) and propValue ~= para then
						checkWD = ' nesakrīt ar vērtību Vikidatos '
					else
						result = para
  			    	end
  			    end
		end
	end

if checkWD and checkF then
		result = result .. checkWD .. checkF
	elseif checkWD and not checkF then
		result = result .. checkWD
	elseif checkF and not checkWD then
		result = result .. checkF
end

	return result
end

return p