Content deleted Content added
Undid revision 941148733 by MSGJ (talk) per followup discussion at Template talk:Requested move#Hide advice when it was followed |
m simplify some code (should be a no-op; if there are any errors no discussion is needed before reverting (WP:TPEDISPUTE)) |
||
(3 intermediate revisions by one other user not shown) | |||
Line 91:
if not validTitle then
-- If invalid, the second parameter is the error message.
return msg▼
end
return 'yes'
--------------------------------------------------------------------------------
-- Confirm protection levels (used at [[Template:Requested move/dated]])
--------------------------------------------------------------------------------
function p.protected(frame)
local args = getArgs(frame, {parentOnly = true})
if args.protected then
local levels = mw.title.new(args.protected).protectionLevels
local levelMove = levels['move'] and levels['move'][1]
local levelEdit = levels['edit'] and levels['edit'][1]
local levelCreate = levels['create'] and levels['create'][1]
if levelMove == 'sysop'
or levelEdit == 'sysop'
or levelEdit == 'editprotected'
or levelCreate == 'sysop' then
elseif levelMove == 'templateeditor'
or levelEdit == 'templateeditor'
or levelCreate == 'templateeditor' then
return 'templateeditor'
end
end
end
Line 169 ⟶ 192:
-- multiple nomination.
local argsByNumCount = #argsByNum
local multi = (argsByNumCount >= 2)
else▼
▲ end
--[[
-- Validate new params.
Line 195 ⟶ 213:
end
end
----------------------------------------------------------------------------
-- Error checks
Line 335 ⟶ 353:
newDupes[newPrefixedText] = true
end
end
end
----------------------------------------------------------------------------
-- Check for page protection
----------------------------------------------------------------------------
local highestProtection = ''
local protectedTitle = ''
-- Checking page protection requires use of .protectionLevels(), one of the
-- "expensive" parser functions, which stop working after 500 uses total.
-- Without some limit set, this starts breaking near 250 distinct titles.
local titleLimit = 80
local titlesChecked = 0
local titles = {}
-- Consolidate duplicate titles (i.e., when moving A to B and B to C)
for i = 1,argsByNumCount do
titles[mw.title.new(argsByNum[i]['current'])] = true
titles[mw.title.new(argsByNum[i]['new'])] = true
end
-- Check each title t, while ignoring the "true" value
for t, _ in pairs(titles) do
if titlesChecked < titleLimit then
local levels = t.protectionLevels
titlesChecked = titlesChecked + 1
local levelMove = levels['move'] and levels['move'][1]
local levelEdit = levels['edit'] and levels['edit'][1]
local levelCreate = levels['create'] and levels['create'][1]
if levelMove == 'sysop'
or levelEdit == 'sysop'
or levelEdit == 'editprotected'
or levelCreate == 'sysop' then
highestProtection = 'sysop'
protectedTitle = tostring(t)
break
elseif levelMove == 'templateeditor'
or levelEdit == 'templateeditor'
or levelCreate == 'templateeditor' then
highestProtection = 'templateeditor'
protectedTitle = tostring(t)
end
-- End the "for" loop if the titleLimit is reached
break
end
end
Line 377 ⟶ 440:
rmd[#rmd + 1] = '|' .. new1param .. argsByNum[1].new
-- Add
if multi then
for i = 2, argsByNumCount do
Line 387 ⟶ 450:
rmd[#rmd + 1] = '|new' .. numString .. '=' .. new
end
end
-- The old multi template always has a bar before the closing curly▼
-- braces, so we will do that too.▼
-- Highest page protection (if admin or template-editor)
if highestProtection == 'sysop' or highestProtection == 'templateeditor' then
rmd[#rmd + 1] = '|protected=' .. protectedTitle
end
-- Pass through demo=yes to the
if args.demo ~= nil then
rmd[#rmd + 1] = '|demo='
rmd[#rmd + 1] = args.demo
end
if multi then
rmd[#rmd + 1] = '|'
end
Line 431 ⟶ 508:
-- Talk blurb
local talk = ''
if yesno(args.talk, true) then
talk = frame:expandTemplate{title = 'Requested move/talk'}
end
|