Module:NoteTA:修订间差异

求闻百科,共笔求闻
添加的内容 删除的内容
无编辑摘要
标签已被回退
(回退SolidBlock对话)的编辑:2003年至2004年阿根廷足球甲级联赛出错:无法调用旧的转换模板)
标签回退
第1行: 第1行:
local p = {}
local z = {}
local TableTools = require 'Module:TableTools'
local WikitextLC = require( 'Module:WikitextLC' )
local insert = table.insert
local CGroup = require 'Module:CGroup'


function p.main(frame)
function Tcode( args )
if args.T == nil or args.T == '' then
local getArgs = require 'Module:Arguments'.getArgs
return ''
local args = getArgs(frame)
local code = mw.html.create()
if args.T and args.T ~= '' then
code:wikitext('-{T|' .. args.T .. '}-')
end
end
local div = mw.html.create( 'div' )
for k, v in TableTools.sparseIpairs(args) do
:attr( 'class', 'noteTA-title' )
-- 视为一条转换组规则。
code:wikitext('-{H|' .. v .. '}-')
:attr( 'data-noteta-code', args.T )
:wikitext( WikitextLC.title( args.T ) )
if args.dt ~= nil and args.dt ~= '' then
div:attr( 'data-noteta-desc', args.dt )
end
end
return tostring( div )
local re = TableTools.allPrefixedNumKeys(args)
end
if re.G then

for k, v in TableTools.sparseIpairs(re.G) do
function group( name, frame )
code:wikitext(tostring(CGroup.toWikitext(CGroup.load(v))))
if name == nil or name == '' then
return ''
end
local moduleTitle = mw.title.makeTitle( 'Module', 'CGroup/' .. name )
if moduleTitle and moduleTitle.exists then
local data = mw.loadData( 'Module:CGroup/' .. name )
local pieces = {}
if data.content then
for i, v in ipairs( data.content ) do
if v.type == 'item' and v.rule then
table.insert( pieces, '-{H|' .. v.rule .. '}-' )
end
end
return tostring( mw.html.create( 'div' )
:attr( 'data-noteta-group-source', 'module' )
:attr( 'data-noteta-group', data.name or name )
:wikitext( table.concat( pieces ) ) )
end
end
local templateTitle = mw.title.makeTitle( 'Template', 'CGroup/' .. name )
if templateTitle and templateTitle.exists then
return frame:expandTemplate{ title = templateTitle }
end
return tostring( mw.html.create( 'div' )
-- :attr( 'id', 'noteTA-group-' .. mw.uri.anchorEncode( name ) )
:attr( 'data-noteta-group-source', 'none' )
:attr( 'data-noteta-group', name ) )
end

function Gcode( args, frame )
local code = {}
for i = 1, 30 do
table.insert( code, group( args['G' .. i], frame ) )
end
code = table.concat( code )
if code ~= '' then
code = tostring( mw.html.create( 'div' )
:attr( 'class', 'noteTA-group' )
:wikitext( code ) )
if args.G31 ~= nil then
code = code .. '[[Category:NoteTA模板参数使用数量超过限制的页面|G]]'
end
end
return code
end

function local_( i, code, desc )
if code == nil or code == '' then
return ''
end
local div = mw.html.create( 'div' )
-- :attr( 'id', 'noteTA-local-' .. i )
:attr( 'data-noteta-code', code )
:wikitext( WikitextLC.hidden( code ) )
if desc ~= nil and desc ~= '' then
div:attr( 'data-noteta-desc', desc )
end
return tostring( div )
end

function Lcode( args )
local code = {}
for i = 1, 30 do
table.insert( code, local_( i, args[i], args['d' .. i] ) )
end
code = table.concat( code )
if code ~= '' then
code = tostring( mw.html.create( 'div' )
:attr( 'class', 'noteTA-local' )
:wikitext( code ) )
if args[31] ~= nil then
code = code .. '[[Category:NoteTA模板参数使用数量超过限制的页面|L]]'
end
end
return code
end

function z.main( frame )
local args
if frame == mw.getCurrentFrame() then
-- Being called from {{noteTA}}
args = frame:getParent().args
else
-- Being called from another module
args = frame
frame = mw.getCurrentFrame()
end
local Tc = Tcode( args )
local Gc = Gcode( args, frame )
local Lc = Lcode( args )
local code = Tc .. Gc .. Lc
if code ~= '' then
local hash = require( 'Module:Crc32lua' ).crc32( mw.dumpObject( args ) )
code = frame:extensionTag{
name = 'indicator',
content = '-{zh:[[File:Conversion Zh.svg|35px|本页使用了标题或全文手工转换,现处于不转换模式|link=]];zh-hans:[[File:Conversion Zh-hans.svg|35px|本页使用了标题或全文手工转换,现处于简体转换模式|link=]];zh-cn:[[File:Conversion Zh-hans.svg|35px|本页使用了标题或全文手工转换,现处于中国大陆简体模式|link=]];zh-my:[[File:Conversion Zh-hans.svg|35px|本页使用了标题或全文手工转换,现处于马来西亚简体模式|link=]];zh-sg:[[File:Conversion Zh-hans.svg|35px|本页使用了标题或全文手工转换,现处于新加坡简体模式|link=]];zh-hant:[[File:Conversion Zh-hant.svg|35px|本页使用了标题或全文手工转换,现处于繁体转换模式|link=]];zh-hk:[[File:Conversion Zh-hant.svg|35px|本页使用了标题或全文手工转换,现处于香港繁体模式|link=]];zh-mo:[[File:Conversion Zh-hant.svg|35px|本页使用了标题或全文手工转换,现处于澳门繁体模式|link=]];zh-tw:[[File:Conversion Zh-hant.svg|35px|本页使用了标题或全文手工转换,现处于台湾繁体模式|link=]];}-',
args = { name = string.format( 'noteTA-%x', hash ) },
} .. tostring( mw.html.create( 'div' )
:attr( 'id', string.format( 'noteTA-%x', hash ) )
:attr( 'class', 'noteTA' )
:wikitext( code ) )
if mw.title.getCurrentTitle():inNamespace( 'Template' ) then
code = code .. '[[Category:放置于模板的noteTA]]'
end
end
end
end
第24行: 第125行:
end
end


return p
return z