Module:WikidataIB: Difference between revisions

m
1 revision imported
m (1 revision imported)
m (1 revision imported)
 
(3 intermediate revisions by 3 users not shown)
Line 11: Line 11:
-- whitelist is passed in named parameter |fetchwikidata (or |fwd)
-- whitelist is passed in named parameter |fetchwikidata (or |fwd)


require("strict")
local p = {}
local p = {}


Line 18: Line 19:
-- Module:ISOdate
-- Module:ISOdate
-- Module:DateI18n
-- Module:DateI18n
-- Module:No globals
-- Module:I18n/complex date
-- Module:I18n/complex date
-- Module:Ordinal
-- Module:Ordinal
Line 160: Line 160:
langobj = mw.language.new( langcode )
langobj = mw.language.new( langcode )
else
else
langcode = mw.getCurrentFrame():preprocess( '{{int:lang}}' )
langcode = mw.getCurrentFrame():callParserFunction('int', {'lang'})
if mw.language.isKnownLanguageTag(langcode) then
if mw.language.isKnownLanguageTag(langcode) then
langobj = mw.language.new( langcode )
langobj = mw.language.new( langcode )
Line 3,067: Line 3,067:
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
p.siteID = function(frame)
p.siteID = function(frame)
local txtlang = frame:preprocess( "{{int:lang}}" ) or ""
local txtlang = frame:callParserFunction('int', {'lang'}) or ""
-- This deals with specific exceptions: be-tarask -> be-x-old
-- This deals with specific exceptions: be-tarask -> be-x-old
if txtlang == "be-tarask" then
if txtlang == "be-tarask" then
Line 3,091: Line 3,091:
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
p.projID = function(frame)
p.projID = function(frame)
local txtlang = frame:preprocess( "{{int:lang}}" ) or ""
local txtlang = frame:callParserFunction('int', {'lang'}) or ""
-- This deals with specific exceptions: be-tarask -> be-x-old
-- This deals with specific exceptions: be-tarask -> be-x-old
if txtlang == "be-tarask" then
if txtlang == "be-tarask" then
Line 3,250: Line 3,250:
local url = frame.args.url or ""
local url = frame.args.url or ""
if url:upper() == "NONE" then return nil end
if url:upper() == "NONE" then return nil end
 
local urls = {}
local quals = {}
local qid = frame.args.qid or ""
local qid = frame.args.qid or ""
if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end
if url and url ~= "" then
if not qid then return nil end
urls[1] = url
else
if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end
if not qid then return nil end


local urls = {}
local quals = {}
if url == "" then
local prop856 = mw.wikibase.getBestStatements(qid, "P856")
local prop856 = mw.wikibase.getBestStatements(qid, "P856")
for k, v in pairs(prop856) do
for k, v in pairs(prop856) do
Line 3,271: Line 3,272:
end -- test for website having a value
end -- test for website having a value
end -- loop through website(s)
end -- loop through website(s)
else
urls[1] = url
end
end
if #urls == 0 then return nil end
if #urls == 0 then return nil end