Jump to content

Module:PD-TH-exempt

From Wikisource

--[=[
Implements [[Template:PD-TH-exempt]]
]=]

local p = {} --p stands for package

local getArgs = require('Module:Arguments').getArgs
local PD = require('Module:PD')
local error_function = require('Module:Error')['error']

function p._PD_TH_exempt(args)
	local work_type = tonumber(args[1] or args.work_type or args.worktype or args['work type'])
	if work_type and (math.ceil(work_type) ~= work_type or work_type < 1 or work_type > 5) then
		work_type = nil
	end
	
	local category = args.category
	if not category and work_type then
		category = "PD-TH-exempt - section 7(" .. work_type .. ")"
	elseif not category then
		category = "PD-TH-exempt without work type"
	end
	
	local section
	if work_type then
		section = "'''section 7(" .. work_type .. ")'''"
	else
		section = error_function({"Template error: please specify the type of this work (see [[Template:PD-TH-exempt#Template documentation|template documentation]])"})
	end
	
	local text = PD.license_scope() .. " in the '''public domain worldwide''' because " .. PD.license_grammar({"it", "they"}) .. " originated in Thailand and " .. PD.license_grammar({"is a work", "are works"}) .. " under " .. section .. " of Thailand's [[:th:พระราชบัญญัติลิขสิทธิ์ พ.ศ. 2537|Copyright Act, 2537 BE (1994)]] ''([https://www.wipo.int/wipolex/en/details.jsp?id=3801 WIPO translation])'', which provides:"
	
	local frame = mw.getCurrentFrame()
	local law_quote = frame:expandTemplate {
		title = 'blockquote',
		args = {
			"'''7.''' The following shall not be deemed copyright works under this Act:\n#news of the day and facts having the character of mere information, not being works in the literary, scientific or artistic fields;\n#the constitution and legislation;\n#regulations, bylaws, notifications, orders, explanations and official correspondence of the Ministries, Departments or any other government or local units;\n#judicial decisions, orders, decisions and official reports;\n#translations and collections of the materials referred to in items (1) to (4), made by the Ministries, Departments or any other government or local units."
		}
	}
	
	text = text .. law_quote
	
	return PD.license({
		['image'] = PD.PD_image,
		['image_r'] = 'Emblem of Thailand.svg',
		['text'] = text,
		['category'] = category
	})
end

function p.PD_TH_exempt(frame)
	return p._PD_TH_exempt(getArgs(frame))
end

return p