Page and Forum

This commit is contained in:
Visman 2017-03-26 22:52:05 +07:00
parent 0a71fc6cb6
commit 7491dfe534
16 changed files with 430 additions and 236 deletions

View file

@ -32,6 +32,12 @@ class Auth extends Page
*/
protected $tmpUser;
/**
* Переменная для meta name="robots"
* @var string
*/
protected $robots = 'noindex';
/**
* Выход пользователя
* @param array $args

View file

@ -117,6 +117,11 @@ class Forum extends Page
$dots = [];
}
if (! $user->isGuest) {
$lower = max((int) $user->uMarkAllRead, (int) $curForum['mf_mark_all_read']);
$upper = max($lower, (int) $user->lastVisit);
}
if ($user->isGuest) {
$sql = "SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to, poll_type FROM ::topics WHERE id IN(?ai:topics) ORDER BY sticky DESC, {$sortBy}, id DESC";
} else {
@ -124,42 +129,54 @@ class Forum extends Page
}
$topics = $this->c->DB->query($sql, $vars)->fetchAll();
if (! $user->isGuest) {
$lower = max((int) $user->uMarkAllRead, (int) $curForum['mf_mark_all_read']);
$upper = max($lower, (int) $user->lastVisit);
}
foreach ($topics as &$cur) {
// цензура
if ($this->config['o_censoring'] == '1') {
$cur['subject'] = preg_replace($this->c->censoring[0], $this->c->censoring[1], $cur['subject']);
}
if (empty($cur['moved_to'])) {
$cur['link'] = $this->c->Router->link('Topic', ['id' => $cur['id'], 'name' => $cur['subject']]);
$cur['link_last'] = $this->c->Router->link('viewPost', ['id' => $cur['last_post_id']]);
if ($user->isGuest) {
$cur['link_new'] = null;
$cur['link_unread'] = null;
$cur['dot'] = false;
} else {
if ($cur['last_post'] > max($upper, $cur['mt_last_visit'])) {
$cur['link_new'] = $this->c->Router->link('TopicGoToNew', ['id' => $cur['id']]);
} else {
$cur['link_new'] = null;
}
if ($cur['last_post'] > max($lower, $cur['mt_last_read'])) {
$cur['link_unread'] = $this->c->Router->link('TopicGoToUnread', ['id' => $cur['id']]);
} else {
$cur['link_unread'] = null;
}
$cur['dot'] = isset($dots[$cur['id']]);
}
} else {
// перенос темы
if ($cur['moved_to']) {
$cur['link'] = $this->c->Router->link('Topic', ['id' => $cur['moved_to'], 'name' => $cur['subject']]);
$cur['link_last'] = null;
$cur['link_new'] = null;
$cur['link_unread'] = null;
$cur['dot'] = false;
continue;
}
// страницы темы
$tPages = ceil(($cur['num_replies'] + 1) / $user->dispPosts);
if ($tPages > 1) {
$cur['pages'] = $this->c->Func->paginate($tPages, -1, 'Topic', ['id' => $cur['id'], 'name' => $cur['subject']]);
} else {
$cur['pages'] = null;
}
$cur['link'] = $this->c->Router->link('Topic', ['id' => $cur['id'], 'name' => $cur['subject']]);
$cur['link_last'] = $this->c->Router->link('ViewPost', ['id' => $cur['last_post_id']]);
$cur['num_views'] = $this->config['o_topic_views'] == '1' ? $this->number($cur['num_views']) : null;
$cur['num_replies'] = $this->number($cur['num_replies']);
$cur['last_post'] = $this->time($cur['last_post']);
// для гостя пусто
if ($user->isGuest) {
$cur['link_new'] = null;
$cur['link_unread'] = null;
$cur['dot'] = false;
continue;
}
// новые сообщения
if ($cur['last_post'] > max($upper, $cur['mt_last_visit'])) {
$cur['link_new'] = $this->c->Router->link('TopicGoToNew', ['id' => $cur['id']]);
} else {
$cur['link_new'] = null;
}
// не прочитанные сообщения
if ($cur['last_post'] > max($lower, $cur['mt_last_read'])) {
$cur['link_unread'] = $this->c->Router->link('TopicGoToUnread', ['id' => $cur['id']]);
} else {
$cur['link_unread'] = null;
}
// активность пользователя в теме
$cur['dot'] = isset($dots[$cur['id']]);
}
unset($cur);
}
@ -203,9 +220,9 @@ class Forum extends Page
'newTopic' => $newOn ? $this->c->Router->link('NewTopic', ['id' => $args['id']]) : null,
'pages' => $this->c->Func->paginate($pages, $page, 'Forum', ['id' => $args['id'], 'name' => $fDesc[$args['id']]['forum_name']]),
];
#echo "<pre>\n";
#var_dump($this->data);
#echo "</pre>\n";
$this->canonical = $page > 1 ? $this->c->Router->link('Forum', ['id' => $args['id'], 'name' => $fDesc[$args['id']]['forum_name'], 'page' => $page])
: $this->c->Router->link('Forum', ['id' => $args['id'], 'name' => $fDesc[$args['id']]['forum_name']]);
return $this;
}

View file

@ -22,6 +22,12 @@ class Install extends Page
*/
protected $onlinePos = null;
/**
* Переменная для meta name="robots"
* @var string
*/
protected $robots = 'noindex';
/**
* Для MySQL
* @var string

View file

@ -83,6 +83,18 @@ abstract class Page
*/
protected $onlineFilter = true;
/**
* Переменная для meta name="robots"
* @var string
*/
protected $robots;
/**
* Переменная для link rel="canonical"
* @var string
*/
protected $canonical;
/**
* Конструктор
* @param Container $container
@ -107,7 +119,6 @@ abstract class Page
return $headers;
}
/**
* Возвращает HTTP статус страницы или null
* @return null|string
@ -164,7 +175,7 @@ abstract class Page
}
return $this->data + [
'pageTitle' => $this->pageTitle(),
'pageHeads' => $this->pageHeads(),
'pageHeaders' => $this->pageHeaders(),
'fLang' => __('lang_identifier'),
'fDirection' => __('lang_direction'),
'fTitle' => $this->config['o_board_title'],
@ -217,9 +228,16 @@ abstract class Page
* Генерация массива заголовков страницы
* @return array
*/
protected function pageHeads()
protected function pageHeaders()
{
return ['link rel="stylesheet" type="text/css" href="' . $this->c->Router->link() . 'style/' . $this->c->user->style . '/style.css' . '"'];
$headers = ['link rel="stylesheet" type="text/css" href="' . $this->c->Router->link() . 'style/' . $this->c->user->style . '/style.css' . '"'];
if ($this->robots) {
$headers[] = 'meta name="robots" content="' . $this->robots . '"';
}
if ($this->canonical) {
$headers[] = 'link rel="canonical" href="' . $this->canonical . '"';
}
return $headers;
}
/**
@ -322,7 +340,7 @@ abstract class Page
{
$units = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB'];
for ($i = 0; $size > 1024; $i++) {
for ($i = 0; $size > 1024; ++$i) {
$size /= 1024;
}

View file

@ -22,6 +22,12 @@ class Redirect extends Page
*/
protected $link;
/**
* Переменная для meta name="robots"
* @var string
*/
protected $robots = 'noindex';
/**
* Возвращает флаг готовности данных
* @return bool

View file

@ -26,6 +26,12 @@ class Register extends Page
*/
protected $index = 'register';
/**
* Переменная для meta name="robots"
* @var string
*/
protected $robots = 'noindex';
/**
* Обработчик регистрации
* @retrun Page

View file

@ -46,6 +46,7 @@ class Rules extends Page
public function confirmation()
{
$this->index = 'register';
$this->robots = 'noindex';
$this->c->Lang->load('register');
$this->titles = [

View file

@ -177,6 +177,11 @@ msgstr "Posts"
msgid "Replies"
msgstr "Replies"
msgid "%s Reply"
msgid_plural "%s Replies"
msgstr[0] "<strong>%s</strong> Reply"
msgstr[1] "<strong>%s</strong> Replies"
msgid "Pages"
msgstr "Pages:"

View file

@ -18,6 +18,11 @@ msgstr "Post new topic"
msgid "Views"
msgstr "Views"
msgid "%s View"
msgid_plural "%s Views"
msgstr[0] "<strong>%s</strong> View"
msgstr[1] "<strong>%s</strong> Views"
msgid "Moved"
msgstr "Moved:"

View file

@ -177,6 +177,12 @@ msgstr "Сообщений"
msgid "Replies"
msgstr "Ответов"
msgid "%s Reply"
msgid_plural "%s Replies"
msgstr[0] "<strong>%s</strong> Ответ"
msgstr[1] "<strong>%s</strong> Ответа"
msgstr[2] "<strong>%s</strong> Ответов"
msgid "Pages"
msgstr "Страницы"

View file

@ -18,6 +18,12 @@ msgstr "Создать тему"
msgid "Views"
msgstr "Просмотров"
msgid "%s View"
msgid_plural "%s Views"
msgstr[0] "<strong>%s</strong> Просмотр"
msgstr[1] "<strong>%s</strong> Просмотра"
msgstr[2] "<strong>%s</strong> Просмотров"
msgid "Moved"
msgstr "Перенесено"

View file

@ -39,7 +39,7 @@
@yield('crumbs')
</div>
<section class="f-subforums">
<ol class="f-forumlist">
<ol class="f-ftlist">
@foreach($forums as $id => $cat)
<li id="id-subforums{!! $id !!}" class="f-category">
<h2>{{ __('Sub forum', 2) }}</h2>
@ -58,7 +58,7 @@
@endif
<div class="f-nav-links">
@yield('crumbs')
@if($newTopic)
@if($newTopic || $pages)
<div class="f-links-b clearfix">
@yield('pages')
@yield('linkpost')
@ -72,6 +72,92 @@
@else
<section class="f-main f-forum">
<h2>{{ $forumName }}</h2>
<div class="f-ftlist">
<ol class="f-table">
<li class="f-row f-thead" value="0">
<div class="f-hcell f-cmain">{!! __('Topic', 1) !!}</div>
<div class="f-hcell f-cstats">{!! __('Stats') !!}</div>
<div class="f-hcell f-clast">{!! __('Last post') !!}</div>
</li>
@foreach($topics as $topic)
@if($topic['moved_to'])
<li id="topic-{!! $topic['id']!!}" class="f-row f-fredir">
<div class="f-cell f-cmain">
<div class="f-ficon"></div>
<div class="f-finfo">
<h3><span class="f-fredirtext">{!! __('Moved') !!}</span> <a class="f-ftname" href="{!! $topic['link'] !!}">{{ $topic['subject'] }}</a></h3>
</div>
</div>
</li>
@else
<li id="topic-{!! $topic['id'] !!}" class="f-row<!--inline-->
@if($topic['link_new']) f-fnew
@endif
@if($topic['link_unread']) f-funread
@endif
@if($topic['sticky']) f-fsticky
@endif
@if($topic['closed']) f-fclosed
@endif
@if($topic['poll_type']) f-fpoll
@endif
@if($topic['dot']) f-fposted
@endif
"><!--endinline-->
<div class="f-cell f-cmain">
<div class="f-ficon"></div>
<div class="f-finfo">
<h3>
@if($topic['dot'])
<span class="f-tdot">·</span>
@endif
@if($topic['sticky'])
<span class="f-stickytxt">{!! __('Sticky') !!}</span>
@endif
@if($topic['closed'])
<span class="f-closedtxt">{!! __('Closed') !!}</span>
@endif
@if($topic['poll_type'])
<span class="f-polltxt">{!! __('Poll') !!}</span>
@endif
<a class="f-ftname" href="{!! $topic['link'] !!}">{{ $topic['subject'] }}</a>
@if($topic['pages'])
<span class="f-tpages">
@foreach($topic['pages'] as $cur)
@if($cur[1] === 'space')
<span class="f-page f-pspacer">{!! __('Spacer') !!}</span>
@else
<a class="f-page" href="{!! $cur[0] !!}">{{ $cur[1] }}</a>
@endif
@endforeach
</span>
@endif
@if($topic['link_new'])
<span class="f-newtxt"><a href="{!! $topic['link_new'] !!}" title="{!! __('New posts info') !!}">{!! __('New posts') !!}</a></span>
@endif
</h3>
<p class="f-cmposter">{!! __('by') !!} {{ $topic['poster'] }}</p>
</div>
</div>
<div class="f-cell f-cstats">
<ul>
<li>{!! __('%s Reply', $topic['num_replies'], $topic['num_replies']) !!}</li>
@if(null !== $topic['num_views'])
<li>{!! __('%s View', $topic['num_views'], $topic['num_views'])!!}</li>
@endif
</ul>
</div>
<div class="f-cell f-clast">
<ul>
<li class="f-cltopic"><a href="{!! $topic['link_last'] !!}" title="&quot;{{ $topic['subject'] }}&quot; - {!! __('Last post') !!}">{{ $topic['last_post'] }}</a></li>
<li class="f-clposter">{!! __('by') !!} {{ $topic['last_poster'] }}</li>
</ul>
</div>
</li>
@endif
@endforeach
</ol>
</div>
</section>
<div class="f-nav-links">
@if($newTopic || $pages)

View file

@ -1,7 +1,7 @@
@extends('layouts/main')
@if($forums)
<section class="f-main">
<ol class="f-forumlist">
<ol class="f-ftlist">
@foreach($forums as $id => $cat)
<li id="cat-{!! $id !!}" class="f-category">
<h2>{{ $cat['name'] }}</h2>

View file

@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ $pageTitle }}</title>
@foreach($pageHeads as $cur)
@foreach($pageHeaders as $cur)
<{!! $cur !!}>
@endforeach
</head>

View file

@ -4,7 +4,7 @@
<div class="f-cell f-cmain">
<div class="f-ficon"></div>
<div class="f-finfo">
<h3><span class="f-fredirtext">{!! __('Link to') !!}</span> <a href="{!! $cur['redirect_url'] !!}">{{ $cur['forum_name'] }}</a></h3>
<h3><span class="f-fredirtext">{!! __('Link to') !!}</span> <a class="f-ftname" href="{!! $cur['redirect_url'] !!}">{{ $cur['forum_name'] }}</a></h3>
@if($cur['forum_desc'])
<p class="f-fdesc">{!! $cur['forum_desc'] !!}</p>
@endif
@ -21,7 +21,7 @@
<div class="f-ficon"></div>
<div class="f-finfo">
<h3>
<a href="{!! $cur['forum_link'] !!}">{{ $cur['forum_name'] }}</a>
<a class="f-ftname" href="{!! $cur['forum_link'] !!}">{{ $cur['forum_name'] }}</a>
@if($cur['new'])
<span class="f-newtxt"><a href="">{!! __('New posts') !!}</a></span>
@endif

View file

@ -497,7 +497,7 @@ select {
.f-nav-links .f-page {
/* float: left; */
border: 0.0625rem solid #AA7939;
padding: 0.125rem 0.4375rem;
padding: 0.125rem 0.375rem;
font-size: 0.875rem;
box-sizing: border-box;
/* margin-left: -0.0625rem; */
@ -514,7 +514,7 @@ select {
border-color: #814A00;
background-color: #814A00;
color: #F8F4E3;
}
}
/********/
/* Тело */
@ -859,193 +859,6 @@ li + li .f-btn {
font-weight: bold;
}
/********************/
/* Таблица разделов */
/********************/
.f-forumlist a {
border: 0;
}
.f-forumlist .f-cell {
padding-top: 0.625rem;
padding-bottom: 0.625rem;
}
.f-forumlist .f-hcell {
display: none;
}
.f-forumlist .f-category {
margin-top: 0.625rem;
}
.f-forumlist .f-row {
border-bottom: 0.0625rem solid #AA7939;
}
.f-forumlist .f-thead {
border-bottom: 0.125rem solid #AA7939;
}
.f-forumlist .f-cmain,
.f-forumlist .f-cstats {
padding-left: 0.625rem;
padding-right: 0.625rem;
}
.f-forumlist .f-cstats {
padding-top: 0;
text-align: right;
font-size: 0.75rem;
}
.f-forumlist .f-cstats li {
display: inline-block;
}
.f-forumlist .f-clast {
display: none;
}
.f-category > h2 {
padding: 0.625rem 0.625rem 0.3125rem 0.625rem;
}
.f-forumlist .f-ficon {
width: 1.5rem;
float: left;
}
.f-forumlist .f-finfo {
margin-left: 1.5rem;
}
.f-forumlist .f-fdesc {
font-size: 0.875rem;
}
.f-fsub {
margin-left: 0.875rem;
font-size: 0.875rem;
}
.f-fsub:before {
font-size: 0.875rem;
content: "└";
margin-left: -0.875rem;
}
.f-fsub > dt {
display: none;
}
.f-modlist {
font-size: 0.875rem;
}
.f-modlist > dt:before {
content: "(";
}
.f-modlist:last-child:after {
content: ")";
}
.f-ficon:before {
font-family: ForkIcon;
font-size: 1.2rem;
color: #814A00;
content: "\e900";
}
.f-fnew .f-ficon:before {
content: "\e901";
}
.f-fredir .f-ficon:before {
content: "\e906";
}
.f-forumlist .f-newtxt {
font-family: Arial, Helvetica, sans-serif;
font-size: 0.875rem;
font-weight: normal;
}
.f-forumlist .f-newtxt:before {
content: "[ ";
}
.f-forumlist .f-newtxt:after {
content: " ]";
}
/*
.icon-document:before {
content: "\e900";
}
.icon-document-text:before {
content: "\e901";
}
.icon-document-upload:before {
content: "\e902";
}
.icon-document-upload2:before {
content: "\e903";
}
.icon-document-locked:before {
content: "\e904";
}
.icon-document-locked2:before {
content: "\e905";
}
.icon-tag-cord:before {
content: "\e906";
}
*/
@media screen and (min-width: 50rem) {
.f-forumlist .f-cell {
display: table-cell;
}
.f-forumlist .f-cmain {
width: 100%;
}
.f-forumlist .f-cstats {
padding-top: 0.625rem;
padding-left: 0;
vertical-align: middle;
white-space: nowrap;
}
.f-forumlist .f-cstats li {
display: block;
}
.f-forumlist .f-clast {
width: 15rem;
padding-right: 0.625rem;
vertical-align: middle;
font-size: 0.875rem;
}
.f-forumlist .f-cltopic,
.f-forumlist .f-clposter,
.f-forumlist .f-cltime {
width: 15rem;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.f-forumlist .f-cltime {
font-size: 0.75rem;
}
}
/*********************/
/* Логин/Регистрация */
/*********************/
@ -1160,9 +973,196 @@ li + li .f-btn {
margin-bottom: 1rem;
}
/**********/
/* Форумы */
/**********/
/***************************************/
/* Таблица разделов, подразделов и тем */
/***************************************/
.f-ftlist a {
border: 0;
}
.f-ftlist .f-cell {
padding-top: 0.625rem;
padding-bottom: 0.625rem;
}
.f-ftlist .f-hcell {
display: none;
}
.f-ftlist .f-category {
margin-top: 0.625rem;
}
.f-ftlist .f-row {
border-bottom: 0.0625rem solid #AA7939;
}
.f-ftlist .f-thead {
border-bottom: 0.125rem solid #AA7939;
}
.f-ftlist .f-cmain,
.f-ftlist .f-cstats {
padding-left: 0.625rem;
padding-right: 0.625rem;
}
.f-ftlist .f-cstats {
padding-top: 0;
text-align: right;
font-size: 0.75rem;
}
.f-ftlist .f-cstats li {
display: inline-block;
}
.f-ftlist .f-clast {
display: none;
}
.f-category > h2 {
padding: 0.625rem 0.625rem 0.3125rem 0.625rem;
}
.f-ftlist .f-ficon {
width: 2rem;
float: left;
}
.f-ftlist .f-finfo {
margin-left: 2rem;
}
.f-ftlist .f-fdesc {
font-size: 0.875rem;
}
.f-fsub {
margin-left: 0.875rem;
font-size: 0.875rem;
}
.f-fsub:before {
font-size: 0.875rem;
content: "└";
margin-left: -0.875rem;
}
.f-fsub > dt {
display: none;
}
.f-modlist {
font-size: 0.875rem;
}
.f-modlist > dt:before {
content: "(";
}
.f-modlist:last-child:after {
content: ")";
}
.f-ficon:before {
font-family: ForkIcon;
font-size: 1.2rem;
color: #814A00;
content: "\e900";
}
.f-fnew .f-ficon:before {
content: "\e901";
}
.f-fredir .f-ficon:before {
content: "\e906";
}
.f-ftlist .f-newtxt {
font-family: Arial, Helvetica, sans-serif;
font-size: 0.875rem;
font-weight: normal;
white-space: nowrap;
}
.f-ftlist .f-newtxt:before {
content: "[ ";
}
.f-ftlist .f-newtxt:after {
content: " ]";
}
/*
.icon-document:before {
content: "\e900";
}
.icon-document-text:before {
content: "\e901";
}
.icon-document-upload:before {
content: "\e902";
}
.icon-document-upload2:before {
content: "\e903";
}
.icon-document-locked:before {
content: "\e904";
}
.icon-document-locked2:before {
content: "\e905";
}
.icon-tag-cord:before {
content: "\e906";
}
*/
@media screen and (min-width: 50rem) {
.f-ftlist .f-cell {
display: table-cell;
}
.f-ftlist .f-cmain {
width: 100%;
}
.f-ftlist .f-cstats {
padding-top: 0.625rem;
padding-left: 0;
vertical-align: middle;
white-space: nowrap;
}
.f-ftlist .f-cstats li {
display: block;
}
.f-ftlist .f-clast {
width: 15rem;
padding-right: 0.625rem;
vertical-align: middle;
font-size: 0.875rem;
}
.f-ftlist .f-cltopic,
.f-ftlist .f-clposter,
.f-ftlist .f-cltime {
width: 15rem;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.f-ftlist .f-cltime {
font-size: 0.75rem;
}
}
/********************/
/* Страница раздела */
/********************/
.f-subforums {
margin: 1rem 0;
}
@ -1171,10 +1171,36 @@ li + li .f-btn {
display: none;
}
.f-subforums .f-forumlist .f-thead {
border-bottom-width: 0.0625rem;
}
.f-forum > h2 {
display: none;
}
.f-forum h3 {
font-family: Arial, Helvetica, sans-serif;
font-weight: normal;
font-size: 1rem;
position: relative;
}
.f-cmposter {
font-size: 0.875rem;
}
.f-tdot {
font-weight: bold;
position: absolute;
margin-left: -0.5rem;
}
.f-tpages .f-page {
border: 0.0625rem solid #AA7939;
padding: 0.0625rem 0.3125rem;
font-size: 0.875rem;
/** box-sizing: border-box; */
line-height: 1.125rem;
}
.f-tpages .f-pspacer {
border: 0;
padding: 0;
}