Ir para o conteúdo

Módulo:Alto uso

De Wiki TokuDrive

local p = {} local getArgs = require('Módulo:Arguments').getArgs

-- "_fetch" examina o argumento "demo" local _fetch = require('Módulo:Transclusion count')._fetch local yesno = require('Módulo:Yesno')

function p._num(args, count, no_percent) if count == nil then if yesno(args['fetch']) == false then if (args[1] or ) ~= then count = tonumber(args[1]) end else count = _fetch(args) end end

-- Constrói a sequência ('string') de saída local return_value = "" if count == nil then if args[1] == "risk" then return "um número muito grande de" else return "muitas" end else -- Usa 2 algarismos significativos para números menores e 3 para os maiores local sigfig = 2 if count >= 100000 then sigfig = 3 end

-- Prepara para arredondar para o número apropriado de "sigfigs" local f = math.floor(math.log10(count)) - sigfig + 1

-- Arredonda e insere "aproximadamente" ou "+" quando apropriado if (args[2] == "yes") or (type(args[1]) == 'string' and (mw.ustring.sub(args[1],-1) == "+")) then -- Arredonda para baixo return_value = string.format("%s+", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) ) * (10^(f))) ) else -- Arredonda para o mais próximo return_value = string.format("aproximadamente %s", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) + 0.5) * (10^(f))) ) end

-- Insere a porcentagem de páginas se for >= 1% e quando "|no-percent=" não estiver definido como sim no_percent = no_percent or args['no-percent'] if count and count > 250000 and not yesno (no_percent) then local numpages = mw.getCurrentFrame():callParserFunction('NUMBEROFPAGES', 'R') local percent = math.floor( ( ( count/numpages ) * 100) + 0.5) if percent >= 1 then return_value = string.format("%s páginas, ou aproximadamente %s%% de todas", return_value, percent) end end end

return return_value end

function p.num(frame, count) return p._num(getArgs(frame), count) end

-- Ações se houver uma contagem de transclusões grande (maior ou igual a 100.000) function p._risk(args) if args[1] == "risk" then return "risk" else local count = _fetch(args) if count and count >= 100000 then return "risk" end end return "" end

function p.risk(frame) return p._risk(getArgs(frame)) end

function p._text(args, count) -- Só mostra as informações sobre como este modelo é atualizado se alguém -- estiver realmente editando a página e talvez tentando atualizar a contagem. local bot_text = (mw.getCurrentFrame():preprocess("2498") == "") and "\n\n----\nMensagem de pré-visualização: A contagem de transclusões é atualizada manualmente." or

if count == nil then if yesno(args['fetch']) == false then if (args[1] or ) ~= then count = tonumber(args[1]) end else count = _fetch(args) end end local title = mw.title.getCurrentTitle() if ( (args.demo or ~= ) and mw.title.new(args.demo, 10) ) then title = mw.title.new(args.demo, 10) end

if title.subpageText == "doc" or title.subpageText == "Testes" then title = title.basePageTitle end

local systemMessages = (args['system'] or ) ~=

-- Isso recupera o localizador de recursos uniforme (L.R.U., 'U.R.L.') do projeto automaticamente para simplificar a localização local templateCount = ('em %s páginas'):format( title:fullUrl():gsub('//(.-)/.*', '%1'), mw.uri.encode(title.fullText), p._num(args, count)) local used_on_text = "Est" .. (title.namespace == 828 and "e módulo Lua" or "a predefinição") .. ' é usad' .. (title.namespace == 828 and "o " or "a "); if systemMessages then used_on_text = used_on_text .. args['system'] .. ((count and count > 2000) and (", e " .. templateCount) or ("")) else used_on_text = used_on_text .. templateCount .. "" end


local sandbox_text = ("subpáginas /Testes ou /Exemplos para testes " .. (title.namespace == 828 and "do " or "da ") .. "%s, ou em sua própria %s. "):format( title.fullText, title.fullText, (title.namespace == 828 and "módulo" or "predefinição"), title.namespace == 828 and "Módulo:Testes|subpágina de testes de módulos" or "Wikipédia:Página de usuário#Subpáginas|subpágina de usuário" )

local infoArg = args["info"] ~= "" and args["info"] if (systemMessages or args[1] == "risk" or (count and count >= 100000) ) then local info = systemMessages and '.
Mudanças feitas aqui podem causar mudanças imediatas na interface de usuário da Wikipédia.' or '.' if infoArg then info = info .. "
" .. infoArg end sandbox_text = info .. '
Para evitar grandes transtornos' .. (count and count >= 100000 and ' e carga do servidor' or ) .. ', quaisquer mudanças devem ser testadas nas ' .. sandbox_text .. 'As mudanças testadas podem ser adicionadas a esta página em uma única edição. ' else sandbox_text = (infoArg and ('.
' .. infoArg .. ' A') or ' e a') .. 's mudanças podem ser amplamente notadas. Teste as mudanças nas ' .. sandbox_text end


local discussion_text = systemMessages and 'Por favor, discuta as mudanças ' or 'Considere discutir as mudanças ' if args["2"] and args["2"] ~= "" and args["2"] ~= "yes" then discussion_text = string.format("%sem %s", discussion_text, args["2"]) else discussion_text = string.format("%sna página de discussão", discussion_text, title.talkPageTitle.fullText ) end

return used_on_text .. sandbox_text .. discussion_text .. " antes de implementá-las." .. bot_text end

function p.text(frame, count) return p._text(getArgs(frame), count) end

function p._main(args, nocat) local count = nil if yesno(args['fetch']) == false then if (args[1] or ) ~= then count = tonumber(args[1]) end else count = _fetch(args) end local image = "Aviso" local type_param = "style" local epilogue = if args['system'] and args['system'] ~= then image = "Aviso" type_param = "content" nocat = nocat or args['nocat'] local categorise = (nocat == or not yesno(nocat)) if categorise and not mw.title.getCurrentTitle().isRedirect then epilogue = mw.getCurrentFrame():preprocess() end elseif (args[1] == "risk" or (count and count >= 100000)) then image = "Aviso" type_param = "content" end

if args["form"] == "editnotice" then return mw.getCurrentFrame():expandTemplate{ title = 'editnotice', args = { ["image"] = image, ["text"] = p._text(args, count), ["expiry"] = (args["expiry"] or "") } } .. epilogue else return require('Módulo:Message box').main('ombox', { type = type_param, image = image, text = p._text(args, count), expiry = (args["expiry"] or "") }) .. epilogue end end

function p.main(frame) return p._main(getArgs(frame)) end return p