Module:Liste1 : Différence entre versions
Ligne 17 : | Ligne 17 : | ||
local result = mw.ext.cargo.query('Supports','idSupport,video',{groupBy = 'idSupport'}) | local result = mw.ext.cargo.query('Supports','idSupport,video',{groupBy = 'idSupport'}) | ||
for d, row in ipairs(result) do | for d, row in ipairs(result) do | ||
− | supports[row['idSupport']] = | + | supports[row['idSupport']] = row['video'] |
end | end | ||
Ligne 43 : | Ligne 43 : | ||
if row['video'] == '' then | if row['video'] == '' then | ||
--row['video'] = supports[row['idSupport']] | --row['video'] = supports[row['idSupport']] | ||
− | tem=tem.. | + | tem=tem..row['idSupport'] |
end | end | ||
tbl[#tbl+1] = frame:expandTemplate{ title = args.template, args = row } | tbl[#tbl+1] = frame:expandTemplate{ title = args.template, args = row } | ||
Ligne 50 : | Ligne 50 : | ||
local outro = frame:preprocess(args.outro or '') | local outro = frame:preprocess(args.outro or '') | ||
− | + | -- return intro .. table.concat(tbl,args.delimiter or '') .. outro..tem | |
− | + | for a,b in pairs(supports) do | |
+ | tem=tem..'---'..a..'-'..b..'@' | ||
+ | end | ||
+ | return tem | ||
+ | |||
end | end | ||
return p | return p |
Version du 7 décembre 2018 à 20:01
La documentation pour ce module peut être créée à Module:Liste1/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'})
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 = {}
local tem = ''
for _, row in ipairs(result) do
if row['dateDebut'] then
if row['dateFin'] then
local a = string.sub(row['dateDebut'],1,4) + string.sub(row['dateFin'],1,4)
row['annee'] = (a-a%2)/2
else
row['annee'] = string.sub(row['dateDebut'],1,4)
end
elseif row['dateFin'] then
row['annee'] = string.sub(row['dateFin'],1,4)
else
row['annee'] = '?'
end
if row['video'] == '' then
--row['video'] = supports[row['idSupport']]
tem=tem..row['idSupport']
end
tbl[#tbl+1] = frame:expandTemplate{ title = args.template, args = row }
end
local intro = frame:preprocess(args.intro or '')
local outro = frame:preprocess(args.outro or '')
-- return intro .. table.concat(tbl,args.delimiter or '') .. outro..tem
for a,b in pairs(supports) do
tem=tem..'---'..a..'-'..b..'@'
end
return tem
end
return p