66 492
contributi
Nessun oggetto della modifica |
(Fallback in case of Title label error) |
||
(40 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 24: | Riga 24: | ||
local Markup | local Markup | ||
if Item['claims']['P37'] then | if Item['claims']['P37'] then | ||
Markup = "<div class='separatorebox'>'''Immagine'''</div>" .. "<div class='contenitoreimgbox'>[[File:" .. Item['claims']['P37'][1].mainsnak.datavalue['value'] .. "|100%]]</div>" | local FileTitle = "File:" .. Item['claims']['P37'][1].mainsnak.datavalue['value'] | ||
local FileCaption = frame:expandTemplate{title = FileTitle} | |||
--Markup = "<div class='separatorebox'>'''Immagine'''</div>" .. "<div class='contenitoreimgbox'>[[File:" .. Item['claims']['P37'][1].mainsnak.datavalue['value'] .. "|100%]]</div>" | |||
--Markup = "<div class='separatorebox'>'''Immagine'''</div>" .. "<div class='contenitoreimgbox'>[[" .. FileTitle .. "|alt={{" .. FileTitle .. "}}|{{" .. FileTitle .. "}}" .. "]]</div>" | |||
Markup = "<div class='separatorebox'>'''Immagine'''</div>" .. "<div class='contenitoreimgbox'>[[" .. FileTitle .. "|alt=" .. FileCaption .. "|" .. FileCaption .. "]]<br /><span style='font-size: smaller;'>" .. FileCaption .. "</span></div>" | |||
else | else | ||
Markup = "" | Markup = "" | ||
Riga 35: | Riga 39: | ||
-- |FileIcona=dsg.png | -- |FileIcona=dsg.png | ||
local ItemQ | local ItemQ | ||
local TitleText | |||
local Item = mw.wikibase.getEntity() | local Item = mw.wikibase.getEntity() | ||
Riga 41: | Riga 46: | ||
end | end | ||
ItemQ = p.QFromP('P14') | ItemQ = p.QFromP('P14') | ||
TitleText = mw.wikibase.getLabelByLang(ItemQ, 'it') | |||
if TitleText == nil then | |||
--Return Q item in case of error processing the label to troubleshoot | |||
TitleText = ItemQ | |||
end | |||
mw.smw.set("Istanza=" .. TitleText) | |||
return TitleText | |||
end | end | ||
function p.ListAllP(frame) | function p.ListAllP(frame) | ||
Riga 56: | Riga 62: | ||
local HTMLTable | local HTMLTable | ||
local CollectionTable = '' | local CollectionTable = '' | ||
local ExcludeP = { | local ExcludeP = {P3 = true, P14 = true, P26 = true, P30 = true, P37 = true, P58 = true, P68 = true, P52 = true, P79 = true, P90 = true} | ||
local Item = mw.wikibase.getEntity() | local Item = mw.wikibase.getEntity() | ||
local ItemQ = mw.wikibase.getEntityIdForCurrentPage() | local ItemQ = mw.wikibase.getEntityIdForCurrentPage() | ||
Riga 68: | Riga 74: | ||
AllP = mw.wikibase.orderProperties(Item:getProperties()) | AllP = mw.wikibase.orderProperties(Item:getProperties()) | ||
--Debug: list unsorted and sorted properties | |||
--AllRows[#AllRows + 1] = {"getProperties:", Item:getProperties()} | |||
--AllRows[#AllRows + 1] = {"AllP:", AllP} | |||
PageTitle = mw.title.getCurrentTitle() | PageTitle = mw.title.getCurrentTitle() | ||
if (mw.wikibase.getLabelByLang(ItemQ, 'en')) and (mw.wikibase.getLabelByLang(ItemQ, 'en')) ~= PageTitle.text then | if (mw.wikibase.getLabelByLang(ItemQ, 'en')) and (mw.wikibase.getLabelByLang(ItemQ, 'en')) ~= PageTitle.text then | ||
AllRows[#AllRows + 1] = {"In originale:", {mw.wikibase.getLabelByLang(ItemQ, 'en')}} | AllRows[#AllRows + 1] = {"In originale:", {mw.wikibase.getLabelByLang(ItemQ, 'en')}} | ||
end | end | ||
if (mw.wikibase.getLabelByLang(ItemQ, 'it')) and (mw.wikibase.getLabelByLang(ItemQ, ' | if (mw.wikibase.getLabelByLang(ItemQ, 'it')) and (mw.wikibase.getLabelByLang(ItemQ, 'it')) ~= PageTitle.text then | ||
AllRows[#AllRows + 1] = {"In italiano:", {mw.wikibase.getLabelByLang(ItemQ, 'it')}} | AllRows[#AllRows + 1] = {"In italiano:", {mw.wikibase.getLabelByLang(ItemQ, 'it')}} | ||
end | end | ||
Riga 91: | Riga 101: | ||
if (type(Value) == "table") then | if (type(Value) == "table") then | ||
if Property == "P72" then --CASE Assigments | if Property == "P72" then --CASE Assigments | ||
AccValues[#AccValues + 1] = LabelOrLink(SnakValue.qualifiers['P73'][1].datavalue.value['id']) .. " " .. LabelOrLink(Value['id']) .. ", " .. LabelOrLink(SnakValue.qualifiers['P76'][1].datavalue.value['id']) .. ", " .. LabelOrLink(SnakValue.qualifiers['P77'][1].datavalue.value['id']) | local Assignment = "" | ||
if SnakValue.qualifiers['P73'] then --Year | |||
Assignment = LabelOrLink(SnakValue.qualifiers['P73'][1].datavalue.value['id']) .. " " | |||
end | |||
if SnakValue.qualifiers['P15'] then | |||
Assignment = Assignment .. SnakValue.qualifiers['P15'][1].datavalue.value .. " " | |||
end | |||
Assignment = Assignment .. LabelOrLink(Value['id']) | |||
if SnakValue.qualifiers['P76'] then --Rank | |||
Assignment = Assignment .. ", " .. LabelOrLink(SnakValue.qualifiers['P76'][1].datavalue.value['id']) | |||
end | |||
if SnakValue.qualifiers['P77'] then --Occupation | |||
Assignment = Assignment .. ", " .. LabelOrLink(SnakValue.qualifiers['P77'][1].datavalue.value['id']) | |||
end | |||
--AccValues[#AccValues + 1] = LabelOrLink(SnakValue.qualifiers['P73'][1].datavalue.value['id']) .. " " .. LabelOrLink(Value['id']) .. ", " .. LabelOrLink(SnakValue.qualifiers['P76'][1].datavalue.value['id']) .. ", " .. LabelOrLink(SnakValue.qualifiers['P77'][1].datavalue.value['id']) | |||
AccValues[#AccValues + 1] = Assignment | |||
elseif Value['entity-type'] == 'item' then | elseif Value['entity-type'] == 'item' then | ||
local GenericItem | |||
if AddSemantic then | if AddSemantic then | ||
GenericItem = LabelOrLink(Value['id'], Header[2]) | |||
else | else | ||
GenericItem = LabelOrLink(Value['id']) | |||
end | end | ||
if SnakValue.qualifiers and SnakValue.qualifiers['P15'] then | |||
GenericItem = SnakValue.qualifiers['P15'][1].datavalue.value .. " " .. GenericItem | |||
end | |||
AccValues[#AccValues + 1] = GenericItem | |||
elseif SnakValue.mainsnak.datavalue['type'] == 'time' then | elseif SnakValue.mainsnak.datavalue['type'] == 'time' then | ||
if AddSemantic then | if AddSemantic then | ||
Riga 104: | Riga 137: | ||
AccValues[#AccValues + 1] = frame:expandTemplate{title = 'TimeL', args = {Tipo='ITEstesa', Istante=Value['time']}} | AccValues[#AccValues + 1] = frame:expandTemplate{title = 'TimeL', args = {Tipo='ITEstesa', Istante=Value['time']}} | ||
end | end | ||
elseif SnakValue.mainsnak.datavalue.type == 'quantity' then | |||
local StringValue | |||
StringValue = string.format('%u', SnakValue.mainsnak.datavalue.value.amount) | |||
if AddSemantic then | |||
mw.smw.set(Header[2] .. "::" .. StringValue) | |||
end | |||
AccValues[#AccValues + 1] = StringValue | |||
else | else | ||
AccValues[#AccValues + 1] = 'TABLE' | AccValues[#AccValues + 1] = 'TABLE' | ||
Riga 135: | Riga 177: | ||
end | end | ||
end | end | ||
--- Function to query for HyperTrek migration data and to construct a proper box | |||
-- to show them, if present | |||
-- @param frame Data from MW session | |||
-- @param AddSemantic Boolean value to instruct about adding SMW prefix | |||
-- @return DIV with HT migration in it or empty string | |||
function p.ListHTData(frame) | |||
local Item = mw.wikibase.getEntity() | |||
if not Item then | |||
Item = mw.wikibase.getEntity('Q1') | |||
end | |||
if AddSemantic == nil then | |||
AddSemantic = true | |||
end | |||
if Item.claims['P79'] then | |||
local DIV = mw.html.create('div') | |||
local DataString | |||
local ImageString | |||
local QualiString = "" | |||
local HTNodes = Item.claims['P79'][1] | |||
ImageString = "[[File:Menu.png|left|middle|30px|HyperTrek logo]]" | |||
DataString = "Informazioni originali lette dal database di '''HyperTrek''' datato " .. frame:expandTemplate{title = 'TimeL', args = {Tipo='ITMedia', Istante=HTNodes.mainsnak.datavalue.value.time}} .. " con i seguenti dettagli: " | |||
for _, Qualifier in pairs(HTNodes.qualifiers) do | |||
QualiString = QualiString .. "<li " .. "title='" .. Qualifier[1].property .. "'>'''" .. mw.wikibase.getLabelByLang(Qualifier[1].property, 'it') .. "''': " .. Qualifier[1].datavalue.value .. "</li>" | |||
end | |||
DIV | |||
:attr('id', 'htdata') | |||
:addClass('htcontainer') | |||
:wikitext(ImageString .. DataString .. "<ul>" .. QualiString .. "</ul>" .. "[[Categoria:Pagine originariamente convertite da HT]]") --.. string.char(10) .. "[[Categoria:Pagine originariamente convertite da HT]]") | |||
return tostring(DIV) | |||
else | |||
return "" | |||
end | |||
end | |||
--[==[ | --[==[ | ||
function p.ExtLinks(frame) | function p.ExtLinks(frame) |