模組:Lua banner
外观
--[=[本模块由[[Template:Lua]]调用暂无模块调用/****************************/本模組由[[Template:Lua]]調用暫無模組調用]=]--localyesno=require('Module:Yesno')localmList=require('Module:List')localmTableTools=require('Module:TableTools')localmMessageBox=require('Module:Message box')localp={}functionp.main(frame)localorigArgs=frame:getParent().argslocalargs={}fork,vinpairs(origArgs)dov=v:match('^%s*(.-)%s*$')ifv~=''thenargs[k]=vendendreturnp._main(frame,args)endfunctionp._main(frame,args)localmodules=mTableTools.compressSparseArray(args)localbox=p.renderBox(modules)localtrackingCategories=p.renderTrackingCategories(args,modules)returnbox..trackingCategoriesend-- if action=edit functionp.main2(frame)localorigArgs=frame:getParent().argslocalargs={}fork,vinpairs(origArgs)dov=v:match('^%s*(.-)%s*$')ifv~=''thenargs[k]=vendendlocalmodules=mTableTools.compressSparseArray(args)returnp.renderBox(modules)end--endfunctionp.renderBox(modules)localboxArgs={}if#modules<1thenboxArgs.text='<strong class="error">错误:未指定-{zh-hans:模块; zh-hant:模組;}-</strong>'elselocalmoduleLinks={}fori,moduleinipairs(modules)domoduleLinks[i]=string.format('%s',module)moduleLinks[i]='[[:Module:'..mw.title.new(moduleLinks[i]).text..']]'localmaybeSandbox=mw.title.new(module..'/sandbox')ifmaybeSandbox.existsthenmoduleLinks[i]=moduleLinks[i]..string.format('([[:%s|沙盒]])',maybeSandbox.fullText)endendlocalmoduleList=mList.makeList('bulleted',moduleLinks)boxArgs.text='此'..(mw.title.getCurrentTitle():inNamespaces(828,829)and'-{zh-hans:模块; zh-hant:模組;}-'or'模板')..'使用[[Wikipedia:Lua|Lua语言]]:\n'..moduleListendboxArgs.type='notice'boxArgs.small=trueboxArgs.image='[[File:Lua-Logo.svg|30px|alt=|link=]]'returnmMessageBox.main('mbox',boxArgs)endfunctionp.renderTrackingCategories(args,modules,titleObj)ifyesno(args.nocat)thenreturn''endlocalcats={}-- 错误分类if#modules<1thencats[#cats+1]='有错误的Lua模板'end-- Lua templates categorytitleObj=titleObjormw.title.getCurrentTitle()localsubpageBlacklist={doc=true,sandbox=true,sandbox2=true,testcases=true}iftitleObj.namespace==10andnotsubpageBlacklist[titleObj.subpageText]thenlocalcategory=args.categoryifnotcategorythenlocalcategories={['Module:String']='使用Module:String的模板',--['Module:Math'] = '使用LuaMath的模板',--['Module:BaseConvert'] = '使用LuaBaseConvert的模板',--['Module:Citation'] = '使用LuaCitation的模板'}categories['Module:Citation/CS1']=categories['Module:Citation']category=modules[1]andcategories[modules[1]]category=categoryor'x'endcats[#cats+1]=categorylocalprotLevels={autoconfirmed=1,extendedconfirmed=2,templateeditor=3,sysop=4}localcurrentProt=titleObj.protectionLevels["edit"][1]ifcurrentProt==nilthencurrentProt=0elsecurrentProt=protLevels[currentProt]endfori,moduleinipairs(modules)doifmw.title.new(module).protectionLevels["edit"]thenlocalmoduleProt=mw.title.new(module).protectionLevels["edit"][1]ifmoduleProt==nilthenmoduleProt=0elsemoduleProt=protLevels[moduleProt]endifmoduleProt<currentProtthencats[#cats+1]="使用受保护Lua模块的模板"breakendendendendfori,catinipairs(cats)docats[i]=string.gsub(string.format('[[Category:%s]]',cat),'%[%[Category:x%]%]','')endreturntable.concat(cats)..'[[Category:Lua模板]]'endreturnp