Module:Delete

local data = require ('Module:Delete/data')

local z =

function extractAliases (item)

allnames = {item'code'}

for j, alias in ipairs (item'aliases') do

table.insert (allnames, alias)

end

return allnames

end

function extractShortDesc (item)

if item'description' then

return item'description':gsub ('{', '{'):gsub ('}', '}'):gsub ('|', '|')

else

return

end

end

function extractDeleteReason (item)

return item'deletereason' or item'criteria' or

end

function shortDesc (frame, name)

name = mw.text.trim (name):upper

wt =

for i, item in ipairs (data) do

if name == or #name == 1 and item'code':sub (1, 1) == name or item'code' == name then

para = extractShortDesc (item)

if para ~= then

table.insert (wt, para)

end

end

end

end

function z.shortDesc (frame)

return shortDesc (frame, frame.args1)

end

function z.reasons (frame)

wt =

for i, item in ipairs (data) do

if item'code' == 'G8' then

-- 在提示選單隱藏 G8

else

allnames = extractAliases (item)

table.insert (wt, .. mw.text.listToText (allnames, '、', ' 或 ') .. .. item'criteria' .. )

end

end

return .. table.concat (wt) ..

end

function clone (t)

local n =

for k, v in pairs (t) do

if type (v) == type () then

nk = clone (v)

else

nk = v

end

end

setmetatable (n, getmetatable (t))

return n

end

local title = mw.title.getCurrentTitle

function z._input (args, options)

options = options or

-- precache

local map =

for i, item in ipairs (options.data or data) do

mapitem'code':lower = i

for j, alias in ipairs (item'aliases') do

mapalias:lower = i

end

end

-- parse

local i = 1

local rows =

while options.maxArgs and (i 20 then

-- 防止無限迴圈

break

end

item = {

code = nil,

criteria = nil

}

end

arg = args'c' .. i

if options.parseCommit and arg and mw.text.trim (arg) ~= then

item'commit' = arg

end

table.insert (rows, item)

i = i + 1

end

if #rows > 0 then

return rows

else

return nil

end

end

function z.input (frame)

if frame.args.parent then

args = frame:getParent .args

else

args = frame.args

end

local rows = z._input (args, {

maxArgs = 10,

checkFunc = true,

checkFile = true,

parseCommit = true

})

if not rows then

return frame.args.deletelink and or '（請填寫理由）' .. (args.cat or args.cate or args.category or)

elseif frame.args.reasoncode then

return rows1'code' or

end

local deletelinks =

local outputs =

local cat

for _, item in ipairs (rows) do

if item'code' and item'code' ~= then

local rowsuffix =

local rowsuffix2 =

local deletesuffix =

-- special case for F1/F5

if item'code' == 'F1' or item'code' == 'F5' then

if item'imgLink' then

deletesuffix = item'imgLink'

else

if item'check' then

rowsuffix2 = ' 為方便管理員檢查，請加上保留檔案的名稱。'

else

item'check' = ' 為方便管理員檢查，請加上保留檔案的名稱。'

end

end

end

-- special case for O1/G10 in user namespace, see Wikipedia: 機器人 / 申請 / Xiplus-abot/8

if title.namespace == 2 and (item'code' == 'O1' or item'code' == 'G10') then

rowsuffix2 = args.cat or args.cate or args.category or

end

if item'check' then

rowsuffix = .. item'check' .. .. (args.cat or args.cate or args.category or)

else

if frame.args.deletelink then

table.insert (deletelinks, 'WP:CSD#' .. item'code' .. '|' .. item'code' .. ': ' .. extractDeleteReason (item) .. deletesuffix)

end

rowsuffix = args.cat or args.cate or args.category or ('Category: 快速刪除候選 |' .. (item'category' or ' 速 ') .. )

end

table.insert (outputs, '* ' .. item'criteria' .. '（WP:CSD#' .. item'code' .. '|CSD ' .. item'code' .. .. deletesuffix .. '）' .. rowsuffix .. rowsuffix2 ..)

elseif item'code' == then

local arg = item'criteria'

-- try to read it as a title

local success, aTitle = mw.title.new (mw.text.trim (arg))

cat = args.cat or args.cate or args.category or

if aTitle and aTitle.exists then

if frame.args.deletelink then

table.insert (deletelinks, ':' .. arg ..)

end

table.insert (outputs, '*' .. cat .. ':' .. arg ..)

else

if frame.args.deletelink then

table.insert (deletelinks, arg)

end

arg = string.gsub (arg, '^(:#)(.*)', '%1%2')

table.insert (outputs, '*' .. cat .. arg)

end

end

if item'commit' then

table.insert (outputs, '*' .. item'commit')

end

end

-- for use by Twinkle

if frame.args.deletelink then

return mw.text.trim (table.concat (deletelinks, '；'):gsub ('。；', '；'):gsub ('。：', '：'))

else

return mw.text.trim (table.concat (outputs, '\n'))

end

end

return z