Refactor
This commit is contained in:
parent
d8c40d6cb3
commit
d25f80c6b3
9 changed files with 49 additions and 33 deletions
|
@ -32,7 +32,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
|||
$html .= '<div class="item">';
|
||||
$html .= ' <i class="large rss middle aligned icon"></i>';
|
||||
$html .= ' <div class="content">';
|
||||
$html .= ' <a class="header" href="/?page=post&slug=' . $post->slug . '">' . $post->title->rendered . '</a>';
|
||||
$html .= ' <a class="header" href="' . Page::PAGE_POST . '&slug=' . $post->slug . '">' . $post->title->rendered . '</a>';
|
||||
$html .= ' <div class="description">' . sprintf(__('Posted on %s'), $date) . '</div>';
|
||||
$html .= ' </div>';
|
||||
$html .= '</div>';
|
||||
|
|
|
@ -21,9 +21,25 @@ class Page
|
|||
{
|
||||
/**
|
||||
* Static
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public const PAGE_BLOG = '/?page=blog';
|
||||
public const PAGE_CHANGELOG = '/?page=changelog';
|
||||
public const PAGE_HOME = '/?page=home';
|
||||
public const PAGE_INSTALL = '/?page=install';
|
||||
public const PAGE_LOGIN_AS = '/?page=login-as';
|
||||
public const PAGE_LOGIN = '/?page=login';
|
||||
public const PAGE_LOGOUT = '/?page=logout';
|
||||
public const PAGE_MAINTENANCE = '/?page=maintenance';
|
||||
public const PAGE_POST = '/?page=post';
|
||||
public const PAGE_POWER = '/?page=power';
|
||||
public const PAGE_PROFILE = '/?page=profile';
|
||||
public const PAGE_REGISTER = '/?page=register';
|
||||
public const PAGE_SETTINGS = '/?page=settings';
|
||||
public const PAGE_UPDATE = '/?page=update';
|
||||
public const PAGE_WISHLIST = '/?page=wishlist';
|
||||
public const PAGE_WISHLISTS_SAVED = '/?page=wishlists-saved';
|
||||
public const PAGE_WISHLISTS = '/?page=wishlists';
|
||||
|
||||
public static function message(string $content = '', string $header = '', string $type = ''): string
|
||||
{
|
||||
ob_start();
|
||||
|
@ -137,14 +153,14 @@ class Page
|
|||
&& isset($_SESSION['_GET']['page'])
|
||||
&& !in_array($_SESSION['_GET']['page'], $ignorePower)
|
||||
) {
|
||||
redirect('/?page=login');
|
||||
redirect(Page::PAGE_LOGIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Power
|
||||
*/
|
||||
if (isset($user->power) && $user->power < $this->power) {
|
||||
redirect('/?page=power&required=' . $this->power);
|
||||
redirect(Page::PAGE_POWER . '&required=' . $this->power);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,9 +175,9 @@ class Page
|
|||
|
||||
if ($options && $options->getOption('updateAvailable') && !in_array($this->name, $ignoreUpdateRedirect)) {
|
||||
if (100 === $user->power) {
|
||||
redirect('/?page=update');
|
||||
redirect(Page::PAGE_UPDATE);
|
||||
} else {
|
||||
redirect('/?page=maintenance');
|
||||
redirect(Page::PAGE_MAINTENANCE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -460,7 +476,7 @@ class Page
|
|||
'items' => array(
|
||||
array(
|
||||
'text' => __('Blog'),
|
||||
'url' => '/?page=blog',
|
||||
'url' => self::PAGE_BLOG,
|
||||
'icon' => 'rss',
|
||||
),
|
||||
),
|
||||
|
@ -486,12 +502,12 @@ class Page
|
|||
'items' => array(
|
||||
array(
|
||||
'text' => __('My lists'),
|
||||
'url' => '/?page=wishlists',
|
||||
'url' => Page::PAGE_WISHLISTS,
|
||||
'icon' => 'list',
|
||||
),
|
||||
array(
|
||||
'text' => __('Saved lists'),
|
||||
'url' => '/?page=wishlists-saved',
|
||||
'url' => Page::PAGE_WISHLISTS_SAVED,
|
||||
'icon' => 'heart',
|
||||
),
|
||||
),
|
||||
|
@ -501,19 +517,19 @@ class Page
|
|||
if ($user->isLoggedIn()) {
|
||||
$pages[$account]['items'][] = array(
|
||||
'text' => __('Profile'),
|
||||
'url' => '/?page=profile',
|
||||
'url' => Page::PAGE_PROFILE,
|
||||
'icon' => 'user circle alternate',
|
||||
);
|
||||
if (100 === $user->power) {
|
||||
$pages[$account]['items'][] = array(
|
||||
'text' => __('Login as'),
|
||||
'url' => '/?page=login-as',
|
||||
'url' => Page::PAGE_LOGIN_AS,
|
||||
'icon' => 'sign out alternate',
|
||||
);
|
||||
}
|
||||
$pages[$account]['items'][] = array(
|
||||
'text' => __('Logout'),
|
||||
'url' => '/?page=logout',
|
||||
'url' => Page::PAGE_LOGOUT,
|
||||
'icon' => 'sign out alternate',
|
||||
);
|
||||
} else {
|
||||
|
@ -523,7 +539,7 @@ class Page
|
|||
'items' => array(
|
||||
array(
|
||||
'text' => __('Login'),
|
||||
'url' => '/?page=login',
|
||||
'url' => Page::PAGE_LOGIN,
|
||||
'icon' => 'sign in alternate',
|
||||
)
|
||||
),
|
||||
|
@ -534,7 +550,7 @@ class Page
|
|||
'items' => array(
|
||||
array(
|
||||
'text' => __('Register'),
|
||||
'url' => '/?page=register',
|
||||
'url' => Page::PAGE_REGISTER,
|
||||
'icon' => 'user plus alternate',
|
||||
)
|
||||
),
|
||||
|
@ -544,7 +560,7 @@ class Page
|
|||
if (isset($user->power) && 100 === $user->power) {
|
||||
$pages[$system]['items'][] = array(
|
||||
'text' => __('Settings'),
|
||||
'url' => '/?page=settings',
|
||||
'url' => Page::PAGE_SETTINGS,
|
||||
'icon' => 'cog',
|
||||
);
|
||||
}
|
||||
|
@ -557,7 +573,7 @@ class Page
|
|||
<div class="ui attached stackable vertical menu sidebar">
|
||||
<div class="ui container">
|
||||
|
||||
<a class="item home" href="/?page=home"><?= $svgLogo ?></a>
|
||||
<a class="item home" href="<?= Page::PAGE_HOME ?>"><?= $svgLogo ?></a>
|
||||
|
||||
<?php foreach ($pages as $page) { ?>
|
||||
<?php foreach ($page['items'] as $item) { ?>
|
||||
|
@ -574,7 +590,7 @@ class Page
|
|||
<div class="pusher">
|
||||
<div class="ui attached menu desktop">
|
||||
<div class="ui container">
|
||||
<a class="item home" href="/?page=home"><?= $svgLogo ?></a>
|
||||
<a class="item home" href="<?= Page::PAGE_HOME ?>"><?= $svgLogo ?></a>
|
||||
|
||||
<?php foreach ($pages as $page) { ?>
|
||||
<?php if ('left' === $page['alignment']) { ?>
|
||||
|
@ -685,7 +701,7 @@ class Page
|
|||
</div>
|
||||
|
||||
<a class="item"
|
||||
href="/?page=changelog"
|
||||
href="<?= Page::PAGE_CHANGELOG ?>"
|
||||
title="<?= __('Changelog') ?>"
|
||||
>
|
||||
<i class="newspaper icon"></i>
|
||||
|
|
|
@ -32,7 +32,7 @@ $posts = Blog::getPosts();
|
|||
);
|
||||
$mediaHTML = isset($post->featured_media) ? Blog::getMediaHTML($post->featured_media) : '';
|
||||
$categoriesHTML = Blog::getCategoriesHTML($post->categories);
|
||||
$postLink = '/?page=post&slug=' . $post->slug;
|
||||
$postLink = Page::PAGE_POST . '&slug=' . $post->slug;
|
||||
?>
|
||||
<div class="column">
|
||||
<div class="ui fluid card stretch">
|
||||
|
|
|
@ -29,7 +29,7 @@ $page->navigation();
|
|||
<?php if ($user->isLoggedIn()) { ?>
|
||||
<div class="column">
|
||||
<a class="ui fluid primary button"
|
||||
href="/?page=wishlists"
|
||||
href="<?= Page::PAGE_WISHLISTS ?>"
|
||||
title="<?= __('My lists') ?>"
|
||||
>
|
||||
<?= __('My lists') ?>
|
||||
|
@ -38,7 +38,7 @@ $page->navigation();
|
|||
<?php } else { ?>
|
||||
<div class="column">
|
||||
<a class="ui fluid primary button"
|
||||
href="/?page=register"
|
||||
href="<?= Page::PAGE_REGISTER ?>"
|
||||
title="<?= __('Register now') ?>"
|
||||
>
|
||||
<?= __('Register now') ?>
|
||||
|
@ -46,7 +46,7 @@ $page->navigation();
|
|||
</div>
|
||||
<div class="column">
|
||||
<a class="ui fluid button"
|
||||
href="/?page=login"
|
||||
href="<?= Page::PAGE_LOGIN ?>"
|
||||
title="<?= __('Login') ?>"
|
||||
>
|
||||
<?= __('Login') ?>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
namespace wishthis;
|
||||
|
||||
if ($options && $options->getOption('isInstalled')) {
|
||||
redirect('/?page=home');
|
||||
redirect(Page::PAGE_HOME);
|
||||
}
|
||||
|
||||
$page = new Page(__FILE__, __('Install'));
|
||||
|
@ -31,7 +31,7 @@ switch ($step) {
|
|||
<p><?= __('Welcome to the wishthis installer.') ?></p>
|
||||
<p><?= __('wishthis needs a database to function properly. Please enter your credentials.') ?></p>
|
||||
|
||||
<form class="ui form" action="/?page=install" method="POST">
|
||||
<form class="ui form" action="<?= Page::PAGE_INSTALL ?>" method="POST">
|
||||
<input type="hidden" name="install" value="true" />
|
||||
<input type="hidden" name="step" value="<?= $step + 1; ?>" />
|
||||
|
||||
|
@ -101,7 +101,7 @@ switch ($step) {
|
|||
<h2 class="ui header"><?= sprintf(__('Step %d'), $step) ?></h2>
|
||||
<p><?= __('Click continue to test the database connection.') ?></p>
|
||||
|
||||
<form class="ui form" action="?page=install" method="POST">
|
||||
<form class="ui form" action="<?= Page::PAGE_INSTALL ?>" method="POST">
|
||||
<input type="hidden" name="install" value="true" />
|
||||
<input type="hidden" name="step" value="<?= $step + 1; ?>" />
|
||||
|
||||
|
@ -229,7 +229,7 @@ switch ($step) {
|
|||
<h1 class="ui header"><?= __('Success') ?></h1>
|
||||
<p>
|
||||
<a class="ui primary button"
|
||||
href="/?page=register"
|
||||
href="<? Page::PAGE_REGISTER ?>"
|
||||
title="<?= __('Register') ?>"
|
||||
>
|
||||
<?= __('Register') ?>
|
||||
|
|
|
@ -40,7 +40,7 @@ if (isset($_POST['login'], $_POST['email'], $_POST['password'])) {
|
|||
}
|
||||
|
||||
if (isset($_SESSION['user'])) {
|
||||
redirect('/?page=home');
|
||||
redirect(Page::PAGE_HOME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,7 +89,7 @@ if (isset($_POST['reset'], $_POST['email'])) {
|
|||
'password-reset-link',
|
||||
$_SERVER['REQUEST_SCHEME'] . '://' .
|
||||
$_SERVER['HTTP_HOST'] .
|
||||
'/?page=register&password-reset=' . $_POST['email'] . '&token=' . $token,
|
||||
Page::PAGE_REGISTER . '&password-reset=' . $_POST['email'] . '&token=' . $token,
|
||||
$mjml
|
||||
);
|
||||
|
||||
|
@ -146,7 +146,7 @@ $page->navigation();
|
|||
title="<?= __('Login') ?>"
|
||||
/>
|
||||
<a class="ui tertiary button"
|
||||
href="/?page=register"
|
||||
href="<?= Page::PAGE_REGISTER ?>"
|
||||
title="<?= __('Register') ?>"
|
||||
>
|
||||
<?= __('Register') ?>
|
||||
|
|
|
@ -13,7 +13,7 @@ $page = new Page(__FILE__, __('Logout'));
|
|||
if (PHP_SESSION_ACTIVE === session_status()) {
|
||||
session_destroy();
|
||||
|
||||
redirect('/?page=home');
|
||||
redirect(Page::PAGE_HOME);
|
||||
}
|
||||
|
||||
$page->header();
|
||||
|
|
|
@ -225,7 +225,7 @@ $page->navigation();
|
|||
title="<?= $buttonSubmit ?>"
|
||||
/>
|
||||
<a class="ui tertiary button"
|
||||
href="/?page=login"
|
||||
href="<?= Page::PAGE_LOGIN ?>"
|
||||
title="<?= __('Login') ?>"
|
||||
>
|
||||
<?= __('Login') ?>
|
||||
|
|
|
@ -28,7 +28,7 @@ $page->navigation();
|
|||
<div class="item">
|
||||
<i class="large heart middle aligned icon"></i>
|
||||
<div class="content">
|
||||
<a class="header" href="/?page=wishlist&hash=<?= $wishlist->hash ?>"><?= $wishlist->getTitle(); ?></a>
|
||||
<a class="header" href="<?= Page::PAGE_WISHLIST ?>&hash=<?= $wishlist->hash ?>"><?= $wishlist->getTitle(); ?></a>
|
||||
<div class="description"><?= $wishlist_user->getDisplayName(); ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue