Module:Requested move
Appearance
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This module is used by one or more bots in their standard operation. Any breaking changes to this module, including moving it or nominating it for deletion, must be communicated in advance to the bot operator(s). The relevant bots are: |
This module implements {{requested move}}. Please see the template pages for documentation.
-- This module implements {{move-multi}}.
local getArgs = require('Module:Arguments').getArgs
local tableTools = require('Module:TableTools')
local p = {}
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
local function err(msg)
-- Generates a wikitext error message
return string.format('<strong class="error">%s</strong>', msg)
end
--------------------------------------------------------------------------------
-- Main functions
--------------------------------------------------------------------------------
function p.main(frame)
local args = getArgs(frame)
-- Subst check
if not mw.isSubsting() then
local msg = 'This template must be [[Wikipedia:Template substitution|substituted]].'
.. mw.text.nowiki(' Replace {{move-multi}} with {{subst:move-multi}}')
return err(msg)
end
-- Check namespaces
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
local subjectSpace = mw.site.namespaces[namespace].subject.id
if not title.isTalkPage then
local msg = '[[Template:Move-multi]] must be used in a TALKSPACE, e.g., [[%s:%s]]'
msg = string.format(msg, mw.site.namespaces[namespace].talk.name, title.text)
return err(msg)
elseif subjectSpace == 14 then -- Category
local msg = '[[Template:Move-multi]] is not for categories,'
.. ' see [[Wikipedia:Categories for discussion]]'
return err(msg)
elseif subjectSpace == 6 then -- File
local msg = '[[Template:Move-multi]] is not for files;'
.. ' see [[Wikipedia:Moving a page#Moving a file page]]'
.. ' (use [[Template:Rename media]] instead)'
return err(msg)
elseif subjectSpace == 2 then -- User
local msg = '[[Template:Move-multi]] is not for moves from user space;'
.. ' see [[Wikipedia:Articles for creation]]'
.. ' (use '
.. mw.text.nowiki('{{')
.. '[[Wikipedia:Substitution|subst]]:[[Template:Submit|submit]]'
.. mw.text.nowiki('}}')
.. ' instead),'
.. ' or [[Help:How to move a page|move it yourself]]'
return err(msg)
end
local subjectTitle = title.subjectPageTitle
if not subjectTitle.exists then
local msg = 'Must create [['
.. subjectTitle.prefixedText
.. ']] before requesting that it be moved'
return err(msg)
end
--[[
-- With the numArgs table we reorganise the numerical data so that it can
-- be easily iterated over. A template invocation like:
-- {{move-multi|current1=Page 1|new1=New page 1|current2=Page 2|new2 = New page 2}}
-- would be converted to a table like
-- { [1] = {current = 'Page 1', new = 'New page 1'}, [2] = {current = 'Page 2', new = 'New page 2'} }
--]]
local numArgs = tableTools.numData(args)
end
return p