-
Notifications
You must be signed in to change notification settings - Fork 0
/
wikitrek-DTBase.lua
589 lines (520 loc) · 20.1 KB
/
wikitrek-DTBase.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
-- [P2G] Auto upload by PageToGitHub on 2024-10-31T00:01:29+01:00
-- [P2G] This code from page Modulo:wikitrek-DTBase
--- This module represent the package containing basic functions to access data from the WikiBase instance DataTrek
-- @module p
-- @author Luca Mauri [[Utente:Lucamauri]]
-- Add other authors below
-- Keyword: wikitrek
local p = {}
function p.Epilogo(frame)
local DoubleReturn = string.char(10) .. string.char(10)
return frame:expandTemplate{ title = 'paginecheportanoqui' } .. DoubleReturn .. "== Collegamenti esterni ==" .. DoubleReturn .. p.ExtLinks(frame) .. DoubleReturn .. "==" .. frame:expandTemplate{ title = 'Etichetta', args = {Tipo=Annotazioni} } .. "==" .. string.char(10) .. mw.text.nowiki("<references/>") .. DoubleReturn .. string.char(10) .. frame:expandTemplate{ title = 'NavGlobale' } .. "categorie"
end
function p.ExtLinks(frame)
local AllRows = ""
local Item = mw.wikibase.getEntity()
if not Item then
Item = mw.wikibase.getEntity('Q1')
end
local LinksStatements = Item:getAllStatements('P26')
for _, LinkStatement in pairs(LinksStatements) do
local LinkURI = LinkStatement.mainsnak.datavalue['value']
local LinkTitle = LinkStatement['qualifiers']['P20'][1].datavalue['value']
local LinkID
local LinkWiki
local ExternalIDList = ""
if not LinkStatement['qualifiers']['P19'] then
LinkWiki = frame:expandTemplate{title='LinkTrek', args={LinkURI, LinkTitle}}
else
LinkID = LinkStatement['qualifiers']['P19'][1].datavalue['value']
LinkWiki = "[" .. LinkURI .. " ''" .. mw.text.nowiki(LinkTitle) .. "''], " .. LinkID
end
if not AllRows then
AllRows = "* " .. LinkWiki
else
AllRows = AllRows .. string.char(10) .. "* " .. LinkWiki
end
end
--[=[
if not AllRows then
--AllRows = "''Nessun collegamento generico [[:datatrek:Item:" .. mw.wikibase.getEntityIdForCurrentPage() .. "|trovato su DataTrek]]''"
AllRows = "''Nessun collegamento generico trovato su DataTrek''"
end
]=]
if AllRows ~= "" then
AllRows = AllRows .. string.char(10) .. string.char(10)
end
ExternalIDList = p.ExternalID()
if ExternalIDList ~= nil and ExternalIDList ~= "" then
ExternalIDList = string.char(10) .. "=== Identificativi esterni ===" .. string.char(10) .. ExternalIDList
end
return AllRows .. "=== Interwiki ===" .. string.char(10) .. p.SiteLinksInterwiki() .. ExternalIDList
end
function p.Categories(frame)
local Opening = '[[Category:'
local CategoryP = 'P30'
local AbbrP = 'P24'
local SeriesP = 'P16'
local InstanceQ
local SeriesQ
local SeriesItem
local AllCategories = {}
local Item = mw.wikibase.getEntity()
if not Item then
Item = mw.wikibase.getEntity('Q1')
end
--Categories manually inserted into the Item
local ItemCategories = Item:getAllStatements(CategoryP)
for _, ItemCategory in pairs(ItemCategories) do
AllCategories[#AllCategories + 1] = Opening .. ItemCategory.mainsnak.datavalue['value'] .. ']]'
end
--Categories from the Instance's Item
InstanceQ = mw.wikibase.getEntity(Item['claims']['P14'][1].mainsnak.datavalue.value['id'])
local InstanceCategories = InstanceQ:getAllStatements(CategoryP)
local ItemSeries = Item:getAllStatements(SeriesP)
for _, InstanceCategory in pairs(InstanceCategories) do
local InstanceValue = InstanceCategory.mainsnak.datavalue['value']
AllCategories[#AllCategories + 1] = Opening .. InstanceValue .. ']]' --InstanceCategory.mainsnak.datavalue['value'] .. ']]'
--Category generated joining the item's Instance category plus the Series short name IF it exists
if ItemSeries then
for _, ItemSer in pairs(ItemSeries) do
SeriesItem = mw.wikibase.getEntity(ItemSer.mainsnak.datavalue.value['id'])
AllCategories[#AllCategories + 1] = Opening .. InstanceValue .. " di " .. SeriesItem.claims[AbbrP][1].mainsnak.datavalue['value'] .. ']]' --SeriesItem.labels['it'].value .. ']]'
end
end
end
--Non ha senso aggiungere categoria per la serie perchè diventerebbe troppo grande
--[=[SeriesQ = mw.wikibase.getEntity(Item['claims']['P16'][1].mainsnak.datavalue.value['id'])
local SeriesCategories = SeriesQ:getAllStatements(CategoryP)
for _, SeriesCategory in pairs(SeriesCategories) do
AllCategories[#AllCategories + 1] = Opening .. InstanceCategory.mainsnak.datavalue['value'] .. " DI " .. SeriesCategory.mainsnak.datavalue['value'] .. ']]'
end]=]
return table.concat(AllCategories, string.char(10))
end
function p.SiteLinksInterwiki()
-- Esempio
-- [[:memoryalpha:{{{Nome}}}|''{{{Nome}}}'']], Memory Alpha
local AllLinks = {}
local Item = mw.wikibase.getEntity()
if not Item then
return "''Nessun collegamento generico trovato su DataTrek''"
end
local SiteLinks = Item['sitelinks']
local Titles = {
wikitrek = 'WikiTrek',
datatrek = 'DataTrek',
enma = 'Memory Alpha (inglese)',
itma = 'Memory Alpha (italiano)',
enmb = 'Memory Beta (inglese)',
sto = 'Star Trek Online wiki',
wikidata = 'Pagina della entità su Wikidata',
enwiki = 'Wikipedia (inglese)',
itwiki = 'Wikipedia (italiano)',
dewiki = 'Wikipedia (tedesco)',
dema = 'Memory Alpha (tedesco)',
demb = 'Memory Beta (tedesco)',
fanlore = 'Fanlore',
trekipedia = 'Trekipedia'
}
for _, SiteLink in pairs(SiteLinks) do
local TitleLabel
TitleLabel = Titles[SiteLink['site']] or SiteLink['site']
if string.find(string.lower(TitleLabel), 'datatrek') then
-- Un link a DataTrek deve portare alla Entità
-- Questo non dovrebbe mai esistere lo aggiungo a mano alla fine del ciclo
AllLinks[#AllLinks + 1] = "* [[:" .. SiteLink['site'] .. ":Item:" .. mw.wikibase.getEntityIdForCurrentPage() .. "|''" .. SiteLink['title'] .. "'']], Pagina della entità su " .. TitleLabel
elseif string.find(string.lower(TitleLabel), 'wikitrek') then
-- Il link a WikiTrek va ignorato perchè è autoreferenziale
else
AllLinks[#AllLinks + 1] = "* [[:" .. SiteLink['site'] .. ":" .. SiteLink['title'] .. "|''" .. SiteLink['title'] .. "'']], " .. TitleLabel
end
end
-- Interlink a DataTrek
AllLinks[#AllLinks + 1] = "* [[" .. 'datatrek' .. ":Item:" .. Item.id .. "|''" .. Item.id .. "'']], Pagina della entità su " .. Titles['datatrek']
--AllLinks[#AllLinks + 1] = "* [[" .. 'datatrek' .. ":Item:" .. mw.wikibase.getEntityIdForCurrentPage() .. "'']], Pagina della entità su " .. Titles['datatrek']
return table.concat(AllLinks, string.char(10))
end
function p.ExternalID()
local AllExtID = {}
local Item = mw.wikibase.getEntity()
local AllP
if not Item then
Item = mw.wikibase.getEntity('Q1')
end
AllP = mw.wikibase.orderProperties(Item:getProperties())
for _, Property in pairs(AllP) do
if Item.claims[Property][1].mainsnak.datatype == 'external-id' then
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))
-- Sets semantic property
mw.smw.set((mw.wikibase.getLabelByLang(Property, 'it') or mw.wikibase.getLabel(Property)) .. " = " .. Item.claims[Property][1].mainsnak.datavalue.value)
end
end
return table.concat(AllExtID, string.char(10))
end
--------------------------------------------------------------------------------
-- Return a URL for the external IDentifier
--
-- @param Property The P beign processed
-- @param The ID value itself
--
-- @return string String containing escaped URL
--------------------------------------------------------------------------------
function p.ExtIDLink(Property, Value)
local ExtIDP = 'P5'
local URL
local FullLink
URL = mw.wikibase.getEntity(Property).claims[ExtIDP][1].mainsnak.datavalue.value
if string.find(Value, "[%%%+%-%*%?]") ~= nil then
FullLink = string.gsub(URL, '$1', mw.uri.encode(Value, "QUERY"):gsub("%%", "%%%%"))
else
FullLink = string.gsub(URL, '$1', Value)
end
return FullLink
end
function p.LinkToEntity(frame, AddSemantic)
-- La URI si otterrebbe con
-- mw.wikibase.getEntityUrl()
-- ma noi usiamo uno InterWiki link
local Text
local p = mw.html.create('p')
if not AddSemantic then
AddSemantic = true
end
if mw.wikibase.getEntity() then
if AddSemantic then
Text = "Modifica i dati nella [[DataTrek ID::" .. mw.wikibase.getEntityIdForCurrentPage() .. "|pagina della entità]] su ''DataTrek''"
else
Text = "Modifica i dati nella [[datatrek:Item:" .. mw.wikibase.getEntityIdForCurrentPage() .. "|pagina della entità]] su ''DataTrek''"
end
else
Text = "Impossibile trovare l'entità collegata"
end
p
:css('font-size', 'smaller')
:css('text-align', 'right')
:css('margin', '1px')
:wikitext(Text)
return tostring(p)
end
--------------------------------------------------------------------------------
-- Set the semantic property for the linked DataTrek entity on the current page
--
-- @param frame The frame of the page
--------------------------------------------------------------------------------
function p.SemanticToEntity(frame)
if mw.wikibase.getEntity() ~= nil then
mw.smw.set("DataTrek ID = " .. mw.wikibase.getEntityIdForCurrentPage())
end
end
--------------------------------------------------------------------------------
-- Set the semantic property for the linked DataTrek entity on the current page
-- to be used as a plain text string
--
-- @param frame The frame of the page
--------------------------------------------------------------------------------
function p.SemanticToItem(frame)
if mw.wikibase.getEntity() ~= nil then
mw.smw.set("DataTrek Item = " .. mw.wikibase.getEntityIdForCurrentPage())
mw.smw.set("DataTrek ID = " .. mw.wikibase.getEntityIdForCurrentPage())
end
end
function p.LabelByLang(frame)
local Item = mw.wikibase.getEntityIdForCurrentPage()
local Lang = frame.args['Lingua']
if not Item then
Item = 'Q1'
end
return mw.wikibase.getLabelByLang(Item, Lang)
end
function p.LabelByLang2(frame)
local Lang = frame.args['Lingua']
local Item = frame.args['Item']
if not Lang then
Lang = 'it'
end
if not Item then
Item = mw.wikibase.getEntityIdForCurrentPage()
end
if not Item then
Item = 'Q1'
end
return mw.wikibase.getLabelByLang(Item, Lang)
end
function p.ItemIcon()
-- |FileIcona=dsg.png
local IconFileName
local Item = mw.wikibase.getEntity()
if not Item then
Item = mw.wikibase.getEntity('Q1')
end
--SeriesQ = Item['claims']['P16'][1]['mainsnak'].datavalue['value']['id']
--FileName = mw.wikibase.getEntity(SeriesQ)['claims']['P3'][1]['mainsnak'].datavalue['value']
IconFileName = Item['claims']['P3'][1].mainsnak.datavalue['value']
return IconFileName
end
function p.ItemIconCascade()
-- |FileIcona=dsg.png
local IconFileName
local Item = mw.wikibase.getEntity()
if not Item then
Item = mw.wikibase.getEntity('Q1')
end
if Item['claims']['P3'] then
-- Item icon has higher priority
IconFileName = Item['claims']['P3'][1].mainsnak.datavalue['value']
elseif Item['claims']['P22'] then
-- Else takes icon from "TIPO"
IconFileName = mw.wikibase.getEntity(Item['claims']['P22'][1].mainsnak.datavalue.value.id)['claims']['P3'][1].mainsnak.datavalue['value']
else
-- If everything fails, takes icon from "ISTANZA"
IconFileName = mw.wikibase.getEntity(Item['claims']['P14'][1].mainsnak.datavalue.value.id)['claims']['P3'][1].mainsnak.datavalue['value']
end
return IconFileName
end
function p.ItemImage()
local ImageFileName
local Item = mw.wikibase.getEntity()
if not Item then
Item = mw.wikibase.getEntity('Q1')
end
ImageFileName = Item['claims']['P37'][1].mainsnak.datavalue['value']
return ImageFileName
end
function p.GenericValue(Property)
-- |FileIcona=dsg.png
local Value
local Item = mw.wikibase.getEntity()
if not Item then
Item = mw.wikibase.getEntity('Q1')
end
Value = Item['claims'][Property][1].mainsnak.datavalue['value']
if not Value then
Value = "''Proprietà non trovata''"
end
return Value
end
--------------------------------------------------------------------------------
-- Return a label ora wikilink or a link to the special Placeholder page for a
-- given Property
-- Return string containing label or link
--
-- @param QItem The item identifier in the from 'Q0'
-- @param[opt=nil] SMWProperty Name of the semantic property to add
-- @param[opt=false] AddSemantic Wether to add sematinc or not
-- @param[opt=""] ForcedLabel Specific label to show regardless DataTrek values
-- @param[opt=false] ForceString Force to return string even in case of Page
-- that should return link
--
-- @treturn string String containing label or wikilink
--------------------------------------------------------------------------------
function p.LabelOrLink(QItem, SMWProperty, AddSemantic, ForcedLabel, ForceString)
local Label
local WTLink
if AddSemantic and SMWProperty and (SMWProperty ~= "") then
AddSemantic = true
else
AddSemantic = false
end
ForceString = ForceString or false
local Item = mw.wikibase.getEntity(QItem)
if Item == nil then
return "'''Error'''"
end
if ForcedLabel ~= "" and ForcedLabel ~= nil then
Label = ForcedLabel
elseif not Item['claims'] or not Item['claims']['P20'] then
Label = Item.labels['it'].value
else
Label = Item['claims']['P20'][1].mainsnak.datavalue['value']
end
if false then
return Label
end
if not mw.wikibase.getSitelink(QItem) and string.find(Label, "Categoria:", 1, true) == nil then
--https://wikitrek.org/wiki/Speciale:AboutTopic/Q64
if AddSemantic then
mw.smw.set(SMWProperty .. "=" .. Label)
end
if ForceString then
return Label
else
return "[[Special:AboutTopic/" .. QItem .. "|" .. Label .. "]]"
end
else
if Item.sitelinks == nil then
WTLink = Label
else
WTLink = Item.sitelinks['wikitrek'].title
end
if not Label then
Label = WTLink
end
if ForceString then
return WTLink
end
if string.find(WTLink, "Categoria:", 1, true) ~= nil then
return "[[" .. WTLink .. "]]"
elseif AddSemantic then
return "[[" .. SMWProperty .. "::" .. WTLink .. "|" .. Label .. "]]"
else
return "[[" .. WTLink .. "|" .. Label .. "]]"
end
end
end
--- Three dashes indicate the beginning of a function or field documented
-- using the LDoc format
-- @param Item Father of Previous and Next
-- @param[opt="Navigatore"] Title
-- @return Table
function p.MakeNavTable(Item, Title)
--[[
<div class="separatorebox">
'''Navigatore episodi'''
</div>
{{{!}} class="wikitable" style="width:100%"
<!-- {{!}}+ Navigatore episodi -->
!< Precedente
!Successivo >
{{!}}-
{{!}} style="text-align:center; width:50%;" {{!}}{{#invoke:DTEpisodio|LinkPrevious}}
{{!}} style="text-align:center;" {{!}}{{#invoke:DTEpisodio|LinkNext}}
{{!}}}
]]
local Previous
local Next
local Table
--Title = Title or "Navigatore"
if not Item then
Item = mw.wikibase.getEntity("Q1")
end
if not Item["P7"] then
Previous = "''nessuno''"
elseif Item["P7"][1].mainsnak == nil then
Previous = p.LabelOrLink(Item["P7"][1].datavalue.value.id)
else
Previous = p.LabelOrLink(Item["P7"][1].mainsnak.datavalue.value.id)
end
if not Item["P23"] then
Next = "''nessuno''"
elseif Item["P23"][1].mainsnak == nil then
Next = p.LabelOrLink(Item["P23"][1].datavalue.value.id)
else
Next = p.LabelOrLink(Item["P23"][1].mainsnak.datavalue.value.id)
end
--Table = "<div class='separatorebox'>'''" .. Title .. "'''</div>"
--Table = Table .. string.char(10) .. "<table class='wikitable' style='width:100%'>"
Table = "<table class='wikitable' style='width:100%'>"
if Title ~= nil then
Table = Table .. string.char(10) .. "<caption>" .. Title .. "</caption>"
end
Table = Table .. string.char(10) .. "<tr><th id='P7' title='P7'>< Precedente</th><th id='P23' title='P23'>Successivo ></th></tr>"
Table = Table .. string.char(10) .. "<tr><td style='text-align:center; width:50%;'>" .. Previous .. "</td>"
Table = Table .. string.char(10) .. "<td style='text-align:center; width:50%;'>" .. Next .. "</td></tr>"
Table = Table .. string.char(10) .. "</table>"
return Table
end
function p.SiteAllP()
local MaxP = 10
local AllP = {}
for PNumber = 1, MaxP, 1 do
if mw.wikibase.entityExists('P' .. PNumber) then
AllP[#AllP + 1] = 'P' .. PNumber
end
end
return table.concat("* " .. AllP, string.char(10))
end
function p.ListReferences(frame)
local AllReferences = {}
local Item = mw.wikibase.getEntityIdForCurrentPage()
if not Item then
Item = 'Q1'
end
local Statements = mw.wikibase.getAllStatements(Item, 'P58')
if not Statements then
return "Nessun riferimento trovato"
else
for _, Statement in pairs(Statements) do
local ReferenceItem = Statement.mainsnak.datavalue.value.id
local Reference = mw.wikibase.getSitelink(ReferenceItem)
if not Reference then
--Reference = Statement.mainsnak.datavalue.value.id
AllReferences[#AllReferences + 1] = "* [[Special:AboutTopic/" .. ReferenceItem .. "]] - " .. ReferenceItem .. " - " .. mw.wikibase.getLabelByLang(mw.wikibase.getEntity(ReferenceItem).claims['P14'][1].mainsnak.datavalue.value.id, "it")
else
if frame.args['AddSemantic'] then
Reference = "Riferimento::" .. Reference
end
AllReferences[#AllReferences + 1] = "* [[" .. Reference .. "]] (" .. mw.wikibase.getLabelByLang(mw.wikibase.getEntity(ReferenceItem).claims['P14'][1].mainsnak.datavalue.value.id, "it") .. ")"
end
end
return table.concat(AllReferences, string.char(10))
end
end
--- generates a list of backlink using SMW query.
--
-- @param frame Info from MW session
-- @return A bullet list of backlinks
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 QueryResult = mw.smw.getQueryResult('[[Riferimento::' .. mw.title.getCurrentTitle().text .. ']]|?DataTrek ID|?Istanza')
if QueryResult == nil then
return "''Nessun risultato''"
end
if type(QueryResult) == "table" then
local Row = ""
local ImagesList = ""
local ResultText = ""
for k, v in pairs(QueryResult.results) do
if string.sub(v.fulltext, 1, 5) == "File:" then
--IF the back reference is a media, don't list it, but show the thumbnail only
--Row = "[[:" .. v.fulltext .. "]]"
ImagesList = ImagesList .. v.fulltext .. "|" .. frame:expandTemplate{ title = v.fulltext} .. string.char(10)
else
Row = "[[" .. v.fulltext .. "]]"
if v.printouts['DataTrek ID'][1] ~= nil then
Row = Row .. " - " .. v.printouts['DataTrek ID'][1]
if v.printouts['Istanza'][1] ~= nil then
Row = Row .. " - " .. v.printouts['Istanza'][1].fulltext
end
end
AllBackReferences[#AllBackReferences + 1] = "*" .. Row
end
end
ResultText = table.concat(AllBackReferences, string.char(10))
ResultText = "<div style='column-count:3;-moz-column-count:3;-webkit-column-count:3'>" .. string.char(10) .. ResultText .. string.char(10) .. "</div>"
if not (ImagesList == nil or ImagesList == "") then
ResultText = ResultText .. string.char(10) .. "=== Immagini collegate ===" .. string.char(10) .. frame:extensionTag( "gallery", ImagesList)
end
return ResultText --table.concat(AllBackReferences, string.char(10))
else
return "''No table''"
end
return QueryResult
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