Jump to content

Module:Infobox body of water tracking

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Plastikspork (talk | contribs) at 04:41, 30 May 2013 (Try new tracking module for Template:Infobox body of water). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

function p.tracking(frame)
    function isblank( val ) 
        return (val == nil) or val:match('^[%s]*$')
    end
    
    local cats = ''
    local args = frame:getParent().args
    
    if (isblank(args['image']) and isblank(args['image_lake']) and isblank(args['image_ocean'])
        and isblank(args['image_Ocean']) and isblank(args['image_bay']) ) then
        cats = cats .. '[[Category:Wikipedia infobox body of water articles without image]]'
    end
    
    if isblank(args['coords']) then 
        cats = cats .. '[[Category:Wikipedia infobox body of water articles without coordinates]]'
    end
    
    if isblank(args['1']) then
    else
        cats = cats .. '[[Category:Wikipedia infobox body of water articles needing maintenance]]'
    end
    
    local duplicate_parameters = 0
    if (args['length_km'] and args['length']) then
        duplicate_parameters = duplicate_parameters + 1
    end
    if (args['width_km'] and args['width']) then
        duplicate_parameters = duplicate_parameters + 1
    end
    if (args['area_km2'] and args['area']) then
        duplicate_parameters = duplicate_parameters + 1
    end
    if (args['depth_m'] and args['depth']) then
        duplicate_parameters = duplicate_parameters + 1
    end
    if (args['max-depth_m'] and args['max-depth']) then
        duplicate_parameters = duplicate_parameters + 1
    end
    if (args['volume_km3'] and args['volume']) then
        duplicate_parameters = duplicate_parameters + 1
    end
    if (args['shore_km'] and args['shore']) then
        duplicate_parameters = duplicate_parameters + 1
    end
    if (args['elevation_m'] and args['elevation']) then
        duplicate_parameters = duplicate_parameters + 1
    end
    if (  (args['image'] and 1 or 0) + (args['image_lake'] and 1 or 0)
        + (args['image_ocean'] and 1 or 0) + (args['image_Ocean'] and 1 or 0)
        + (args['image_bay'] and 1 or 0) > 1 ) then
        duplicate_parameters = duplicate_parameters + 1
    end
    
    if (duplicate_parameters > 0) then
        cats = cats .. '[[Category:Wikipedia infobox body of water articles using duplicate parameters]]'
    end
    
    local deprecated_parameters = 0
    if (args['length'] or ''):match('^[%s]*[0-9\.,]+[^%s]*$') then
        deprecated_parameters = deprecated_parameters + 1
    end
    if (args['width'] or ''):match('^[%s]*[0-9\.,]+[^%s]*$') then
        deprecated_parameters = deprecated_parameters + 1
    end
    if (args['area'] or ''):match('^[%s]*[0-9\.,]+[^%s]*$') then
        deprecated_parameters = deprecated_parameters + 1
    end
    if (args['depth'] or ''):match('^[%s]*[0-9\.,]+[^%s]*$') then
        deprecated_parameters = deprecated_parameters + 1
    end
    if (args['max-depth'] or ''):match('^[%s]*[0-9\.,]+[^%s]*$') then
        deprecated_parameters = deprecated_parameters + 1
    end
    if (args['volume'] or ''):match('^[%s]*[0-9\.,]+[^%s]*$') then
        deprecated_parameters = deprecated_parameters + 1
    end
    if (args['shore'] or ''):match('^[%s]*[0-9\.,]+[^%s]*$') then
        deprecated_parameters = deprecated_parameters + 1
    end
    if (args['elevation'] or ''):match('^[%s]*[0-9\.,]+[^%s]*$') then
        deprecated_parameters = deprecated_parameters + 1
    end
    if (deprecated_parameters > 0) then
        cats = cats .. '[[Category:Wikipedia infobox body of water articles using deprecated parameters]]'
    end
    
    return cats
end
    
return p