66 436
contributi
Nessun oggetto della modifica |
(Item added to References) |
||
(22 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 396: | Riga 396: | ||
else | else | ||
for _, Statement in pairs(Statements) do | for _, Statement in pairs(Statements) do | ||
local | 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/" .. | AllReferences[#AllReferences + 1] = "* [[Special:AboutTopic/" .. ReferenceItem .. "]] - " .. ReferenceItem | ||
else | else | ||
if frame.args['AddSemantic'] then | if frame.args['AddSemantic'] then | ||
Reference = "Riferimento::" .. Reference | |||
end | |||
AllReferences[#AllReferences + 1] = "* [[" .. Reference .. "]] - " .. ReferenceItem | |||
end | end | ||
end | end | ||
Riga 415: | Riga 416: | ||
-- @return A bullet list of backlinks | -- @return A bullet list of backlinks | ||
function p.ListBackReferences(frame) | function p.ListBackReferences(frame) | ||
-- See example here https://github.com/SemanticMediaWiki/SemanticScribunto/blob/master/docs/mw.smw.getQueryResult.md | |||
-- See also here https://doc.semantic-mediawiki.org/md_content_extensions_SemanticScribunto_docs_mw_8smw_8getQueryResult.html | |||
local AllBackReferences = {} | local AllBackReferences = {} | ||
--[=[ | --[=[ | ||
Riga 439: | Riga 442: | ||
--local QueryResult = mw.smw.getQueryResult('[[Riferimento::' .. mw.title.getCurrentTitle().text .. ']]|?DataTrek ID') | --local QueryResult = mw.smw.getQueryResult('[[Riferimento::' .. mw.title.getCurrentTitle().text .. ']]|?DataTrek ID') | ||
--local queryResult = mw.smw.getQueryResult( frame.args ) | --local queryResult = mw.smw.getQueryResult( frame.args ) | ||
local | local QueryResult = mw.smw.getQueryResult('[[Riferimento::' .. mw.title.getCurrentTitle().text .. ']]|?DataTrek ID') | ||
if | if QueryResult == nil then | ||
return " | return "''Nessun risultato''" | ||
end | end | ||
if type( | if type(QueryResult) == "table" then | ||
local | local Row = "" | ||
for k,v in pairs( | for k, v in pairs(QueryResult.results) do | ||
if v.fulltext and v.fullurl then | --[=[if v.fulltext and v.fullurl then | ||
myResult = myResult .. k .. " | " .. v.fulltext .. " " .. v.fullurl .. " | " .. "<br/>" | myResult = myResult .. k .. " | " .. v.fulltext .. " " .. v.fullurl .. " | " .. "<br/>" | ||
else | else | ||
myResult = myResult .. k .. " | no page title for result set available (you probably specified ''mainlabel=-')" | myResult = myResult .. k .. " | no page title for result set available (you probably specified ''mainlabel=-')" | ||
end]=] | |||
if string.sub(v.fulltext, 1, 5) == "File:" then | |||
Row = "[[:" .. v.fulltext .. "]]" --string.sub(v.fulltext, 3) | |||
else | |||
Row = "[[" .. v.fulltext .. "]]" | |||
end | end | ||
if v.printouts['DataTrek ID'][1] ~= nil then | |||
Row = Row .. " - " .. v.printouts['DataTrek ID'][1] | |||
end | |||
AllBackReferences[#AllBackReferences + 1] = "*" .. Row | |||
end | end | ||
return table.concat(AllBackReferences, string.char(10)) | |||
else | |||
return "''No table''" | |||
end | end | ||
return queryResult | return queryResult | ||
end | end | ||
return p | return p |