Anonimo

Modulo:DTBase: differenze tra le versioni

Da Wikitrek.
New labels for Interwiki
mNessun oggetto della modifica
(New labels for Interwiki)
(33 versioni intermedie di uno stesso utente non sono mostrate)
Riga 46: Riga 46:
end
end
function p.Categories(frame)
function p.Categories(frame)
local Opening = '[[Categoria:'
local Opening = '[[Category:'
local CategoryP = 'P30'
local CategoryP = 'P30'
local AbbrP = 'P24'
local AbbrP = 'P24'
Riga 116: Riga 116:
itwiki = 'Wikipedia (inglese)',
itwiki = 'Wikipedia (inglese)',
dema = 'Memory Alpha (tedesco)',
dema = 'Memory Alpha (tedesco)',
demb = 'Memory Beta (tedesco)'
demb = 'Memory Beta (tedesco)',
fanlore = 'Fanlore',
trekipedia = 'Trekipedia'
}
}
Riga 287: Riga 289:
local WTLink
local WTLink
if (not AddSemantic) and SMWProperty and (SMWProperty ~= "") then
if AddSemantic and SMWProperty and (SMWProperty ~= "") then
AddSemantic = true
AddSemantic = true
else
else
Riga 308: Riga 310:
end
end
if not mw.wikibase.getSitelink(QItem) then
if not mw.wikibase.getSitelink(QItem) and string.find(Label, "Categoria:", 1, true) == nil then
--if mw.wikibase.getSitelink(QItem) == nil or (not mw.wikibase.getSitelink(QItem)) then
--if mw.wikibase.getSitelink(QItem) == nil or (not mw.wikibase.getSitelink(QItem)) then
return Label
--return Label
--https://wikitrek.org/wiki/Speciale:AboutTopic/Q64
return "[[Special:AboutTopic/" .. QItem .. "|" .. Label .. "]]"
else
else
WTLink = Item.sitelinks['wikitrek'].title
if Item.sitelinks == nil then
WTLink = Label
else
WTLink = Item.sitelinks['wikitrek'].title
end
if not Label then
if not Label then
Label = WTLink
Label = WTLink
end
end
if AddSemantic then
if string.find(WTLink, "Categoria:", 1, true) ~= nil then
return "[[" .. WTLink .. "]]"
elseif AddSemantic then
return "[[" .. SMWProperty .. "::" .. WTLink .. "|" .. Label .. "]]"
return "[[" .. SMWProperty .. "::" .. WTLink .. "|" .. Label .. "]]"
else
else
Riga 352: Riga 363:
if not Item["P7"] then
if not Item["P7"] then
Previous = "no prev"
Previous = "''nessuno''"
else
else
Previous = p.LabelOrLink(Item["P7"][1].datavalue.value.id)
Previous = p.LabelOrLink(Item["P7"][1].mainsnak.datavalue.value.id)
end
end
if not Item["P23"] then
if not Item["P23"] then
Next = "no next"
Next = "''nessuno''"
else
else
Next = p.LabelOrLink(Item["P23"][1].datavalue.value.id)
Next = p.LabelOrLink(Item["P23"][1].mainsnak.datavalue.value.id)
end
end
Riga 396: Riga 407:
else
else
for _, Statement in pairs(Statements) do
for _, Statement in pairs(Statements) do
local Reference = mw.wikibase.getSitelink(Statement.mainsnak.datavalue.value.id)
local ReferenceItem = Statement.mainsnak.datavalue.value.id
local Reference = mw.wikibase.getSitelink(ReferenceItem)
if not Reference then
if not Reference then
Reference = Statement.mainsnak.datavalue.value.id
--Reference = Statement.mainsnak.datavalue.value.id
AllReferences[#AllReferences + 1] = "* [[Special:AboutTopic/" .. Reference .. "]]"
AllReferences[#AllReferences + 1] = "* [[Special:AboutTopic/" .. ReferenceItem .. "]] - " .. ReferenceItem
else
else
if frame.args['AddSemantic'] then
if frame.args['AddSemantic'] then
Reference = "Riferimento::" .. Reference
Reference = "Riferimento::" .. Reference
end
end
AllReferences[#AllReferences + 1] = "* [[" .. Reference .. "]]"
AllReferences[#AllReferences + 1] = "* [[" .. Reference .. "]] - " .. ReferenceItem
end
end
end
end
Riga 460: Riga 472:
Row = "[[" .. v.fulltext .. "]]"
Row = "[[" .. v.fulltext .. "]]"
             end
             end
             Row = Row .. " - " .. v.printouts['DataTrek ID'][1]
             if v.printouts['DataTrek ID'][1] ~= nil then
            Row = Row .. " - " .. v.printouts['DataTrek ID'][1]
            end
           
AllBackReferences[#AllBackReferences + 1] = "*" .. Row
AllBackReferences[#AllBackReferences + 1] = "*" .. Row
         end
         end
Riga 470: Riga 485:
     return queryResult
     return queryResult
end
end
--- Generates a table of episodes with details using SMW query.
--- Writes a gneric UL list from property, adding SMW link if specified
--  
--  
-- @frame Info from MW session
-- @param PName Info from MW session
-- @return A table with episodes list and details
-- @param SMWPrefix
function p.EpisodesTable(frame)
-- @return A bullet list of backlinks
local Value
function p.PropertyList(frame)
local Selection
--{{#invoke:DTBase|PropertyList|P59|Scritto da}}
local Item = mw.wikibase.getEntity()
local AllReferences = {}
local Item = mw.wikibase.getEntityIdForCurrentPage()
if not Item then
if not Item then
Item = mw.wikibase.getEntity('Q1')
Item = 'Q1'
end
end
if Item.claims[P90][1] then
local Statements = mw.wikibase.getAllStatements(Item, frame.args["Property"])
if Item.claims[P18][1] then
if not Statements then
Selection = "[[Istanza::" .. "]][[Stagione::" .. "]]"
return "Nessun riferimento trovato"
else
elseif table.getn(Statements) == 1 then
Selection = "[[Istanza::" .. "]]"
return p.LabelOrLink(Statements[1].mainsnak.datavalue.value.id, frame.args["SMWPrefix"], true)
end
else
else
return "No P90"
for _, Statement in pairs(Statements) do
end
--local ReferenceItem = Statement.mainsnak.datavalue.value.id
 
AllReferences[#AllReferences + 1] = "<li>" .. p.LabelOrLink(Statement.mainsnak.datavalue.value.id, frame.args["SMWPrefix"], true) .. "</li>"
Value = Item['claims'][Property][1].mainsnak.datavalue['value']
local QueryResult = mw.smw.ask(Selection .. '|?Titolo italiano|?Numero di produzione|?Data di trasmissione|format=broadtable|sort=Numero di produzione|order=asc|class=sortable wikitable smwtable')
end
--- Prepares the selection for the SMW query to generate a list of episodes
-- with details using SMW query.
--
-- @frame Info from MW session
-- @return Query text
function p.EpisodesQuerySelection(frame)
local Value
local Selection
local Item = mw.wikibase.getEntity()
if not Item then
Item = mw.wikibase.getEntity('Q1')
end
if Item.claims['P90'] then
if Item.claims['P18'] then
Selection = "[[Istanza::{{#property:P90}}]][[Stagione::{{#property:P18}}]]"
else
Selection = "[[Istanza::{{#property:P90}}]]"
end
end
return Selection
return "<ul>" .. table.concat(AllReferences, string.char(10)) .. "</ul>"
else
return "No P90"
end
end
end
end
return p
return p