Renamed IndexController class and methods
This commit is contained in:
parent
e857032a73
commit
aeb73e2a5c
10 changed files with 24 additions and 18 deletions
|
@ -45,6 +45,11 @@ $context->simpleActionName = null;
|
||||||
$context->simpleActionName);
|
$context->simpleActionName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
\Chibi\Router::register(['StaticPagesController', 'mainPageView'], 'GET', '');
|
||||||
|
\Chibi\Router::register(['StaticPagesController', 'mainPageView'], 'GET', '/index');
|
||||||
|
\Chibi\Router::register(['StaticPagesController', 'helpView'], 'GET', '/help');
|
||||||
|
\Chibi\Router::register(['StaticPagesController', 'helpView'], 'GET', '/help/{tab}');
|
||||||
|
|
||||||
\Chibi\Router::register(['AuthController', 'loginView'], 'GET', '/auth/login');
|
\Chibi\Router::register(['AuthController', 'loginView'], 'GET', '/auth/login');
|
||||||
\Chibi\Router::register(['AuthController', 'loginAction'], 'POST', '/auth/login');
|
\Chibi\Router::register(['AuthController', 'loginAction'], 'POST', '/auth/login');
|
||||||
\Chibi\Router::register(['AuthController', 'logoutAction'], 'POST', '/auth/logout');
|
\Chibi\Router::register(['AuthController', 'logoutAction'], 'POST', '/auth/logout');
|
||||||
|
@ -81,10 +86,6 @@ $postValidation =
|
||||||
|
|
||||||
foreach (['GET', 'POST'] as $method)
|
foreach (['GET', 'POST'] as $method)
|
||||||
{
|
{
|
||||||
\Chibi\Router::register(['IndexController', 'indexAction'], $method, '');
|
|
||||||
\Chibi\Router::register(['IndexController', 'indexAction'], $method, '/index');
|
|
||||||
\Chibi\Router::register(['IndexController', 'helpAction'], $method, '/help');
|
|
||||||
\Chibi\Router::register(['IndexController', 'helpAction'], $method, '/help/{tab}');
|
|
||||||
\Chibi\Router::register(['LogController', 'listAction'], $method, '/logs');
|
\Chibi\Router::register(['LogController', 'listAction'], $method, '/logs');
|
||||||
\Chibi\Router::register(['LogController', 'viewAction'], $method, '/log/{name}', ['name' => '[0-9a-zA-Z._-]+']);
|
\Chibi\Router::register(['LogController', 'viewAction'], $method, '/log/{name}', ['name' => '[0-9a-zA-Z._-]+']);
|
||||||
\Chibi\Router::register(['LogController', 'viewAction'], $method, '/log/{name}/{page}', ['name' => '[0-9a-zA-Z._-]+', 'page' => '\d*']);
|
\Chibi\Router::register(['LogController', 'viewAction'], $method, '/log/{name}/{page}', ['name' => '[0-9a-zA-Z._-]+', 'page' => '\d*']);
|
||||||
|
|
|
@ -46,6 +46,6 @@ class AuthController
|
||||||
unset($_SESSION['login-redirect-url']);
|
unset($_SESSION['login-redirect-url']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
\Chibi\Util\Url::forward(\Chibi\Router::linkTo(['IndexController', 'indexAction']));
|
\Chibi\Util\Url::forward(\Chibi\Router::linkTo(['StaticPagesController', 'mainPageView']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
class IndexController
|
class StaticPagesController
|
||||||
{
|
{
|
||||||
public function indexAction()
|
public function mainPageView()
|
||||||
{
|
{
|
||||||
$context = getContext();
|
$context = getContext();
|
||||||
$context->transport->postCount = PostModel::getCount();
|
$context->transport->postCount = PostModel::getCount();
|
||||||
|
$context->viewName = 'static-main';
|
||||||
|
|
||||||
$featuredPost = $this->getFeaturedPost();
|
$featuredPost = $this->getFeaturedPost();
|
||||||
if ($featuredPost)
|
if ($featuredPost)
|
||||||
|
@ -17,15 +18,19 @@ class IndexController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function helpAction($tab = null)
|
public function helpView($tab = null)
|
||||||
{
|
{
|
||||||
$config = getConfig();
|
$config = getConfig();
|
||||||
$context = getContext();
|
$context = getContext();
|
||||||
|
|
||||||
if (empty($config->help->paths) or empty($config->help->title))
|
if (empty($config->help->paths) or empty($config->help->title))
|
||||||
throw new SimpleException('Help is disabled');
|
throw new SimpleException('Help is disabled');
|
||||||
|
|
||||||
$tab = $tab ?: array_keys($config->help->subTitles)[0];
|
$tab = $tab ?: array_keys($config->help->subTitles)[0];
|
||||||
if (!isset($config->help->paths[$tab]))
|
if (!isset($config->help->paths[$tab]))
|
||||||
throw new SimpleException('Invalid tab');
|
throw new SimpleException('Invalid tab');
|
||||||
|
|
||||||
|
$context->viewName = 'static-help';
|
||||||
$context->path = TextHelper::absolutePath($config->help->paths[$tab]);
|
$context->path = TextHelper::absolutePath($config->help->paths[$tab]);
|
||||||
$context->tab = $tab;
|
$context->tab = $tab;
|
||||||
}
|
}
|
|
@ -126,7 +126,7 @@ class UserController
|
||||||
if ($oldId == Auth::getCurrentUser()->id)
|
if ($oldId == Auth::getCurrentUser()->id)
|
||||||
Auth::logOut();
|
Auth::logOut();
|
||||||
|
|
||||||
\Chibi\Util\Url::forward(\Chibi\Router::linkTo(['IndexController', 'indexAction']));
|
\Chibi\Util\Url::forward(\Chibi\Router::linkTo(['StaticPagesController', 'mainPageView']));
|
||||||
LogHelper::log('{user} removed {subject}\'s account', ['subject' => TextHelper::reprUser($name)]);
|
LogHelper::log('{user} removed {subject}\'s account', ['subject' => TextHelper::reprUser($name)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ class UserController
|
||||||
//check if already logged in
|
//check if already logged in
|
||||||
if (Auth::isLoggedIn())
|
if (Auth::isLoggedIn())
|
||||||
{
|
{
|
||||||
\Chibi\Util\Url::forward(\Chibi\Router::linkTo(['IndexController', 'indexAction']));
|
\Chibi\Util\Url::forward(\Chibi\Router::linkTo(['StaticPagesController', 'mainPageView']));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -283,7 +283,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
['PostController', 'featureAction'],
|
['PostController', 'featureAction'],
|
||||||
['id' => $this->context->transport->post->id]),
|
['id' => $this->context->transport->post->id]),
|
||||||
'data-confirm-text' => 'Are you sure you want to feature this post on the main page?',
|
'data-confirm-text' => 'Are you sure you want to feature this post on the main page?',
|
||||||
'data-redirect-url' => \Chibi\Router::linkTo(['IndexController', 'indexAction']),
|
'data-redirect-url' => \Chibi\Router::linkTo(['StaticPagesController', 'mainPageView']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
Assets::setSubtitle('help');
|
Assets::setSubtitle('help');
|
||||||
Assets::addStylesheet('index-help.css');
|
Assets::addStylesheet('static-help.css');
|
||||||
|
|
||||||
$tabs = getConfig()->help->subTitles;
|
$tabs = getConfig()->help->subTitles;
|
||||||
$firstTab = !empty($tabs) ? array_keys($tabs)[0] : null;
|
$firstTab = !empty($tabs) ? array_keys($tabs)[0] : null;
|
||||||
|
@ -17,7 +17,7 @@ $showTabs = count($tabs) > 1;
|
||||||
<li class="<?= $tab ?>">
|
<li class="<?= $tab ?>">
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<a href="<?= \Chibi\Router::linkTo(
|
<a href="<?= \Chibi\Router::linkTo(
|
||||||
['IndexController', 'helpAction'],
|
['StaticPagesController', 'helpView'],
|
||||||
$tab == $firstTab ? [] : ['tab' => $tab]) ?>">
|
$tab == $firstTab ? [] : ['tab' => $tab]) ?>">
|
||||||
<?= $text ?>
|
<?= $text ?>
|
||||||
</a>
|
</a>
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
Assets::setSubtitle('home');
|
Assets::setSubtitle('home');
|
||||||
Assets::addStylesheet('index-index.css');
|
Assets::addStylesheet('static-main.css');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div id="welcome">
|
<div id="welcome">
|
|
@ -15,8 +15,8 @@
|
||||||
|
|
||||||
$registerNavItem(
|
$registerNavItem(
|
||||||
'Home',
|
'Home',
|
||||||
\Chibi\Router::linkTo(['IndexController', 'indexAction']),
|
\Chibi\Router::linkTo(['StaticPagesController', 'mainPageView']),
|
||||||
$activeController == 'index' and $activeAction == 'index');
|
$activeController == 'static-pages' and $activeAction == 'main-page');
|
||||||
|
|
||||||
if (Access::check(Privilege::ListPosts))
|
if (Access::check(Privilege::ListPosts))
|
||||||
{
|
{
|
||||||
|
@ -89,8 +89,8 @@
|
||||||
{
|
{
|
||||||
$registerNavItem(
|
$registerNavItem(
|
||||||
getConfig()->help->title,
|
getConfig()->help->title,
|
||||||
\Chibi\Router::linkTo(['IndexController', 'helpAction']),
|
\Chibi\Router::linkTo(['StaticPagesController', 'helpView']),
|
||||||
$activeController == 'index' and $activeAction == 'help');
|
$activeController == 'static-pages' and $activeAction == 'help');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($nav as $navItem)
|
foreach ($nav as $navItem)
|
||||||
|
|
Loading…
Reference in a new issue