Modulo:DTBase: differenze tra le versioni
Da Wikitrek.
Backlink routine fixed |
Wikimedia Commons description added |
||
| (16 versioni intermedie di uno stesso utente non sono mostrate) | |||
| Riga 50: | Riga 50: | ||
end | end | ||
ExternalIDList = p.ExternalID() | ExternalIDList = p.ExternalID(frame) | ||
if ExternalIDList ~= nil and ExternalIDList ~= "" then | if ExternalIDList ~= nil and ExternalIDList ~= "" then | ||
| Riga 132: | Riga 132: | ||
demb = 'Memory Beta (tedesco)', | demb = 'Memory Beta (tedesco)', | ||
fanlore = 'Fanlore', | fanlore = 'Fanlore', | ||
trekipedia = 'Trekipedia' | trekipedia = 'Trekipedia', | ||
commonswiki = 'Wikimedia Commons' | |||
} | } | ||
| Riga 156: | Riga 157: | ||
return table.concat(AllLinks, string.char(10)) | return table.concat(AllLinks, string.char(10)) | ||
end | end | ||
function p.ExternalID() | function p.ExternalID(frame) | ||
local AllExtID = {} | local AllExtID = {} | ||
local AllSources | |||
local SourcesP = {} | |||
local Item = mw.wikibase.getEntity() | local Item = mw.wikibase.getEntity() | ||
local AllP | local AllP | ||
local finalList = "" | |||
if not Item then | if not Item then | ||
Item = mw.wikibase.getEntity('Q1') | Item = mw.wikibase.getEntity('Q1') | ||
| Riga 165: | Riga 169: | ||
AllP = mw.wikibase.orderProperties(Item:getProperties()) | AllP = mw.wikibase.orderProperties(Item:getProperties()) | ||
SourcesP = {P200 = true} | |||
for _, Property in pairs(AllP) do | for _, Property in pairs(AllP) do | ||
if Item.claims[Property][1].mainsnak.datatype == 'external-id' then | if Item.claims[Property][1].mainsnak.datatype == 'external-id' then | ||
-- Sets semantic property | -- Sets semantic property | ||
mw.smw.set((mw.wikibase.getLabelByLang(Property, 'it') or mw.wikibase.getLabel(Property)) .. " = " .. Item.claims[Property][1].mainsnak.datavalue.value) | mw.smw.set((mw.wikibase.getLabelByLang(Property, 'it') or mw.wikibase.getLabel(Property)) .. " = " .. Item.claims[Property][1].mainsnak.datavalue.value) | ||
if (SourcesP[Property]) then | |||
--ID is for external source | |||
if AllSources == nil then | |||
AllSources = {} | |||
end | |||
table.insert(AllSources, "* " .. frame:expandTemplate{title = 'CitazioneIEEE', args = {'Contributori Memory Alpha', Item.sitelinks['itma'].title, 'Memory Alpha', Item.claims[Property][1].qualifiers['P201'][1].datavalue.value.time, p.ExtIDLink(Property, Item.claims[Property][1].mainsnak.datavalue.value)}}) | |||
else | |||
--ID is normal external link | |||
AllExtID[#AllExtID + 1] = "* [" .. p.ExtIDLink(Property, Item.claims[Property][1].mainsnak.datavalue.value) .. " ''" .. Item.claims[Property][1].mainsnak.datavalue.value .. "''], " .. (mw.wikibase.getLabelByLang(Property, 'it') or mw.wikibase.getLabel(Property)) | |||
end | |||
end | end | ||
end | end | ||
if AllExtID ~= nil and AllExtID ~= "" then | |||
finalList = table.concat(AllExtID, string.char(10)) | |||
end | |||
if AllSources ~= nil and AllSources ~= "" then | |||
finalList = finalList .. string.char(10) .. "== Fonti Esterne (" .. frame:expandTemplate{title = 'Beta'} .. ") ==" .. string.char(10) .. table.concat(AllSources, string.char(10)) | |||
end | |||
mw.smw.set("finalList = " .. finalList) | |||
return finalList | |||
end | end | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
| Riga 189: | Riga 214: | ||
URL = mw.wikibase.getEntity(Property).claims[ExtIDP][1].mainsnak.datavalue.value | URL = mw.wikibase.getEntity(Property).claims[ExtIDP][1].mainsnak.datavalue.value | ||
if string.find(Value, "[%%%+%-%*%?]") ~= nil then | if string.find(Value, "[%%%+%-%*%?]") ~= nil and string.find(Value, " ") ~= nil then | ||
FullLink = string.gsub(URL, '$1', mw.uri.encode(Value, "QUERY"):gsub("%%", "%%%%")) | FullLink = string.gsub(URL, '$1', mw.uri.encode(Value, "QUERY"):gsub("%%", "%%%%")) | ||
else | else | ||