Wiki - KEONHACAI COPA

Mô đun:Cat main

Tài liệu mô đun[tạo]
-- This module implements {{cat main}}.

local mHatnote = require('Mô đun:Hatnote')
local yesno = require('Mô đun:Yesno')
local mTableTools -- lazily initialise
local mArguments -- lazily initialise

local p = {}

function p.catMain(frame)
	mTableTools = require('Mô đun:TableTools')
	mArguments = require('Mô đun:Arguments')
	local args = mArguments.getArgs(frame, {wrappers = 'Bản mẫu:Bài chính thể loại'})
	local pages = mTableTools.compressSparseArray(args)
	local options = {
		article = args.article,
		selfref = args.selfref
	}
	return p._catMain(options, unpack(pages))
end

function p._catMain(options, ...)
	options = options or {}

	-- Get the links table.
	local links = mHatnote.formatPages(...)
	if not links[1] then
		local page = mw.title.getCurrentTitle().text
		links[1] = mHatnote._formatLink(page)
	end
	for i, link in ipairs(links) do
		links[i] = string.format("'''%s'''", link)
	end

	-- Get the pagetype.
	local pagetype
	if yesno(options.article) ~= false then
		pagetype = 'Bài viết'
	else
		pagetype = 'Trang'
	end

	-- Work out whether we need to be singular or plural.
	local stringToFormat
	if #links > 1 then
		stringToFormat = '%s chính của [[Wikipedia:Thể loại|thể loại]] này là %s.'
	else
		stringToFormat = '%s chính của [[Wikipedia:Thể loại|thể loại]] này là %s.'
	end

	-- Get the text.
	local text = string.format(
		stringToFormat,
		pagetype,
		mw.text.listToText(links)
	)
	
	-- Pass it through to Module:Hatnote.
	local hnOptions = {}
	hnOptions.selfref = options.selfref
	hnOptions.extraclasses = 'relarticle mainarticle'

	return mHatnote._hatnote(text, hnOptions)
end

return p
Wiki - Keonhacai copa chuyên cung cấp kiến thức thể thao, keonhacai tỷ lệ kèo, bóng đá, khoa học, kiến thức hằng ngày được chúng tôi cập nhật mỗi ngày mà bạn có thể tìm kiếm tại đây có nguồn bài viết: https://vi.wikipedia.org/wiki/M%C3%B4_%C4%91un:Cat_main