1 | <?php |
||||
2 | |||||
3 | use Ffcms\Core\Helper\Date; |
||||
4 | use Ffcms\Core\Helper\Type\Any; |
||||
5 | use Ffcms\Core\Helper\Type\Arr; |
||||
6 | use Ffcms\Core\Helper\Type\Str; |
||||
7 | use Ffcms\Templex\Url\Url; |
||||
8 | |||||
9 | /** @var array $pagination */ |
||||
10 | /** @var array $configs */ |
||||
11 | /** @var \Ffcms\Templex\Template\Template $this */ |
||||
12 | /** @var array $category */ |
||||
13 | /** @var Apps\Model\Front\Content\EntityCategoryList $model */ |
||||
14 | |||||
15 | $catConfigs = []; |
||||
16 | foreach ($model->category['configs'] as $key=>$value) { |
||||
17 | $catConfigs[$key] = (bool)$value; |
||||
18 | } |
||||
19 | $catMeta = [ |
||||
20 | 'date' => $catConfigs['showDate'], |
||||
21 | 'author' => $catConfigs['showAuthor'], |
||||
22 | 'views' => $catConfigs['showViews'] |
||||
23 | ]; |
||||
24 | |||||
25 | $breads = null; |
||||
26 | if (!\App::$Request->isPathInjected()) { |
||||
27 | $breads = [ |
||||
28 | Url::to('/') => __('Home'), |
||||
29 | Url::to('content/list') => __('Contents'), |
||||
30 | $model->category['title'] |
||||
31 | ]; |
||||
32 | } |
||||
33 | |||||
34 | $this->layout('_layouts/default', [ |
||||
35 | 'title' => $model->category['title'], |
||||
36 | 'breadcrumbs' => $breads |
||||
37 | ]); |
||||
38 | ?> |
||||
39 | <?php $this->start('body') ?> |
||||
40 | <script> |
||||
41 | // content id array |
||||
42 | var contentIds = []; |
||||
43 | </script> |
||||
44 | <?php if (!\App::$Request->isPathInjected()): ?> |
||||
45 | <h1> |
||||
46 | <?= $model->category['title'] ?> |
||||
47 | <?php if (!Str::likeEmpty($model->category['rss'])): ?> |
||||
48 | <small><a href="<?= $model->category['rss'] ?>" target="_blank"><i class="fa fa-rss"></i></a></small> |
||||
49 | <?php endif; ?> |
||||
50 | <div class="float-right"> |
||||
51 | <div class="btn-group" role="group"> |
||||
52 | <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
||||
53 | <i class="fa fa-sort-amount-desc"></i> <?= __('Sorting')?> <span class="caret"></span> |
||||
54 | </button> |
||||
55 | <div class="dropdown-menu"> |
||||
56 | <a class="dropdown-item" href="<?= $model->category['sort']['newest'] ?>"><?= __('Newest') ?> </a> |
||||
57 | <a class="dropdown-item" href="<?= $model->category['sort']['rating'] ?>"><?= __('Rating') ?></a> |
||||
58 | <a class="dropdown-item" href="<?= $model->category['sort']['views'] ?>"><?= __('Popularity') ?></a> |
||||
59 | </div> |
||||
60 | </div> |
||||
61 | </div> |
||||
62 | </h1> |
||||
63 | <?php if (Str::length($model->category['description']) > 0): ?> |
||||
64 | <p class="text-muted"><?= $model->category['description'] ?></p> |
||||
65 | <?php endif; ?> |
||||
66 | <hr /> |
||||
67 | <?php endif; ?> |
||||
68 | <?php if ($model->getContentCount() < 1): ?> |
||||
69 | <p class="alert alert-warning"><?= __('This category is empty!') ?></p> |
||||
70 | <?php return; endif; ?> |
||||
71 | <?php foreach ($model->items as $item): ?> |
||||
72 | <article class="article-item" itemscope="itemscope" itemtype="https://schema.org/NewsArticle"> |
||||
73 | <h2 itemprop="name"> |
||||
74 | <?php if ($item['important']): ?> |
||||
75 | <i class="fa fa-fire" style="color: #a50000"></i> |
||||
76 | <?php endif; ?> |
||||
77 | <a href="<?= \App::$Alias->baseUrl . $item['uri'] ?>"> |
||||
78 | <?= $item['title'] ?> |
||||
79 | </a> |
||||
80 | </h2> |
||||
81 | <?php if (Arr::in(true, $catMeta)): ?> |
||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
82 | <div class="meta"> |
||||
83 | <?php if ($catConfigs['showCategory'] === true): ?> |
||||
84 | <span class="spaced"><i class="fa fa-list"></i> |
||||
85 | <?= Url::a( |
||||
86 | ['content/list', [$item['category']->path]], |
||||
87 | \App::$Translate->getLocaleText($item['category']->title), |
||||
0 ignored issues
–
show
It seems like
App::Translate->getLocal...tem['category']->title) can also be of type null ; however, parameter $text of Ffcms\Templex\Url\Url::a() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
88 | ['itemprop' => 'genre'] |
||||
89 | ) ?> |
||||
90 | </span> |
||||
91 | <?php endif; ?> |
||||
92 | <?php if ($catConfigs['showDate'] === true): ?> |
||||
93 | <span class="spaced"><i class="fa fa-calendar"></i> |
||||
94 | <time datetime="<?= date('c', Date::convertToTimestamp($item['date'])) ?>" itemprop="datePublished"> |
||||
95 | <?= $item['date'] ?> |
||||
96 | </time> |
||||
97 | </span> |
||||
98 | <?php endif; ?> |
||||
99 | <?php if ($catConfigs['showAuthor'] === true): ?> |
||||
100 | <span class="spaced"><i class="fa fa-user"></i> |
||||
101 | <?php |
||||
102 | $ownerNick = $item['author']->profile === null ? __('Unknown') : $item['author']->profile->getNickname(); |
||||
103 | if ($item['author']->getId() < 1) { |
||||
104 | echo '<s>' . $ownerNick . '</s>'; |
||||
105 | } else { |
||||
106 | echo Url::a(['profile/show', [$item['author']->getId()]], $ownerNick, ['itemprop' => 'author']); |
||||
107 | } |
||||
108 | ?> |
||||
109 | </span> |
||||
110 | <?php endif; ?> |
||||
111 | <?php if ($catConfigs['showViews'] === true): ?> |
||||
112 | <span class="spaced"><i class="fa fa-eye"></i> <?= $item['views'] ?></span> |
||||
113 | <?php endif; ?> |
||||
114 | </div> |
||||
115 | <?php else: ?> |
||||
116 | <hr /> |
||||
117 | <?php endif; ?> |
||||
118 | <div class="row"> |
||||
119 | <div class="col-md-12"> |
||||
120 | <?php if ($catConfigs['showPoster'] === true && $item['thumb'] !== null): ?> |
||||
121 | <img src="<?= \App::$Alias->scriptUrl . $item['thumb'] ?>" class="image_poster img-thumbnail d-none d-sm-block" alt="<?= __('Poster for') ?>: <?= Str::lowerCase($item['title']) ?>" /> |
||||
122 | <?php endif; ?> |
||||
123 | <div itemprop="text articleBody"> |
||||
124 | <?= $item['text'] ?> |
||||
125 | </div> |
||||
126 | </div> |
||||
127 | </div> |
||||
128 | <div class="meta"> |
||||
129 | <?php /**if ((int)$catConfigs['showRating'] === 1) { |
||||
130 | echo \App::$View->render('content/_rate', [ |
||||
131 | 'id' => $item['id'], |
||||
132 | 'canRate' => $item['canRate'], |
||||
133 | 'rating' => $item['rating'] |
||||
134 | ]); |
||||
135 | }*/ ?> |
||||
136 | |||||
137 | <span class="spaced"><i class="fa fa-comment-o"></i> |
||||
138 | <a href="<?= \App::$Alias->baseUrl . $item['uri'] ?>#comments-list"><?= __('Comments') ?>: <span itemprop="commentCount" id="comment-count-<?= $item['id'] ?>">0</span></a> |
||||
139 | </span> |
||||
140 | <span class="float-right"> |
||||
141 | <?php if ((int)$catConfigs['showTags'] === 1 && $item['tags'] !== null && Any::isArray($item['tags'])): ?> |
||||
142 | <span class="spaced"><i class="fa fa-tags"></i> |
||||
143 | <?php |
||||
144 | foreach ($item['tags'] as $tag) { |
||||
145 | $tag = trim($tag); |
||||
146 | echo Url::a(['content/tag', [urlencode($tag)]], $tag, ['class' => 'badge badge-secondary']) . " "; |
||||
147 | } |
||||
148 | ?> |
||||
149 | </span> |
||||
150 | <meta itemprop="keywords" content="<?php implode(',', $item['tags']); ?>"> |
||||
151 | <?php endif; ?> |
||||
152 | </span> |
||||
153 | </div> |
||||
154 | </article> |
||||
155 | <script> |
||||
156 | contentIds.push(<?= $item['id'] ?>); |
||||
157 | </script> |
||||
158 | <?php endforeach; ?> |
||||
159 | |||||
160 | <?php //\App::$View->render('content/_rateJs') ?> |
||||
161 | |||||
162 | <?= $this->bootstrap()->pagination(['content/my'], ['class' => 'pagination justify-content-center']) |
||||
163 | ->size($pagination['total'], $pagination['page'], $pagination['step']) |
||||
164 | ->display(); ?> |
||||
165 | |||||
166 | <script> |
||||
167 | $(document).ready(function() { |
||||
168 | if (typeof contentIds === 'object' || contentIds.length > 0) { |
||||
169 | $.getJSON(script_url + '/api/comments/count/content?lang='+script_lang, {id: contentIds}, function(json){ |
||||
170 | // check if response is success |
||||
171 | if (json.status !== 1 || typeof json.count !== 'object') { |
||||
172 | return null; |
||||
173 | } |
||||
174 | // list response json counts by itemId => count |
||||
175 | for (var itemId in json.count) { |
||||
176 | $('#comment-count-' + itemId).text(json.count[itemId]); |
||||
177 | } |
||||
178 | }); |
||||
179 | } |
||||
180 | }) |
||||
181 | </script> |
||||
182 | <?php $this->stop() ?> |