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

變更

前往: 導覽搜尋

模块:PageList

增加 1,764 位元組, 6 年前
無編輯摘要
local plp ={}local getArgs
local SPLITseparators ="、"{local LASTSPLIT dot ="和"true,local LIMIT pipe =20true, comma = true, ['tpt-languages'] = true}
pl.main=local functiongetSeparator(framesep) if not getArgs type(sep) ~= 'string' then getArgs = requirereturn nil end if separators[sep] then return mw.message.new(sep .. 'Module-separator'):Arguments'plain().getArgs else return sep
end
local args = getArgs(frame, {parentFirst=true})
local curPage_obj=mw.title.getCurrentTitle()
args["nspace"]=args["nspace"] or curPage_obj.nsText
return pl._main(args)
end
pl._main=local functiongenerateLink(args) local delim=args["delim"] or "" local edelim=args["edelim"] or delim local NS=args["page, nspace"] --mw.log(, delim, endDelim) --mw.log(edelim) --mw.log(NS) local out={} for i=1,LIMIT do local curVal,nextVal=args[i],args[i+1] if i~=1 not page then table.insert(out,(nextVal==nil and LASTSPLIT) or SPLIT) end if curVal~=return nil then table.insert(out,mw.ustring.format("%s[[:%s%s]]%s",delim,((NS=="" and "") or (NS..":")),curVal,edelim)) end if nextVal==nil then break end
end
return tablelocal pagename = mw.title.new(page) if not pagename then -- Default to the args we were passed if our page -- object was nil. pagename = page else pagename = pagename.text end delim = delim or '' endDelim = endDelim or delim nspace = nspace or '' if nspace == 'all' then nspace = '' pagename = page end local outStr = mw.ustring.gsub( string.concatformat(out '%s[[:%s:%s|%s]]%s',"" delim, nspace, pagename, page, endDelim ), ':+', ':' ) return outStr
end
 function p._main(args) local t = {} local separator = getSeparator(args.separator) local conjunction = getSeparator(args.conjunction) for i, v in ipairs(args) do table.insert(t, generateLink( v, args.nspace, args.delim, args.edelim )) end return plmw.text.listToText(t, separator, conjunction)end function p.main(frame) local origArgs = require('Module:Arguments').getArgs(frame, { trim = false, removeBlanks = false, wrappers = 'Template:Pagelist' })  -- Process integer args. Allow for explicit positional arguments that are -- specified out of order, e.g. {{br separated entries|3=entry3}}. -- After processing, the args can be accessed accurately from ipairs. local args = {} for k, v in pairs(origArgs) do if type(k) == 'number' and k >= 1 and math.floor(k) == k and string.match(v, '%S') then -- Remove blank or whitespace values. table.insert(args, k) end end table.sort(args) for i, v in ipairs(args) do args[i] = origArgs[v] -- Trim whitespace. if type(args[i]) == 'string' then args[i] = mw.text.trim(args[i]) end end  -- Get old named args. We don't need to remove blank values -- as for the nspace and edelim parameters the behaviour is different -- depending on whether the parameters are blank or absent, and for -- the delim parameter the default should be the blank string anyway. args.delim = origArgs.delim args.edelim = origArgs.edelim args.nspace = origArgs.nspace  -- Get new named args, "separator" and "conjunction", and strip blank values. if origArgs.separator and origArgs.separator ~= '' then args.separator = origArgs.separator end if origArgs.conjunction and origArgs.conjunction ~= '' then args.conjunction = origArgs.conjunction end  return p._main(args)end return p