Module:HookCategories

From Linux Web Expert

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

local p = {}
function p.cat(frame)
	if frame.args.skip ~= "" then
		return ""
	end
	local extension = frame.args.extension
	if extension == "" then
		local skin = frame.args.skin
		if skin == "" then
			local titleObj  = mw.title.new("Manual:Hooks/" .. frame.args[1])
			if titleObj.exists then
				if titleObj:getContent():find("removed *= *1.", 1, false) then
					return "[[Category:Extensions using removed hooks" .. frame:preprocess("{{#translation:}}") .. "]]"
				elseif titleObj:getContent():find("deprecated *= *1.", 1, false) then
					return "[[Category:Extensions using deprecated hooks" .. frame:preprocess("{{#translation:}}") .. "]]"
				end
			else
				return "[[Category:Extensions using redlinked hooks" .. frame:preprocess("{{#translation:}}") .. "]]"
			end
		else
			local titleObj = mw.title.new("Skin:" .. skin)
			if not titleObj.exists then
				return "[[Category:Extensions using hooks from redlinked sources" .. frame:preprocess("{{#translation:}}") .. "]]"
			end
		end
	else
		local titleObj = mw.title.new("Extension:" .. extension)
		if not titleObj.exists then
			return "[[Category:Extensions using hooks from redlinked sources" .. frame:preprocess("{{#translation:}}") .. "]]"
		end
	end
end
return p