Content deleted Content added
try again |
upgrade getValue to functionality of getValueAndQuals |
||
Line 72:
-- takes cardinal numer as a numeric and returns the ordinal as a string
-- we need three exceptions in English for 1st, 2nd, 3rd, 21st, .. 31st, etc.
local function makeOrdinal
local ordsuffix = i18n.ordinal.default
if cardinal % 10 == 1 then
Line 336:
-- the prefered/normal filter function, and a qualifier propertyID.
-- It returns a sequence (table) of values representing the values of that property
-- and qualifiers that match the
--
local function propertyvalueandquals(objproperty, args, filter, qualID)
Line 621:
-------------------------------------------------------------------------------
-- _getvalue is the common function for getValue, getPreferredValue, and getNormalValue
--
local function _getvalue(frame, entity, props, filter, propertyID, qualID)
-- table 'out' is going to to store the return value(s):
local out = propertyvalueandquals(props, frame.args, filter, qualID)
-- format the table of values and return it as a string:
return assembleoutput(out, frame.args, entity.id, propertyID)
Line 648 ⟶ 649:
-- The property ID is passed as the first unnamed parameter and is required.
-- A locally supplied parameter may optionaly be supplied as the second unnamed parameter.
-- The function will now also return qualifiers if parameter qual is supplied
--
p.getValue = function(frame)
Line 660 ⟶ 662:
return errorOrEntity
end
-- qual is a string containing the property ID of the qualifier(s) to be returned
-- if qual == "ALL" then all qualifiers returned
-- if qual == "DATES" then qualifiers P580 (start time) and P582 (end time) returned
-- if nothing or an empty string is passed set it nil -> no qualifiers returned
local qualID = mw.text.trim(frame.args.qual or ""):upper()
if qualID == "" then qualID = nil end
local function filter(claim)
return true
end
return _getvalue(frame, errorOrEntity, props, filter, propertyID, qualID)
end
|