Foundation Wiki
Advertisement

Documentation for this module may be created at Module:Namespace manager/doc

local p = {}
 
function p.articleManagement(frame)
    local namespaceAccess = {
        ['MAIN']      = 'true',
        ['TALK']      = 'false',
        ['FILE']      = 'true',
        ['FILE_TALK'] = 'false',
        ['USER']      = 'false',
        ['USER_TALK'] = 'false'
    }
 
    local namespace = nil
 
    if string.len(frame.args[1]) ~= 0 then
        namespace = frame.args[1]
    else
        namespace = 'MAIN'
    end
 
    local access = namespaceAccess[string.upper(namespace)]
 
    if access == nil then
        access = 'false'
    end
 
    return access
end

function _pagename(pagename)
	endChar = string.len(pagename)
	--Detect if title is potentially a disambiguation
	if string.sub(pagename, endChar) == ')' then
		stringParts = mw.text.split(pagename, " %(")
		stringCount = table.getn(stringParts)
		if stringCount == 2 then
			result = stringParts[1]
		else
			result = ''
			for k,v in ipairs(stringParts) do
				if k ~= stringCount then
					result = result .. v
					if k ~= stringCount then
						result = result .. ' ('
					end
				end
			end
		end
	else
		result = pagename
	end
	--Check if pagename is in a name and strip it out
	checkNs = string.find(result, ':')
	checkNonNs = string.find(result, ':\b')
	if checkNs ~= nil and checkNs ~= checkNonNs then
		result = string.sub(result, checkNs)
	end
	return result
end

function p.pagename (frame)
	return _pagename(frame.args[1])
end

return p
Advertisement