Modul:License
Aspect
| Acest format utilizează Lua: |
Implementează {{licență}}.
require('strict')
local p = {} --p stands for package
local getArgs = require('Modul:Arguments').getArgs
function p._license(args)
local frame = mw.getCurrentFrame()
-- Parameters
local text = frame:preprocess(args.text or '{{{text}}}')
local image = args.image or args.imagine
local image_r = args.image_r or args['image-r'] or args['imagine_d']
local image_size = args.image_size or args['image-size'] or args['dim_imagine'] or 'x48px'
local image_r_size = args.image_r_size or args['image-r-size'] or args['dim_imagine_d'] or image_size
local warning = args.warning or args.avertisment
local category = args.category or args.categorie
local category2 = args.category2 or args.categorie2
if category == '' then
category = nil
end
if category2 == '' then
category2 = nil
end
-- license banner
local leftField = mw.html.create('div')
if image then
leftField
:newline()
:tag('span')
:addClass('imageLeft')
:wikitext('[[Fișier:' .. image .. '|' .. image_size .. '|alt=|link=]]')
:done()
:newline()
else
leftField
:newline()
:tag('span')
:addClass('noimageLeft')
:done()
:newline()
end
local centerField = mw.html.create('div')
:tag('div')
:newline()
:wikitext(text)
:newline()
:allDone()
if warning then
centerField
:tag('div')
:tag('div')
:newline()
:wikitext('[[Fișier:OOjs UI icon alert destructive black-darkred.svg|35px]]')
:newline()
:done()
:tag('div')
:newline()
:wikitext(warning)
:allDone()
end
local rightField = mw.html.create('div')
if image_r then
rightField
:newline()
:tag('span')
:addClass('imageRight')
:wikitext('[[Fișier:' .. image_r .. '|' .. image_r_size .. '|alt=|link=]]')
:done()
:newline()
else
rightField
:newline()
:tag('span')
:addClass('noimageRight')
:done()
:newline()
end
local licenseBanner = mw.html.create('div')
:tag('div')
:tag('div')
:node(leftField)
:node(centerField)
:node(rightField)
:allDone()
-- Commons auto-detection
local commonsAutoDetection = mw.html.create('div')
:addClass('licensetpl')
:newline()
:tag('span')
:addClass('licensetpl_short')
:wikitext('Domeniu public')
:done()
:tag('span')
:addClass('licensetpl_long')
:wikitext('Domeniu public')
:done()
:tag('span')
:addClass('licensetpl_link_req')
:wikitext('fals')
:done()
:tag('span')
:addClass('licensetpl_attr_req')
:wikitext('fals')
:done()
:newline()
:allDone()
-- Categorization
local namespace = args.namespace or args['spațiu_de_nume'] or mw.title.getCurrentTitle().nsText
local noCatNamespaces = {
['Ajutor'] = true,
['Discuție Ajutor'] = true,
['Format'] = true,
['Discuție Format'] = true,
['Wikisource'] = true,
['Discuție Wikisource'] = true,
['Modul'] = true,
['Discuție Modul'] = true,
['Categorie'] = true,
['Discuție Categorie'] = true
}
local categoryContent = ''
if not noCatNamespaces[namespace] then
if namespace == 'Autor' or namespace == 'Discuție Autor' then
if category then
category = 'Autor-' .. category
end
if category2 then
category2 = 'Autor-' .. category2
end
end
if category then
category = '[[Categorie:' .. category .. ']]'
end
if category2 then
category2 = '[[Categorie:' .. category2 .. ']]'
end
categoryContent = (category or '') .. (category2 or '')
end
-- licenseContainer is the class that styles depend on
local overallDiv = mw.html.create('div')
:addClass('licenseContainer licenseBanner dynlayout-exempt')
:addClass(args['clasă'])
:attr('id', args.id)
:node(licenseBanner)
:node(commonsAutoDetection)
:wikitext(categoryContent)
local templateStyles = frame:extensionTag('templatestyles', '', {src = 'Format:Licență/styles.css'})
return templateStyles .. tostring(overallDiv)
end
function p.license(frame)
return p._license(getArgs(frame))
end
return p