<!DOCTYPE html>
<html lang="en">
<head>
	<script>(function(w){var dpr=((w.devicePixelRatio===undefined)?1:w.devicePixelRatio);var r=new XMLHttpRequest();r.open('GET','/retinaimages.php?devicePixelRatio='+dpr);r.send();})(window)</script>

	<meta charset="utf-8">
	<title><?php echo(COMPANY_NAME); ?></title>

	<!--[if lt IE 9]>
	    <script src="/js/min/html5shiv.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<![endif]-->

	<meta name="viewport" content = "width = device-width, initial-scale = 1, minimum-scale = 1, maximum-scale = 1, user-scalable=no" />

	<link href='https://fonts.googleapis.com/css?family=Rajdhani:700,400|Lato:400,700' rel='stylesheet'>
	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
	<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.min.css" integrity="sha384-/qLewTwqEHLrVTnUlbu3ATiIUIu0EIi9BGAu6pmzyrvSbDzsDjFnnT13e+oX6hG0" crossorigin="anonymous">
	<?php
	// For the admin area, not loading Font Awesome isn't an option. Its free or pro.
	if(!INSTALLED || Mainframe::site()->fontawesome != 2)
	{
		?><link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" crossorigin="anonymous"><?php
	}
	else if(Mainframe::site()->fontawesome == 2)
	{
		?><link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.7.2/css/all.css" crossorigin="anonymous"><?php
	}
	?>
	<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.10.18/r-2.2.2/datatables.min.css"/>
	<link rel="stylesheet" href="/css/min/nv-tabs.min.css?v=<?php echo(PRODUCT_VERSION); ?>">
	<link rel="stylesheet" href="/css/min/wickedpicker.min.css?v=<?php echo(PRODUCT_VERSION); ?>">
	<link rel="stylesheet" href="/css/min/ng-quick-date-plus-default-theme.min.css?v=<?php echo(PRODUCT_VERSION); ?>">
	<link rel="stylesheet" href="https://cdn.nerivon.ca/nvform.min.css" />
	<link rel="stylesheet" href="/css/min/styles.min.css?v=<?php echo(PRODUCT_VERSION); ?>" />

	<link rel="shortcut icon" href="/images/favicon.ico" />
	<link rel="icon" href="/images/favicon.ico" />

	<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
	<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
	<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.18/r-2.2.2/datatables.min.js"></script>
	<script src="https://www.gstatic.com/charts/loader.js"></script>
	<script src="/js/js-webshim/minified/polyfiller.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<script> webshim.polyfill("forms forms-ext filereader"); </script>

	<script>
		var ckEditorModules = <?php echo(method_exists('Mainframe', "moduleJS") ? Mainframe::moduleJS() : "null"); ?>;
		var PRODUCT 		= <?php echo(json_encode((isset($product) ? $product : new StdClass()), JSON_NUMERIC_CHECK)); ?>;
		var SHOPPER_GROUPS 	= <?php echo(json_encode((isset($shopper_groups) ? $shopper_groups : new StdClass()), JSON_NUMERIC_CHECK)); ?>;
		var TAGS 			= <?php echo(json_encode((isset($tags) ? $tags : array()), JSON_NUMERIC_CHECK)); ?>;
	</script>

	<script src="/inc/ckeditor/ckeditor.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
</head>

<body ng-app="app">
	<noscript><style id="devicePixelRatio" media="only screen and (-moz-min-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2)">#devicePixelRatio{background-image:url("/retinaimages.php?devicePixelRatio=2")}</style></noscript>

	<?php
	$errorlog = file_exists(ABSOLUTE_PATH . "/error_log") || file_exists(APPLICATION_PATH . "/logs/error_log");

	if(isset($show_menu) && $show_menu)
	{
		?>
		<div class="nv-sidebar row m-0">
			<div class="col-2">
				<a href="#" onclick="return false" class="nv-sidebar-link nv-sidebar-trigger" title="Open Menu"><em class="fas fa-lg fa-bars"></em></a><?php
				?><!-- <span class="nv-autocomplete-container">
					<input type="search" id="search_q" placeholder="Search" autofocus />
				</span> -->
			</div>
			<div class="col-8 text-center">
				<?php
				if($user->has(ACTION_PAGES))
				{
					?><a class="nv-sidebar-link" href="/admin/pages" title="Content Pages"><em class="far fa-fw fa-lg fa-edit" aria-hidden="true"></em></a><?php
				}
				if($user->has(ACTION_MENUS))
				{
					?><a class="nv-sidebar-link" href="/admin/menus" title="Menu Links"><em class="fas fa-fw fa-lg fa-link" aria-hidden="true"></em></a><?php
				}
				if($user->has(ACTION_MODULES))
				{
					?><a class="nv-sidebar-link" href="/admin/modules" title="Modules"><em class="fas fa-fw fa-lg fa-puzzle-piece" aria-hidden="true"></em></a><?php
				}
				if($user->has(ACTION_MEDIA))
				{
					?><a class="nv-sidebar-link" href="/finder" title="Media Manager"><em class="fas fa-fw fa-lg fa-camera" aria-hidden="true"></em></a><?php
				}
				if($user->has(ACTION_DOCUMENTS))
				{
					?><a class="nv-sidebar-link" href="/admin/documents" title="Documents"><em class="far fa-fw fa-lg fa-file-pdf" aria-hidden="true"></em></a><?php
				}
				if($user->has(ACTION_SEO))
				{
					?><a class="nv-sidebar-link" href="/admin/seo" title="Search Engine Optimization (SEO)"><em class="fas fa-fw fa-lg fa-sitemap" aria-hidden="true"></em></a><?php
				}
				if($errorlog)
				{
					?><a class="nv-sidebar-link" href="/admin/errorlog" title="Error Log"><em class="fas fa-fw fa-lg fa-exclamation-triangle" aria-hidden="true"></em></a><?php
				}
				?>
				<a class="nv-sidebar-link" href="<?php echo(LIVE_SITE); ?>" title="View My Website" target="_blank"><em class="fas fa-fw fa-lg fa-eye" aria-hidden="true"></em></a>
				<a class="nv-sidebar-link" href="/login/logout" title="Logout"><em class="fas fa-fw fa-lg fa-sign-out-alt" aria-hidden="true"></em></a>
			</div>
			<div class="col-2 text-right">
				<a class="nv-sidebar-link" href="/admin/help" title="View <?php echo(PRODUCT_NAME); ?> User Manual"><em class="fas fa-fw fa-lg fa-question-circle" aria-hidden="true"></em></a>
			</div>
		</div>
		<div class="nv-sidebar-content container-fluid">
			<?php $this->load->view("admin/menu", array("sites" => $sites, "user" => $user)); ?>
		</div>
		<?php
	}
	?>
	<div class="container-fluid <?php echo((isset($show_menu) && $show_menu ? "content" : "")); ?> py-3">
		<?php
		$landing = isset(Mainframe::site()->show_landing) && Mainframe::site()->show_landing;
		$dev     = ENVIRONMENT == "development" && uri_string() != "admin/environment/production";

		if($landing || $dev)
		{
			?><div class="alert alert-warning text-center"><?php

			if($landing)
			{
				?>Your site is hidden behind a landing page. <a href="/admin/activate/<?php echo(Mainframe::site()->site_id); ?>">Click here to activate your site</a> when you're ready.<?php
			}
			if($dev)
			{
				if($landing)
				{
					?><hr><?php
				}
				?>Your site is in debug mode. <a href="/admin/environment/production">Click here to switch to production</a> to avoid unwanted debug information.<?php
			}
			?></div><?php
		}