context->simpleControllerName; $activeAction = $this->context->simpleActionName; $registerNavItem = function ($text, $link, $active = false) use (&$nav) { $nav []= [ 'text' => $text, 'link' => $link, 'active' => $active]; }; $registerNavItem( 'Home', \Chibi\Router::linkTo(['IndexController', 'indexAction']), $activeController == 'index' and $activeAction == 'index'); if (PrivilegesHelper::confirm(Privilege::ListPosts)) { $registerNavItem( 'Browse', \Chibi\Router::linkTo(['PostController', 'listAction']), $activeController == 'post' and $activeAction != 'upload'); } if (PrivilegesHelper::confirm(Privilege::UploadPost)) { $registerNavItem( 'Upload', \Chibi\Router::linkTo(['PostController', 'uploadAction']), $activeController == 'post' and $activeAction == 'upload'); } if (PrivilegesHelper::confirm(Privilege::ListComments)) { $registerNavItem( 'Comments', \Chibi\Router::linkTo(['CommentController', 'listAction']), $activeController == 'comment'); } if (PrivilegesHelper::confirm(Privilege::ListTags)) { $registerNavItem( 'Tags', \Chibi\Router::linkTo(['TagController', 'listAction']), $activeController == 'tag'); } if (PrivilegesHelper::confirm(Privilege::ListUsers)) { $registerNavItem( 'Users', \Chibi\Router::linkTo(['UserController', 'listAction']), $activeController == 'user' and $activeAction != 'registration' and (!isset($this->context->route->arguments['name']) or $this->context->route->arguments['name'] != $this->context->user->name)); } if (!$this->context->loggedIn) { $registerNavItem( 'Log in', \Chibi\Router::linkTo(['AuthController', 'loginAction']), $activeController == 'auth' and $activeAction == 'login'); $registerNavItem( 'Register', \Chibi\Router::linkTo(['UserController', 'registrationAction']), $activeController == 'user' and $activeAction == 'registration'); } else { $registerNavItem( 'My account', \Chibi\Router::linkTo(['UserController', 'viewAction'], ['name' => $this->context->user->name]), $activeController == 'user' and isset($this->context->route->arguments['name']) and $this->context->route->arguments['name'] == $this->context->user->name); $registerNavItem( 'Log out', \Chibi\Router::linkTo(['AuthController', 'logoutAction'])); } if (!empty(getConfig()->help->title)) { $registerNavItem( getConfig()->help->title, \Chibi\Router::linkTo(['IndexController', 'helpAction']), $activeController == 'index' and $activeAction == 'help'); } 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); } ?> context->user))): ?>