跳转到内容

模組:Fullurl

本页使用了标题或全文手工转换
被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由SunAfterRain留言 | 贡献2019年8月11日 (日) 02:03编辑。这可能和当前版本存在着巨大的差异。

local fullurl = {}

function fullurl._getaction(action)
	local actionlist = {
		--[""] = viewpaid,
		--["view"] = viewpaid,
		["edit"] = editpaid,
		--["history"] = historoypaid,
		--["delete"] = deletepaid,
		--["protect"] = protectpaid,
	}
	if actionlist[action] == nil then
		return ""
	end
	return actionlist[action]
end

function fullurl.fullurl(frame)
	if frame == mw.getCurrentFrame() then
        args = frame.args
    else
        args = frame
        if type(args) ~= type({}) then args = {frame} end
    end
	local title = args['title'] or args[1] or tostring(mw.title.getCurrentTitle())
	local text = args['text'] or args[2] or title
	local action = (args['action'] and 'action=' or '') .. (args['action'] or '')
	local preloadparams = {}
	local preloadparams2 = ''
	local i=1
    while true do
        t_preloadparams=args['preloadparams'..i]
        if (t_preloadparams~=nil) then
        	if t_preloadparams ~= '' then
            	table.insert(preloadparams,t_preloadparams)
            end
            i=i+1
        else
            break
        end 
    end
    for i=1,#preloadparams do
        preloadparams2 = 'preloadparams[]=' .. ids[i]
    end
    local viewpaid = ''
    local editpaid = (args['section'] and '&section=' or '') .. (args['section'] or '') ..
                     (args['summary'] and '&summary=' or '') .. (args['summary'] or '') ..
                     (args['preload'] and '&preload=' or '') .. (args['preload'] or '') .. 
                     (args['preloadtitle'] and '&preloadtitle=' or '') .. (args['preloadtitle'] or '') .. 
                     preloadparams2
    
    local other = args['other'] or ''
    local paid = ((args['action'] == 'edit') and editpaid or '')
    return '<span class="plainlinks">[' .. tostring(mw.uri.fullUrl(title,action .. paid .. other)) .. ' ' .. text .. ']</span>'
end

return fullurl