Modulo:European and national party data/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Ahecht (discussione | contributi)
raw
Ahecht (discussione | contributi)
simplify
Riga 310:
local reference = local_parameter_to_value_or_boolean (frame, 'reference', 'boolean'); -- check verbose and make boolean
ifreference = (reference and option ~= "raw-noref") and 'references=yes' or ''; then -- if reference is true, then the call will return a reference
local verbose = local_parameter_to_value_or_boolean (frame, 'verbose', 'boolean'); -- check verbose and make boolean
local raw = (option == "raw" or option == "raw-noref") and "raw=yes" or "raw=no"; -- check raw and format correctly
local linked = (option == "linked") and "linked=yes" or "linked=no"; -- check linked and format correctly
if reference and option ~= "raw-noref" then -- if reference is true, then the call will return a reference
reference = 'references=yes';
else
reference = '';
end
local party_qid = ""; -- init party_qid
Riga 333 ⟶ 330:
return make_error_msg (substitute (cfg.error_messages_t.unknown_party, {party}), template_name);
end
if not party then -- direct call when no party is specified
party_qid = "" -- This should not be needed since the function
end -- should error out above if no party specified.
if property_id == "label" then -- if the label of the Wikidata element is requested
data = xlate_wikidata ('label', party_qid, '', '', '', 'reference=no', 'preferred=no', 'raw=no', 'linked=no');
if not party then
data = xlate_wikidata ('label', '', '', '', '', 'reference=no', 'preferred=no', 'raw=no', 'linked=no');
else
data = xlate_wikidata ('label', party_qid, '', '', '', 'reference=no', 'preferred=no', 'raw=no', 'linked=no');
end
elseif property_id == "individual members date" then -- special case
data = xlate_wikidata ('qualifier', party_qid, 'P2124', 'P585', '', 'reference=no', 'preferred=yes', 'raw=yes', 'linked=no');
if not party then
data = xlate_wikidata ('qualifier', '', 'P2124', 'P585', '', 'reference=no', 'preferred=yes', 'raw=yes', 'linked=no');
else
data = xlate_wikidata ('qualifier', party_qid, 'P2124', 'P585', '', 'reference=no', 'preferred=yes', 'raw=yes', 'linked=no');
end
else -- for all other cases
data = xlate_wikidata ('property', party_qid, property_id, '', '', reference, 'preferred=no', 'raw=no', 'linked=no');
if not party then -- direct call when no party is specified
if option == "raw" or option == "raw-noref" then
data = xlate_wikidata ('property', '', property_id, '', '', reference, 'preferred=no', 'raw=yes', 'linked=no');
elseif option == "linked" then
data = xlate_wikidata ('property', '', property_id, '', '', reference, 'preferred=no', 'raw=no', 'linked=yes');
else
xlate_wikidata ('property', '', property_id, '', '', reference, 'preferred=no', 'raw=no', 'linked=no');
end
else -- otherwise we add the qID
if option == "raw" or option == "raw-noref" then
data = xlate_wikidata ('property', party_qid, property_id, '', '', reference, 'preferred=no', 'raw=yes', 'linked=no');
elseif option == "linked" then
data = xlate_wikidata ('property', party_qid, property_id, '', '', reference, 'preferred=no', 'raw=no', 'linked=yes');
else
data = xlate_wikidata ('property', party_qid, property_id, '', '', reference, 'preferred=no', 'raw=no', 'linked=no');
end
end
end
Riga 1 073 ⟶ 1 050:
return allpp_get_data (frame, party, 'individual members date');
elseif data_type == "individual members year" then
return mw.getContentLanguage():formatDate(xlate_param ('Y'),allpp_get_data (frame, party, 'individual members date', 'raw'));
elseif data_type == "label" then
return allpp_get_data (frame, party, 'label');