Editing
Module:Check for clobbered parameters
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local function trim(s) return s:match('^%s*(.-)%s*$') end local function isnotempty(s) return s and s:match('%S') end function p.check(frame) local args = frame.args local pargs = frame:getParent().args local checknested = isnotempty(args['nested']) local delimiter = isnotempty(args['delimiter']) and args['delimiter'] or ';' local argpairs = {} for k, v in pairs(args) do if type(k) == 'number' then local plist = mw.text.split(v, delimiter) local pfound = {} local count = 0 for ii, vv in ipairs(plist) do vv = trim(vv) if checknested and pargs[vv] or isnotempty(pargs[vv]) then count = count + 1 table.insert(pfound, vv) end end if count > 1 then table.insert(argpairs, pfound) end end end local warnmsg = {} local res = '' local cat = '' if args['cat'] and mw.ustring.match(args['cat'],'^[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]:') then cat = args['cat'] end local template = args['template'] and ' in ' .. args['template'] or '' if #argpairs > 0 then for i, v in ipairs( argpairs ) do table.insert( warnmsg, mw.ustring.format( 'Using more than one of the following parameters%s: <code>%s</code>.', template, table.concat(v, '</code>, <code>') ) ) if cat ~= '' then res = res .. '[[' .. cat .. '|' .. (v[1] == '' and ' ' or '') .. v[1] .. ']]' end end end if #warnmsg > 0 then res = require('Module:If preview')._warning({ table.concat(warnmsg, '<br>') }) .. res end return res end return p
Summary:
Please note that all contributions to Ikwipedia are considered to be released under the Creative Commons Attribution-ShareAlike (see
Ikwipedia:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Move
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information