<?php
if (!isset($path)) $path = NULL;

$template_source = '';
$template_source_error = NULL;

if ($path) {
	$template_source = template_read_source($path, $template_source_error);

	if ($template_source_error && template_resolve_writable_path($path)) {
		$template_source = "<?php\n\n";
		$template_source_error = 'Template-Datei existiert noch nicht. Sie wird beim Speichern erstellt.';
	}
}

print "
<div class='container popup'>";
include('includes/form/alert.php');
print "
	<form action='".$_SERVER['SCRIPT_NAME']."?".$_SERVER['QUERY_STRING']."' method='post' enctype='multipart/form-data'>
		<input type='hidden' name='csrf_token' value='".htmlspecialchars(csrf_token())."'>
		<input type='hidden' name='update' value='1' />";

if (isset($update_parent) && $update_parent === true) print "<input type='hidden' id='update_parent' name='update_parent' value='1' />";

print "
		<ul class='tabs toggle'>
			<li class='current'>
				<a href='#' title='".LABEL_DATA."' data-id='data'><i class='material-icons md-24'>edit</i>".LABEL_DATA."</a>
			</li>
		</ul>
		
		<div class='quick-action'>";
if (isset($id) && $id) print "<span class='id'>#".$id."</span>";
print "
		</div><!-- /.quick-action -->
		
		<div class='form' data-id='data'>
			<div class='form-content'>";
include('includes/form/id.php');
include('includes/form/label.php');

include('form/template_editor.php');

include('includes/form/sortorder.php');

include('includes/form/error.php');
include('includes/form/c_active.php');

print "
				<div class='form-action'>
					<button type='submit' class='btn save' name='submit' title='".LABEL_SAVE."'><i class='material-icons md-24'>save_alt</i>".LABEL_SAVE."</button>
				</div><!-- /.form-action -->
			</div><!-- /.form-content -->
		</div><!-- /.form -->
					
	</form>
		
</div><!-- /.container -->";