Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

Apps/View/Front/default/content/read.php (1 issue)

Checks if the types of the passed arguments in a function/method call are compatible.

Bug Minor
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 Apps\Model\Front\Content\EntityContentRead $model */
10
/** @var Apps\Model\Front\Content\EntityContentSearch $search */
11
/** @var \Ffcms\Templex\Template\Template $this */
12
/** @var bool $trash */
13
/** @var array $configs */
14
15
// check if content is trashed or hidden from display and show it only for admin with content.index permissions
16
if (($trash || !$model->display) && (!\App::$User->isAuth() || !\App::$User->identity()->role->can('Admin/Content/Index'))) {
17
    throw new \Ffcms\Core\Exception\NotFoundException(__('Page not found'));
18
}
19
// set meta title
20
$title = $model->metaTitle;
21
if (Any::isEmpty($title)) {
22
    $title = $model->title;
23
}
24
// set meta description
25
$description = $model->metaDescription;
26
// set meta keywords
27
$keywords = null;
28
if (Any::isArray($model->metaKeywords) && count($model->metaKeywords) > 0) {
29
    $keywords = implode(', ', $model->metaKeywords);
30
}
31
// don't use breadcrumbs on injected pathway rule
32
$breadcrumbs = null;
33
if (!\App::$Request->isPathInjected() && (bool)$model->getCategory()->getProperty('showCategory')) {
34
    $breadcrumbs = [
35
        Url::to('/') => __('Home')
36
    ];
37
    if (Any::isArray($model->catNesting)) {
38
        foreach ($model->catNesting as $cat) {
39
            if (Str::likeEmpty($cat['path'])) {
40
                $breadcrumbs[Url::to('content/list', [$cat['path']])] = __('Contents');
41
            } else {
42
                $breadcrumbs[Url::to('content/list', [$cat['path']])] = $cat['name'];
43
            }
44
        }
45
        $breadcrumbs[] = __('Content') . ': ' . Str::sub($title, 0, 40);
46
    }
47
}
48
49
// render with global layout
50
$this->layout('_layouts/default', [
51
    'title' => $title,
52
    'keywords' => $keywords,
53
    'description' => $description,
54
    'breadcrumbs' => $breadcrumbs
55
]);
56
57
$properties = [
58
    'date' => (bool)$model->getCategory()->getProperty('showDate'),
59
    'author' => (bool)$model->getCategory()->getProperty('showAuthor'),
60
    'views' => (bool)$model->getCategory()->getProperty('showViews'),
61
    'category' => (bool)$model->getCategory()->getProperty('showCategory'),
62
    'rating' => (bool)$model->getCategory()->getProperty('showRating'),
63
    'tags' => (bool)$model->getCategory()->getProperty('showTags')
64
];
65
$showComments = (bool)$model->getCategory()->getProperty('showComments');
66
$showPoster = (bool)$model->getCategory()->getProperty('showPoster');
67
?>
68
69
<?php $this->push('css') ?>
70
<link rel="stylesheet" href="<?= \App::$Alias->scriptUrl ?>/vendor/phpffcms/ffcms-assets/node_modules/@fancyapps/fancybox/dist/jquery.fancybox.min.css" />
71
<?php $this->stop() ?>
72
73
<?php $this->start('body') ?>
74
    <article class="article-item article-border" itemscope="itemscope" itemtype="https://schema.org/NewsArticle">
75
        <h1><?= $model->title ?></h1>
76
        <?php if (Arr::in(true, $properties)): ?>
0 ignored issues
show
true of type true is incompatible with the type double|integer|string expected by parameter $needle of Ffcms\Core\Helper\Type\Arr::in(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

76
        <?php if (Arr::in(/** @scrutinizer ignore-type */ true, $properties)): ?>
Loading history...
77
            <div class="meta">
78
                <?php if ((bool)$properties['category']): ?>
79
                    <span class="spaced"><i class="fa fa-list"></i> <?= Url::a(['content/list', [$model->catPath]], $model->catName, ['itemprop' => 'genre']) ?></span>
80
                <?php endif; ?>
81
                <?php if ((bool)$properties['date']): ?>
82
                    <span class="spaced"><i class="fa fa-calendar"></i> <time datetime="<?= date('c', Date::convertToTimestamp($model->getRecord()->created_at)) ?> itemprop="datePublished"><?= $model->createDate ?></time></span>
83
                <?php endif; ?>
84
                <?php if ((bool)$properties['author']): ?>
85
                    <?php if ($model->authorId && $model->authorId > 0): ?>
86
                        <span class="spaced"><i class="fa fa-user"></i> <?= Url::a(['profile/show', [$model->authorId]], $model->authorName, ['itemprop' => 'author']) ?></span>
87
                    <?php else: ?>
88
                        <span class="spaced"><i class="fa fa-user"></i> <s><?= $model->authorName ?></s></span>
89
                    <?php endif; ?>
90
                <?php endif; ?>
91
                <?php if ((bool)$properties['views']): ?>
92
                    <span class="spaced"><i class="fa fa-eye"></i> <?= $model->views ?></span>
93
                <?php endif ?>
94
                <?php if (\App::$User->isAuth() && \App::$User->identity()->role->can('Admin/Content/Update')): ?>
95
                    <span class="float-right"><a href="<?= \App::$Alias->scriptUrl . '/admin/content/update/' . $model->id ?>" target="_blank"><i class="fa fa-pencil" style="color: #ff0000;"></i></a></span>
96
                <?php endif; ?>
97
            </div>
98
        <?php else: ?>
99
            <hr />
100
        <?php endif; ?>
101
        <?php if ($trash): ?>
102
            <p class="alert alert-danger"><i class="fa fa-trash"></i> <?= __('This content is placed in trash') ?></p>
103
        <?php endif; ?>
104
        <?php if (!$model->display): ?>
105
            <p class="alert alert-warning"><i class="fa fa-pencil"></i> <?= __('This content now is on moderation stage') ?></p>
106
        <?php endif; ?>
107
        <div class="row">
108
            <div class="col-12">
109
                <div id="content-text">
110
                    <?php if ($showPoster === true && $model->posterFull && $model->posterThumb): ?>
111
                        <a href="<?= $model->posterFull ?>" data-fancybox="image">
112
                            <img alt="<?= __('Poster for') ?>: <?= Str::lowerCase($model->title) ?>" src="<?= \App::$Alias->scriptUrl . $model->posterThumb ?>" class="image_poster img-thumbnail" />
113
                        </a>
114
                    <?php endif ;?>
115
                    <?= $model->text ?>
116
                </div>
117
            </div>
118
        </div>
119
        <?php if ($model->galleryItems && Any::isArray($model->galleryItems)): ?>
120
            <div class="row mb-4">
121
                <?php foreach ($model->galleryItems as $thumb => $full): ?>
122
                <div class="col-6 col-lg-4 mt-2">
123
                    <figure>
124
                        <a class="d-block mb-4" data-fancybox="images" href="<?= \App::$Alias->scriptUrl . $full ?>">
125
                            <img class="img-fluid" src="<?= \App::$Alias->scriptUrl . $thumb ?>" alt="gallery image">
126
                        </a>
127
                    </figure>
128
                </div>
129
                <?php endforeach; ?>
130
            </div>
131
        <?php endif; ?>
132
        <?php if ($search->items && Any::isArray($search->items)): ?>
133
            <div class="h3"><?= __('Similar content') ?></div>
134
            <div class="accordion" id="accordion-similar-group">
135
            <?php $idx = 1; ?>
136
            <?php foreach ($search->items as $item): ?>
137
                <div class="card">
138
                    <div class="card-header" id="similar-heading-<?= $item['id'] ?>">
139
                        <h5 class="mb-0">
140
                            <button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#similar-collapse-<?= $item['id'] ?>" aria-expanded="false" aria-controls="similar-collapse-<?= $item['id'] ?>">
141
                                <?= $item['title'] ?>
142
                            </button>
143
                        </h5>
144
                    </div>
145
                    <div id="similar-collapse-<?= $item['id'] ?>" class="collapse" aria-labelledby="similar-heading-<?= $item['id'] ?>" data-parent="#accordion-similar-group">
146
                        <div class="card-body">
147
                            <a href="<?= \App::$Alias->baseUrl . $item['uri'] ?>">
148
                                <?= $item['snippet'] ?>
149
                            </a>
150
                        </div>
151
                    </div>
152
                </div>
153
            <?php ++$idx; ?>
154
            <?php endforeach; ?>
155
            </div>
156
        <?php endif; ?>
157
158
        <div class="row">
159
            <div class="col-md-12">
160
                <div class="float-left">
161
                    <?php if ($properties['rating']) {
162
                        /**echo \App::$View->render('content/_rate', [
163
                            'id' => $model->id,
164
                            'rating' => $model->rating,
165
                            'canRate' => $model->canRate
166
                        ]);*/
167
                    } ?>
168
                    <?php //\App::$View->render('content/_rateJs') ?>
169
                </div>
170
                <div class="float-right">
171
                    <?php if ($properties['tags']): ?>
172
                        <div id="content-tags">
173
                            <?php
174
                            if (Any::isArray($model->metaKeywords) && count($model->metaKeywords) > 0 && Str::length($model->metaKeywords[0]) > 0) {
175
                                echo '<i class="fa fa-tags"></i> ';
176
                                foreach ($model->metaKeywords as $tag) {
177
                                    $tag = trim($tag);
178
                                    echo Url::a(['content/tag', [urlencode($tag)]], $tag, ['class' => 'badge badge-secondary']) . "&nbsp;";
179
                                }
180
                            }
181
                            ?>
182
                        </div>
183
                    <?php endif; ?>
184
                </div>
185
            </div>
186
        </div>
187
        <?php if (!Str::likeEmpty($model->source)): ?>
188
            <div id="content-source" style="padding-top: 5px;">
189
                <?php
190
                $sourceUrl = $model->source;
191
                $parseUrl = parse_url($sourceUrl);
192
                $sourceHost = $parseUrl['host'];
193
                ?>
194
                <i class="fa fa-link"></i> <?= __('Source') ?>: <a href="<?= $sourceUrl ?>" rel="nofollow" target="_blank">
195
                    <?= $sourceHost ?>
196
                </a>
197
            </div>
198
        <?php endif; ?>
199
    </article>
200
<?php if ($showComments === true): ?>
201
    <div class="row">
202
        <div class="col-md-12">
203
            <div class="h3 text-success"><?= __('Comments') ?></div>
204
            <hr />
205
            <?= \Widgets\Front\Comments\Comments::widget(['name' => 'content', 'id' => $model->id, 'config' => 'small']); ?>
206
        </div>
207
    </div>
208
<?php endif; ?>
209
<?php $this->stop() ?>
210
211
<?php $this->push('javascript') ?>
212
213
<?= \Widgets\Tinymce\Tinymce::widget(['config' => 'small']); ?>
214
<script src="<?= \App::$Alias->scriptUrl ?>/vendor/phpffcms/ffcms-assets/node_modules/@fancyapps/fancybox/dist/jquery.fancybox.min.js"></script>
215
216
<?php $this->stop() ?>
217