2013-12-05 23:16:25 +01:00
|
|
|
<ul class="main-nav">
|
|
|
|
<?php
|
2014-02-01 11:17:02 +01:00
|
|
|
$nav = [];
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
if ($this->context->route)
|
|
|
|
{
|
|
|
|
$activeController = $this->context->route->simpleControllerName;
|
|
|
|
$activeAction = $this->context->route->simpleActionName;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$activeController = null;
|
|
|
|
$activeAction = null;
|
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
$registerNavItem = function ($text, $link, $active = false) use (&$nav)
|
|
|
|
{
|
|
|
|
$nav []= [
|
|
|
|
'text' => $text,
|
|
|
|
'link' => $link,
|
|
|
|
'active' => $active];
|
|
|
|
};
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
$registerNavItem(
|
|
|
|
'Home',
|
|
|
|
\Chibi\UrlHelper::route('index', 'index'),
|
|
|
|
$activeController == 'index' and $activeAction == 'index');
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
if (PrivilegesHelper::confirm(Privilege::ListPosts))
|
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
'Browse',
|
|
|
|
\Chibi\UrlHelper::route('post', 'list'),
|
|
|
|
$activeController == 'post' and $activeAction != 'upload');
|
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
if (PrivilegesHelper::confirm(Privilege::UploadPost))
|
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
'Upload',
|
|
|
|
\Chibi\UrlHelper::route('post', 'upload'),
|
|
|
|
$activeController == 'post' and $activeAction == 'upload');
|
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
if (PrivilegesHelper::confirm(Privilege::ListComments))
|
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
'Comments',
|
|
|
|
\Chibi\UrlHelper::route('comment', 'list'),
|
|
|
|
$activeController == 'comment');
|
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
if (PrivilegesHelper::confirm(Privilege::ListTags))
|
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
'Tags',
|
|
|
|
\Chibi\UrlHelper::route('tag', 'list'),
|
|
|
|
$activeController == 'tag');
|
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
if (PrivilegesHelper::confirm(Privilege::ListUsers))
|
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
'Users',
|
|
|
|
\Chibi\UrlHelper::route('user', 'list'),
|
2014-04-27 15:59:29 +02:00
|
|
|
$activeController == 'user' and $activeAction != 'registration' and
|
|
|
|
(!isset($this->context->route->arguments['name']) or
|
|
|
|
$this->context->route->arguments['name'] != $this->context->user->name));
|
2014-02-01 11:17:02 +01:00
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
if (!$this->context->loggedIn)
|
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
'Log in',
|
|
|
|
\Chibi\UrlHelper::route('auth', 'login'),
|
|
|
|
$activeController == 'auth' and $activeAction == 'login');
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
$registerNavItem(
|
|
|
|
'Register',
|
|
|
|
\Chibi\UrlHelper::route('user', 'registration'),
|
|
|
|
$activeController == 'user' and $activeAction == 'registration');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
'My account',
|
|
|
|
\Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->user->name]),
|
2014-04-27 15:59:29 +02:00
|
|
|
$activeController == 'user' and isset($this->context->route->arguments['name']) and
|
|
|
|
$this->context->route->arguments['name'] == $this->context->user->name);
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
$registerNavItem(
|
|
|
|
'Log out',
|
|
|
|
\Chibi\UrlHelper::route('auth', 'logout'));
|
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
if (!empty($this->config->help->title))
|
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
$this->config->help->title,
|
|
|
|
\Chibi\UrlHelper::route('index', 'help'),
|
|
|
|
$activeController == 'index' and $activeAction == 'help');
|
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
foreach ($nav as $navItem)
|
|
|
|
{
|
|
|
|
extract($navItem);
|
|
|
|
echo TextHelper::htmlTag('li', TextHelper::HTML_OPEN, ['class' => rtrim('main-nav-item ' . ($active ? 'active' : ''))]);
|
|
|
|
echo TextHelper::htmlTag('a', TextHelper::HTML_OPEN, ['href' => $link]);
|
|
|
|
echo $text;
|
|
|
|
echo TextHelper::htmlTag('a', textHelper::HTML_CLOSE);
|
|
|
|
echo TextHelper::htmlTag('li', textHelper::HTML_CLOSE);
|
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
?>
|
|
|
|
|
|
|
|
<?php if (PrivilegesHelper::confirm(Privilege::ChangeUserSettings, PrivilegesHelper::getIdentitySubPrivilege($this->context->user))): ?>
|
|
|
|
<li class="safety">
|
|
|
|
<ul>
|
|
|
|
<?php foreach (PostSafety::getAll() as $safety): ?>
|
2014-04-27 15:59:29 +02:00
|
|
|
<?php if (PrivilegesHelper::confirm(
|
|
|
|
Privilege::ListPosts,
|
|
|
|
PostSafety::toString($safety))): ?>
|
|
|
|
|
2014-04-27 14:44:06 +02:00
|
|
|
<li class="safety-<?= TextCaseConverter::convert(PostSafety::toString($safety), TextCaseConverter::CAMEL_CASE, TextCaseConverter::SPINAL_CASE) ?>">
|
2014-04-27 15:59:29 +02:00
|
|
|
|
|
|
|
<a class="<?= $this->context->user->hasEnabledSafety($safety) ? 'enabled' : 'disabled' ?>"
|
|
|
|
href="<?= \Chibi\UrlHelper::route('user', 'toggle-safety', ['safety' => $safety]) ?>"
|
|
|
|
title="Searching <?= PostSafety::toDisplayString($safety) ?> posts: <?= $this->context->user->hasEnabledSafety($safety) ? 'enabled' : 'disabled' ?>">
|
|
|
|
|
2014-04-27 14:44:06 +02:00
|
|
|
<span><?= ucfirst(PostSafety::toDisplayString($safety)) ?></span>
|
2014-04-27 15:59:29 +02:00
|
|
|
|
2013-12-05 23:16:25 +01:00
|
|
|
</a>
|
|
|
|
</li>
|
2014-04-27 15:59:29 +02:00
|
|
|
|
2013-12-05 23:16:25 +01:00
|
|
|
<?php endif ?>
|
|
|
|
<?php endforeach ?>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<?php endif ?>
|
|
|
|
|
|
|
|
<li class="search">
|
2014-04-27 14:44:06 +02:00
|
|
|
<form name="search" action="<?= \Chibi\UrlHelper::route('post', 'list') ?>" method="get">
|
2014-04-27 15:59:29 +02:00
|
|
|
|
|
|
|
<input
|
|
|
|
class="autocomplete"
|
|
|
|
type="search"
|
|
|
|
name="query"
|
|
|
|
placeholder="Search…"
|
|
|
|
value="<?= isset($this->context->transport->searchQuery) ? htmlspecialchars($this->context->transport->searchQuery) : '' ?>"/>
|
|
|
|
|
2013-12-05 23:16:25 +01:00
|
|
|
</form>
|
|
|
|
</li>
|
|
|
|
</ul>
|