Changes

Jump to navigation Jump to search
m
Changed protection level for "Module:Infobox school tracking": High-risk Lua module ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))
local p = {}

function p.tracking(frame)
local function isblank( val )
return (val == nil) or val:match('^[%s]*$')
end
local function trim(s)
return s:match('^%s*(.-)%s*$')
end
local function isnotblank(s)
return s and trim(s) ~= ''
end
local cats = ''
local args = frame:getParent().args
local unknown_parameters = {}
local duplicate_parameters = {}
local count = 0

if isnotblank(args['fundingtype']) and isnotblank(args['type']) then
table.insert(duplicate_parameters, 'fundingtype = type')
end
if isnotblank(args['religious_affiliation']) and isnotblank(args['religion']) then
table.insert(duplicate_parameters, 'religious_affiliation = religion')
end
if isnotblank(args['head_name']) and isnotblank(args['head_label']) then
table.insert(duplicate_parameters, 'head_name = head_label')
end
if isnotblank(args['employees']) and isnotblank(args['num_employ']) then
table.insert(duplicate_parameters, 'employees = num_employ')
end
count = 0
if isnotblank(args['address']) then count = count + 1 end
if isnotblank(args['street']) then count = count + 1 end
if isnotblank(args['streetaddress']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'address = street = streetaddress')
end
count = 0
if isnotblank(args['city']) then count = count + 1 end
if isnotblank(args['town']) then count = count + 1 end
if isnotblank(args['city/town']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'city = town = city/town')
end
count = 0
if isnotblank(args['postcode']) then count = count + 1 end
if isnotblank(args['postalcode']) then count = count + 1 end
if isnotblank(args['zipcode']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'postcode = postalcode = zipcode')
end
count = 0
if isnotblank(args['educational_authority']) then count = count + 1 end
if isnotblank(args['educational authority']) then count = count + 1 end
if isnotblank(args['authority']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'educational_authority = educational authority = authority')
end
count = 0
if isnotblank(args['school_number']) then count = count + 1 end
if isnotblank(args['schoolnumber']) then count = count + 1 end
if isnotblank(args['number']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'school_number = schoolnumber = number')
end
count = 0
if isnotblank(args['staff']) then count = count + 1 end
if isnotblank(args['number_of_staff']) then count = count + 1 end
if isnotblank(args['number of staff']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'staff = number_of_staff = number of staff')
end
count = 0
if isnotblank(args['lower_age']) then count = count + 1 end
if isnotblank(args['age_range']) then count = count + 1 end
if isnotblank(args['age range']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'lower_age = age_range = age range')
end
count = 0
if isnotblank(args['pupils']) then count = count + 1 end
if isnotblank(args['number_of_pupils']) then count = count + 1 end
if isnotblank(args['number of pupils']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'pupils = number_of_pupils = number of pupils')
end
count = 0
if isnotblank(args['average_class_size']) then count = count + 1 end
if isnotblank(args['avg_class_size']) then count = count + 1 end
if isnotblank(args['class']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'average_class_size = avg_class_size = class')
end
count = 0
if isnotblank(args['colours']) then count = count + 1 end
if isnotblank(args['colors']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'colours = colors')
end
count = 0
if isnotblank(args['schoolcolours']) then count = count + 1 end
if isnotblank(args['schoolcolors']) then count = count + 1 end
if isnotblank(args['school_colours']) then count = count + 1 end
if isnotblank(args['school_colors']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'schoolcolours = schoolcolors = school_colours = school_colors')
end
count = 0
if isnotblank(args['feeders']) then count = count + 1 end
if isnotblank(args['feeder_schools']) then count = count + 1 end
if isnotblank(args['main feeder schools']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'feeders = feeder_schools = main feeder schools')
end
count = 0
if isnotblank(args['enrolment']) then count = count + 1 end
if isnotblank(args['enrollment']) then count = count + 1 end
if isnotblank(args['students']) then count = count + 1 end
if isnotblank(args['pupils']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'enrolment = enrollment = students = pupils')
end
count = 0
if isnotblank(args['enrolment_as_of']) then count = count + 1 end
if isnotblank(args['enrollment_as_of']) then count = count + 1 end
if isnotblank(args['students_as_of']) then count = count + 1 end
if isnotblank(args['pupils_as_of']) then count = count + 1 end
if count > 1 then
table.insert(duplicate_parameters, 'enrolment_as_of = enrollment_as_of = students_as_of = pupils_as_of')
end
if isnotblank(frame.args['nocat']) then
cats = ''
end
warnmsg = {}
if #unknown_parameters > 0 then
for i, v in ipairs( unknown_parameters ) do
local t = mw.text.split(v, '=')
table.insert(warnmsg, 'Unknown parameter <code>' .. t[1] .. '</code> ' .. t[2])
cats = cats .. '[[Category:Pages using infobox school with deprecated parameters|' .. t[1] .. ']]'
end
end
if #duplicate_parameters > 0 then
for i, v in ipairs( duplicate_parameters ) do
local t = mw.text.split(v, '=')
table.insert(warnmsg, 'Using more than one of the following parameters: <code>' ..
table.concat(t, '</code>, <code>') .. '</code>')
cats = cats .. '[[Category:Pages using infobox school with deprecated parameters|' .. t[1] .. ']]'
end
end
if #warnmsg > 0 then
if frame:preprocess( "{{REVISIONID}}" ) == "" then
cats = '<div class="hatnote" style="color:red"><strong>Infobox school warning:</strong> ' .. table.concat(warnmsg, '<br>') .. '</div>' .. cats
end
end
return cats
end

return p
Anonymous user

Navigation menu