Marvel Database
Advertisement
Marvel Database

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

-- module for Marvel Database:Gallery Template
local p = {}
local getArgs = require('Module:Arguments').getArgs 
local h = require("Module:HF")
local design = require('Module:Design')
local standard = require("Module:StandardizedName")

function p.main(frame)
	local args = getArgs(frame)
	local subpageText = mw.title.getCurrentTitle().subpageText
	local baseText = mw.title.getCurrentTitle().baseText
	local sortname = require('Module:StandardizedName').name_for_sorting({baseText})
	--local pagetype = require('Module:PageType').get_page_type(baseText)
	local GalleryType = args.GalleryType
	local GalleryData = args.GalleryData
	local categories = {}
	local output_categories = {}
	local output = ''
	
	if not h.isempty(GalleryType)
		then GalleryType = p.get_gallery_type( string.lower(GalleryType) )
		else GalleryType = ''
	end

	if subpageText ~= 'Gallery'
		then
			table.insert(output_categories, 'Wrong Galleries')
			output = design.messagebox({'This template means to be used on "/Gallery" subpages.'})
		else
			if GalleryType == 'Video Game'
				then output, categories = require('Module:Category Message Templates').lua_standard_subcategories_and_subpages2(baseText, 'Gallery', GalleryType)
				else output, categories = require('Module:Category Message Templates').lua_standard_subcategories_and_subpages(baseText, 'Gallery', GalleryType)	
			end
			output_categories = h.join_tables(output_categories, categories)
			if h.isempty(GalleryData) or string.find(mw.text.nowiki( GalleryData ), 'gallery') == nil 
				then 
					table.insert(output_categories, 'Empty Galleries')
					output = design.messagebox({'The gallery is empty.'})
				else
					output = '__NOEDITSECTION__'..output
					--if GalleryType ~= pagetype
					--	then
					--		table.insert(output_categories, 'Wrong Galleries')
					--		output = output..design.messagebox({'"GalleryType" parameter "'..GalleryType..'" does not match the type "'..pagetype..'"of the base page.'})
					--end
					output = output..'\n'..GalleryData
					output = '<center>'..output..'</center>'
					output = output..design.add_section('See Also', args.SeeAlso, 2)..'\n<references />'
			end
			
	end
	
	return frame:preprocess(output), h.add_categories(output_categories, sortname)
end


--------------------------------------------------------------------------------
function p.get_gallery_type(value)
	local output = ''
	if h.in_list({ 'char', 'character', 'character gallery' }, value)
		then output = 'Character'
		elseif h.in_list({ 'team', 'team gallery' }, value)
			then output = 'Team'
		elseif h.in_list({ 'organization', 'organization gallery' }, value)
			then output = 'Organization'
		elseif h.in_list({ 'location', 'location gallery' }, value)
			then output = 'Location'		
		elseif h.in_list({ 'item', 'item gallery' }, value)
			then output = 'Item'
		elseif h.in_list({ 'vehicle', 'vehicle gallery' }, value)
			then output = 'Vehicle'
		elseif h.in_list({ 'race', 'race gallery' }, value)
			then output = 'Race'
		elseif h.in_list({ 'universe', 'reality' }, value)
			then output = 'Reality'		
		elseif h.in_list({ 'event', 'event gallery' }, value)
			then output = 'Event'		
		elseif h.in_list({ 'user', 'user art', 'user-art', 'user art gallery' }, value)
			then output = 'User Art'
		elseif h.in_list({ 'cover', 'cover art', 'artist', 'artist gallery' }, value)
			then output = 'Artist'
		elseif h.in_list({ 'staff', 'marvel staff', 'marvel staff gallery' }, value)
			then output = 'Marvel Staff'
		elseif h.in_list({ 'game', 'video game', 'video game gallery' }, value)
			then output = 'Video Game'
	end

	return output
end

return p
Advertisement