Módulo:Message box: diferenças entre revisões

Conteúdo apagado Conteúdo adicionado
m restaurando traduções
adotando versão de w:Módulo:Message box e re-implementando especificação "elseif ns == 106 then" (específica do Wikisource)
Linha 3:
 
-- Load necessary modules.
require('ModuleMódulo:No globals')
local getArgs
local yesno = require('ModuleMódulo:Yesno')
 
-- Get a language object for formatDate and ucfirst.
Linha 11:
 
-- Define constants
local CONFIG_MODULE = 'ModuleMódulo:Message box/configuration'
local DEMOSPACES = {
talk = 'tmbox',
image = 'imbox',
file = 'imbox',
category = 'cmbox',
article = 'ambox',
main = 'ambox'},
['discussão'] = 'tmbox',
imagem = 'imbox',
ficheiro = 'imbox',
categoria = 'cmbox',
artigo = 'ambox',
principal = 'ambox',
}
 
--------------------------------------------------------------------------------
Linha 68 ⟶ 81:
 
-- Set the title object and the namespace.
obj.title = getTitleObject(args.page) or getTitleObject(args['página']) or mw.title.getCurrentTitle()
 
-- Set the config for our box type.
Linha 81 ⟶ 94:
-- use template from DEMOSPACES
obj.cfg = cfg[DEMOSPACES[demospace]]
elseif string.find( demospace, 'talk' ) or string.find( demospace, 'Discussão' ) or string.find( demospace, 'discussão' ) then
-- demo as a talk page
obj.cfg = cfg.tmbox
Linha 135 ⟶ 148:
end
if sort then
cat = string.format('[[CategoryCategoria:%s|%s]]', cat, sort)
else
cat = string.format('[[CategoryCategoria:%s]]', cat)
end
self.hasCategories = true
Linha 156 ⟶ 169:
 
-- Get type data.
self.type = args.type or args.tipo
local typeData = cfg.types[self.type]
self.invalidTypeError = cfg.showInvalidTypeError
Linha 162 ⟶ 175:
and not typeData
typeData = typeData or cfg.types[cfg.default]
self.typeClass = typeData.class or typeData.classe
self.typeImage = typeData.image or typeData.imagem
 
-- Find if the box has been wrongly substituted.
Linha 171 ⟶ 184:
self.isSmall = cfg.allowSmall and (
cfg.smallParam and args.small == cfg.smallParam
or cfg.smallParam and args.small == 'esquerda'
or not cfg.smallParam and yesno(args.small)
or cfg.smallParam and args.pequeno == cfg.smallParam
or cfg.smallParam and args.pequeno == 'esquerda'
or not cfg.smallParam and yesno(args.pequeno)
or cfg.smallParam and args.pequena == cfg.smallParam
or cfg.smallParam and args.pequena == 'esquerda'
or not cfg.smallParam and yesno(args.pequena)
)
 
-- Add attributes, classes and styles.
self.id = args.id
self.name = args.name or args.nome
if self.name then
self:addClass('box-' .. string.gsub(self.name,' ','_'))
Linha 190 ⟶ 210:
end
self:addClass(self.typeClass)
self:addClass(if args.class) then
self.style = :addClass(args.styleclass)
self.attrs =elseif args.attrsclasse then
self:addClass(args.classe)
 
end
if args.style then
self.style = args.style
elseif args.estilo then
self.style = args.estilo
end
if args.attrs then
self.attrs = args.attrs
elseif args.atrs then
self.attrs = args.atrs
end
-- Set text style.
self.textstyle =if args.textstyle then
self.textstyle = args.textstyle or args.estilotexto or args['estilo-texto'] or args['estilo_texto']
 
end
-- Find if we are on the template page or not. This functionality is only
-- used if useCollapsibleTextFields is set, or if both cfg.templateCategory
Linha 208 ⟶ 242:
local templateName = mw.ustring.match(
self.name,
'^[tTpP][rR][eE][mMdD][pPeE][lLfF][aAiI][tTnI][eEçÇ][ãÃ][oO][%s_]*:[%s_]*(.*)$'
) or self.name
templateName = 'TemplatePredefinição:' .. templateName
self.templateTitle = getTitleObject(templateName)
end
Linha 221 ⟶ 255:
if self.useCollapsibleTextFields then
-- Get the self.issue value.
local textoPequeno = args.smalltext or args.textopequeno or args['texto-pequeno'] or args['texto_pequeno']
if self.isSmall and args.smalltext then
if self.issueisSmall =and args.smalltexttextoPequeno then
self.issue = textoPequeno
else
local sect
iflocal seccao = args.sect ==or args['secção'] thenor args['seção']
if seccao == '' then
sect = 'This ' .. (cfg.sectionDefault or 'page')
elseif if type(argscfg.sect) == 'string'sectionDefault then
sect = 'ThisEste ' .. argscfg.sectsectionDefault
else
sect = 'Esta página'
end
elseif type(seccao) == 'string' then
sect = seccao
end
local issue = args.issue or args.problema
issue = type(issue) == 'string' and issue ~= '' and issue or nil
local text = args.text or args.texto
text = type(text) == 'string' and text or nil
local issues = {}
Linha 242 ⟶ 282:
 
-- Get the self.talk value.
local talk = args.talk or args['discussão']
-- Show talk links on the template page or template subpages if the talk
-- parameter is blank.
Linha 270 ⟶ 310:
end
if talkTitle and talkTitle.exists then
local talkText = 'Discussão relevante pode ser encontrada em'
if talkArgIsTalkPage then
talkText = string.format(
Linha 280 ⟶ 320:
else
talkText = string.format(
'%s thena [[%s#%s|página de discussão]].',
talkText,
talkTitle.prefixedText,
Linha 291 ⟶ 331:
 
-- Get other values.
self.fix = args.fix ~= '' and args.fix or args.conserto ~= '' and args.conserto or nil
local date
if args.date andthen
if args.date ~= '' then
date = args.date
elseif args.date == '' and self.isTemplatePage then
date = lang:formatDate('F "de" Y')
end
else
if yesno(args.removalnotice)data ~= '' then
date = args.data
elseif args.data == '' and self.isTemplatePage then
date = lang:formatDate('F "de" Y')
end
end
if date then
self.date = string.format(" <small class='date-container'>''(<span class='date'>%s</span>)''</small>", lang:ucfirst(date))
end
self.info = args.info
if yesno(args.removalnotice or args['avisoderemoção'] or args['aviso-de-remoção'] or args['aviso_de_remoção'] or args['avisoremoção'] or args['aviso-remoção'] or args['aviso_remoção']) then
if yesno(args.removalnotice) then
self.removalNotice = cfg.removalNotice
end
Linha 310 ⟶ 358:
-- types other than ambox, and also by ambox when small=yes.
if self.isSmall then
self.text = args.smalltext or args.text or args.textopequeno or args['texto-pequeno'] or args['texto_pequeno'] or args.texto
else
self.text = args.text or args.texto
end
 
-- Set the below row.
self.below = (cfg.below and args.below) or (cfg.below and args.abaixo)
 
-- General image settings.
Linha 322 ⟶ 370:
self.imageEmptyCell = cfg.imageEmptyCell
if cfg.imageEmptyCellStyle then
self.imageEmptyCellStyle = 'border: none; padding: 0px; width:1px'
end
 
-- Left image settings.
local imageLeft = (self.isSmall and args.smallimage or args.image
if or self.isSmall and args.smalltext thenimagempequena
if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none'
or self.isSmall and args['imagem-pequena']
or not cfg.imageCheckBlank and imageLeft ~= 'none'
or self.isSmall and args['imagem_pequena']
or args.image
or args.imagem)
if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none' and imageLeft ~= 'em branco' and imageLeft ~= 'nenhuma'
if or not cfg.imageCheckBlank and imageLeft ~= 'blanknone' and imageLeft ~= 'nonenenhuma'
then
self.imageLeft = imageLeft
Linha 335 ⟶ 388:
and (cfg.imageSmallSize or '30x30px')
or '40x40px'
self.imageLeft = string.format('[[FileFicheiro:%s|%s|link=|alt=]]', self.typeImage
or 'Imbox notice.png', imageSize)
end
Linha 341 ⟶ 394:
 
-- Right image settings.
local imageRight = (self.isSmall and args.smallimageright or args.imageright)
or (self.isSmall and args.imagemdireitapequena)
if not (cfg.imageRightNone and imageRight == 'none') then
or (self.isSmall and args['imagem-direita-pequena'])
or (self.isSmall and args['imagem_direita_pequena'])
or args.imageright or args.imagemdireita or args['imagem-direita'] or args['imagem_direita']
if not ((cfg.imageRightNone and imageRight == 'none') or (cfg.imageRightNone and imageRight == 'nenhuma')) then
self.imageRight = imageRight
end
Linha 356 ⟶ 413:
 
local nums = {}
for _, prefix in ipairs{'cat', 'category', 'all', 'categoria', 'todos'} do
args[prefix .. '1'] = args[prefix]
nums = union(nums, getArgNums(args, prefix))
Linha 362 ⟶ 419:
 
-- The following is roughly equivalent to the old {{Ambox/category}}.
local date = args.date or args.data
date = type(date) == 'string' and date
local preposition = 'fromdesde'
for _, num in ipairs(nums) do
local mainCat = args['cat' .. tostring(num)]
or args['category' .. tostring(num)] or args['categoria' .. tostring(num)]
local allCat = args['all' .. tostring(num)] or args['todos' .. tostring(num)]
mainCat = type(mainCat) == 'string' and mainCat
allCat = type(allCat) == 'string' and allCat
if mainCat and date and date ~= '' then
local catTitle = string.format('%s %s %s', mainCat, preposition, mw.ustring.lower(date))
self:addCat(0, catTitle)
catTitle = getTitleObject('CategoryCategoria:' .. catTitle)
if not catTitle or not catTitle.exists then
self:addCat(0, 'Páginas!Artigos com parâmetro de data inválido naem predefiniçãopredefinições')
end
elseif mainCat and (not date or date == '') then
Linha 432 ⟶ 489:
-- Set categories for all namespaces.
if self.invalidTypeError then
local allSort = (self.title.namespace == 0 and 'MainPrincipal:' or '') .. self.title.prefixedText
self:addCat('all', 'Caixas!Parâmetro de mensagemmessage Wikisourcebox que precisamprecisa de manutençãoconserto', allSort)
end
if self.isSubstituted then
self:addCat('all', '!Páginas com predefinições substituídas incorretamente')
end
end
Linha 458 ⟶ 515:
-- Convert category tables to strings and pass them through
-- [[Module:Category handler]].
return require('ModuleMódulo:Category handler')._main{
main = table.concat(self.categories[0] or {}),
template = table.concat(self.categories[10] or {}),
all = table.concat(self.categories.all or self.categories.todos or {}),
nocat = self.args.nocat or self.args.semcat,
page = self.args.page or self.args['página']
}
end
Linha 469 ⟶ 526:
function MessageBox:export()
local root = mw.html.create()
root:wikitext(mw.getCurrentFrame():extensionTag('templatestyles', '', {src = 'Ambox/styles.css'}))
 
-- Add the subst check error.
Linha 475 ⟶ 533:
:addClass('error')
:wikitext(string.format(
'TemplatePredefinição <code>%s[[TemplatePredefinição:%s|%s]]%s</code> foi substituídosubstituída incorretamente.',
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
))
Linha 579 ⟶ 637:
:css('text-align', 'center')
:wikitext(string.format(
'Esta caixamessage debox mensagemestá estáa usandoutilizar um parâmetro "type=%s" inválido e precisanecessita de manutençãoconserto.',
self.type or ''
))
Linha 613 ⟶ 671:
return function (frame)
if not getArgs then
getArgs = require('ModuleMódulo:Arguments').getArgs
end
return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))