<?php use PHPCensor\Helper\Lang; ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title><?php print $title; ?><?php print !empty($subtitle) ? ' - ' . $subtitle : ''; ?></title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>

    <link href="<?php print APP_URL; ?>assets/vendor/admin-lte/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="<?php print APP_URL; ?>assets/vendor/admin-lte/dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css" />
    <link href="<?php print APP_URL; ?>assets/css/ansi-colors.css" rel="stylesheet" type="text/css" />
    <link href="<?php print APP_URL; ?>assets/css/main.css" rel="stylesheet" type="text/css" />

    <link href="<?php print APP_URL; ?>assets/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <link href="<?php print APP_URL; ?>assets/vendor/ion-icons/css/ionicons.min.css" rel="stylesheet" type="text/css" />

    <script>
        var APP_URL  = '<?= APP_URL; ?>';
        var LANGUAGE = '<?= Lang::getLanguage(); ?>';

        <?php if (defined('JSON_UNESCAPED_UNICODE')): ?>
        var STRINGS = <?= json_encode(Lang::getStrings(), JSON_UNESCAPED_UNICODE); ?>;
        <?php else: ?>
        var STRINGS = <?= json_encode(Lang::getStrings()); ?>;
        <?php endif; ?>
    </script>

    <script src="<?php print APP_URL; ?>assets/vendor/admin-lte/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="<?php print APP_URL; ?>assets/js/class.js"></script>
    <script src="<?php print APP_URL; ?>assets/vendor/sprintf-js/dist/sprintf.min.js"></script>
    <script src="<?php print APP_URL; ?>assets/js/app.js" type="text/javascript"></script>

</head>
<body class="app-layout <?php print !empty($skin) ? 'skin-' . $skin : 'skin-black'; ?>">
<div class="wrapper row-offcanvas row-offcanvas-left">

<!-- header logo: style can be found in header.less -->
<header class="main-header">
<a href="<?php print APP_URL; ?>" class="logo">PHP Censor</a>
<!-- Header Navbar: style can be found in header.less -->
<nav class="navbar navbar-static-top" role="navigation">
<!-- Sidebar toggle button-->
<a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
    <span class="sr-only"><?php Lang::out('toggle_navigation'); ?></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
</a>
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">

<li class="dropdown messages-menu app-pending">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        <i class="fa fa-clock-o"></i>
        <span class="label label-info app-pending-count"></span>
    </a>
    <ul class="dropdown-menu">
        <li class="header"><?php Lang::out('n_builds_pending', 0); ?></li>
        <li>
            <ul class="menu app-pending-list">
            </ul>
        </li>
    </ul>
</li>

<li class="dropdown messages-menu app-running">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        <i class="fa fa-cogs"></i>
        <span class="label label-warning app-running-count"></span>
    </a>
    <ul class="dropdown-menu">
        <li class="header"><?php Lang::out('n_builds_running', 0); ?></li>
        <li>
            <ul class="menu app-running-list">
            </ul>
        </li>
    </ul>
</li>

<?php if (!$this->LoginIsDisabled()->check()): ?>
<!-- User Account: style can be found in dropdown.less -->
<li class="dropdown user user-menu">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        <i class="glyphicon glyphicon-user"></i>
        <span><?php print $this->User()->getName(); ?> <i class="caret"></i></span>
    </a>
    <ul class="dropdown-menu">
        <!-- User image -->
        <li class="user-header">
            <img src="https://www.gravatar.com/avatar/<?php print md5($this->User()->getEmail()); ?>?d=mm" class="img-circle" alt="<?php print $this->User()->getName(); ?>" />
            <p>
                <?php print $this->User()->getName(); ?>
            </p>
        </li>

        <!-- Menu Footer-->
        <li class="user-footer">
            <div class="pull-left">
                <a href="<?php print APP_URL ?>user/profile" class="btn btn-default btn-flat"><?php Lang::out('edit_profile'); ?></a>
            </div>
            <div class="pull-right">
                <a href="<?php print APP_URL ?>session/logout" class="btn btn-default btn-flat"><?php Lang::out('sign_out'); ?></a>
            </div>
        </li>
    </ul>
</li>
<?php endif; ?>
</ul>
</div>
</nav>
</header>
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar sidebar-offcanvas">
        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">

            <?php if (!$this->LoginIsDisabled()->check()): ?>
            <!-- Sidebar user panel -->
            <div class="user-panel">
                <div class="pull-left image">
                    <img src="https://www.gravatar.com/avatar/<?php print md5($this->User()->getEmail()); ?>?d=mm" class="img-circle" alt="<?php print $this->User()->getName(); ?>" />
                </div>
                <div class="pull-left info">
                    <p><?php Lang::out('hello_name', $this->User()->getName()); ?></p>
                </div>
            </div>
            <?php endif; ?>

            <!-- sidebar menu: : style can be found in sidebar.less -->
            <ul class="sidebar-menu">
                <li<?php print (array_key_exists('archived', $_GET) ? '' : ' class="active"'); ?>>
                    <a href="<?php print APP_URL; ?>">
                        <i class="fa fa-dashboard"></i> <span><?php Lang::out('dashboard'); ?></span>
                    </a>
                </li>

                <?php if ($this->User()->getIsAdmin()): ?>
                    <li class="treeview">
                        <a href="#">
                            <i class="fa fa-edit"></i>
                            <span><?php Lang::out('admin_options'); ?></span>
                            <i class="fa fa-angle-left pull-right"></i>
                        </a>
                        <ul class="treeview-menu">
                            <li>
                                <a href="<?php print APP_URL; ?>project/add">
                                    <i class="fa fa-angle-double-right"></i> <?php Lang::out('add_project'); ?>
                                </a>
                            </li>
                            <li>
                                <a href="<?php print APP_URL; ?>group">
                                    <i class="fa fa-angle-double-right"></i> <?php Lang::out('project_groups'); ?>
                                </a>
                            </li>
                            <li>
                                <a href="<?php print APP_URL; ?>user">
                                    <i class="fa fa-angle-double-right"></i> <?php Lang::out('manage_users'); ?>
                                </a>
                            </li>
                        </ul>
                    </li>
                <?php endif; ?>

                <?php foreach ($groups as $group): ?>
                    <li class="treeview">
                        <a href="#">
                            <i class="fa fa-folder"></i>
                            <span><?php print $group['title']; ?></span>
                            <i class="fa fa-angle-left pull-right"></i>
                        </a>

                        <?php if (count($group['projects'])): ?>
                        <ul class="treeview-menu">
                            <?php foreach($group['projects'] as $project): ?>
                            <li>
                                <a href="<?php print APP_URL; ?>project/view/<?php print $project->getId(); ?>">
                                    <i class="fa fa-<?php print $project->getIcon(); ?>"></i>
                                    <span><?php print $project->getTitle(); ?></span>
                                </a>
                            </li>
                            <?php endforeach; ?>
                        </ul>
                        <?php endif; ?>

                    </li>
                <?php endforeach; ?>

                <li class="treeview">
                    <a href="#">
                        <i class="fa fa-archive"></i> <span><?php Lang::out('archived_menu'); ?></span>
                        <i class="fa fa-angle-left pull-right"></i>
                    </a>

                    <?php if (count($archived_projects)): ?>
                        <ul class="treeview-menu">
                            <?php foreach($archived_projects as $archived_project): ?>
                                <li>
                                    <a href="<?php print APP_URL; ?>project/view/<?= $archived_project->getId(); ?>">
                                        <i class="fa fa-<?= $archived_project->getIcon(); ?>"></i>
                                        <span><?= $archived_project->getTitle(); ?></span>
                                    </a>
                                </li>
                            <?php endforeach; ?>
                        </ul>
                    <?php endif; ?>
                </li>

            </ul>
        </section>
        <!-- /.sidebar -->
    </aside>

    <!-- Right side column. Contains the navbar and content of the page -->
    <aside class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <div class="pull-right">
                <?php print (!empty($actions) ? $actions : ''); ?>
            </div>

            <h1>
                <?php print !empty($title) ? $title : 'PHP Censor'; ?>

                <?php if (!empty($subtitle)): ?>
                <small><?php print $subtitle; ?></small>
                <?php endif; ?>
            </h1>


        </section>

        <!-- Main content -->
        <section class="content">
            <?php
            if (!empty($_SESSION['global_error'])) {
                $message = $_SESSION['global_error'];
                unset($_SESSION['global_error']);
                print '<div class="alert alert-danger">' . $message . '</div>';
            }
            ?>

            <?php print $content; ?>
        </section><!-- /.content -->
    </aside><!-- /.content-wrapper -->
</div><!-- ./wrapper -->

<script src="<?php print APP_URL; ?>assets/vendor/admin-lte/plugins/jQueryUI/jquery-ui.min.js" type="text/javascript"></script>
<script src="<?php print APP_URL; ?>assets/vendor/admin-lte/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>

<link href="<?php print APP_URL; ?>assets/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

<script src="<?php print APP_URL; ?>assets/vendor/admin-lte/plugins/chartjs/Chart.min.js" type="text/javascript"></script>
<script src="<?php print APP_URL; ?>assets/vendor/admin-lte/dist/js/app.min.js" type="text/javascript"></script>

</body>
</html>
