Module:L
Apparence
La documentation de ce module est générée par le modèle {{Documentation module}}.
Les éditeurs peuvent travailler dans le bac à sable (créer).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
local p = {}
function p.main(frame)
-- Initialisation
local args = frame:getParent().args
if args[1] == nil or args[1] == '' then
return '<span class="error">Erreur modèle L : Aucun nom de page fourni</span>'
end
if args['cat'] == '' then
args['cat'] = nil
end
local page = mw.title.new(args[1])
local pageDebat
-- Création des différents liens internes
local liensInternes = { -- à faire : remplacer "Accès à l’article" par "Accès au modèle", etc. selon l'espace de nom de la page
article = '[[:' .. args[1] .. '|<span title="Accès à l’article">A</span>]]',
discussion = '[[' .. page.talkPageTitle.fullText .. '|<span title="page de discussion de l’article">D</span>]]',
journal = '[' .. tostring(mw.uri.fullUrl( 'Spécial:Journal', 'type=delete&page=' .. args[1] )) .. ' <span title="Journal d’effacement">J</span>]',
}
if page.namespace == 6 then
pageDebat = mw.title.new('Wikipédia:Images à supprimer/' .. (args['cat'] or args[1]))
liensInternes["débat"] = '[[' .. pageDebat.fullText .. '|<span title="Images à supprimer">' .. args[1] .. '</span>]]'
else
pageDebat = mw.title.new(mw.title.new(args['cat'] or args[1]).talkPageTitle.fullText .. '/Admissibilité')
liensInternes["débat"] = '[[' .. pageDebat.fullText .. '|<span title="Débat d\'admissibilité">' .. (args['cat'] and (args[1] .. ' <small>(Débat groupé)</small>)') or args[1]) .. '</span>]]'
end
-- Calcul du nombre de votes
local nb_votes = {
conserver=0,
supprimer=0,
fusionner=0,
autre=0
}
if pageDebat.content then
local linespdd=mw.text.split(pageDebat.content,"\n")
local i=1
local sectionavis=0
local continuer = true
while i <= #linespdd and continuer do
if string.find(linespdd[i], "=== Avis ===") then
if sectionavis==1 then
continuer = false
else
sectionavis=1
i = i + 1
end
elseif string.find(linespdd[i], "==Ancienne discussion") or string.find(linespdd[i], "= Ancienne discussion") then
continuer = false
elseif string.match(linespdd[i], "^====") then
local type_vote
local vote=string.match(linespdd[i], "====%s*(.-)%s*====")
if string.find(vote, "Suppr") then
type_vote = "supprimer"
elseif string.find(vote, "Conserv") then
type_vote = "conserver"
elseif string.find(string.lower(vote), "fusionn") then
type_vote = "fusionner"
else
type_vote = "autre" -- inclut les avis non décomptés
end
i = i + 1
while i <= #linespdd and not string.match(linespdd[i], "^=") do
if string.match(linespdd[i], "^#") and mw.text.trim(linespdd[i]) ~= '#' and not string.match(linespdd[i], "^#:") and not string.match(linespdd[i], "^##") and not string.match(linespdd[i], "^#%*") then
nb_votes[type_vote] = nb_votes[type_vote] + 1
end
i = i + 1
end
else
i = i + 1
end
end
end
return '<small class="plainlinks">[' .. liensInternes["article"] .. ' · ' .. liensInternes["discussion"] .. ' · ' .. liensInternes["journal"] .. ']</small> (' .. nb_votes["conserver"] ..'[[Fichier:Symbol support vote.svg|15px|alt=|link=|'.. nb_votes["conserver"] .. ' votes conserver]] ' .. nb_votes["supprimer"] ..'[[Fichier:Symbol oppose vote.svg|15px|alt=|link=|'.. nb_votes["supprimer"] .. ' votes supprimer]] ' .. nb_votes["fusionner"] ..'[[Fichier:Symbol merge vote.svg|15px|alt=|link=|'.. nb_votes["fusionner"] .. ' votes fusionner]]) ' .. liensInternes["débat"]
end
return p