Changes

90 bytes added ,  16:52, 18 October 2020
no edit summary
Line 321: Line 321:  
if parameter then
 
if parameter then
 
if parameter == "link" then
 
if parameter == "link" then
local linkTarget = mw.wikibase.getSitelink(id)
+
local linkTarget = mw.wikibase.sitelink(id)
local linkName = mw.wikibase.getLabel(id)
+
local linkName = mw.wikibase.label(id)
 
if linkTarget then
 
if linkTarget then
 
-- if there is a local Wikipedia article link to it using the label or the article title
 
-- if there is a local Wikipedia article link to it using the label or the article title
Line 334: Line 334:  
end
 
end
 
else
 
else
return mw.wikibase.getLabel(id) or id
+
return mw.wikibase.label(id) or id
 
end
 
end
 
end
 
end
Line 426: Line 426:  
if refparts then refparts = refparts .. ", " else refparts = "" end
 
if refparts then refparts = refparts .. ", " else refparts = "" end
 
-- output the label of the property of the reference part, e.g. "imported from" for P143
 
-- output the label of the property of the reference part, e.g. "imported from" for P143
refparts = refparts .. tostring(mw.wikibase.getLabel(snakkey)) .. ": "
+
refparts = refparts .. tostring(mw.wikibase.label(snakkey)) .. ": "
 
-- output all values of this reference part, e.g. "German Wikipedia" and "English Wikipedia" if the referenced claim was imported from both sites
 
-- output all values of this reference part, e.g. "German Wikipedia" and "English Wikipedia" if the referenced claim was imported from both sites
 
for snakidx = 1, #snakval do
 
for snakidx = 1, #snakval do
Line 446: Line 446:  
return false, input_parm, nil, nil
 
return false, input_parm, nil, nil
 
end
 
end
local entity = mw.wikibase.getEntity(qid)
+
local entity = mw.wikibase.getEntityObject(qid)
 
local claims
 
local claims
 
if entity and entity.claims then
 
if entity and entity.claims then
Line 471: Line 471:  
for k, v in pairs(claims) do
 
for k, v in pairs(claims) do
 
local qnumber = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
 
local qnumber = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
local sitelink = mw.wikibase.getSitelink(qnumber)
+
local sitelink = mw.wikibase.sitelink(qnumber)
local label = labelHook(qnumber) or mw.wikibase.getLabel(qnumber) or qnumber
+
local label = labelHook(qnumber) or mw.wikibase.label(qnumber) or qnumber
 
if sitelink then
 
if sitelink then
 
out[#out + 1] = "[[" .. sitelink .. "|" .. label .. "]]"
 
out[#out + 1] = "[[" .. sitelink .. "|" .. label .. "]]"
Line 504: Line 504:  
local id = frame.args[2]
 
local id = frame.args[2]
 
-- return description of a Wikidata entity in the given language or the default language of this Wikipedia site
 
-- return description of a Wikidata entity in the given language or the default language of this Wikipedia site
return mw.wikibase.getEntity(id):getDescription(langcode or wiki.langcode)
+
return mw.wikibase.getEntityObject(id).descriptions[langcode or wiki.langcode].value
 
end
 
end
   Line 511: Line 511:  
local id = frame.args[2]
 
local id = frame.args[2]
 
-- return label of a Wikidata entity in the given language or the default language of this Wikipedia site
 
-- return label of a Wikidata entity in the given language or the default language of this Wikipedia site
return mw.wikibase.getEntity(id):getLabel(langcode or wiki.langcode)
+
return mw.wikibase.getEntityObject(id).labels[langcode or wiki.langcode].value
 
end
 
end
   Line 584: Line 584:  
local input_parm = mw.text.trim(frame.args[3] or "")
 
local input_parm = mw.text.trim(frame.args[3] or "")
 
if input_parm == "FETCH_WIKIDATA" then
 
if input_parm == "FETCH_WIKIDATA" then
local entity = mw.wikibase.getEntity()
+
local entity = mw.wikibase.getEntityObject()
 
if entity.claims[propertyID] ~= nil then
 
if entity.claims[propertyID] ~= nil then
 
local out = {}
 
local out = {}
Line 605: Line 605:  
local function outputValue(value)
 
local function outputValue(value)
 
local qnumber = "Q" .. value.datavalue.value["numeric-id"]
 
local qnumber = "Q" .. value.datavalue.value["numeric-id"]
if (mw.wikibase.getSitelink(qnumber)) then
+
if (mw.wikibase.sitelink(qnumber)) then
return "[[" .. mw.wikibase.getSitelink(qnumber) .. "]]"
+
return "[[" .. mw.wikibase.sitelink(qnumber) .. "]]"
 
else
 
else
 
return "[[:d:" .. qnumber .. "|" ..qnumber .. "]]<abbr title='" .. i18n["errors"]["local-article-not-found"] .. "'>[*]</abbr>"
 
return "[[:d:" .. qnumber .. "|" ..qnumber .. "]]<abbr title='" .. i18n["errors"]["local-article-not-found"] .. "'>[*]</abbr>"
Line 664: Line 664:  
local function outputHook(value)
 
local function outputHook(value)
 
if value.datavalue.value["numeric-id"] then
 
if value.datavalue.value["numeric-id"] then
return mw.wikibase.getLabel("Q" .. value.datavalue.value["numeric-id"])
+
return mw.wikibase.label("Q" .. value.datavalue.value["numeric-id"])
 
else
 
else
 
return value.datavalue.value
 
return value.datavalue.value
Line 744: Line 744:  
-- formatPropertyValues returns a table with the P1323 values concatenated with ", " so we have to split them out into a table in order to construct the return string
 
-- formatPropertyValues returns a table with the P1323 values concatenated with ", " so we have to split them out into a table in order to construct the return string
 
p.getTAValue = function(frame)
 
p.getTAValue = function(frame)
local ent = mw.wikibase.getEntity()
+
local ent = mw.wikibase.getEntityObject()
 
local props = ent:formatPropertyValues('P1323')
 
local props = ent:formatPropertyValues('P1323')
 
local out = {}
 
local out = {}
Line 798: Line 798:  
local input_parm = mw.text.trim(frame.args[1] or "")
 
local input_parm = mw.text.trim(frame.args[1] or "")
 
if input_parm == "FETCH_WIKIDATA" then
 
if input_parm == "FETCH_WIKIDATA" then
local ent = mw.wikibase.getEntity(id)
+
local ent = mw.wikibase.getEntityObject(id)
 
local imgs
 
local imgs
 
if ent and ent.claims then
 
if ent and ent.claims then
Line 863: Line 863:  
-- returns the page id (Q...) of the current page or nothing of the page is not connected to Wikidata
 
-- returns the page id (Q...) of the current page or nothing of the page is not connected to Wikidata
 
function p.pageId(frame)
 
function p.pageId(frame)
return mw.wikibase.getEntityIdForCurrentPage()
+
local entity = mw.wikibase.getEntityObject()
 +
if not entity then return nil else return entity.id end
 
end
 
end
   Line 878: Line 879:     
-- get wikidata entity
 
-- get wikidata entity
local entity = mw.wikibase.getEntity(id)
+
local entity = mw.wikibase.getEntityObject(id)
 
if not entity then
 
if not entity then
 
if showerrors then return printError("entity-not-found") else return default end
 
if showerrors then return printError("entity-not-found") else return default end
Line 935: Line 936:  
id = nil
 
id = nil
 
end
 
end
local data = mw.wikibase.getEntity(id)
+
local data = mw.wikibase.getEntityObject(id)
 
if not data then
 
if not data then
 
return nil
 
return nil
Line 979: Line 980:  
function p.Dump(frame)
 
function p.Dump(frame)
 
local f = (frame.args[1] or frame.args.id) and frame or frame:getParent()
 
local f = (frame.args[1] or frame.args.id) and frame or frame:getParent()
local data = mw.wikibase.getEntity(f.args.id)
+
local data = mw.wikibase.getEntityObject(f.args.id)
 
if not data then
 
if not data then
 
return i18n.warnDump
 
return i18n.warnDump