模組:Category handler/shared

對HuaTaiLohankhapedia
Kàu tō-lám 跳至搜尋


  1. 重定向 Template:Uses Loa

-{H|zh-hans:重定向; zh-hant:閣再導向;}--{H|zh-cn:文字; zh-tw:字元;}--{H|zh-hans:文件; zh-hant:檔案;}--{H|zh-hans:快捷方式; zh-hant:捷徑;}--{H|zh-hans:項目; zh-hant:專案; zh-tw:計畫; zh-hk:計畫; zh-mo:計畫;}--{H|zh-cn:計算機; zh-sg:電腦; zh-tw:電腦;}-Lua 錯誤 於第53行的模組:Effective_protection_level中:attempt to index field 'TitleBlacklist' (a nil value)。


-- This module contains shared functions used by [[Module:Category handler]]
-- and its submodules.

local p = {}

function p.matchesBlacklist(page, blacklist)
	for i, pattern in ipairs(blacklist) do
		local match = mw.ustring.match(page, pattern)
		if match then
			return true
		end
	end
	return false
end

function p.getParamMappings(useLoadData)
	local dataPage = 'Module:Namespace detect/data'
	if useLoadData then
		return mw.loadData(dataPage).mappings
	else
		return require(dataPage).mappings
	end
end

function p.getNamespaceParameters(titleObj, mappings)
	-- We don't use title.nsText for the namespace name because it adds
	-- underscores.
	local mappingsKey
	if titleObj.isTalkPage then
		mappingsKey = 'talk'
	else
		mappingsKey = mw.site.namespaces[titleObj.namespace].name
	end
	mappingsKey = mw.ustring.lower(mappingsKey)
	return mappings[mappingsKey] or {}
end

return p