<?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' />";

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 (isset($library_modules) && is_array($library_modules)){
	foreach ($library_modules AS $key => $value){
		if (isset(${'c_'.$key}) && ${'c_'.$key}){
			if ($tab == $key){
				print "
			<li class='current'>";
			} else {
				print "
			<li>";
			}
			print "
				<a href='#' title='".$value['text']."' data-id='".$key."'><i class='material-icons md-24'>".$value['icon']."</i>".$value['text']."</a>
			</li>";
		}
	}
}
if (isset($c_links) && $c_links){
	if ($tab == 'links'){
		print "
			<li class='current'>";
	} else {
		print "
			<li>";
	}
	print "
				<a href='#' title='".LABEL_LINKS."' data-id='links'><i class='material-icons md-24'>link</i>".LABEL_LINKS."</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/datetime.php');

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

include('form/template.php');
include('includes/form/language.php');

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

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

include('includes/form/teaser.php');
include('includes/form/content.php');
include('includes/form/addition.php');

include('includes/form/link.php');
include('form/c_thumbnails.php');

include('includes/form/class.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 -->";

if (isset($library_modules) && is_array($library_modules)){
	foreach ($library_modules AS $key => $value){
		if (isset(${'c_'.$key}) && ${'c_'.$key} && is_file('includes/form/'.$key.'.php')){
			include('includes/form/'.$key.'.php');
		}
	}
}
if (isset($c_links) && $c_links && is_file('includes/form/links.php')){
	include('includes/form/links.php');
}

print "
	</form>
	
</div><!-- /.container -->";