Module:WikidataIB/sandbox1: Difference between revisions

Content deleted Content added
<sync with main>
Inline single-use "_getvalue" function
Line 872:
return out
end
 
 
-------------------------------------------------------------------------------
-- _getvalue is the private function for getValue
-------------------------------------------------------------------------------
-- Dependencies: propertyvalueandquals(); assembleoutput();
-- parseParam; sourced; labelOrId; i18n.latestdatequalifier; format_Date;
-- findLang; makeOrdinal; roundto; decimalPrecision; decimalToDMS;
-------------------------------------------------------------------------------
local function _getvalue(frame, props, propertyID, entityid)
 
-- 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
 
-- set a language object in the frame.args table
frame.args.langobj = findLang(frame.args.lang)
 
-- table 'out' stores the return value(s):
local out = propertyvalueandquals(props, frame.args, qualID)
 
-- format the table of values and return it as a string:
return assembleoutput(out, frame.args, entityid, propertyID)
end
 
 
-------------------------------------------------------------------------------
Line 911 ⟶ 883:
-- The function will now also return qualifiers if parameter qual is supplied
-------------------------------------------------------------------------------
-- Dependencies: setRanks(; parseInput; _getvalue; propertyvalueandquals; assembleoutput; parseParam; sourced;
-- labelOrId; i18n.latestdatequalifier; format_Date; makeOrdinal; roundto; decimalPrecision; decimalToDMS;
-------------------------------------------------------------------------------
Line 929 ⟶ 901:
return props -- either the input parameter or nothing
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
 
-- set a language object in the frame.args table
frame.args.langobj = findLang(frame.args.lang)
 
-- table 'out' stores the return value(s):
return _getvalue(frame, props, propertyID, entityid)
local out = propertyvalueandquals(props, frame.args, qualID)
 
-- format the table of values and return it as a string:
return assembleoutput(out, frame.args, entityid, propertyID)
end
 
Line 940 ⟶ 925:
-- now redundant to getValue with |rank=best
-------------------------------------------------------------------------------
-- Dependencies: p.getValue; setRanks; parseInput; _getvalue; propertyvalueandquals; assembleoutput;
-- parseParam; sourced; labelOrId; i18n.latestdatequalifier; format_Date;
-- makeOrdinal; roundto; decimalPrecision; decimalToDMS;