Module:Liste3 : Différence entre versions
(23 révisions intermédiaires par un autre utilisateur non affichées) | |||
Ligne 33 : | Ligne 33 : | ||
end | end | ||
− | local debut = | + | local debut = 1900 |
− | local periode,nb = | + | local periode,nb = 10,0 |
local d,f = debut,debut+periode | local d,f = debut,debut+periode | ||
− | |||
local retour, tbl = '',{''} | local retour, tbl = '',{''} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | epoques = { | + | local epoques = {} |
− | n = 1 | + | local n = 1 |
− | epoques[n] = { | + | epoques[n] = {d..' > '..f,{}} |
− | |||
for _,row in ipairs(result) do | for _,row in ipairs(result) do | ||
if row['annee'] >= f + 1 then | if row['annee'] >= f + 1 then | ||
Ligne 67 : | Ligne 48 : | ||
d,f,n = f,f+periode,n+1 | d,f,n = f,f+periode,n+1 | ||
epoques[n] = {} | epoques[n] = {} | ||
− | epoques[n | + | epoques[n] = {d..' > '..f, {}} |
end | end | ||
table.insert(epoques[n][2], row) | table.insert(epoques[n][2], row) | ||
Ligne 73 : | Ligne 54 : | ||
for _,epoque in ipairs(epoques) do | for _,epoque in ipairs(epoques) do | ||
− | retour = retour .. epoque[1] ..' | + | retour = retour .. frame:expandTemplate{ title = 'Banniere2', args = {Titre = epoque[1] ..'<span class="toHide"> : </span><span class="periodeNbFilms">' .. #epoque[2] .. ' films</span>'}} |
− | for | + | local nn |
+ | for n,film in ipairs(epoque[2]) do | ||
+ | if n == 4 then | ||
+ | retour = retour .. '\n <div class="mw-collapsible mw-collapsed"><div class="mw-collapsible-content">' | ||
+ | end | ||
retour = retour .. frame:expandTemplate{ title = args.template, args = film} | retour = retour .. frame:expandTemplate{ title = args.template, args = film} | ||
+ | nn = n | ||
+ | end | ||
+ | if nn > 4 then | ||
+ | retour = retour .. '</div></div>' | ||
end | end | ||
end | end | ||
− | |||
local intro = frame:preprocess(args.intro or '') | local intro = frame:preprocess(args.intro or '') |
Version actuelle datée du 1 février 2021 à 17:49
La documentation pour ce module peut être créée à Module:Liste3/doc
local p = {}
function p.main(frame)
if frame == mw.getCurrentFrame() then
args = require('Module:ProcessArgs').merge(true)
else
frame = mw.getCurrentFrame()
end
local query = {}
for k, v in pairs(args) do
if string.sub(k, 0, 2) == 'q?' then
query[string.sub(k, 3)] = v
end
end
supports={}
local result = mw.ext.cargo.query('Supports','idSupport,video',{groupBy = 'idSupport',limit=3000})
for d, row in ipairs(result) do
supports[row['idSupport']] = row['video']
end
result = mw.ext.cargo.query(query.tables, query.fields, query)
if not next(result) then
return frame:preprocess(args.default or '')
end
local tbl = {}
for _, row in ipairs(result) do
row['annee'] = tonumber(row['annee'])
if row['video'] == '' then
if supports[row['idSupport']] then row['video']=supports[row['idSupport']] end
end
end
local debut = 1900
local periode,nb = 10,0
local d,f = debut,debut+periode
local retour, tbl = '',{''}
local epoques = {}
local n = 1
epoques[n] = {d..' > '..f,{}}
for _,row in ipairs(result) do
if row['annee'] >= f + 1 then
while row['annee'] > f + periode do
d,f = f,f+periode
end
d,f,n = f,f+periode,n+1
epoques[n] = {}
epoques[n] = {d..' > '..f, {}}
end
table.insert(epoques[n][2], row)
end
for _,epoque in ipairs(epoques) do
retour = retour .. frame:expandTemplate{ title = 'Banniere2', args = {Titre = epoque[1] ..'<span class="toHide"> : </span><span class="periodeNbFilms">' .. #epoque[2] .. ' films</span>'}}
local nn
for n,film in ipairs(epoque[2]) do
if n == 4 then
retour = retour .. '\n <div class="mw-collapsible mw-collapsed"><div class="mw-collapsible-content">'
end
retour = retour .. frame:expandTemplate{ title = args.template, args = film}
nn = n
end
if nn > 4 then
retour = retour .. '</div></div>'
end
end
local intro = frame:preprocess(args.intro or '')
local outro = frame:preprocess(args.outro or '')
return intro .. retour .. outro
end
return p