更改

添加199字节 、 2023年12月24日 (日) 19:41
导入1个版本
第1行: 第1行:  
--[=[
 
--[=[
   −
  这个 模块由[[Template:Lua]]调用
+
  模块由[[Template:Lua]]调用
 
 暂无模块调用
 
 暂无模块调用
 
/****************************/
 
/****************************/
  這個 模組由[[Template:Lua]]調用
+
  模組由[[Template:Lua]]調用
 
 暫無模組調用
 
 暫無模組調用
 +
 
]=]--
 
]=]--
 +
 
local yesno = require('Module:Yesno')
 
local yesno = require('Module:Yesno')
 
local mList = require('Module:List')
 
local mList = require('Module:List')
第28行: 第30行:  
function p._main(frame, args)
 
function p._main(frame, args)
 
local modules = mTableTools.compressSparseArray(args)
 
local modules = mTableTools.compressSparseArray(args)
local box = p.renderBox(frame, modules)
+
local box = p.renderBox(modules)
 
local trackingCategories = p.renderTrackingCategories(args, modules)
 
local trackingCategories = p.renderTrackingCategories(args, modules)
 
return box .. trackingCategories
 
return box .. trackingCategories
第43行: 第45行:  
end
 
end
 
local modules = mTableTools.compressSparseArray(args)
 
local modules = mTableTools.compressSparseArray(args)
return p.renderBox(frame, modules)
+
return p.renderBox(modules)
 
end
 
end
 
--end
 
--end
   −
function p.renderBox(frame, modules)
+
function p.renderBox(modules)
 
local boxArgs = {}
 
local boxArgs = {}
 
if #modules < 1 then
 
if #modules < 1 then
boxArgs.text = '<strong class="error">错误: 没有 指定-{zh-hans:模块; zh-hant:模組;}-</strong>'
+
boxArgs.text = '<strong class="error">错误: 指定-{zh-hans:模块; zh-hant:模組;}-</strong>'
 
else
 
else
 
local moduleLinks = {}
 
local moduleLinks = {}
 
for i, module in ipairs(modules) do
 
for i, module in ipairs(modules) do
 
moduleLinks[i] = string.format('%s', module)
 
moduleLinks[i] = string.format('%s', module)
moduleLinks[i] = '[[:Module:' ..frame:callParserFunction{name = "PAGENAME", args = moduleLinks[i]} .. ']]'
+
moduleLinks[i] = '[[:Module:' .. mw.title.new(moduleLinks[i]).text .. ']]'
 +
local maybeSandbox = mw.title.new(module .. '/sandbox')
 +
if maybeSandbox.exists then
 +
moduleLinks[i] = moduleLinks[i] .. string.format(' ([[:%s|沙盒]] ', maybeSandbox.fullText)
 +
end
 
end
 
end
 
local moduleList = mList.makeList('bulleted', moduleLinks)
 
local moduleList = mList.makeList('bulleted', moduleLinks)
boxArgs.text = ' ' .. 
+
boxArgs.text = ' ' .. 
 
(mw.title.getCurrentTitle():inNamespaces(828,829) and '-{zh-hans:模块; zh-hant:模組;}-' or '模板') ..
 
(mw.title.getCurrentTitle():inNamespaces(828,829) and '-{zh-hans:模块; zh-hant:模組;}-' or '模板') ..
 
'使用[[Wikipedia:Lua|Lua语言]]:\n' .. moduleList
 
'使用[[Wikipedia:Lua|Lua语言]]:\n' .. moduleList
第64行: 第70行:  
boxArgs.type = 'notice'
 
boxArgs.type = 'notice'
 
boxArgs.small = true
 
boxArgs.small = true
boxArgs.image = '[[File:Lua-logo-nolabel.svg|30px|alt=|link=]]'
+
boxArgs.image = '[[File:Lua-Logo.svg|30px|alt=|link=]]'
 
return mMessageBox.main('mbox', boxArgs)
 
return mMessageBox.main('mbox', boxArgs)
 
end
 
end
第113行: 第119行:  
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end
 
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end
 
for i, module in ipairs(modules) do
 
for i, module in ipairs(modules) do
local moduleProt = mw.title.new(module).protectionLevels["edit"][1]
+
if mw.title.new(module).protectionLevels["edit"] then
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end
+
local moduleProt = mw.title.new(module).protectionLevels["edit"][1]
if moduleProt < currentProt then
+
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end
cats[#cats + 1] = "使用受保护Lua模块的模板"
+
if moduleProt < currentProt then
break
+
cats[#cats + 1] = "使用受保护Lua模块的模板"
 +
break
 +
end
 
end
 
end
 
end
 
end