求真百科歡迎當事人提供第一手真實資料,洗刷冤屈,終結網路霸凌。

變更

前往: 導覽搜尋

模块:Lua banner

增加 590 位元組, 6 年前
無編輯摘要
-- 本模組嵌入模板This module implements the {{lua}}template.
local yesno = require('Module:Yesno')
local mList = require('Module:List')
local mTableTools = require('Module:TableTools')
local mMessageBox = require('Module:Message box')
local p = {}
function p.main(frame)
local origArgs = frame:getParent().args
return p._main(args)
end
function p._main(args)
local modules = mTableTools.compressSparseArray(args)
return box .. trackingCategories
end
function p.renderBox(modules)
local boxArgs = {}
if #modules < 1 then
boxArgs.text = '<strong class="error"> 錯誤:未指定模組Error: no modules specified</strong>'
else
local moduleLinks = {}
end
local moduleList = mList.makeList('bulleted', moduleLinks)
boxArgs.text = ' 使用This template uses [[Wikipedia:Lua|Lua 語言編寫]] :\n' .. moduleList
end
boxArgs.type = 'notice'
boxArgs.small = true
boxArgs.image = '[[File:Lua-logo-nolabel.svg|30px|alt=Lua 标志|link=Wikipedia:Lua]]'
return mMessageBox.main('mbox', boxArgs)
end
function p.renderTrackingCategories(args, modules, titleObj)
if yesno(args.nocat) then
return ''
end
local cats = {}
-- Error category
if #modules < 1 then
cats[#cats + 1] = ' 模板未指定Lua模組Lua templates with errors'
end
-- Lua templates category
titleObj = titleObj or mw.title.getCurrentTitle()
if not category then
local categories = {
['Module:String'] = ' 基于Lua字符串的模板Lua String-based templates', ['Module:Math'] = ' 基於Lua數學模組的模板Templates based on the Math Lua module', ['Module:BaseConvert'] = ' 基于Lua模块BaseConvert的模板Templates based on the BaseConvert Lua module', ['Module:Citation'] = ' 基于Lua的引用模板Lua-based citation templates'
}
categories['Module:Citation/CS1'] = categories['Module:Citation']
category = modules[1] and categories[modules[1]]
category = category or ' 基于Lua编程语言的模板Lua-based templates'
end
cats[#cats + 1] = category
local protLevels = {
autoconfirmed = 1,
extendedconfirmed = 2,
templateeditor = 3,
sysop = 4
}
local currentProt = titleObj.protectionLevels["edit"][1]
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end
for i, module in ipairs(modules) do
local moduleProt = mw.title.new(module).protectionLevels["edit"][1]
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end
if moduleProt < currentProt then
cats[#cats + 1] = "Templates using under-protected Lua modules"
break
end
end
end
for i, cat in ipairs(cats) do
cats[i] = string.format('[[ 分類Category:%s]]', cat)
end
return table.concat(cats)
end
return p
匿名用戶