66 383
contributi
(Item added to References) |
(New labels for Interwiki) |
||
(25 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 = '[[ | 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 | 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 | |||
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 = " | 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 = " | 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 474: | Riga 485: | ||
return queryResult | return queryResult | ||
end | end | ||
--- Writes a gneric UL list from property, adding SMW link if specified | |||
-- | |||
-- @param PName Info from MW session | |||
-- @param SMWPrefix | |||
-- @return A bullet list of backlinks | |||
function p.PropertyList(frame) | |||
--{{#invoke:DTBase|PropertyList|P59|Scritto da}} | |||
local AllReferences = {} | |||
local Item = mw.wikibase.getEntityIdForCurrentPage() | |||
if not Item then | |||
Item = 'Q1' | |||
end | |||
local Statements = mw.wikibase.getAllStatements(Item, frame.args["Property"]) | |||
if not Statements then | |||
return "Nessun riferimento trovato" | |||
elseif table.getn(Statements) == 1 then | |||
return p.LabelOrLink(Statements[1].mainsnak.datavalue.value.id, frame.args["SMWPrefix"], true) | |||
else | |||
for _, Statement in pairs(Statements) do | |||
--local ReferenceItem = Statement.mainsnak.datavalue.value.id | |||
AllReferences[#AllReferences + 1] = "<li>" .. p.LabelOrLink(Statement.mainsnak.datavalue.value.id, frame.args["SMWPrefix"], true) .. "</li>" | |||
end | |||
return "<ul>" .. table.concat(AllReferences, string.char(10)) .. "</ul>" | |||
end | |||
end | |||
return p | return p |