Modulo:Categoria per anno: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m s→ret
m aggiornato Modulo:Controllo Wikidata, -everyNS +ns
 
(19 versioni intermedie di un altro utente non mostrate)
Riga 1:
local p = {}
 
local DEFAULT_PROP = 'P571'
function err(msg)
local DEFAULT_CHECK_CAT = 'Data di fondazione o creazione'
local DEFAULT_CHECK_GENRE = 'fs'
 
local function err(msg)
string.format('<span class="error">msg</span>', msg)
end
 
function p._main(args)
local rets = ''
 
args.cat = args[1] or args.cat
local mWikidata, mString, mControlloWd = require('Modulo:Wikidata'), require('Modulo:String'), require('Modulo:Controllo Wikidata')
local from, localValue, catPart, wikidataLabel = args.from, args.localValue, args.catPart, args.wikidataLabel
 
if wikidataValuenot args.cat then
local wikidataProp = args.wikidataProp or 'P571'
return err('richiesto parametro catPartcat')
local wikidataLabelGenere = args.wikidataLabelGenere or 'fs'
end
 
local wikidataValue = mWikidata._getProperty( { wikidataProp, localValue, from = from } )
 
if not catPartargs.prop then
args.prop = DEFAULT_PROP
return err('richiesto parametro catPart')
end
 
local value = require('Modulo:Wikidata')._getProperty( {
if wikidataValue then
args.prop,
-- @TODO mString.match does not work out of a frame
args.value,
local year = mString._match( {
sfrom = wikidataValue,args.from
} )
pattern = '%d%d%d%d',
if value then
nomatch = ''
local year = mw.ustring.match(value, '%d%d%d%d')
} )
if year and year ~= '' then
 
rets = rets .. string.format(
if year and year ~= '' then
args.raw and '%s' or '[[Categoria:%s]]',
ret = ret .. string.format(
string.format(catPartargs.cat, year)
'[[Categoria:%s]]',
string.format(catPart, year)
)
end
end
 
if not args.raw then
ret = ret .. mControlloWd._main( {wikidataProp, localValue, wikidataLabel, genere = wikidataLabelGenere} )
if DEFAULT_PROP == args.prop and not args.checkCat then
args.checkCat = DEFAULT_CHECK_CAT
args.checkGenre = DEFAULT_CHECK_GENRE
end
local check = require('Modulo:Controllo Wikidata')._main( {
args.prop,
args.value,
args.checkCat,
genere = args.checkGenre,
ns = args.ns
} )
if check then
s = s .. check
end
end
 
return rets
end