« Module:Icône de titre » : différence entre les versions

De Lagny-sur-Marne Wiki
Aller à la navigation Aller à la recherche
0x010D (discussion | contributions)
Nouvelle page : local p = {} function p.main(frame) local args = {} local argsParent = frame:getParent().args --Paramètres vides interprétés par Lua for cle, val in pairs(argsParent) do...
 
0x010D (discussion | contributions)
Aucun résumé des modifications
 
(14 versions intermédiaires par le même utilisateur non affichées)
Ligne 4 : Ligne 4 :
local args = {}
local args = {}
local argsParent = frame:getParent().args
local argsParent = frame:getParent().args
 
--Paramètres vides interprétés par Lua
--Paramètres vides interprétés par Lua
for cle, val in pairs(argsParent) do
for cle, val in pairs(argsParent) do
if val ~= '' then
if val ~= '' then
--args[cle] = mw.text.trim(val)
args[cle] = mw.text.trim(val)
args[mw.ustring.lower(cle)] = mw.text.trim(val)
end
end
end
end
 
return p._main(args)
return p._main(args)
end
end
 
function p._main(args)
function p._main(args)
local res = mw.html.create('div')
local res = mw.html.create()
local fichierWiki = '[[Fichier:%s|%spx|link=%s|%s|alt=%s]]'
local iconeTitre = mw.html.create()
local frame = mw.getCurrentFrame()
res
local fichierWiki = '[[Fichier:%s|%spx|link=%s|%s|%s|alt=%s]]'
:addClass('icone_de_titre')
local argsId = args.id
:css('display', 'none')
local nowiki = frame:extensionTag{name = 'nowiki'}
:css('float', 'right')
 
:css('margin-top', '1em')
iconeTitre
:tag('span')
:wikitext(mw.ustring.format(fichierWiki,
:attr('title', args.texte or 'Exemple de texte')
args.image or 'Fairytale bookmark.png',
:wikitext(mw.ustring.format(fichierWiki,
args.taille or 20,
args.image or 'Fairytale bookmark.png',
args.lien or 'Modèle:Icône de titre',
args.taille or 20,
args['paramètre'] or '',
args.lien or 'Modèle:Icône de titre',
args.texte or 'Exemple de texte',
args['paramètre'] or '',
args.texte or 'Exemple de texte'))
args.texte or 'Exemple de texte'))
 
if not args.id then
return tostring(res)
local nsPage = mw.title.getCurrentTitle().namespace
if nsPage == 2 or nsPage == 3 then
argsId = args.image or 'Fairytale bookmark.png'
end
end
 
res:wikitext(frame:extensionTag('indicator', tostring(iconeTitre), {name = argsId}))
 
if not args.id then
res:wikitext('[[Catégorie:Page utilisant une icône de titre sans identifiant]]')
end
 
return nowiki .. tostring(res)
end
end


return p
return p

Dernière version du 15 juin 2015 à 15:08

local p = {}

function p.main(frame) local args = {} local argsParent = frame:getParent().args

--Paramètres vides interprétés par Lua for cle, val in pairs(argsParent) do if val ~= then args[cle] = mw.text.trim(val) end end

return p._main(args) end

function p._main(args) local res = mw.html.create() local iconeTitre = mw.html.create() local frame = mw.getCurrentFrame() local fichierWiki = '%s' local argsId = args.id local nowiki = frame:extensionTag{name = 'nowiki'}

iconeTitre

		:wikitext(mw.ustring.format(fichierWiki,

args.image or 'Fairytale bookmark.png', args.taille or 20, args.lien or 'Modèle:Icône de titre', args['paramètre'] or , args.texte or 'Exemple de texte', args.texte or 'Exemple de texte'))

if not args.id then local nsPage = mw.title.getCurrentTitle().namespace if nsPage == 2 or nsPage == 3 then argsId = args.image or 'Fairytale bookmark.png' end end

res:wikitext(frame:extensionTag('indicator', tostring(iconeTitre), {name = argsId}))

if not args.id then res:wikitext() end

return nowiki .. tostring(res) end

return p