Update pages

Add constants for $this->fIndex.
This commit is contained in:
Visman 2021-03-18 18:01:31 +07:00
parent 6210cb69bb
commit 0a60f0482a
10 changed files with 44 additions and 35 deletions

View file

@ -17,6 +17,17 @@ use function \ForkBB\__;
abstract class Page extends Model
{
const FI_INDEX = 'index';
const FI_USERS = 'userlist';
const FI_RULES = 'rules';
const FI_SRCH = 'search';
const FI_REG = 'register';
const FI_LOGIN = 'login';
const FI_PROFL = 'profile';
const FI_PM = 'pm';
const FI_ADMIN = 'admin';
const FI_LGOUT = 'logout';
/**
* Заголовки страницы
* @var array
@ -45,17 +56,17 @@ abstract class Page extends Model
$formats[1] = __($formats[1]);
$container->TIME_FORMATS = $formats;
$this->fIndex = 'index'; # string Указатель на активный пункт навигации
$this->httpStatus = 200; # int HTTP статус ответа для данной страницы
# $this->nameTpl = null; # null|string Имя шаблона
# $this->titles = []; # array Массив титула страницы | setTitles()
$this->fIswev = []; # array Массив info, success, warning, error, validation информации
# $this->onlinePos = ''; # null|string Позиция для таблицы онлайн текущего пользователя
$this->onlineDetail = false; # bool Формировать данные по посетителям online или нет
$this->onlineFilter = true; # bool Посетители только по текущей странице или по всем
# $this->robots = ''; # string Переменная для meta name="robots"
# $this->canonical = ''; # string Переменная для link rel="canonical"
$this->hhsLevel = 'common'; # string Ключ для $c->HTTP_HEADERS (для вывода заголовков HTTP из конфига)
$this->fIndex = self::FI_INDEX; # string Указатель на активный пункт навигации
$this->httpStatus = 200; # int HTTP статус ответа для данной страницы
# $this->nameTpl = null; # null|string Имя шаблона
# $this->titles = []; # array Массив титула страницы | setTitles()
$this->fIswev = []; # array Массив info, success, warning, error, validation информации
# $this->onlinePos = ''; # null|string Позиция для таблицы онлайн текущего пользователя
$this->onlineDetail = false; # bool Формировать данные по посетителям online или нет
$this->onlineFilter = true; # bool Посетители только по текущей странице или по всем
# $this->robots = ''; # string Переменная для meta name="robots"
# $this->canonical = ''; # string Переменная для link rel="canonical"
$this->hhsLevel = 'common'; # string Ключ для $c->HTTP_HEADERS (для вывода заголовков HTTP из конфига)
$this->fTitle = $container->config->o_board_title;
$this->fDescription = $container->config->o_board_desc;
@ -103,7 +114,7 @@ abstract class Page extends Model
$navUser = [];
$navGen = [
'index' => [
self::FI_INDEX => [
$r->link('Index'),
'Index',
'Home page',
@ -114,7 +125,7 @@ abstract class Page extends Model
'1' == $this->user->g_read_board
&& $this->user->viewUsers
) {
$navGen['userlist'] = [
$navGen[self::FI_USERS] = [
$r->link('Userlist'),
'User list',
'List of users',
@ -129,7 +140,7 @@ abstract class Page extends Model
|| '1' == $this->c->config->o_regs_allow
)
) {
$navGen['rules'] = [
$navGen[self::FI_RULES] = [
$r->link('Rules'),
'Rules',
'Board rules',
@ -174,7 +185,7 @@ abstract class Page extends Model
'Find unanswered topics',
];
$navGen['search'] = [
$navGen[self::FI_SRCH] = [
$r->link('Search'),
'Search',
'Search topics and posts',
@ -183,26 +194,26 @@ abstract class Page extends Model
}
if ($this->user->isGuest) {
$navUser['register'] = [
$navUser[self::FI_REG] = [
$r->link('Register'),
'Register',
'Register',
];
$navUser['login'] = [
$navUser[self::FI_LOGIN] = [
$r->link('Login'),
'Login',
'Login',
];
} else {
$navUser['profile'] = [
$navUser[self::FI_PROFL] = [
$this->user->link,
['User %s', $this->user->username],
'Your profile',
];
if ($this->user->usePM) {
$navUser['pm'] = [
'#', // ????
$navUser[self::FI_PM] = [
$r->link('PM'),
$this->user->u_pm_num_new > 0
? ['PM %s', $this->user->u_pm_num_new]
: 'PM'
@ -212,14 +223,14 @@ abstract class Page extends Model
}
if ($this->user->isAdmMod) {
$navUser['admin'] = [
$navUser[self::FI_ADMIN] = [
$r->link('Admin'),
'Admin',
'Administration functions',
];
}
$navUser['logout'] = [
$navUser[self::FI_LGOUT] = [
$r->link('Logout'),
'Logout',
'Logout',

View file

@ -14,7 +14,7 @@ use ForkBB\Core\Container;
use ForkBB\Models\Page;
use function \ForkBB\__;
class Admin extends Page
abstract class Admin extends Page
{
/**
* @var array
@ -26,7 +26,7 @@ class Admin extends Page
parent::__construct($container);
$this->aIndex = 'index'; # string Указатель на активный пункт навигации в меню админки
$this->fIndex = 'admin';
$this->fIndex = self::FI_ADMIN;
$this->onlinePos = 'admin';
$this->robots = 'noindex, nofollow';
$this->hhsLevel = 'secure';

View file

@ -91,7 +91,7 @@ class Auth extends Page
$ref = $this->c->Secury->replInvalidChars($_SERVER['HTTP_REFERER'] ?? '');
$this->hhsLevel = 'secure';
$this->fIndex = 'login';
$this->fIndex = self::FI_LOGIN;
$this->nameTpl = 'login';
$this->onlinePos = 'login';
$this->robots = 'noindex';
@ -311,7 +311,7 @@ class Auth extends Page
}
$this->hhsLevel = 'secure';
$this->fIndex = 'login';
$this->fIndex = self::FI_LOGIN;
$this->nameTpl = 'passphrase_reset';
$this->onlinePos = 'passphrase_reset';
$this->robots = 'noindex';
@ -438,7 +438,7 @@ class Auth extends Page
}
$this->hhsLevel = 'secure';
$this->fIndex = 'login';
$this->fIndex = self::FI_LOGIN;
$this->nameTpl = 'change_passphrase';
$this->onlinePos = 'change_passphrase';
$this->robots = 'noindex';

View file

@ -39,7 +39,6 @@ class Forum extends Page
return $this->c->Message->message('Not Found', true, 404);
}
$this->fIndex = 'index';
$this->nameTpl = 'forum';
$this->onlinePos = 'forum-' . $args['id'];
$this->canonical = $this->c->Router->link(

View file

@ -45,7 +45,6 @@ class Moderate extends Page
{
parent::__construct($container);
$this->fIndex = 'index';
$this->nameTpl = 'moderate';
$this->onlinePos = 'moderate';
$this->robots = 'noindex, nofollow';

View file

@ -40,7 +40,7 @@ abstract class Profile extends Page
$this->hhsLevel = 'secure';
$this->rules = $this->c->ProfileRules->setUser($this->curUser);
$this->robots = 'noindex';
$this->fIndex = $this->rules->my ? 'profile' : 'userlist';
$this->fIndex = $this->rules->my ? self::FI_PROFL : self::FI_USERS;
$this->nameTpl = 'profile';
$this->onlinePos = 'profile-' . $this->curUser->id; // ????
$this->title = __(['%s\'s profile', $this->curUser->username]);

View file

@ -78,7 +78,7 @@ class Register extends Page
}
$this->hhsLevel = 'secure';
$this->fIndex = 'register';
$this->fIndex = self::FI_REG;
$this->nameTpl = 'register';
$this->onlinePos = 'register';
$this->titles = __('Register');

View file

@ -20,7 +20,7 @@ class Rules extends Page
*/
public function view(): Page
{
$this->fIndex = 'rules';
$this->fIndex = self::FI_RULES;
$this->nameTpl = 'rules';
$this->onlinePos = 'rules';
$this->canonical = $this->c->Router->link('Rules');
@ -43,7 +43,7 @@ class Rules extends Page
{
$this->c->Lang->load('register');
$this->fIndex = 'register';
$this->fIndex = self::FI_REG;
$this->nameTpl = 'rules';
$this->onlinePos = 'rules';
$this->robots = 'noindex';

View file

@ -524,7 +524,7 @@ class Search extends Page
$this->posts = $list;
}
$this->fIndex = 'search';
$this->fIndex = self::FI_SRCH;
$this->onlinePos = 'search';
$this->robots = 'noindex';
$this->model = $model;

View file

@ -137,7 +137,7 @@ class Userlist extends Page
$this->fIswev = ['i', 'No users found'];
}
$this->fIndex = 'userlist';
$this->fIndex = self::FI_USERS;
$this->nameTpl = 'userlist';
$this->onlinePos = 'userlist';
$this->canonical = $this->c->Router->link('Userlist', $args);