The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
package NewSpirit::Object;

$extensions = {
	'cipp' 		=> 'cipp',

	'cipp-module'	=> 'cipp-module',

	'cgi' 		=> 'cgi',

	'cipp-inc' 	=> 'cipp-inc',

	'gif' 		=> 'cipp-img',
	'jpg' 		=> 'cipp-img',
	'jpeg' 		=> 'cipp-img',
	'jpe' 		=> 'cipp-img',
	'png' 		=> 'cipp-img',
	'GIF' 		=> 'cipp-img',
	'JPG' 		=> 'cipp-img',
	'JPEG' 		=> 'cipp-img',
	'JPE' 		=> 'cipp-img',
	'PNG' 		=> 'cipp-img',

	'jar'		=> 'jar',
	'cab'		=> 'jar',
	'class'		=> 'jar',
	'properties'	=> 'jar',
	'JAR'		=> 'jar',
	'CAB'		=> 'jar',
	'CLASS'		=> 'jar',
	'PROPERTIES'	=> 'jar',

	'cipp-sql' 	=> 'cipp-sql',

	'cipp-html' 	=> 'cipp-html',
	'cipp-js'	=> 'cipp-html',
	'cipp-css'	=> 'cipp-html',
	
	'html' 		=> 'text',
	'js'		=> 'text',
	'css'		=> 'text',

	'cipp-config' 	=> 'cipp-config',

	'ddl-config'	=> 'ddl-config',

	'cipp-driver-config' 	=> 'cipp-base-conf',
	'cipp-base-config' 	=> 'cipp-base-conf',
	
	'txt'		=> 'text',
	
	'cipp-db'	=> 'cipp-db',
        
        'po'            => 'po',
        'text-domain'   => 'text-domain',

	'depend-all'	=> 'depend-all',
	
	'ns-unknown'	=> 'generic',
};

$object_type_order = [
	'cipp', 'cipp-inc', 'cipp-module', 'cipp-config', 'ddl-config', 'cipp-html',
	'cipp-img', 'cipp-sql', 'cipp-db', 'cgi', 'html', 'text',
        'po', 'text-domain',
	'jar', 'generic', 'blob', 'cipp-base-conf'
];

%blob_definition = (
	name 	=> 'Arbitrary Binary File',
	module 	=> 'NewSpirit::Object::Blob',
	icon 	=> 'icon_html.gif',
	default_extension => 'ns-blob',
	mime_type => 'application/x-spirit-unknown-type',
	properties => {
		install_target_dir => {
			description => 'Installation Type',
			default => "htdocs",
			type => {
				type => 'popup',
				items => [
					[ "htdocs", "static (install in prod/htdocs)" ],
					[ "cgi-bin", "program (install in prod/cgi-bin)" ],
					[ "", "no installation" ]
				],
			},
		},
		_original_filename => {
			description => 'original filename',
			default => undef,
			type => "text"
		},
	},
	property_order => [ 'install_target_dir', '_original_filename'  ],
	file_upload => 1,
	depend_install_object_types => [
		'cipp',
		'cipp-html',
	],
);

%jar_definition = %blob_definition;

$jar_definition{name}              = "Java File";
$jar_definition{default_extension} = "jar";

$object_types = {
	'jar' => \%jar_definition,

	'generic' => {
		name 	=> 'Generic File / Unknown Type',
		module 	=> 'NewSpirit::Object::Generic',
		icon 	=> 'icon_html.gif',
		default_extension => 'ns-unknown',
		mime_type => 'application/x-spirit-unknown-type',
		properties => {
			install_target_dir => {
				description => 'Installation Type',
				default => "",
				type => {
					type => 'popup',
					items => [
						[ "htdocs", "static (install in prod/htdocs)" ],
						[ "cgi-bin", "program (install in prod/cgi-bin)" ],
						[ "", "no installation" ]
					],
				},
			},
			show_as_text => {
				description => 'Viewable in Browser?',
				default => 0,
				type => "switch"
			},
			_original_filename => {
				description => 'original filename',
				default => undef,
				type => "text"
			},
		},
		property_order => [ 'show_as_text', 'install_target_dir', '_original_filename' ],
		file_upload => 1,
		depend_install_object_types => [
			'cipp',
			'cipp-html',
		],
	},

	'cipp' => {
		name 	=> 'CIPP Program',
		module 	=> 'NewSpirit::CIPP::CGI',
		icon 	=> 'icon_cipp.gif',
		default_extension => 'cipp',
		mime_type => 'application/x-spirit-object',
		properties => {
			mime_type => {
				description => 'Mime Type',
				default => 'text/html',
				type => [
					'text/html',
					'text/plain',
					'cipp/dynamic'
				]
			},
		},
		property_order => [ 'mime_type' ],
		file_upload => 0,
	},	
	'cipp-module' => {
		name 	=> 'CIPP Module',
		module 	=> 'NewSpirit::CIPP::Module',
		icon 	=> 'icon_cipp-module.gif',
		default_extension => 'cipp-module',
		mime_type => 'application/x-spirit-object',
		properties => {
			_pkg_name => {
				description => 'Module Package Name',
				default => "",
				type => 'text'
			}
		},
		property_order => [ '_pkg_name' ],
		file_upload => 0,
	},	
	'cgi' => {
		name 	=> 'Raw CGI Program',
		module 	=> 'NewSpirit::Object::Text',
		icon 	=> 'icon_cgi.gif',
		default_extension => 'cgi',
		target 	=> 'cgi-bin',
		mime_type => 'application/x-spirit-object',
		file_upload => 0,
	},	
	'cipp-inc' => {
		name 	=> 'CIPP Include',
		module 	=> 'NewSpirit::CIPP::Include',
		icon 	=> 'icon_cipp-inc.gif',
		default_extension => 'cipp-inc',
		mime_type => 'application/x-spirit-object',
		file_upload => 0,
		depend_install_object_types => [
			'cipp',
			'cipp-html',
			'cipp-module',
			'cipp-inc',
		],
	},	
	'cipp-img' => {
		name 	=> 'Image',
		module 	=> 'NewSpirit::Object::Image',
		icon 	=> 'icon_cipp-img.gif',
		default_extension => 'jpg',
		mime_type => 'image/gif',
		properties => {
			_image_filename => {
				description => 'Original Filename',
				default => undef,
				type => 'text'
			}
		},
		property_order => [ '_image_filename' ],
		file_upload => 1,
	},	
	'cipp-sql' => {
		name 	=> 'CIPP SQL Script',
		module 	=> 'NewSpirit::CIPP::SQL',
		icon 	=> 'icon_cipp-sql.gif',
		default_extension => 'cipp-sql',
		mime_type => 'application/x-spirit-object',
		properties => {
			sql_db => {
				description => 'Database Object',
				default => undef,
				type => 'method'
			}
		},
		property_order => [ 'sql_db' ],
		file_upload => 0,
	},	
	'cipp-html' => {
		name 	=> 'CIPP HTML',
		module 	=> 'NewSpirit::CIPP::HTML',
		icon 	=> 'icon_cipp-html.gif',
		default_extension => 'cipp-html',
		mime_type => 'application/x-spirit-object',
		file_upload => 0,
	},	
	'cipp-config' => {
		name 	=> 'CIPP Configuration',
		module 	=> 'NewSpirit::CIPP::Config',
		icon 	=> 'icon_cipp-config.gif',
		default_extension => 'cipp-config',
		mime_type => 'application/x-spirit-object',
		file_upload => 0,
		properties => {
			replace_object => {
				description => 'The following object should be replaced...',
				default => undef,
				type => 'text'
			},
			target_config => {
				description => '... when this base configuration is used for installation',
				default => undef,
				type => 'method'
			},
		},
		property_order => [ 'replace_object', 'target_config' ],
		depend_install_object_types => [
			'cipp-html',
		],
	},	
	'ddl-config' => {
		name 	=> 'Dimedis::Ddl Configuration',
		module 	=> 'NewSpirit::CIPP::Config',
		icon 	=> 'icon_cipp-config.gif',
		default_extension => 'cipp-config',
		mime_type => 'application/x-spirit-object',
		file_upload => 0,
		properties => {
			replace_object => {
				description => 'The following object should be replaced...',
				default => undef,
				type => 'text'
			},
			target_config => {
				description => '... when this base configuration is used for installation',
				default => undef,
				type => 'method'
			},
		},
		property_order => [ 'replace_object', 'target_config' ],
		depend_install_object_types => [ ],
	},	
	'cipp-base-conf' => {
		name 	=> 'CIPP Base Configuration',
		module 	=> 'NewSpirit::CIPP::Base',
		icon 	=> 'icon_cipp-driver-config.gif',
		default_extension => 'cipp-base-config',
		mime_type => 'application/x-spirit-object',
		file_upload => 0,
		depend_install_object_types => [
			'cipp-html',
		],
	},	
	'text' => {
		name 	=> 'Textfile',
		module 	=> 'NewSpirit::Object::Text',
		icon 	=> 'icon_html.gif',
		default_extension => 'txt',
		mime_type => 'application/x-spirit-object',
		file_upload => 0,
	},
	'cipp-db' => {
		name 	=> 'CIPP Database Configuration',
		module 	=> 'NewSpirit::CIPP::DB',
		icon 	=> 'icon_cipp-db.gif',
		default_extension => 'cipp-db',
		mime_type => 'application/x-spirit-object',
		file_upload => 0,
		properties => {
			replace_object => {
				description => 'The following object should be replaced...',
				default => undef,
				type => 'text'
			},
			target_config => {
				description => '... when this base configuration is used for installation',
				default => undef,
				type => 'method'
			},
		},
		property_order => [ 'replace_object', 'target_config' ],
	},
	'po' => {
		name 	=> 'gettext message catalog',
		module 	=> 'NewSpirit::CIPP::PO',
		icon 	=> 'icon_po.gif',
		default_extension => 'po',
		mime_type => 'text/plain',
		file_upload => 0,
		properties => {},
		property_order => [],
		depend_install_object_types => [ ],
	},	
	'text-domain' => {
		name 	=> 'gettext text domain',
		module 	=> 'NewSpirit::CIPP::TextDomain',
		icon 	=> 'icon_text-domain.gif',
		default_extension => 'text-domain',
		mime_type => 'text/plain',
		file_upload => 0,
		properties => {},
		property_order => [],
		depend_install_object_types => [ ],
	},	
	'depend-all' => {
		name 	=> 'Internal Object',
		module 	=> 'NewSpirit::Object::Install',
		icon 	=> '',
		default_extension => '',
		mime_type => '',
		file_upload => 0,
		properties => {},
		property_order => [],
		depend_install_object_types => [
			'cipp-base-conf',
			'cipp-inc',
			'cipp-config',
			'ddl-config',
			'cipp-db',
			'cipp-img',
			'cipp-sql',
			'cipp-html',
			'cipp-module',
			'cipp',
			'text',
                        'po',
			'jar',
			'generic',
		]
	},
};

# The object types with these extensions
# support the prod-replace feature
# (so they must have the attributes
# 'replace_object' and 'target_config')

%prod_replace_extensions = (
	'cipp-config' => 1,
	'cipp-db' => 1,
);

#print Dumper($object_types);

1;