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

/**
 * Backend template
 *
 * @category   Extension (settings)
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-11-19
 */
 
?>

<?php if($_SESSION['user'] == sha1($administrator_name)) { ?>
	<form id="settings" action="index.php?backend=settings&amp;area=template" method="post" accept-charset="utf-8" enctype="multipart/form-data">
		<div class="column">
			<!-- Template info -->
			<h4><?php echo txt('settings', 'Gewählte Seitenvorlage'); ?></h4>
			
			<p>
				<strong><?php echo $template_data['title']; ?> <?php echo $template_data['version']; ?></strong><br>
				<?php echo $template_data['description']; ?>
			</p>
			
			<p class="small">
				© <a style="text-decoration: none" href="<?php echo $template_data['home']; ?>"><?php echo $template_data['copyright']; ?></a><br>
			</p>

			<!-- Template settings -->
			<h4><?php echo txt('settings', 'Einstellungen'); ?></h4>

			<p>
				<label><?php echo txt('settings', 'Seitenvorlage auswählen'); ?>:</label>
				<select name="template" size="1">
					<?php foreach($templates as $template_this) { ?>
						<option value="<?php echo clean_output($template_this['path']); ?>" <?php echo ($user_data['frontend template'] == $template_this['path'] ? 'selected="selected"' : ''); ?> ><?php echo $template_this['title']; ?></option>
					<?php } ?>
				</select>
			</p>

			<p>
				<label><?php echo txt('settings', 'Stil der Seitenvorlage'); ?>:</label>
				<select name="template_style" size="1">
					<option value="none"><?php echo txt('settings', 'Standard'); ?></option>
					<?php foreach($frontend_template_styles as $entry) if(trim($entry) != '') { ?>
						<option value="<?php echo trim($entry); ?>" <?php echo ($user_data['frontend template style'] == trim($entry) ? 'selected="selected"' : ''); ?> ><?php echo trim($entry); ?></option>
					<?php } ?>
				</select>
			</p>
			
			<p>
				<label><?php echo txt('settings', 'Datumsformat'); ?>:</label>
				<input class="text" type="text" name="date_print" value="<?php echo clean_output($user_data['date format print']); ?>" title="<?php echo txt('settings', 'Geben Sie ein Datumsformat entsprechend der PHP-Funktion date() ein.'); ?>">
			</p>
		    
		    <h4><?php echo txt('settings', 'Seitenliste'); ?></h4>
			
			<p>
				<label><?php echo txt('settings', 'Sortierung'); ?>:</label>
				<select name="sort_by" size="1">
					<option value="none" <?php if($user_data['sort by'] == 'none') echo 'selected="selected"'; ?> ><?php echo txt('settings', 'Keine (wie Position im Menü)'); ?></option>
					<option value="category" <?php if($user_data['sort by'] == 'category') echo 'selected="selected"'; ?> ><?php echo txt('settings', 'Kategorie (alphabetisch)'); ?></option>
					<option value="date" <?php if($user_data['sort by'] == 'date') echo 'selected="selected"'; ?> ><?php echo txt('settings', 'Datum (entsprechend Datumsformat)'); ?></option>
					<option value="initial" <?php if($user_data['sort by'] == 'initial') echo 'selected="selected"'; ?> ><?php echo txt('settings', 'Alphabetisch'); ?></option>
				</select>
			</p>
		
			<p>
				<label><?php echo txt('settings', 'Datumsformat'); ?>:</label>
				<input class="text" type="text" name="date_sort_format" value="<?php echo clean_output($user_data['date format sort']); ?>" title="<?php echo txt('settings', 'Geben Sie ein Datumsformat entsprechend der PHP-Funktion date() ein.'); ?>">
			</p>
			
			<br>
			
		    <p>
		    	<input type="checkbox" id="show_sort_headlines" name="show_sort_headlines" <?php echo ($user_data['show sort headlines'] == 1 ? 'checked="checked"' : ''); ?>>
				<label class="checkbox" for="show_sort_headlines"><?php echo txt('settings', 'Überschriften anzeigen'); ?></label>
			</p>
		    
		    <p>
		    	<input type="checkbox" id="sort_ascending" name="sort_ascending" <?php echo ($user_data['sort ascending'] == 1 ? 'checked="checked"' : ''); ?>>
				<label class="checkbox" for="sort_ascending"><?php echo txt('settings', 'Aufsteigend sortieren'); ?></label>
			</p>
		
		    <p>
		    	<input type="checkbox" id="show_info_pages" name="show_info_pages" <?php echo ($user_data['show info pages'] == 1 ? 'checked="checked"' : ''); ?>>
		    	<label class="checkbox" for="show_info_pages"><?php echo txt('settings', 'Infoseiten anzeigen'); ?></label>
		    </p>
		    
		    <?php connector('settings template after'); ?>
		</div>
		
		<div class="column last-column">
			<!-- Logo -->
			<h4><?php echo txt('settings', 'Logo'); ?></h4>
			
			<?php if(is_file($user_data['logo'])) { ?>
				<p><img style="max-width: 100%" src="<?php echo $user_data['logo']; ?>" alt="<?php echo txt('settings', 'Logo'); ?>"></p>
			<?php } ?>
			
			<p>
				<label for="logo_upload"><?php echo txt('settings', 'Neues Logo'); ?>:</label>
				<input style="margin-top: 1em" type="file" name="logo_upload" id="logo_upload">
			</p>
			
			<p>
				<input type="checkbox" name="delete_old_logo" id="delete_old_logo"> <label for="delete_old_logo" class="checkbox"><?php echo txt('settings', 'Alte Logodatei löschen'); ?></label>
			</p>

			<!-- HTML header -->
			<h4><?php echo txt('settings', 'Header (HTML)'); ?></h4>
			
			<p>
				<textarea rows="10" cols="10" id="template_html_header" name="template_html_header"><?php echo htmlspecialchars($template_user_header); ?></textarea>
			</p>

			<!-- HTML footer -->
			<h4><?php echo txt('settings', 'Footer (HTML)'); ?></h4>
			
			<p>
				<textarea rows="10" cols="10" id="template_html_footer" name="template_html_footer"><?php echo htmlspecialchars($template_user_footer); ?></textarea>
			</p>
		</div>
		
		<input id="save" name="save_settings" type="submit" value="<?php echo txt('settings', 'Speichern'); ?>">
	</form>
<?php } ?>
