Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:File license

From Tardis Wiki, the free Doctor Who reference
Revision as of 19:34, 4 March 2024 by Bongolium500 (talk | contribs)

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

local p = {} --p stands for package
local h = {} --h stands for helper

function p.makeLicense(frame)
	local args = frame:getParent().args
	
	local image = args["image"] or ""
	local imageSize = tonumber(args["imageSize"]) or 80
	local typeOfFile = args["typeOfFile"] or "image"
	local source = args["source"] or ""
	local license = args["license"] or ""
	local copyrightHolder = args["copyrightHolder"] or ""
	local intent = args["intent"] or "to illustrate articles"
	local tentative = args["tentative"] or ""
	
	if tentative == "false" then
		tentativeText = "It is believed that use"
	else
		tentativeText = "Use"
	end
	
	local typeOfFileArticle = "a"
	local vowels = {["a"] = true, ["e"] = true, ["i"] = true, ["o"] = true, ["u"] = true}
	if vowels[string.sub(typeOfFile, 1, 1)] then
		typeOfFileArticle = "an"
	end
	
	local sourceText = ""
	if source ~= "" then
		sourceText = " from " .. source
	end
	
	local imageCode = ""
	if image ~= "" then
		imageCode = '<span style="margin-top:5px;float:left;margin-right:10px;">[[File:' .. image .. '|' .. tostring(imageSize) .. "px]]</span>"
	else
		local imageData = mw.loadData("Module:File license/data/images")
		if imageData[copyrightHolder] then
			imageCode = '<span style="margin-top:5px;float:left;margin-right:10px;">[[File:' .. imageData[copyrightHolder] .. '|' .. tostring(imageSize) .. "px]]</span>"
		end
	end
	
	local copyrightHolderText = ""
	if copyrightHolder ~= "" then
		local copyrightHolderData = mw.loadData("Module:File license/data/copyright holders")
		if copyrightHolderData[copyrightHolder] then
			copyrightHolderText = copyrightHolderData[copyrightHolder]
		elseif copyrightHolderDisplay then
			copyrightHolderText = "[[" .. copyrightHolder .. "|" .. copyrightHolderDisplay .. "]]"
		else
			copyrightHolderText = copyrightHolder
		end
	end
	
	local licenseData = mw.loadData("Module:File license/data/licenses")
	local licenseText = ""
	if licenseData[license] then
		licenseText = licenseData[license]
	end
	
	local finalLicense = '<div id="license">' .. imageCode .. "This file is " .. typeOfFileArticle .. " '''" .. typeOfFile .. "'''" .. sourceText .. ". It's copyright is owned by " .. copyrightHolderText .. ".<br/>" .. tentativeText .. " of this " .. typeOfFile .. " " .. intent .. " on Tardis Wiki, hosted on servers in __ by Wiki Federation, " .. licenseText .. "</div>"
	return finalLicense
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.