<?php
if (!isset($sortorder)) $sortorder = NULL;
if (!isset($c_active)) $c_active = NULL;
if ($action == 'add' && !$c_active) $c_active = 1;
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' />";

if (isset($level_data) && is_array($level_data)){
	foreach ($level_data AS $key => $value){
		print "
<input type='hidden' name='level_data[".$key."][language]' value='".$value['language']."' />
<input type='hidden' name='level_data[".$key."][title]' value='".$value['title']."' />";
	}
}
print "
		<ul class='tabs toggle'>";
if ($tab == 'data'){
	print "
			<li class='current'>";
} else {
	print "
			<li>";
}
print "
				<a href='#' title='".LABEL_DATA."' data-id='data'><i class='material-icons md-24'>edit</i>".LABEL_DATA."</a>
			</li>";

if ($backend_module != 'library'){
	if ($tab == 'content'){
		print "
			<li class='current'>";
	} else {
		print "
			<li>";
	}
	print "
				<a href='#' title='".LABEL_CONTENT."' data-id='content'><i class='material-icons md-24'>article</i>".LABEL_CONTENT."</a>
			</li>";
	if ($tab == 'seo'){
		print "
			<li class='current'>";
	} else {
		print "
			<li>";
	}
	print "
				<a href='#' title='".LABEL_SEO."' data-id='seo'><i class='material-icons md-24'>query_stats</i>".LABEL_SEO."</a>
			</li>";
}
print "
		</ul>
		
		<div class='quick-action'>";
if (isset($id) && $id) print "<span class='id'>#".$id."</span>";
print "
		</div><!-- /.quick-action -->
		
		<div class='form ";
if ($tab != 'data') print "hidden";
print "' data-id='data'>
			<div class='form-content'>";

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


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


include('includes/form/level_title.php');
if ($backend_module != 'library'){
	include('includes/form/url.php');
	include('includes/form/level_c_position.php');
	include('includes/form/class.php');
}


include('includes/form/level_c_active.php');
include('includes/form/error.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 -->";
		

if ($backend_module != 'media'){
	print "
		<div class='form ";
if ($tab != 'content') print "hidden";
print "' data-id='content'>
			<div class='form-content'>";
				
	include('includes/form/level_teaser.php');
	include('includes/form/level_content.php');
	include('includes/form/level_addition.php');
	
	include('includes/form/level_link.php');
	include('includes/form/level_c_thumbnails.php');
	
	include('includes/form/error.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 -->";
		
	print "
		<div class='form ";
if ($tab != 'seo') print "hidden";
print "' data-id='seo'>
			<div class='form-content'>";
				
	include('includes/form/level_meta_title.php');
	include('includes/form/level_meta_description.php');
	
	include('includes/form/error.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 -->";
}
print "		
	</form>
	
</div><!-- /.container -->";