Module:Liste1 : Différence entre versions
(Une révision intermédiaire par le même utilisateur non affichée) | |||
Ligne 15 : | Ligne 15 : | ||
supports={} | supports={} | ||
− | local result = mw.ext.cargo.query('Supports','idSupport,video',{groupBy = 'idSupport',limit= | + | local result = mw.ext.cargo.query('Supports','idSupport,video',{groupBy = 'idSupport',limit=3000}) |
for d, row in ipairs(result) do | for d, row in ipairs(result) do | ||
supports[row['idSupport']] = row['video'] | supports[row['idSupport']] = row['video'] | ||
end | end | ||
− | |||
result = mw.ext.cargo.query(query.tables, query.fields, query) | result = mw.ext.cargo.query(query.tables, query.fields, query) | ||
− | |||
if not next(result) then | if not next(result) then | ||
return frame:preprocess(args.default or '') | return frame:preprocess(args.default or '') | ||
Ligne 28 : | Ligne 26 : | ||
local tbl = {} | local tbl = {} | ||
− | |||
for _, row in ipairs(result) do | for _, row in ipairs(result) do | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
if row['video'] == '' then | if row['video'] == '' then | ||
if supports[row['idSupport']] then row['video']=supports[row['idSupport']] end | if supports[row['idSupport']] then row['video']=supports[row['idSupport']] end | ||
Ligne 51 : | Ligne 35 : | ||
local outro = frame:preprocess(args.outro or '') | local outro = frame:preprocess(args.outro or '') | ||
− | return | + | return intro .. table.concat(tbl,args.delimiter or '') .. outro |
end | end | ||
return p | return p |
Version actuelle datée du 10 décembre 2018 à 17:12
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',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
if row['video'] == '' then
if supports[row['idSupport']] then row['video']=supports[row['idSupport']] end
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
end
return p