<!-- MODULE: image-set -->

<?php quick_help(txt('image-set', 'quick-help: image-set')); ?>

<?php if(!defined('master_script')) die();
	
/**
 * Default settings
 *
 * @category   Module (image-set)
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2010-06-15
 */

	if(!isset($module_settings['image-set']['images dir'])) $module_settings['image-set']['images dir'] = $system_data['folder']['pages'] . $_GET['page'] . '/';
	if(!isset($module_settings['image-set']['images sort order'])) $module_settings['image-set']['images sort order'] = 'none';
	if(!isset($module_settings["image-set"]["image width"])) $module_settings["image-set"]["image width"] = 800;
	if(!isset($module_settings["image-set"]["image height"])) $module_settings["image-set"]["image height"] = 600;
	if(!isset($module_settings["image-set"]["open image"])) $module_settings["image-set"]["open image"] = 'disabled';
	if(!isset($module_settings["image-set"]["image properties"])) $module_settings["image-set"]["image properties"] = 1;
	if(!isset($module_settings["image-set"]["link attributes"])) $module_settings["image-set"]["link attributes"] = 'rel=&quot;lytebox[' . $_GET['module-position'] . ']&quot;';
	if(!isset($module_settings["image-set"]["popup width"])) $module_settings["image-set"]["popup width"] = 800;
	if(!isset($module_settings["image-set"]["popup height"])) $module_settings["image-set"]["popup height"] = 600;
	
	if(!is_dir($module_settings['image-set']['images dir'])) $module_settings['image-set']['images dir'] = $system_data['folder']['pages'] . $_GET['page'] . '/';
	
/**
 * Get dir list
 *
 * @category   Module (image-set)
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2010-06-15
 */
	
	$page_folder = $system_data['folder']['pages'] . $_GET['page'] . '/';
	$image_dirs = dirlist($page_folder, array('storage', 'cache'));
	$image_dirs = array_merge(array($page_folder), $image_dirs);

/**
 * Backend template
 *
 * @category   Module (image-set)
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2010-06-15
 */
	
?>

<form accept-charset="utf-8" method="post" action="index.php?backend=edit-content&amp;page=<?php echo $_GET['page']; ?>&amp;module-to-edit=<?php echo $_GET['module-to-edit']; ?>&amp;module-position=<?php echo $_GET['module-position']; ?>" onsubmit="return this.confirm">
	<?php include($system_data['folder']['modules'] . 'module-properties/backend-template.tpl'); ?>
	
	<?php connector('image-set backend tpl before'); ?>

	<h4><?php echo txt('image-set', 'Bildserie'); ?></h4>

	<div class="column">
		<p>
			<label for="images_dir"><?php echo txt('image-set', 'Quellverzeichnis'); ?>:</label>
			<select size="1" name="images_dir" id="images_dir">
				<?php foreach($image_dirs as $dir) { ?>
					<option value="<?php echo clean_output($dir); ?>/" <?php if($dir . '/' == $module_settings['image-set']['images dir']) echo 'selected="selected"'; ?>><?php echo str_replace($system_data['folder']['pages'], '', $dir); ?></option>
				<?php } ?>
			</select>
		</p>

	   	<div class="advanced-input">
			<label for="images_sort_order"><?php echo txt('image-set', 'Sortierung'); ?>:</label>
			<select size="1" name="images_sort_order" id="images_sort_order">
				<option value="none" <?php if($module_settings['image-set']['images sort order'] == 'none') echo 'selected="selected"'; ?>><?php echo txt('image-set', 'Keine (Dateiliste)'); ?></option>
				<option value="reverse" <?php if($module_settings['image-set']['images sort order'] == 'reverse') echo 'selected="selected"'; ?>><?php echo txt('image-set', 'Umgekehrt'); ?></option>
				<option value="random" <?php if($module_settings['image-set']['images sort order'] == 'random') echo 'selected="selected"'; ?>><?php echo txt('image-set', 'Zufällig'); ?></option>
				<option value="name_descending" <?php if($module_settings['image-set']['images sort order'] == 'name_descending') echo 'selected="selected"'; ?>><?php echo txt('image-set', 'Name (absteigend)'); ?></option>
				<option value="name_ascending" <?php if($module_settings['image-set']['images sort order'] == 'name_ascending') echo 'selected="selected"'; ?>><?php echo txt('image-set', 'Name (aufsteigend)'); ?></option>
			</select>
			
	   		<a id="filelist" href="#filelist" onclick="images_openFilelist(); return false" title="<?php echo txt('image-set', 'Dateiliste bearbeiten.'); ?>">&nbsp;</a>
	   	</div>
	   	
	   	<br>

		<table style="width: 100%">
			<tr>
				<td>
					<label for="image_width"><?php echo txt('images', 'Maximale Bildgröße'); ?>:</label>
				</td>
				<td style="text-align: right">
					<input type="text" id="image_width" name="image_width" class="number" value="<?php echo clean_output($module_settings["image-set"]["image width"]); ?>"> × <input type="text" id="image_height" name="image_height" class="number" value="<?php echo clean_output($module_settings["image-set"]["image height"]); ?>"> px
				</td>
			</tr>
		</table>
	</div>

	<div class="column last-column">
		<p>
    		<label for="open_image"><?php echo txt('image-set', 'Vollbildansicht'); ?>:</label>
    		<select name="open_image" id="open_image" size="1" onchange="showImageSettings(this.options[this.selectedIndex].value)">
    			<option value="disabled" <?php if($module_settings["image-set"]["open image"] == 'disabled') echo 'selected="selected"'; ?>><?php echo txt('image-set', 'Keine Vollbildansicht'); ?></option>
    			<option value="popup" <?php if($module_settings["image-set"]["open image"] == 'popup') echo 'selected="selected"'; ?>><?php echo txt('image-set', 'In einem Popup öffnen'); ?></option>
    			<option value="custom" <?php if($module_settings["image-set"]["open image"] == 'custom') echo 'selected="selected"'; ?>><?php echo txt('image-set', 'Eigene Methode'); ?></option>
    		</select>
    	</p>
    	
		<br>

		<div id="popup-settings" style="display: none">
			<p>
				<input type="checkbox" name="image_properties" id="image_properties" <?php if($module_settings["image-set"]["image properties"] == 1) echo 'checked="checked"'; ?>>
				<label class="checkbox" for="image_properties"><?php echo txt('image-set', 'Bildeigenschaften anzeigen'); ?></label>
			</p>

	    	<br>

			<table style="width: 100%">
				<tr>
					<td>
						<label for="popup_width"><?php echo txt('image-set', 'Fenstergröße'); ?>:</label>
					</td>
					<td style="text-align: right">
						<input type="text" id="popup_width" name="popup_width" class="number" style="margin-right: 0" value="<?php echo clean_output($module_settings["image-set"]["popup width"]); ?>"> × <input type="text" id="popup_height" name="popup_height" class="number" value="<?php echo clean_output($module_settings["image-set"]["popup height"]); ?>"> px
					</td>
				</tr>
			</table>
			
			<br>
			
			<p><small><?php echo txt('image-set', 'Bei deaktiverter Anzeige der Bildeigenschaften wird die Fenstergröße automatisch angepasst.'); ?></small></p>
		</div>

		<div id="custom-settings" style="display: none">
			<p>
				<label for="link_attributes"><?php echo txt('image-set', 'Link-Attribute'); ?>:</label>
				<input type="text" name="link_attributes" id="link_attributes" class="text" value="<?php echo clean_output($module_settings["image-set"]["link attributes"]); ?>">
			</p>
		</div>
	</div>
	
	<div style="clear: both"><br></div>

	<?php connector('images backend tpl after'); ?>

	<script type="text/javascript">
		// Open imagelist plugin
		var images_openFilelist = function() {
			var select = document.getElementById('images_dir');
			var dir = select.options[select.selectedIndex].value;
			
			var link = document.getElementById('filelist');
			link.href = 'index.php?backend&actions=imagelist.php&dir=' + dir;

			MoreCSS.modalWindow(link, ['modal-window-width:350', 'modal-window-height:' + (MoreCSS.innerSize('height') - 100)], 'iframe');
		};
		
		var settingAreas = ['popup', 'custom'];
		
		// Show full image settings
		var showImageSettings = function(showArea) {
			for(var i = 0; i < settingAreas.length; i++) {
				document.getElementById(settingAreas[i] + '-settings').style.display = (settingAreas[i] == showArea) ? 'block' : 'none';
			}
		};
		
		showImageSettings('<?php echo $module_settings["image-set"]["open image"]; ?>');
	</script>

	<!-- Save -->
	<input name="save_image_set" type="hidden">
	<input id="save" name="save_content" type="submit" value="<?php echo txt('image-set', 'Speichern'); ?>">
	<input id="delete" name="delete_content" type="submit" value="<?php echo txt('image-set', 'Löschen'); ?>" onclick="this.form.confirm = window.confirm('<?php echo txt('image-set', 'Soll das Inhaltselement wirklich gelöscht werden?'); ?>')">
</form>