Anonimo

Modulo:DTSem: differenze tra le versioni

Da Wikitrek.
External formatter uri
mNessun oggetto della modifica
(External formatter uri)
 
Riga 1: Riga 1:
-- <nowiki>
--------------------------------------------------------------------------------
-- This module handles generic semantic functions to support modules
-- Comments are compatible with LDoc https://github.com/lunarmodules/ldoc
--
-- @module p
-- @author Luca Mauri [[Utente:Lucamauri]]
-- @keyword: wikitrek
-- Keyword: wikitrek
-- Keyword: wikitrek
--------------------------------------------------------------------------------
local p = {}
local p = {}


Riga 52: Riga 61:
return string.char(10) .. AllLabels
return string.char(10) .. AllLabels
end
end
--------------------------------------------------------------------------------
-- Take parameters out of the frame and pass them to p._buildUniversalIncipit().
-- Return the result.
--
-- @param {Frame} Info from MW session
-- @return {string} The full incipit wikitext
--------------------------------------------------------------------------------
function p.URIFromatterFromDT(frame)
local Item
local Type
Item = mw.wikibase.getEntity()
if not Item then
Item = mw.wikibase.getEntity(frame.args['Item'])
end
if not Item then
Item = mw.wikibase.getEntity('Q1')
end
if (not Item['claims']) or (not Item['claims']['P5']) then
return "ERROR"
else
Type = Item['claims']['P5'][1].mainsnak.datavalue.value
return "[[External formatter uri::" .. Type .. "|''" .. Type .. "'']]"
end
end
--------------------------------------------------------------------------------
-- Generic value parser from arbitrary Item and Property
-- Return the result.
--
-- @param {Item} The Entity
-- @param {Property} String containing the property identifier and number
-- @return {string} Value of the mainsnak
--------------------------------------------------------------------------------
function p.GenericFromDT(Item, Property)
if (not Item['claims']) or (not Item['claims'][Property]) then
return "ERROR"
else
return Item['claims'][Property][1].mainsnak.datavalue.value
end
end
--- Function to calculate the number of seasons of a series
--- Function to calculate the number of seasons of a series
--  
--