Jump to content
Wikipedia The Free Encyclopedia

Module:National squad

From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
Warning This Lua module is used on approximately 58,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them.
This module depends on the following other modules:

This module implements Template:National squad and Template:National squad no numbers to avoid articles being added to Category:Pages where post-expand include size is exceeded when the template is used many times.

The above documentation is transcluded from Module:National squad/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.

 -- This module implements [[Template:National squad]] and 
 -- [[Template:National squad no numbers]] to avoid articles being added to 
 -- [[:Category:Pages where template include size is exceeded]]
 -- when the template is used many times.
 localp={}
 localprefixes={
 ['male']=' men\'s',
 ['men']=' men\'s',
 ['mens']=' men\'s',
 ['men\'s']=' men\'s',
 ['female']=' women\'s',
 ['women']=' women\'s',
 ['womens']=' women\'s',
 ['women\'s']=' women\'s',
 ['']=''
 }
 functionp.main(frame)
 localgetArgs=require('Module:Arguments').getArgs
 localargs=getArgs(frame,{parentFirst=true})
 localcountry=args.countryor'{{{country}}}'
 localcoach_label=args.coach_typeor'Coach'
 localcomp=args.compor'{{{comp}}}'
 localsport=args.sportor'football'
 localgender=prefixes[args.genderor'']or''
 localtitlestyle='background-color:'..(args.bgor'transparent')..';'
 ..'color:'..(args.fgor'inherit')..';'
 ..'border:1px solid '..(args.bordercoloror'#aaa')
 localimage=args.country~='Unified Team'andrequire('Module:Flagg').luaMain(frame,{
 'cxxl',
 args.countryor'none',
 args.flagvar,
 size='50px'
 })orframe:expandTemplate{
 title='flagicon image',
 args={'Olympic flag.svg',size='50px'}
 }

 localospan='<span style="color:'..(args.fgor'inherit')..'">'
 localcspan='</span>'
 localtitle=string.format('[[%s|%s%s%s]] – [[%s|%s%s%s]]',
 args['team link']or(country..gender..' national '..sport..' team'),
 ospan,args.titleorcountry..' squad',cspan,
 args['comp link']orcomp,ospan,comp,cspan)

 localhaspos=false

 -- Tracking and preview warnings
 localknownargs={['bg']=1,['fg']=1,['bordercolor']=1,['coach']=1,['coach_type']=1,
 ['comp']=1,['comp link']=1,['country']=1,['flagvar']=1,['gender']=1,
 ['list']=1,['name']=1,['nonumbers']=1,['note']=1,['sport']=1,['team link']=1,['title']=1}
 localbadargs={}
 localnumlist={}
 fork,vinpairs(args)do
 ifknownargs[k]then
 elseiftype(k)=='string'then
 localn=tonumber(k:match('^p(%d+)$')ork:match('pos(%d+)')or'-1')
 ifk:match('^p%d+$')andn>=0andn<=99then
 table.insert(numlist,k:match('^p(%d+)$'))
 elseifargs.nonumbersand(k:match('^pos%d+$')andn>=0andn<=99)then
 ifvandv~=''thenhaspos=trueend
 elseifvandv~=''then
 table.insert(badargs,k)
 end
 elseifvandv~=''then
 table.insert(badargs,k)
 end
 end
 table.sort(
 numlist,
 function(a,b)
 returntonumber(a)<tonumber(b)or(tonumber(a)==tonumber(b)and#a>#b)
 end
 )
 localpv=require('Module:If preview')
 localpreview,tracking='',''
 if#badargs>0then
 fork,vinpairs(badargs)do
 ifv==''thenv=' 'end
 v=mw.ustring.gsub(v,'[^%w\\-_ ]','?')
 preview=preview..pv._warning({
 'Page using national squad with unknown parameter "'..v..'".'
 })
 tracking=tracking..'[[Category:Pages using national squad with unknown parameters|'..v..']]'
 end
 end
 if(args['title']==nilandargs['team link']==nilandargs.country==nil)orargs.comp==nilthen
 tracking=tracking..'[[Category:Pages using national squad with unknown parameters|!]]'
 end
 ifnotargs['comp link']then
 tracking=tracking..'[[Category:Pages using national squad without comp link]]'
 end
 ifnotargs['sport']then
 ifnotargs['team link']then
 tracking=tracking..'[[Category:Pages using national squad without sport or team link]]'
 end
 end
 ifsport~='football'andsport~='futsal'andsport~='basketball'then
 ifnotargs['team link']then
 localsortkey=mw.ustring.gsub(sport,'[^A-Za-z]',' ')
 tracking=tracking..'[[Category:Pages using national squad without team link and with an atypical sport|'..sortkey..' ]]'
 end
 end
 ifprefixes[args.genderor'']==nilthen
 tracking=tracking..'[[Category:Pages using national squad with unsupported gender]]'
 end
 ifargs.name==nilthen
 tracking=tracking..'[[Category:Pages using national squad without name]]'
 end
 -- if tracking ~= '' and mw.title.getCurrentTitle().namespace > 0 then tracking = '' end

 locallist1=args.listor''
 iflist1==''then
 fori,kinipairs(numlist)do
 ifargs['p'..k]then
 localn=args.nonumbersand(args['pos'..k]or'')ortostring(k)
 ifn~=''orhaspos==truethen
 list1=list1..string.format(
 '*%s&nbsp;<span class="vcard agent"><span class="fn">%s</span></span>\n',
 n,args['p'..k])
 else
 list1=list1..string.format(
 '*<span class="vcard agent"><span class="fn">%s</span></span>\n',args['p'..k])
 end
 end
 end
 ifargs.coachthen
 list1=list1..string.format(
 '*<span class="vcard agent">%s:&nbsp;<span class="fn">%s</span></span>',
 coach_label,args.coach)
 end
 end
 locallist3=args.noteand(''..args.note..'')ornil

 returnrequire('Module:Navbox')._navbox({
 name=args.name,
 titlestyle=titlestyle,
 listclass='hlist',bodyclass='vcard',titleclass='fn org',
 image=image,title=title,list1=list1,list3=list3
 })..tracking..preview
 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /