Module:Extension

local lang = mw.language.getContentLanguage local translation = mw.getCurrentFrame:expandTemplate{ title = 'translation' } local addr = { GNU = '//www.gnu.org/', CC = '//creativecommons.org/licenses/' } local cats = { GPL = 'GPL licensed extensions', CC = 'Creative Commons licensed extensions' } local licenses = { ['GPL']   = { '[' .. addr.GNU .. 'copyleft/gpl.html GNU General Public License]', cats.GPL }, ['GPL2']  = { '[' .. addr.GNU .. 'licenses/gpl-2.0.html GNU General Public License 2.0]', cats.GPL }, ['GPL2+'] = { '[' .. addr.GNU .. 'licenses/gpl-2.0.html GNU General Public License 2.0] or later', cats.GPL }, ['GPL3']  = { '[' .. addr.GNU .. 'licenses/gpl-3.0.html GNU General Public License 3.0]', cats.GPL }, ['GPL3+'] = { '[' .. addr.GNU .. 'licenses/gpl-3.0.html GNU General Public License 3.0] or later', cats.GPL }, ['AGPL3+'] = { '[' .. addr.GNU .. 'licenses/agpl-3.0.html GNU Affero General Public License 3.0] or later', cats.GPL }, ['LGPL']  = { '[' .. addr.GNU .. 'copyleft/lesser.html GNU Lesser General Public License]' }, ['LGPL3'] = { '[' .. addr.GNU .. 'licenses/lgpl-3.0.html GNU Lesser General Public License 3.0]' }, ['FDL']   = { '[' .. addr.GNU .. 'licenses/fdl.html GNU Free Documentation License]' }, } local types = { ajax               = { 'Ajax',                                        'Ajax extensions' }, api                = { 'API',                                  'API extensions' }, ['beta feature']   = { 'Beta Feature',                         'Beta Feature extensions' }, contenthandler     = { 'ContentHandler',               'ContentHandler extensions' }, database           = { 'Database',                    'Database extensions' }, db                 = { 'Database',                                               'Database extensions' }, ['data extraction'] = { 'Data extraction',                                       'Data extraction extensions' }, example            = { 'Example',                                                'Extension examples' }, ['extended syntax'] = { 'Extended syntax',      'Extended syntax extensions' }, filerepo           = { 'File repository',                                        'File repository extensions' }, hook               = { 'Hook',                                  'Hook extensions' }, interface          = { 'User interface',                                         'User interface extensions' }, link               = { 'Link markup',           'Link markup extensions' }, media              = { 'Media',                                                  'Media handling extensions' }, mywiki             = { 'MyWiki',                      'Personalization extensions' }, notify             = { 'Notify',                                                 'Notification extensions' }, ['page action']    = { 'Page action', 'Page action extensions' }, parser             = { 'Parser extension',      'Parser extensions' }, ['parser function'] = { 'Parser function',           'Parser function extensions' }, pfunc              = { 'Parser functions',           'Parser function extensions' }, search             = { 'Search',                                                 'Search extensions' }, skin               = { 'Skin',                                  'Skin extensions' }, special            = { 'Special page',                  'Special page extensions' }, ['special page']   = { 'Special page',                  'Special page extensions' }, locale             = { 'Locale',                         'Internationalization extensions' }, tag                = { 'Tag',                          'Tag extensions' }, ['user access']    = { 'User access',                        'User access extensions' }, ['user identity']  = { 'User identity',                      'User identity extensions' }, ['user rights']    = { 'User rights',                        'User rights extensions' }, ['user activity']  = { 'User activity',                      'User activity extensions' }, variable           = { 'Variable',                          'Variable extensions' }, -- DEPRECATED TYPES (as per 2007-09 taxonomy discussion) category           = { 'Category',                                               'Category extensions',  deprecated = true }, form               = { 'Form',                                                   'Form extensions',      deprecated = true }, list               = { 'List',                                                   'List extensions',      deprecated = true }, namespace          = { 'Namespace',                        'Namespace extensions', deprecated = true }, ['table']          = { 'Table',                                                  'Table extensions',     deprecated = true }, }

-- DEPRECATED TYPES (multiple types handled via type1,type2,...) local deprecatedTypes = { ['link, tag, special'] = { 'link', 'tag', 'special' }, ['parser function, special'] = { 'parser function', 'special page' }, ['tag, parser function'] = { 'tag', 'parser function' }, ['tag, parser function, special'] = { 'tag', 'parser function', 'special page' }, ['tag, special'] = { 'tag', 'special page' }, ['parser, pfunc'] = { 'parser function' }, ['parser, hook, special'] = { 'tag' -- sic, 'hook', 'special' }, }

local function cat( title ) return '' end

local function tcat( title ) return cat( title .. translation ) end

local function getType( str, str2 ) local str = mw.ustring.lower( str ) local cnf = types[str] local res if cnf then res = cnf[1] .. ''		if cnf.deprecated then res = res .. '\'\'-deprecated\'\'' .. tcat( 'Extensions with deprecated types' ) end else cnf = deprecatedTypes[str] if cnf then local dtypes = {} for _, sstr in ipairs( cnf ) do				table.insert( dtypes, getType( sstr ) ) end res = table.concat( dtypes, ', ' ) .. ' \'\'(deprecated, please use type1,type2'			if #cnf > 2 then				res = res .. ',type3'			end			res = res .. ' instead)\'\'' .. tcat( 'Extensions with deprecated types' ) elseif str == '_missing_' then res = tcat( 'Extensions with invalid or missing type' ) elseif str == '_demomode_' then if str2 then res = lang:ucfirst( str2 ) else res = "unknown" end else res = ( str or '\'\'unknown\'\'' ) .. ' (\'\'\'\'\'invalid type\'\'\'\'\')' .. tcat( 'Extensions with invalid or missing type' ) end end return res end

local p = {}

function p.getTypes( frame ) local args = frame:getParent.args local res = '' local params = { args.type1 or args['type'] or 'missing', args.type2, args.type3, args.type4, args.type5, args.type6, }	for _, param in ipairs( params ) do		if param == nil or mw.text.trim( param ) == '' then break end local param = mw.text.trim( param ) if args.templatemode == 'nocats' then res = res .. getType( '_demomode_', param ) else res = res .. getType( param ) end end return res end

function p.getType( frame ) return getType( frame.args[1] ) end

return p