Módulo:Testes/Gkiyoshinishimoto/Protected edit request/active
Aspeto
Este módulo é usado internamente por Módulo:Testes/Gkiyoshinishimoto/Protected edit request e não é útil em nenhum outro lugar.
require('strict')
local yesno, makeMessageBox -- passado a partir de Módulo:Testes/Gkiyoshinishimoto/Protected edit request
local makeToolbar = require('Módulo:Testes/Gkiyoshinishimoto/Toolbar')._main
local getPagetype = require('Módulo:Testes/Gkiyoshinishimoto/Pagetype')._main
local effectiveProtectionLevel = require('Módulo:Testes/Gkiyoshinishimoto/Effective protection level')._main
----------------------------------------------------------------------
-- Funções auxiliares
----------------------------------------------------------------------
local function makeWikilink(page, display)
if display then
return mw.ustring.format('[[%s|%s]]', page, display)
else
return mw.ustring.format('[[%s]]', page)
end
end
----------------------------------------------------------------------
-- Classe de título
----------------------------------------------------------------------
-- Esta é basicamente a classe "mw.title" com alguns extras adicionados.
local title = {}
title.__index = title
function title.getProtectionLevelText(protectionLevel)
-- Obtém o texto para usar em âncoras e ligações ('links') de urna.
local levels = {unprotected = 'editunprotected', autoconfirmed = 'editsemiprotected', extendedconfirmed = 'editextendedprotected', autoreviewer = 'editautoreviewprotected', templateeditor = 'edittemplateprotected', sysop = 'editprotected', interfaceadmin = 'editinterfaceprotected'}
return levels[protectionLevel]
end
function title.new(...)
local success, obj = pcall(mw.title.new, ...)
if not (success and obj) then return end
title.init(obj)
return obj
end
function title.init(obj)
-- Adiciona uma propriedade protectionLevel.
obj.protectionLevel = effectiveProtectionLevel(obj.exists and 'edit' or 'create', obj)
if obj.protectionLevel == '*' then
-- Faz com que as páginas desprotegidas retornem "unprotected".
obj.protectionLevel = 'unprotected'
elseif obj.protectionLevel == 'user' then
-- Se nós só precisamos ser registrados, finge que precisamos ser autoconfirmados, já que é o mais próximo que temos.
obj.protectionLevel = 'autoconfirmed'
end
-- Adiciona uma propriedade "pagetype".
obj.pagetype = getPagetype{page = obj.prefixedText, defaultns = 'all'}
-- Adiciona métodos de criação de ligações ('links').
function obj:makeUrlLink(query, display)
return mw.ustring.format('[%s %s]', self:fullUrl(query), display)
end
function obj:makeViewLink(display)
return self:makeUrlLink({redirect = 'no'}, display)
end
function obj:makeEditLink(display)
return self:makeUrlLink({action = 'edit'}, display)
end
function obj:makeHistoryLink(display)
return self:makeUrlLink({action = 'history'}, display)
end
function obj:makeLastEditLink(display)
return self:makeUrlLink({diff = 'cur', oldid = 'prev'}, display)
end
function obj:makeWhatLinksHereLink(display)
return makeWikilink('Especial:Páginas afluentes/' .. self.prefixedText, display)
end
function obj:makeCompareLink(otherTitle, display)
display = display or 'diff'
local comparePagesTitle = title.new('Especial:Comparar páginas')
return comparePagesTitle:makeUrlLink({page1 = self.prefixedText, page2 = otherTitle.prefixedText}, display)
end
function obj:makeLogLink(logType, display)
local logTitle = title.new('Especial:Registo')
return logTitle:makeUrlLink({type = logType, page = self.prefixedText}, display)
end
function obj:urlEncode()
return mw.uri.encode(self.prefixedText, 'WIKI')
end
function obj:makeUrnLink(boxProtectionLevel)
-- Gera uma ligação ('link') de urna. O nível de proteção é obtido da predefinição, em vez de detectado na própria página,
-- pois a detecção pode ser imprecisa para páginas protegidas em cascata e na lista negra de títulos a partir de novembro de 2013.
local protectionLinkText = title.getProtectionLevelText(boxProtectionLevel)
return mw.ustring.format('[urn:x-wp-%s:%s <span></span>]', protectionLinkText, self:urlEncode())
end
-- Obtém um objeto de título de subpágina, mas passa por "pcall" em vez de usar o "mw.title:subPageTitle" desprotegido.
function obj:getSubpageTitle(subpage)
return title.new(self.prefixedText .. '/' .. subpage)
end
function obj:getSandboxTitle()
if self.isSubpage and self.contentModel == 'sanitized-css' then
local success2, obj2 = pcall(mw.title.makeTitle, self.namespace, self.baseText .. '/Testes/' .. self.subpageText)
if success2 and obj2 then
title.init(obj2)
return obj2
end
end
return self:getSubpageTitle('Testes')
end
end
----------------------------------------------------------------------
-- Classe "TitleTable"
----------------------------------------------------------------------
local titleTable = {}
titleTable.__index = titleTable
function titleTable.new(args)
-- Obtém argumentos numéricos e cria objetos de título para cada um deles.
local nums = {}
for k, v in pairs(args) do
if type(k) == 'number' then
table.insert(nums, k)
end
end
table.sort(nums)
local titles = {}
for _, num in ipairs(nums) do
local title = title.new(args[num])
table.insert(titles, title)
end
-- Obtém o título atual e obtém o título de assunto se nenhum título for especificado.
titles.currentTitle = mw.title.getCurrentTitle()
if #titles < 1 then
local subjectNs = titles.currentTitle.subjectNsText
if subjectNs ~= '' then
subjectNs = subjectNs .. ':'
end
table.insert(titles, title.new(subjectNs .. titles.currentTitle.text))
end
-- Define a metatabela.
setmetatable(titles, titleTable)
return titles
end
function titleTable:memoize(memoField, func, ...)
if self[memoField] ~= nil then
return self[memoField]
else
self[memoField] = func(...)
return self[memoField]
end
end
function titleTable:titleIterator()
local i = 0
local n = #self
return function()
i = i + 1
if i <= n then
return self[i]
end
end
end
function titleTable:hasSameProperty(memoField, getPropertyFunc)
-- Se a tabela de títulos tiver mais de um título, verifica se eles têm a mesma propriedade.
-- A propriedade é encontrada usando a função "getPropertyFunc", que usa um objeto de título como seu único argumento.
local function hasSameProperty(getPropertyFunc)
local property
for i, obj in ipairs(self) do
if i == 1 then
property = getPropertyFunc(obj)
elseif getPropertyFunc(obj) ~= property then
return false
end
end
return true
end
return self:memoize(memoField, hasSameProperty, getPropertyFunc)
end
function titleTable:hasSameExistenceStatus()
-- Retorna "true" (verdadeiro) se todos os títulos existirem ou se todos não existirem. Retorna "false" (falso) se houver uma mistura de estado ('status') de existência.
return self:hasSameProperty('sameExistenceStatus', function (title) return title.exists end)
end
function titleTable:hasSameProtectionStatus()
-- Verifica se todos os títulos têm o mesmo estado ('status') de proteção (seja para proteção de criação ou para proteção de edição - os dois não se misturam).
local sameExistenceStatus = self:hasSameExistenceStatus()
if sameExistenceStatus then
return self:hasSameProperty('sameProtectionStatus', function (title) return title.protectionLevel end)
else
return sameExistenceStatus
end
end
function titleTable:hasSamePagetype()
-- Verifica se todos os títulos têm o mesmo tipo de página ("pagetype").
return self:hasSameProperty('samePagetype', function (title) return title.pagetype end)
end
function titleTable:propertyExists(memoField, getPropertyFunc)
-- Verifica se existe um título com uma determinada propriedade.
-- A propriedade é encontrada usando a função "getPropertyFunc", que usa um objeto de título como seu único argumento
-- e deve retornar um valor booleano.
local function propertyExists(getPropertyFunc)
for titleObj in self:titleIterator() do
if getPropertyFunc(titleObj) then
return true
end
end
return false
end
return self:memoize(memoField, propertyExists, getPropertyFunc)
end
function titleTable:hasNonInterfacePage()
return self:propertyExists('nonInterfacePage', function (titleObj) return titleObj.namespace ~= 8 end)
end
function titleTable:hasTemplateOrModule()
return self:propertyExists('templateOrModule', function (titleObj) return titleObj.namespace == 10 or titleObj.namespace == 828 end)
end
function titleTable:hasNonTemplateOrModule()
return self:propertyExists('nontemplateormodule', function (titleobj) return titleobj.namespace ~= 10 and titleobj.namespace ~= 828 end)
end
function titleTable:hasOtherProtectionLevel(level)
for titleObj in self:titleIterator() do
if titleObj.protectionLevel ~= level then
return true
end
end
return false
end
function titleTable:getProtectionLevels()
local function getProtectionLevels()
local levels = {}
for titleObj in self:titleIterator() do
local level = titleObj.protectionLevel
levels[level] = true
end
return levels
end
return self:memoize('protectionLevels', getProtectionLevels)
end
----------------------------------------------------------------------
-- Definição de classe Blurb
----------------------------------------------------------------------
local blurb = {}
blurb.__index = blurb
function blurb.new(titleTable, boxProtectionLevel)
local obj = {}
obj.titles = titleTable
obj.boxProtectionLevel = boxProtectionLevel
obj.linkCount = 0 -- Contador para o número total de itens nas listas de ligações ('links') do objeto.
setmetatable(obj, blurb)
return obj
end
-- Métodos estáticos --
function blurb.makeParaText(name, val)
local pipe = mw.text.nowiki('|')
local equals = mw.text.nowiki('=')
val = val and ("''" .. val .. "''") or ''
return mw.ustring.format('<code style="white-space: nowrap;">%s%s%s%s</code>', pipe, name, equals, val)
end
function blurb.makeTemplateLink(s)
return mw.ustring.format('%s[[Predefinição:%s|%s]]%s', mw.text.nowiki('{{'), s, s, mw.text.nowiki('}}'))
end
function blurb:makeProtectionText()
local boxProtectionLevel = self.boxProtectionLevel
local levels = {['*'] = 'sem proteção', autoconfirmed = 'com semiproteção ao nível de usuários confirmados', extendedconfirmed = 'com semiproteção ao nível de autoconfirmados estendidos', autoreviewer = 'com semiproteção ao nível de autorrevisores', templateeditor = 'com proteção ao nível de editores de predefinições', sysop = 'com proteção', interfaceadmin = 'com proteção ao nível de administradores de interface'}
for level, protectionText in pairs(levels) do
if level == boxProtectionLevel then
return mw.ustring.format('%s', protectionText)
end
end
error('Nível de proteção desconhecido ' .. boxProtectionLevel)
end
function blurb.getPagetypePlural(title)
local pagetype = title.pagetype
if pagetype == 'article' then
return 'páginas de artigos'
elseif pagetype == 'user page' then
return 'páginas de usuários'
elseif pagetype == 'project page' then
return 'páginas de projetos'
elseif pagetype == 'file' then
return 'páginas de ficheiros'
elseif pagetype == 'interface page' then
return 'páginas de interface'
elseif pagetype == 'template' then
return 'páginas de predefinições'
elseif pagetype == 'help page' then
return 'páginas de ajuda'
elseif pagetype == 'category' then
return 'páginas de categorias'
elseif pagetype == 'portal' then
return 'páginas de portais'
elseif pagetype == 'draft' then
return 'páginas de rascunhos'
elseif pagetype == 'Timed Text page' then
return 'página de textos temporizados'
elseif pagetype == 'module' then
return 'páginas de módulos'
elseif pagetype == 'topic' then
return 'páginas de tópicos'
elseif pagetype == 'gadget' then
return 'páginas de gadgets'
elseif pagetype == 'gadget definition' then
return 'página de definições de gadgets'
elseif pagetype == 'talk page' then
return 'páginas de discussões'
elseif pagetype == 'special page' then
return 'páginas especiais'
end
end
function blurb.getPagetypePt(title)
local pagetype = title.pagetype
if pagetype == 'article' then
return 'página de artigo'
elseif pagetype == 'user page' then
return 'página de usuário'
elseif pagetype == 'project page' then
return 'página de projeto'
elseif pagetype == 'file' then
return 'página de ficheiro'
elseif pagetype == 'interface page' then
return 'página de interface'
elseif pagetype == 'template' then
return 'página de predefinição'
elseif pagetype == 'help page' then
return 'página de ajuda'
elseif pagetype == 'category' then
return 'página de categoria'
elseif pagetype == 'portal' then
return 'página de portal'
elseif pagetype == 'draft' then
return 'página de rascunho'
elseif pagetype == 'Timed Text page' then
return 'página de texto temporizado'
elseif pagetype == 'module' then
return 'página de módulo'
elseif pagetype == 'topic' then
return 'página de tópico'
elseif pagetype == 'gadget' then
return 'página de gadget'
elseif pagetype == 'gadget definition' then
return 'página de definição de gadget'
elseif pagetype == 'talk page' then
return 'página de discussão'
elseif pagetype == 'special page' then
return 'página especial'
end
end
-- Métodos normais --
function blurb:makeLinkList(title)
local tbargs = {} -- A lista de argumentos para passar para Módulo:Testes/Gkiyoshinishimoto/Toolbar
tbargs.style = 'font-size: smaller;'
tbargs.separator = 'dot'
-- Ligações ('links') de página.
table.insert(tbargs, title:makeEditLink('editar'))
table.insert(tbargs, title:makeHistoryLink('histórico'))
table.insert(tbargs, title:makeLastEditLink('edição mais recente'))
table.insert(tbargs, title:makeWhatLinksHereLink('afluentes'))
-- Ligações ('links') de Testes.
local sandboxTitle = title:getSandboxTitle()
if sandboxTitle and sandboxTitle.exists then
table.insert(tbargs, sandboxTitle:makeViewLink('página de testes'))
table.insert(tbargs, sandboxTitle:makeEditLink('editar página de testes'))
table.insert(tbargs, sandboxTitle:makeHistoryLink('histórico página de testes'))
table.insert(tbargs, sandboxTitle:makeLastEditLink('edição mais recente na página de testes'))
table.insert(tbargs, title:makeCompareLink(sandboxTitle, 'diferenças em relação à página de testes'))
end
-- Ligações ('links') de Exemplos para testes.
local testcasesTitle = title:getSubpageTitle('Exemplos para testes')
if testcasesTitle and testcasesTitle.exists then
table.insert(tbargs, testcasesTitle:makeViewLink('Exemplos para testes'))
end
-- Ligação ('link') para contagem de transclusões.
if title.namespace == 10 or title.namespace == 828 then -- Apenas adiciona a ligação ('link') de contagem de transclusões para predefinições e módulos.
local tclink = mw.uri.new{
host = 'templatecount.toolforge.org',
path = '/index.php',
query = {
lang = 'pt',
name = title.text,
namespace = title.namespace,
},
fragment = 'bottom'
}
tclink = string.format('[%s contagem de transclusões]', tostring(tclink))
table.insert(tbargs, tclink)
end
-- Ligação ('link') de registro de proteção.
if title.namespace ~= 8 then -- As páginas de MediaWiki não têm entradas de registro de proteção
table.insert(tbargs, title:makeLogLink('protect', 'registro de proteção'))
end
self.linkCount = self.linkCount + #tbargs -- Mantém o número total de ligações ('links') criadas pelo objeto.
return makeToolbar(tbargs)
end
function blurb:makeLinkLists()
local titles = self.titles
if #titles == 1 then
return self:makeLinkList(titles[1])
else
local ret = {}
table.insert(ret, '<ul>')
for i, titleObj in ipairs(titles) do
table.insert(ret, mw.ustring.format('<li>%s %s</li>', titleObj:makeViewLink(titleObj.prefixedText), self:makeLinkList(titleObj)))
end
table.insert(ret, '</ul>')
return table.concat(ret)
end
end
function blurb:makeIntro()
local titles = self.titles
local requested = 'É solicitado que'
local protectionText
if titles:hasNonInterfacePage() then
protectionText = ' ' .. self:makeProtectionText()
else
protectionText = '' -- As páginas de 'interface' não podem ser desprotegidas, portanto não precisamos dizer explicitamente que estão protegidas.
end
-- Lida com casos em que recebemos vários títulos.
if #titles > 1 then
local pagetype
if titles:hasSamePagetype() then
pagetype = blurb.getPagetypePlural(titles[1])
else
pagetype = 'páginas'
end
return mw.ustring.format("'''%s edições sejam feitas em %s %s''':", requested, pagetype, protectionText)
end
-- Trata de casos em que nos é passado apenas um título.
local title = titles[1]
local stringToFormat
if title.exists then
stringToFormat = '%s uma edição seja feita em %s (%s %s).'
else
stringToFormat = '%s que %s receba proteção de %s %s.'
end
stringToFormat = "'''" .. stringToFormat .. "'''"
local pagetype = blurb.getPagetypePt(titles[1])
return mw.ustring.format(stringToFormat, requested, title:makeViewLink(title.prefixedText), pagetype, protectionText)
end
function blurb:makeBody()
local titles = self.titles
local protectionLevels = titles:getProtectionLevels()
local boxProtectionLevel = self.boxProtectionLevel
local hasNonInterfacePage = titles:hasNonInterfacePage()
local isPlural = false
if #titles > 1 then
isPlural = true
end
local descriptionText = "Esta predefinição precisa ser seguida por uma '''descrição completa e específica''' da solicitação, "
if boxProtectionLevel == 'sysop' or boxProtectionLevel == 'templateeditor' then
local editText = 'a edição solicitada'
if isPlural then
editText = 'as edições solicitadas'
end
local descriptionCompleteText = mw.ustring.format('para que até mesmo um editor que não é familiarizado com o assunto possa completar rapidamente %s.', editText)
descriptionText = descriptionText .. descriptionCompleteText
else
descriptionText = descriptionText .. 'ou seja, especifique qual texto deve ser removido e uma cópia literal do texto que deve substituí-lo. '
.. [["Por favor, altere ''X''" '''não é aceitável''' e será rejeitado; a solicitação '''deve''' estar no formato "Por favor, altere ''X'' para ''Y''".]]
end
local smallText = ''
if boxProtectionLevel == 'sysop' or boxProtectionLevel == 'templateeditor' then
local templateFullText
if boxProtectionLevel == 'sysop' then
templateFullText = 'protegidas'
elseif boxProtectionLevel == 'templateeditor' then
templateFullText = 'protegidas ao nível de editores de predefinições'
end
smallText = 'Solicitações de edição para as páginas ' .. templateFullText .. " devem ser usadas apenas para edições que sejam '''incontroversas''' ou apoiadas por [[Wikipédia:Consenso|consenso]]."
.. " Se a edição proposta for controversa, discuta-a na página de discussão da página protegida '''antes''' de usar esta predefinição."
else
local userText
local responseTemplate
if boxProtectionLevel == 'autoreviewer' then
userText = 'usuário [[Wikipédia:Tipos de usuários#Autorrevisores|autorrevisor]]'
responseTemplate = blurb.makeTemplateLink('ERp')
elseif boxProtectionLevel == 'extendedconfirmed' then
userText = 'usuário [[Wikipédia:Tipos de usuários#Autoconfirmados estendidos|autoconfirmado estendido]]'
responseTemplate = blurb.makeTemplateLink('EEp')
elseif boxProtectionLevel == 'autoconfirmed' then
userText = 'usuário [[Wikipédia:Tipos de usuários#Autoconfirmados|autoconfirmado]]'
responseTemplate = blurb.makeTemplateLink('ESp')
elseif boxProtectionLevel == 'interfaceadmin' then
userText = '[[Wikipédia:Administradores de interface|administrador de interface]]'
responseTemplate = blurb.makeTemplateLink('EIp')
else
userText = 'usuário'
responseTemplate = blurb.makeTemplateLink('ESp')
end
local answeredPara = blurb.makeParaText('answered', 'no')
local stringToFormat = 'A edição pode ser realizada por qualquer %s. '
.. [[Lembre-se de alterar o parâmetro %s para "'''yes'''" quando a solicitação for aceita, rejeitada ou em espera aguardando entrada do usuário. ]]
.. "Isso ocorre para que solicitações inativas ou concluídas não preencham desnecessariamente a categoria de solicitações de edição. "
.. 'Você também pode usar a predefinição %s na resposta.'
smallText = mw.ustring.format(stringToFormat, userText, answeredPara, responseTemplate)
end
if not isPlural then
local title = titles[1]
if title.namespace == 10 or title.namespace == 828 then
local pagetype = blurb.getPagetypePt(titles[1])
local sandboxTitle = title:getSubpageTitle('Testes')
if sandboxTitle and sandboxTitle.exists then
smallText = smallText .. ' Considere fazer as mudanças na '
.. sandboxTitle:makeViewLink("página de testes desta " .. pagetype)
local testcasesTitle = title:getSubpageTitle('Exemplos para testes')
if testcasesTitle and testcasesTitle.exists then
smallText = smallText .. ' e ' .. testcasesTitle:makeViewLink('teste-as minuciosamente aqui')
end
smallText = smallText .. ' antes de enviar uma solicitação de edição.'
end
end
end
if hasNonInterfacePage then
smallText = smallText .. ' Para solicitar que uma página seja [[Wikipédia:Pedidos/Proteção|protegida]] ou [[Wikipédia:Pedidos/Desproteção|desprotegida]], faça uma [[Wikipédia:Pedidos|solicitação]].'
end
if boxProtectionLevel == 'sysop' or boxProtectionLevel == 'templateeditor' or boxProtectionLevel == 'interfaceadmin' then
smallText = smallText .. ' Quando a solicitação for concluída ou negada, adicione o parâmetro ' .. blurb.makeParaText('answered', 'yes') .. ' para desativar a predefinição.'
end
return mw.ustring.format('%s\n<p style="font-size:smaller; line-height:1.3em;">\n%s\n</p>', descriptionText, smallText)
end
function blurb:export()
local intro = self:makeIntro()
local linkLists = self:makeLinkLists()
local body = self:makeBody()
-- Inicia longas listas de ligações ('links') em uma nova linha.
local linkListSep = ' '
if self.linkCount > 5 then
linkListSep = '<br />'
end
return mw.ustring.format('%s%s%s\n\n%s', intro, linkListSep, linkLists, body)
end
----------------------------------------------------------------------
-- Subclasse de classe de caixa para caixas ativas de "Módulo:Testes/Gkiyoshinishimoto/Protected edit request"
----------------------------------------------------------------------
local box = {}
box.__index = box
function box.new(protectionType, args)
-- No sistema de herança usado aqui, a metatabela de um objeto é sua classe e a metatabela de uma classe é sua superclasse.
local obj = getmetatable(box).new(protectionType, args)
setmetatable(obj, box)
local boxProtectionLevels = {semi = 'autoconfirmed', extended = 'extendedconfirmed', review = 'autoreviewer', template = 'templateeditor', full = 'sysop', interface = 'interfaceadmin'}
obj.boxProtectionLevel = boxProtectionLevels[protectionType]
obj.demo = yesno(args.demo)
-- Define objetos dependentes.
obj.titles = titleTable.new(args)
if not yesno(args.force) and obj.titles:hasSameProperty('sameProtectionStatus', function (title) return title.protectionLevel end) and obj.titles[1].protectionLevel ~= 'unprotected' then
obj.boxProtectionLevel = obj.titles[1].protectionLevel
end
obj.blurb = blurb.new(obj.titles, obj.boxProtectionLevel)
return obj
end
function box:setImage()
local titles = self.titles
local boxProtectionLevel = self.boxProtectionLevel
local padlock
if boxProtectionLevel == 'sysop' then
padlock = 'Crystal Clear action lock.png' -- 'Full-protection-shackle.svg' na enwiki
elseif boxProtectionLevel == 'interfaceadmin' then
padlock = 'Interface-protection-shackle.svg'
elseif boxProtectionLevel == 'templateeditor' then
padlock = 'Template-protection-shackle.svg'
elseif boxProtectionLevel == 'autoreviewer' then
padlock = 'Crystal Clear action lock - silver.png'
elseif boxProtectionLevel == 'autoconfirmed' then
padlock = 'Crystal Clear action lock3.png' -- 'Semi-protection-shackle.svg' na enwiki
elseif boxProtectionLevel == 'extendedconfirmed' then
padlock = 'Crystal Clear action lock4.png' -- 'Extended-protection-shackle.svg' na enwiki
else
padlock = 'Padlock-bronze-open.svg'
end
local stringToFormat = '[[Ficheiro:%s|%dpx|alt=|link=]]'
local smallPadlock = mw.ustring.format(stringToFormat, padlock, 25)
local largePadlock = mw.ustring.format(stringToFormat, padlock, 60)
self:setArg('smallimage', smallPadlock)
self:setArg('image', largePadlock)
end
function box:buildUrnLinks()
local ret = {}
local boxProtectionLevel = self.boxProtectionLevel
for titleObj in self.titles:titleIterator() do
table.insert(ret, titleObj:makeUrnLink(boxProtectionLevel))
end
return mw.ustring.format('<span class="plainlinks" style="display:none">%s</span>', table.concat(ret))
end
function box:setBlurbText()
self:setArg('text', self.blurb:export() .. self:buildUrnLinks())
end
function box:exportRequestTmbox()
self:setImage()
self:setBlurbText()
self:setArg('class', 'editrequest')
self:setArg('id', title.getProtectionLevelText(self.boxProtectionLevel)) -- Para âncora. Sim, isso leva a vários elementos com o mesmo ID. Provavelmente deveríamos consertar isso em algum momento
return makeMessageBox('tmbox', self.tmboxArgs)
end
function box:exportRequestCategories()
local cats = {}
local boxProtectionLevel = self.boxProtectionLevel
local function addCat(cat)
table.insert(cats, mw.ustring.format('[[Categoria:%s]]', cat))
end
local protectionCats = {
autoconfirmed = '!Solicitações de edição em páginas semiprotegidas da Wikipédia',
extendedconfirmed = '!Solicitações de edição em páginas semiprotegidas por autoconfirmados estendidos da Wikipédia',
templateeditor = '!Solicitações de edição em páginas protegidas por editores de predefinições da Wikipédia',
sysop = '!Solicitações de edição em páginas protegidas por administradores da Wikipédia',
interfaceadmin = '!Solicitações de edição em páginas protegidas por administradores de interface da Wikipédia'
}
addCat(protectionCats[boxProtectionLevel])
if self.titles:hasOtherProtectionLevel(boxProtectionLevel) then
addCat('!Solicitações de edição da Wikipédia possivelmente usando predefinições incorretas')
end
return table.concat(cats)
end
function box:export()
local title = self.titles.currentTitle
if not title.isTalkPage and not self.demo and not yesno(self.args.skiptalk) then
return '<span class="error">Erro: Solicitações de edição em páginas protegidas só podem ser feitas em páginas de discussão.</span>[[Categoria:!Páginas que não são de discussão com uma predefinição de solicitação de edição]]'
end
local ret = {}
table.insert(ret, self:exportRequestTmbox())
if not self.demo then
table.insert(ret, self:exportRequestCategories())
end
return table.concat(ret)
end
----------------------------------------------------------------------
-- Função exportada para Módulo:Testes/Gkiyoshinishimoto/Protected edit request
----------------------------------------------------------------------
return function(superclass, yn, mb)
yesno = yn
makeMessageBox = mb
return setmetatable(box, superclass)
end