<!-- MODULE: images -->

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

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

	if(!isset($module_settings['images']['images dir'])) $module_settings['images']['images dir'] = $system_data['folder']['pages'] . $_GET['page'] . '/';
	if(!isset($module_settings['images']['images sort order'])) $module_settings['images']['images sort order'] = 'none';
	if(!isset($module_settings["images"]["images per row"])) $module_settings["images"]["images per row"] = 5;
	if(!isset($module_settings["images"]["thumbnail size"])) $module_settings["images"]["thumbnail size"] = 156;
	if(!isset($module_settings["images"]["thumbnail crop width"])) $module_settings["images"]["thumbnail crop width"] = 156;
	if(!isset($module_settings["images"]["thumbnail crop height"])) $module_settings["images"]["thumbnail crop height"] = 156;
	if(!isset($module_settings["images"]["thumbnail mode"])) $module_settings["images"]["thumbnail mode"] = 'normal';
	if(!isset($module_settings["images"]["thumbnail background"])) $module_settings["images"]["thumbnail background"] = '#000000';
	if(!isset($module_settings["images"]["thumbnail quality"])) $module_settings["images"]["thumbnail quality"] = 85;
	if(!isset($module_settings['images']['thumbnail reflection'])) $module_settings['images']['thumbnail reflection'] = 0;
	if(!isset($module_settings['images']['thumbnail rotation'])) $module_settings['images']['thumbnail rotation'] = 0;
	if(!isset($module_settings['images']['thumbnail rotate cw'])) $module_settings['images']['thumbnail rotate cw'] = 1;
	
	if(!isset($module_settings["images"]["image width"])) $module_settings["images"]["image width"] = 800;
	if(!isset($module_settings["images"]["image height"])) $module_settings["images"]["image height"] = 600;
	if(!isset($module_settings["images"]["image fullscreen"])) $module_settings["images"]["image fullscreen"] = 0;
	if(!isset($module_settings["images"]["image properties"])) $module_settings["images"]["image properties"] = 1;
	if(!isset($module_settings["images"]["open image"])) $module_settings["images"]["open image"] = 'page';
	if(!isset($module_settings["images"]["popup width"])) $module_settings["images"]["popup width"] = 800;
	if(!isset($module_settings["images"]["popup height"])) $module_settings["images"]["popup height"] = 600;
	if(!isset($module_settings["images"]["page start full"])) $module_settings["images"]["page start full"] = 0;
	if(!isset($module_settings["images"]["page show controls"])) $module_settings["images"]["page show controls"] = 1;
	if(!isset($module_settings["images"]["page show images"])) $module_settings["images"]["page show images"] = 1;
	if(!isset($module_settings["images"]["link attributes"])) $module_settings["images"]["link attributes"] = 'rel=&quot;lytebox[' . $_GET['module-position'] . ']&quot;';
	if(!isset($module_settings["images"]["slideshow"])) $module_settings["images"]["slideshow"] = 0;
	if(!isset($module_settings["images"]["slideshow pause start"])) $module_settings["images"]["slideshow pause start"] = 0;
	if(!isset($module_settings["images"]["slideshow loop"])) $module_settings["images"]["slideshow loop"] = 1;
	if(!isset($module_settings["images"]["slideshow seconds"])) $module_settings["images"]["slideshow seconds"] = 5;

	if(!isset($module_settings["images"]["gallery description"])) $module_settings["images"]["gallery description"] = '';
	if(!isset($module_settings["images"]["gallery link text"])) $module_settings["images"]["gallery link text"] = txt('images', 'Zu den Bildern');

	if(!is_dir($module_settings['images']['images dir'])) $module_settings['images']['images dir'] = $system_data['folder']['pages'] . $_GET['page'] . '/';
	
/**
 * Get dir list
 *
 * @category   Module (images)
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-05-16
 */
	
	$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 (images)
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-12-07
 */
	
?>

<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('images backend tpl before'); ?>

	<h4><?php echo txt('images', 'Vorschaubilder'); ?></h4>

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

    	<p>
    		<label for="thumbnail_mode"><?php echo txt('images', 'Verkleinerung'); ?>:</label>
    		<select size="1" name="thumbnail_mode" id="thumbnail_mode">
    			<option value="normal" <?php if($module_settings['images']['thumbnail mode'] == 'normal') echo 'selected="selected"'; ?>><?php echo txt('images', 'Normal'); ?></option>
    			<option value="variable width" <?php if($module_settings['images']['thumbnail mode'] == 'variable width') echo 'selected="selected"'; ?>><?php echo txt('images', 'Mit variabler Breite'); ?></option>
    			<option value="variable height" <?php if($module_settings['images']['thumbnail mode'] == 'variable height') echo 'selected="selected"'; ?>><?php echo txt('images', 'Mit variabler Höhe'); ?></option>
    			<option value="crop" <?php if($module_settings['images']['thumbnail mode'] == 'crop') echo 'selected="selected"'; ?>><?php echo txt('images', 'Zuschneiden'); ?></option>
    		</select>
		</p>
		
		<hr>
		
		<table style="width: 100%">
			<tr>
				<td>
					<label for="images_per_row"><?php echo txt('images', 'Bilder pro Reihe'); ?>:</label> 
				</td>
				<td style="text-align: right">
					<input type="text" id="images_per_row" name="images_per_row" class="number" style="margin-right: 0" value="<?php echo clean_output($module_settings["images"]["images per row"]); ?>"> × 
					<input type="text" id="thumbnail_size" name="thumbnail_size" class="number" value="<?php echo clean_output($module_settings["images"]["thumbnail size"]); ?>"> 
					<label class="checkbox" for="thumbnail_size">px</label>
				</td>
			</tr>
			<tr>
				<td>
					<label for="thumbnail_crop_width"><?php echo txt('images', 'Zuschnitt'); ?>:</label> 
				</td>
				<td style="text-align: right">
					<input type="text" id="thumbnail_crop_width" name="thumbnail_crop_width" class="number" style="margin-right: 0" value="<?php echo clean_output($module_settings["images"]["thumbnail crop width"]); ?>"> × 
					<input type="text" id="thumbnail_crop_height" name="thumbnail_crop_height" class="number" value="<?php echo clean_output($module_settings["images"]["thumbnail crop height"]); ?>"> 
					<label class="checkbox" for="thumbnail_crop_width">px</label>
				</td>
			</tr>
		</table>
	</div>

	<div class="column last-column">
		<label for="thumbnail_quality"><?php echo txt('images', 'Bildqualität'); ?>:</label>
		<div class="slider"><div id="slider-01"><input type="text" name="thumbnail_quality" id="thumbnail_quality" class="number" value="<?php echo clean_output($module_settings["images"]["thumbnail quality"]); ?>"></div></div>
		
		<hr>
		
		<label for="thumbnail_reflection"><?php echo txt('images', 'Spiegelung'); ?>:</label>
		<div class="slider"><div id="slider-02"><input type="text" name="thumbnail_reflection" id="thumbnail_reflection" class="number" value="<?php echo clean_output($module_settings["images"]["thumbnail reflection"]); ?>"></div></div>

		<label for="thumbnail_rotation"><?php echo txt('images', 'Drehung'); ?>:</label>
		<div class="slider"><div id="slider-03"><input type="text" name="thumbnail_rotation" id="thumbnail_rotation" class="number" value="<?php echo clean_output($module_settings["images"]["thumbnail rotation"]); ?>"></div></div>
		
		<p>
			<input type="checkbox" id="thumbnail_rotate_cw" name="thumbnail_rotate_cw" <?php if($module_settings["images"]["thumbnail rotate cw"] == 1) echo 'checked="checked"'; ?>>  
			<label class="checkbox" for="thumbnail_rotate_cw"><?php echo txt('images', 'Im Uhrzeigersinn drehen'); ?></label>
		</p>
		
		<hr>

		<table style="width: 100%">
			<tr>
				<td>
					<label for="thumbnail_background"><?php echo txt('images', 'Hintergrundfarbe'); ?>:</label> 
				</td>
				<td style="text-align: right">
					<input style="display: inline; width: 73px" size="7" maxlength="7" type="text" id="thumbnail_background" name="thumbnail_background" value="<?php echo clean_output($module_settings["images"]["thumbnail background"]); ?>"> 
					<label class="checkbox" for="thumbnail_crop_width">hex</label>
				</td>
			</tr>
		</table>
	</div>
	
	<div style="clear: both"><br></div>

	<h4><?php echo txt('images', 'Vollbildansicht'); ?></h4>

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

	<div style="clear: both"><br></div>

	<div id="general-settings" class="column" style="display: none">
		<table style="width: 100%">
			<tr>
				<td>
					<label for="image_width"><?php echo txt('images', '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["images"]["image width"]); ?>"> × <input type="text" id="image_height" name="image_height" class="number" value="<?php echo clean_output($module_settings["images"]["image height"]); ?>"> px
				</td>
			</tr>
		</table>
		
		<hr>

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

	<div id="popup-settings" class="column last-column" style="display: none">
		<table style="width: 100%">
			<tr>
				<td>
					<label for="popup_width"><?php echo txt('images', '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["images"]["popup width"]); ?>"> × <input type="text" id="popup_height" name="popup_height" class="number" value="<?php echo clean_output($module_settings["images"]["popup height"]); ?>"> px
				</td>
			</tr>
		</table>
		
		<br>
		
		<p><small><?php echo txt('images', 'Bei deaktiverter Anzeige der Bildeigenschaften wird die Fenstergröße automatisch an die Bildgröße angepasst.'); ?></small></p>
	</div>

	<div id="page-settings" class="column last-column" style="display: none">
		<p>
			<input type="checkbox" name="image_fullscreen" id="image_fullscreen" <?php if($module_settings["images"]["image fullscreen"] == 1) echo 'checked="checked"'; ?>>
			<label class="checkbox" for="image_fullscreen"><?php echo txt('images', 'Browserfüllend maximieren'); ?></label>
		</p>

		<p>
			<input type="checkbox" name="page_start_full" id="page_start_full" <?php if($module_settings["images"]["page start full"] == 1) echo 'checked="checked"'; ?>>
			<label class="checkbox" for="page_start_full"><?php echo txt('images', 'In Vollbildansicht starten'); ?></label>
		</p>

		<p>
			<input type="checkbox" name="page_show_controls" id="page_show_controls" <?php if($module_settings["images"]["page show controls"] == 1) echo 'checked="checked"'; ?>>
			<label class="checkbox" for="page_show_controls"><?php echo txt('images', 'Steuerungselemente anzeigen'); ?></label>
		</p>

		<p>
			<input type="checkbox" name="page_show_images" id="page_show_images" <?php if($module_settings["images"]["page show images"] == 1) echo 'checked="checked"'; ?>>
			<label class="checkbox" for="page_show_images"><?php echo txt('images', 'Vorschaubilder anzeigen'); ?></label>
		</p>
	</div>

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

	<div style="clear: both"><br></div>

	<div id="slideshow-settings" style="display: none">
		<h4><?php echo txt('images', 'Automatische Diashow'); ?></h4>

		<div class="column">
			<p>
				<input type="checkbox" name="slideshow" id="slideshow" <?php if($module_settings["images"]["slideshow"] == 1) echo 'checked="checked"'; ?>>
				<label class="checkbox" for="slideshow"><?php echo txt('images', 'Automatische Diashow aktivieren'); ?></label>
			</p>
	
			<p>
				<input type="checkbox" name="slideshow_pause_start" id="slideshow_pause_start" <?php if($module_settings["images"]["slideshow pause start"] == 1) echo 'checked="checked"'; ?>>
				<label class="checkbox" for="slideshow_pause_start"><?php echo txt('images', 'Diashow in Pause starten'); ?></label>
			</p>

			<p>
				<input type="checkbox" name="slideshow_loop" id="slideshow_loop" <?php if($module_settings["images"]["slideshow loop"] == 1) echo 'checked="checked"'; ?>>
				<label class="checkbox" for="slideshow_loop"><?php echo txt('images', 'Diashow in Endlosschleife'); ?></label>
			</p>
		</div>

		<div class="column last-column">
			<p>
	    		<input type="text" id="slideshow_seconds" name="slideshow_seconds" class="number" maxlength="2" value="<?php echo $module_settings["images"]["slideshow seconds"]; ?>">
	    		<label class="checkbox" for="slideshow_seconds"><?php echo txt('images', 'Sekunden / Bild'); ?></label>
	    	</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 = ['page', 'popup', 'custom'];
		
		// Show full image settings
		var showImageSettings = function(showArea) {
			document.getElementById('general-settings').style.display = (showArea == 'disabled') ? 'none' : 'block';
			document.getElementById('slideshow-settings').style.display = (showArea == 'page') ? 'block' : 'none';

			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["images"]["open image"]; ?>');
	</script>

	<h4><?php echo txt('images', 'Titel und Beschreibungen'); ?></h4>
	
	<p class="context"><?php echo txt('images', 'Sie können für jedes Bild einen eigenen Titel und eine vollformatierte Beschreibung als Eigenschaften der Datei verfassen. Öffnen Sie hierfür die Dateverwaltung, markieren Sie ein Bild und wählen Sie <em>Eigenschaften</em> unter <em>Bearbeiten</em>.'); ?></p>
	<p><a class="img-symbol" href="index.php?backend=files&pagetype=<?php echo $page_info->pagetype; ?>&catalogue=<?php echo $page_info->catalogue; ?>&page=<?php echo $page_info->alias; ?>"><img src="<?php echo $system_data['folder']['plugins']; ?>icons/page_white_edit.png"> <?php echo txt('images', 'Dateiverwaltung öffnen'); ?></a></p>
	
	<br>
	
	<!-- TinyMCE -->
	<script type="text/javascript">
		// Init TinyMCE
		tinyMCE.init({
			// General options
			mode : 'exact',
			elements : 'gallery_description',
			theme : 'advanced',
			skin : 'pagemap',
	
			language : '<?php echo substr($user_data['backend language'],0 , 2); ?>',
			button_tile_map : true,
			width : '625',
			height : '450',
			
			element_format : '<?php echo $template_data['syntax']; ?>',
			cleanup : true,
			cleanup_on_startup : true,
			paste_auto_cleanup_on_paste : true,
	
			plugins : 'advhr, advimage, advlink, autosave, contextmenu, emotions, fullscreen, insertdatetime, layer, media, nonbreaking, paste, safari, searchreplace, style, table, visualchars, xhtmlxtras',
			
			// Plugin options
			plugin_insertdate_dateFormat : '%d.%m.%Y',
			plugin_insertdate_timeFormat : '%H:%M:%S',
			
			// Theme options
			theme_advanced_buttons1 : 'fullscreen,|,undo,redo,|,pastetext,cleanup,removeformat,newdocument,|,replace,|,styleprops,attribs,code,|,image,media,advhr,|,link,unlink,anchor,|,charmap,nonbreaking,|,cite,abbr,acronym',
			theme_advanced_buttons2 : 'bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect,,styleselect,|,forecolor,backcolor',
			theme_advanced_buttons3 : 'sub,sup,|,bullist,numlist,|,outdent,indent,|,visualaid,tablecontrols',
			
			theme_advanced_font_sizes : '9px,10px,11px,12px,14px,16px,18px,20px,22px,24px,26px,28px,30px,36px,48px,60px,72px',
			theme_advanced_blockformats : 'div,p,blockquote,address,pre,h1,h2,h3,h4,h5,h6',
			theme_advanced_toolbar_location : 'top',
			theme_advanced_toolbar_align : 'left',
			theme_advanced_statusbar_location : 'bottom',
			theme_advanced_resizing : true,
			extended_valid_elements : 'iframe[style|src|width|height|name|align|frameborder|allowtransparency]',
			
			// Drop lists
			external_link_list_url : 'index.php?backend&actions=tinymce-filelist.php&action=filelist&type=all&path=<?php echo $system_data['folder']['pages'] . $_GET['page']; ?>/',
			external_image_list_url : 'index.php?backend&actions=tinymce-filelist.php&action=filelist&type=images&path=<?php echo $system_data['folder']['pages'] . $_GET['page']; ?>/',
			media_external_list_url : 'index.php?backend&actions=tinymce-filelist.php&action=filelist&type=multimedia&path=<?php echo $system_data['folder']['pages'] . $_GET['page']; ?>/',
			
			// CSS
			content_css : 'index.php?backend&actions=tinymce-content-css.php'
		});
	</script>

	<h4><?php echo txt('images', 'Einleitungstext'); ?></h4>
	
	<p><textarea name="gallery_description" id="gallery_description" cols="10" rows="5"><?php echo strip_custom_tags(stripslashes($module_settings["images"]["gallery description"]), true, false, true, false, false); ?></textarea></p>
	
	<div class="column">
		<p>
			<label for="gallery_link_text"><?php echo txt('images', 'Verweistext zur Galerie'); ?>:</label>
			<input type="text" id="gallery_link_text" name="gallery_link_text" value="<?php echo $module_settings["images"]["gallery link text"]; ?>">
		</p>
	</div>
	
	<!-- Save -->
	<input name="save_images" type="hidden">
	<input id="save" name="save_content" type="submit" value="<?php echo txt('images', 'Speichern'); ?>">
	<input id="delete" name="delete_content" type="submit" value="<?php echo txt('images', 'Löschen'); ?>" onclick="this.form.confirm = window.confirm('<?php echo txt('images', 'Soll das Inhaltselement wirklich gelöscht werden?'); ?>')">
</form>