ข้ามไปเนื้อหา

มอดูล:เป็นบทความ

จากวิกิพีเดีย สารานุกรมเสรี
Documentation icon คู่มือการใช้งานมอดูล[ดู] [แก้] [ประวัติ] [ล้างแคช]

มอดูล:เป็นบทความ ใช้เพื่อพิจารณาว่าหน้าใดหน้าหนึ่งเป็นบทความ หน้าเปลี่ยนทาง หน้าแก้ความกำกวม ไม่มีหน้า หรือใช้เป็นชื่อหน้าไม่ได้

การใช้งาน[แก้]

ค่าที่ส่งคืน[แก้]

ผลลัพธ์และค่าที่ส่งคืน
ผลลัพธ์ ค่าที่ส่งคืน
บทความ บทความ
หน้าเปลี่ยนทาง เปลี่ยนทาง
หน้าแก้ความกำกวม แก้ความกำกวม
ไม่มีหน้า ว่าง
ใช้เป็นชื่อหน้าไม่ได้ ใช้ชื่อนี้ไม่ได้

รายการพารามิเตอร์[แก้]

พารามิเตอร์ คำอธิบาย
1 พารามิเตอร์ตำแหน่งหรือหมายเลข; ชื่อหน้า

local p = {}

local disambiguationTemplates = {
	"[Dd]isambiguation",
	"[Dd]isambig",
	"[Dd]isamb",
	"[Dd]ab",
	"[Ss]urname",
	"[Tt]emplate disambiguation",
	"แก้ความกำกวม",
	"หน้าแก้ความกำกวม"
}

function p.main(frame)
	local getArgs = require("Module:Arguments").getArgs
	local args = getArgs(frame)
	local page = mw.title.new(args[1], 0)
	
	if not page then
		return "ใช้ชื่อนี้ไม่ได้"
	end

	if not page.exists then
		return "ว่าง"
	end

	if page.isRedirect then
		return "เปลี่ยนทาง"
	end

	local content = page:getContent()
	if content then
		content = string.gsub(content, "noinclude", "<!-- noinclude -->")
		for _, name in ipairs(disambiguationTemplates) do
			if content:match("{{%s?" .. name .. "%s?}}") and not content:match("{{{%s?" .. name .. "%s?}}}") then -- to disable false positives in parameter names {{{disamb}}}
				return "แก้ความกำกวม"
			end
		end
	end

	return "บทความ"
end

return p