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-04-29 21:35:29 +02:00
|
|
|
$activeController = $this->context->simpleControllerName;
|
|
|
|
$activeAction = $this->context->simpleActionName;
|
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',
|
2014-04-29 21:35:29 +02:00
|
|
|
\Chibi\Router::linkTo(['IndexController', 'indexAction']),
|
2014-02-01 11:17:02 +01:00
|
|
|
$activeController == 'index' and $activeAction == 'index');
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-04-29 23:52:17 +02:00
|
|
|
if (Access::check(Privilege::ListPosts))
|
2014-02-01 11:17:02 +01:00
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
'Browse',
|
2014-04-29 21:35:29 +02:00
|
|
|
\Chibi\Router::linkTo(['PostController', 'listAction']),
|
2014-02-01 11:17:02 +01:00
|
|
|
$activeController == 'post' and $activeAction != 'upload');
|
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-04-29 23:52:17 +02:00
|
|
|
if (Access::check(Privilege::UploadPost))
|
2014-02-01 11:17:02 +01:00
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
'Upload',
|
2014-04-29 21:35:29 +02:00
|
|
|
\Chibi\Router::linkTo(['PostController', 'uploadAction']),
|
2014-02-01 11:17:02 +01:00
|
|
|
$activeController == 'post' and $activeAction == 'upload');
|
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-04-29 23:52:17 +02:00
|
|
|
if (Access::check(Privilege::ListComments))
|
2014-02-01 11:17:02 +01:00
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
'Comments',
|
2014-04-29 21:35:29 +02:00
|
|
|
\Chibi\Router::linkTo(['CommentController', 'listAction']),
|
2014-02-01 11:17:02 +01:00
|
|
|
$activeController == 'comment');
|
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-04-29 23:52:17 +02:00
|
|
|
if (Access::check(Privilege::ListTags))
|
2014-02-01 11:17:02 +01:00
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
'Tags',
|
2014-04-29 21:35:29 +02:00
|
|
|
\Chibi\Router::linkTo(['TagController', 'listAction']),
|
2014-02-01 11:17:02 +01:00
|
|
|
$activeController == 'tag');
|
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-04-29 23:52:17 +02:00
|
|
|
if (Access::check(Privilege::ListUsers))
|
2014-02-01 11:17:02 +01:00
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
'Users',
|
2014-04-29 21:35:29 +02:00
|
|
|
\Chibi\Router::linkTo(['UserController', 'listAction']),
|
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',
|
2014-04-29 21:35:29 +02:00
|
|
|
\Chibi\Router::linkTo(['AuthController', 'loginAction']),
|
2014-02-01 11:17:02 +01:00
|
|
|
$activeController == 'auth' and $activeAction == 'login');
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-02-01 11:17:02 +01:00
|
|
|
$registerNavItem(
|
|
|
|
'Register',
|
2014-04-29 21:35:29 +02:00
|
|
|
\Chibi\Router::linkTo(['UserController', 'registrationAction']),
|
2014-02-01 11:17:02 +01:00
|
|
|
$activeController == 'user' and $activeAction == 'registration');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$registerNavItem(
|
|
|
|
'My account',
|
2014-04-29 21:35:29 +02:00
|
|
|
\Chibi\Router::linkTo(['UserController', 'viewAction'], ['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',
|
2014-04-29 21:35:29 +02:00
|
|
|
\Chibi\Router::linkTo(['AuthController', 'logoutAction']));
|
2014-02-01 11:17:02 +01:00
|
|
|
}
|
2013-12-05 23:16:25 +01:00
|
|
|
|
2014-04-29 21:35:29 +02:00
|
|
|
if (!empty(getConfig()->help->title))
|
2014-02-01 11:17:02 +01:00
|
|
|
{
|
|
|
|
$registerNavItem(
|
2014-04-29 21:35:29 +02:00
|
|
|
getConfig()->help->title,
|
|
|
|
\Chibi\Router::linkTo(['IndexController', 'helpAction']),
|
2014-02-01 11:17:02 +01:00
|
|
|
$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
|
|
|
?>
|
|
|
|
|
2014-04-29 23:52:17 +02:00
|
|
|
<?php if (Access::check(Privilege::ChangeUserSettings, Access::getIdentity($this->context->user))): ?>
|
2013-12-05 23:16:25 +01:00
|
|
|
<li class="safety">
|
|
|
|
<ul>
|
|
|
|
<?php foreach (PostSafety::getAll() as $safety): ?>
|
2014-04-29 23:52:17 +02:00
|
|
|
<?php if (Access::check(
|
2014-04-27 15:59:29 +02:00
|
|
|
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' ?>"
|
2014-04-29 21:35:29 +02:00
|
|
|
href="<?= \Chibi\Router::linkTo(['UserController', 'toggleSafetyAction'], ['safety' => $safety]) ?>"
|
2014-04-27 15:59:29 +02:00
|
|
|
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-29 21:35:29 +02:00
|
|
|
<form name="search" action="<?= \Chibi\Router::linkTo(['PostController', 'listAction']) ?>" 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>
|