<?php
/**
 * error.php
 * 
 * Layout for errors that occur in Joomla (for example, when a 404 occurs)
 * 
 * @package     Joomla.Administrator
 * @subpackage  Templates.<%= _.slugify(name).toUpperCase() %>
 * @copyright   Copyright (C) <%= currentDate %> <%= authorName %>. All rights reserved.
 * @license     <%= license %>
 */

defined("_JEXEC") or die;

// Getting params from template
$params = JFactory::getApplication()->getTemplate(true)->params;

$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$lang = JFactory::getLanguage();
$this->language = $doc->language;
$this->direction = $doc->direction;
$input = $app->input;
$user = JFactory::getUser();

// Detecting Active Variables
$option = $input->get("option", "");
$view = $input->get("view", "");
$layout = $input->get("layout", "");
$task = $input->get("task", "");
$itemid = $input->get("Itemid", "");
$sitename = $app->getCfg("sitename");

$cpanel = ($option === "com_cpanel");

$showSubmenu = false;
$this->submenumodules = JModuleHelper::getModules("submenu");
foreach ($this->submenumodules as $submenumodule) {
	$output = JModuleHelper::renderModule($submenumodule);
	if (strlen($output)) {
		$showSubmenu = true;
		break;
	}
}

// Logo file
if ($params->get("logoFile")) {
	$logo = JUri::root() . $params->get("logoFile");
}
else {
	$logo = $this->baseurl . "/templates/" . $this->template . "/images/logo.png";
}

// Template Parameters
$displayHeader = $params->get("displayHeader", "1");
$statusFixed = $params->get("statusFixed", "1");
$stickyToolbar = $params->get("stickyToolbar", "1");
?>
<!DOCTYPE html>
<html class = "no-js" xml:lang = "<?php echo $this->language; ?>" lang = "<?php echo $this->language; ?>" dir = "<?php echo $this->direction; ?>">
<head>
	<meta http-equiv = "content-type" content = "text/html; charset=utf-8"/>
	<meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1">
	<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
	<title><?php echo $this->title; ?> <?php echo htmlspecialchars($this->error->getMessage()); ?></title>
	<?php // If debug  mode
	$debug = JFactory::getConfig()->get("debug_lang");
	if ((defined("JDEBUG") && JDEBUG) || $debug) : ?>
		<!-- Load additional CSS styles for debug mode-->
		<link rel = "stylesheet" href = "<?php echo JUri::root() ?>/media/cms/css/debug.css" type = "text/css"/>
	<?php endif; ?>
	<?php
	// If Right-to-Left
	if ($this->direction == "rtl") {
		?>
		<link rel = "stylesheet" href = "<?php echo JUri::root() ?>/media/jui/css/bootstrap-rtl.css" type = "text/css"/>
	<?php
	}
	// Load specific language related CSS
	$file = "language/" . $lang->getTag() . "/" . $lang->getTag() . ".css";
	if (is_file($file)) {
		?>
		<link rel = "stylesheet" href = "<?php echo $file; ?>" type = "text/css"/>
	<?php
	}
	?>
	<link rel = "stylesheet" href = "<?php echo $this->baseurl; ?>/templates/<?php echo $this->template; ?>/styles/css/template<?php echo($this->direction == "rtl" ? "-rtl" : ""); ?>.css" type = "text/css"/>
	<link href = "<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/favicon.ico" rel = "shortcut icon" type = "image/vnd.microsoft.icon"/>
	<script src = "../media/jui/js/jquery.js" type = "text/javascript"></script>
	<script src = "../media/jui/js/jquery-noconflict.js" type = "text/javascript"></script>
	<script src = "../media/jui/js/bootstrap.js" type = "text/javascript"></script>
	<script src = "<?php echo $this->baseurl; ?>/templates/<?php echo $this->template; ?>/js/template.js" type = "text/javascript"></script>
	<!--[if lt IE 9]>
	<script src = "../media/jui/js/html5.js"></script>
	<![endif]-->
</head>

<body class = "admin <?php echo $option . " view-" . $view . " layout-" . $layout . " task-" . $task . " "; ?>" data-spy = "scroll" data-target = ".subhead" data-offset = "87">
	<!-- Top Navigation -->
	<nav class = "navbar navbar-inverse navbar-fixed-top">
		<div class = "navbar-inner">
			<div class = "container-fluid">
				<?php if ($params->get("admin_menus") != "0") : ?>
					<a class = "btn btn-navbar" data-toggle = "collapse" data-target = ".nav-collapse">
						<i class="icon-menu"></i>
					</a>
				<?php endif; ?>
				<a class = "admin-logo" href = "<?php echo $this->baseurl; ?>"><span class = "icon-joomla"></span></a>

				<a class = "brand hidden-desktop hidden-tablet" href = "<?php echo JUri::root(); ?>" title = "<?php echo JText::sprintf("TPL_<%= _.slugify(name).toUpperCase() %>_PREVIEW", $sitename); ?>" target = "_blank"><?php echo JHtml::_("string.truncate", $sitename, 14, false, false); ?>
					<span class = "icon-out-2 small"></span></a>

				<?php if ($params->get("admin_menus") != "0") : ?>
				<div class = "nav-collapse">
					<?php else : ?>
					<div>
						<?php endif; ?>
						<?php
						// Display menu modules
						$this->menumodules = JModuleHelper::getModules("menu");
						foreach ($this->menumodules as $menumodule) {
							$output = JModuleHelper::renderModule($menumodule, array("style" => "none"));
							$params = new JRegistry;
							$params->loadString($menumodule->params);
							echo $output;
						}
						?>
						<ul class = "nav nav-user<?php echo ($this->direction == "rtl") ? " pull-left" : " pull-right"; ?>">
							<li class = "dropdown">
								<a class = "dropdown-toggle" data-toggle = "dropdown" href = "#"><span class = "icon-cog"></span>
									<b class = "caret"></b></a>
								<ul class = "dropdown-menu">
									<li>
									<span>
										<span class = "icon-user"></span>
										<strong><?php echo $user->name; ?></strong>
									</span>
									</li>
									<li class = "divider"></li>
									<li class = "">
										<a href = "index.php?option=com_admin&task=profile.edit&id=<?php echo $user->id; ?>"><?php echo JText::_("TPL_<%= _.slugify(name).toUpperCase() %>_EDIT_ACCOUNT"); ?></a>
									</li>
									<li class = "divider"></li>
									<li class = "">
										<a href = "<?php echo JRoute::_("index.php?option=com_login&task=logout&" . JSession::getFormToken() . "=1"); ?>"><?php echo JText::_("TPL_<%= _.slugify(name).toUpperCase() %>_LOGOUT"); ?></a>
									</li>
								</ul>
							</li>
						</ul>
						<a class = "brand visible-desktop visible-tablet" href = "<?php echo JUri::root(); ?>" title = "<?php echo JText::sprintf("TPL_<%= _.slugify(name).toUpperCase() %>_PREVIEW", $sitename); ?>" target = "_blank"><?php echo JHtml::_("string.truncate", $sitename, 14, false, false); ?>
							<span class = "icon-out-2 small"></span></a>
					</div>
					<!--/.nav-collapse -->
				</div>
			</div>
	</nav>
	<!-- Header -->
	<header class = "header">
		<?php if ($displayHeader) : ?>
			<div class = "container-logo">
				<img src = "<?php echo $logo; ?>" class = "logo"/>
			</div>
		<?php endif; ?>
		<div class = "container-title">
			<h1 class = "page-title"><?php echo JText::_("ERROR"); ?></h1>
		</div>
	</header>
	<?php if ((!$statusFixed) && ($this->countModules("status"))) : ?>
		<!-- Begin Status Module -->
		<div id = "status" class = "navbar status-top hidden-phone">
			<div class = "btn-toolbar">
				<div class = "btn-group pull-right">
					<p>
						&copy; <?php echo date("Y"); ?> <?php echo $sitename; ?>
					</p>
				</div>
				<?php
				// Display status modules
				$this->statusmodules = JModuleHelper::getModules("status");
				foreach ($this->statusmodules as $statusmodule) {
					$output = JModuleHelper::renderModule($statusmodule, array("style" => "no"));
					$params = new JRegistry;
					$params->loadString($statusmodule->params);
					echo $output;
				}
				?>
			</div>
		</div>
		<!-- End Status Module -->
	<?php endif; ?>
	<div class = "subhead-spacer" style = "margin-bottom: 20px"></div>
	<!-- container-fluid -->
	<div class = "container-fluid container-main">
		<section id = "content">
			<!-- Begin Content -->
			<div class = "row-fluid">
				<div class = "span12">
					<!-- Begin Content -->
					<h1 class = "page-header"><?php echo JText::_("JERROR_AN_ERROR_HAS_OCCURRED"); ?></h1>
					<blockquote>
						<span class = "label label-inverse"><?php echo $this->error->getCode(); ?></span> <?php echo $this->error->getMessage(); ?>
					</blockquote>
					<p>
						<a href = "<?php echo $this->baseurl; ?>" class = "btn"><i class = "icon-dashboard"></i> <?php echo JText::_("JGLOBAL_TPL_CPANEL_LINK_TEXT"); ?>
						</a></p>
					<!-- End Content -->
				</div>
			</div>
			<!-- End Content -->
		</section>
	</div>
</body>
</html>
