<?php if(!defined('master_script')) die();

/**
 * Default data
 *
 * @category   Module (images)
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-12-07
 */
	
	$modules['images']['version'] = '1.2';
	$modules['images']['author'] = 'Nico Wenig';
	$modules['images']['support'] = 'mailto:nico.wenig@yellowgreen.de';
	$modules['images']['pagemap version'] = '0.5';
	$modules['images']['for'] = 'all';
	$modules['images']['key'] = 'images';
	$modules['images']['path'] = $system_data['folder']['modules'] . $modules['images']['key'] . '/';
	$modules['images']['languages'] = $system_data['folder']['modules'] . $modules['images']['key'] . '/languages/';
	$modules['images']['protected'] = 0;
	$modules['images']['preview'] = 0;
	
	include_txt($modules['images']['key'], $modules['images']['languages']);

/**
 * Save module to page
 *
 * @category   Module (images)
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2010-08-08
 */

	if(isset($_POST['save_images'])) {
		// Parse data
		$_POST['images_per_row'] = intval($_POST['images_per_row']) == '' ? 5 : intval($_POST['images_per_row']);
		$_POST['thumbnail_size'] = intval($_POST['thumbnail_size']) == '' ? 156 : intval($_POST['thumbnail_size']);
		$_POST['thumbnail_crop_width'] = intval($_POST['thumbnail_crop_width']) == '' ? 156 : intval($_POST['thumbnail_crop_width']);
		$_POST['thumbnail_crop_height'] = intval($_POST['thumbnail_crop_height']) == '' ? 156 : intval($_POST['thumbnail_crop_height']);
		$_POST['thumbnail_background'] = is_rgb($_POST['thumbnail_background']) ? $_POST['thumbnail_background'] : '#000000';
		$_POST['thumbnail_quality'] = intval($_POST['thumbnail_quality']) == '' ? 85 : intval($_POST['thumbnail_quality']);
		$_POST['thumbnail_reflection'] = intval($_POST['thumbnail_reflection']) == '' ? 0 : intval($_POST['thumbnail_reflection']);
		$_POST['thumbnail_rotation'] = intval($_POST['thumbnail_rotation']) == '' ? 0 : intval($_POST['thumbnail_rotation']);
		$_POST['thumbnail_rotate_cw'] = isset($_POST['thumbnail_rotate_cw']) ? 1 : 0;
		
		$_POST['image_width'] = intval($_POST['image_width']) == '' ? 800 : intval($_POST['image_width']);
		$_POST['image_height'] = intval($_POST['image_height']) == '' ? 600 : intval($_POST['image_height']);
		$_POST['image_fullscreen'] = isset($_POST['image_fullscreen']) ? 1 : 0;
		$_POST['image_properties'] = isset($_POST['image_properties']) ? 1 : 0;
		$_POST['popup_width'] = intval($_POST['popup_width']) == '' ? 800 : intval($_POST['popup_width']);
		$_POST['popup_height'] = intval($_POST['popup_height']) == '' ? 600 : intval($_POST['popup_height']);
		$_POST['page_start_full'] = isset($_POST['page_start_full']) ? 1 : 0;
		$_POST['page_show_controls'] = isset($_POST['page_show_controls']) ? 1 : 0;
		$_POST['page_show_images'] = isset($_POST['page_show_images']) ? 1 : 0;

		$_POST['slideshow'] = isset($_POST['slideshow']) ? 1 : 0;
		$_POST['slideshow_pause_start'] = isset($_POST['slideshow_pause_start']) ? 1 : 0;
		$_POST['slideshow_loop'] = isset($_POST['slideshow_loop']) ? 1 : 0;
		$_POST['slideshow_seconds'] = intval($_POST['slideshow_seconds']) < 0 ? 5 : intval($_POST['slideshow_seconds']);
		$_POST['slideshow_seconds'] = $_POST['slideshow_seconds'] > 10 ? 10 : $_POST['slideshow_seconds'];
	
		// Delete page cache
		$cachedir = $_POST['images_dir'] . 'cache/';
		if(file_exists($cachedir)) rec_rmdir($cachedir);
		
		// Create module section
		$module_content_to_save = '
			<!-- MODULE: images -->
			
			<?php
				$module_settings["images"] = array(
					"language" => "' . clean_string($_POST['language'], true) . '",
					"margin top" => ' . intval($_POST['margin_top']) . ',
					"margin left" => ' . intval($_POST['margin_left']) . ',
					"css class" => "' . clean_string($_POST['css_class'], true) . '",
					"css id" => "' . clean_string($_POST['css_id'], true) . '",
					
					"images dir" => "' . $_POST['images_dir'] . '",
					"images sort order" => "' . $_POST['images_sort_order'] . '",
					"images per row" => ' . $_POST['images_per_row'] . ',
					"thumbnail size" => ' . $_POST['thumbnail_size'] . ',
					"thumbnail crop width" => ' . $_POST['thumbnail_crop_width'] . ',
					"thumbnail crop height" => ' . $_POST['thumbnail_crop_height'] . ',
					"thumbnail mode" => "' . $_POST['thumbnail_mode'] . '",
					"thumbnail background" => "' . $_POST['thumbnail_background'] . '",
					"thumbnail quality" => ' . $_POST['thumbnail_quality'] . ',
					"thumbnail reflection" => ' . $_POST['thumbnail_reflection'] . ',
					"thumbnail rotation" => ' . $_POST['thumbnail_rotation'] . ',
					"thumbnail rotate cw" => ' . $_POST['thumbnail_rotate_cw'] . ',
					"image width" => ' . $_POST['image_width'] . ',
					"image height" => ' . $_POST['image_height'] . ',
					"image fullscreen" => ' . $_POST['image_fullscreen'] . ',
					"image properties" => ' . $_POST['image_properties'] . ',
					"open image" => "' . $_POST['open_image'] . '",
					"popup width" => ' . $_POST['popup_width'] . ',
					"popup height" => ' . $_POST['popup_height'] . ',
					"page start full" => ' . $_POST['page_start_full'] . ',
					"page show controls" => ' . $_POST['page_show_controls'] . ',
					"page show images" => ' . $_POST['page_show_images'] . ',
					"link attributes" => "' . clean_string($_POST['link_attributes'], true) . '",
					"slideshow" => ' . $_POST['slideshow'] . ',
					"slideshow pause start" => ' . $_POST['slideshow_pause_start'] . ',
					"slideshow loop" => ' . $_POST['slideshow_loop'] . ',
					"slideshow seconds" => ' . $_POST['slideshow_seconds'] . ',
					"gallery description" => "' . strip_custom_tags($_POST['gallery_description'], true, false, true, false, true) . '",
					"gallery link text" => "' . clean_string($_POST['gallery_link_text'], true) . '"
				);

				' . connector('images backend save') . '
				include_module("images", false);
			?>
		';
	}

?>