Modul:Taxonbar: Versiyalar orasidagi farq
Programmer (munozara | hissa) kTahrir izohi yoʻq |
zs-wikidata-inert: Wikibase klienti yoʻqligida Wikidata xatolarini bostirish |
||
| (2 oraliq tahrir tomonidan 2 foydalanuvchi koʻrsatilmagan) | |||
| Qator 1: | Qator 1: | ||
-- [zs-wikidata-inert] With no Wikibase client every from=Q… lookup returns | |||
-- nil, so this module can only emit "not a valid Wikidata entity ID" errors | |||
-- and Wikidata tracking categories. Both are suppressed below while the | |||
-- mw.wikibase stub is in force. Auto-added on import. | |||
local zs_no_wikibase = mw.wikibase == nil or mw.wikibase.zsProbeNoSuchKey ~= nil | |||
-- [zs-wikibase-guard] Ziyosfera has no Wikibase client; stub mw.wikibase so | |||
-- modules reading Wikidata degrade to nil instead of erroring. Auto-added on import. | |||
if not mw.wikibase then mw.wikibase = setmetatable({}, { __index = function() return function() return nil end end }) end | |||
require('strict') | require('strict') | ||
| Qator 564: | Qator 572: | ||
end | end | ||
--Fetch Wikidata item | --Fetch Wikidata item | ||
local from = resolveEntityId(parentArgs['from'..f]) | |||
local item = wikibaseGetEntity(from) | |||
local label = nil | |||
if type(item) == 'table' then | |||
local statements = getBestStatement(item, 'P225') | |||
if statements | |||
and statements.mainsnak | |||
and statements.mainsnak.datavalue | |||
then | |||
label = statements.mainsnak.datavalue.value | |||
end | |||
label = label or getEntityLabel(item) | |||
else | |||
-- Ziyosfera'da Wikibase mavjud bo'lmasa QID'ni | |||
-- noto'g'ri deb belgilamaymiz. | |||
if hasWikibase then | |||
if parentArgs['from'..f] then | |||
tCats[1] = '' | |||
tCats[5] = | |||
'[[Turkum:Taxonbars with invalid from parameters]]' | |||
errors = errors .. | |||
mw.text.tag( | |||
'strong', | |||
{ class = 'error' }, | |||
'Error: "' .. | |||
parentArgs['from'..f] .. | |||
'" is not a valid Wikidata entity ID.<br />' | |||
) | |||
end | |||
else | |||
-- Wikibase yo'q: | |||
-- QID parametrini saqlaymiz, lekin tekshirmaymiz. | |||
if parentArgs['from'..f] then | |||
tCats[1] = '' | |||
end | end | ||
end | |||
end | |||
if label and label ~= '' then | if label and label ~= '' then | ||
title = mw.title.new(label) | title = mw.title.new(label) | ||
| Qator 745: | Qator 782: | ||
if not isNilOrEmpty( parentArgs['demo'] ) then | if not isNilOrEmpty( parentArgs['demo'] ) then | ||
outString = outString..mw.text.nowiki(table.concat(tCats))..'<br />' | outString = outString..mw.text.nowiki(table.concat(tCats))..'<br />' | ||
elseif currentTitle.namespace == 0 then | elseif currentTitle.namespace == 0 and not zs_no_wikibase then | ||
outString = outString..table.concat(tCats) | outString = outString..table.concat(tCats) | ||
end | end | ||
if zs_no_wikibase then errors = '' end | |||
return outString..errors | return outString..errors | ||
end | end | ||
return p | return p | ||