Issues (36)

views/article/partial/nav.php (2 issues)

Severity
1
<?php
2
3
use carono\exchange1c\models\Article;
4
use carono\exchange1c\widgets\Panel;
5
use yii\helpers\Html;
6
7
/**
8
 * @var Article $article
9
 */
10
$query = Article::find()
11
    ->orderBy(['{{%article}}.[[pos]]' => SORT_ASC])
12
    ->andWhere(['parent_id' => $article->parent_id])
13
    ->andWhere(['<>', '[[id]]', $article->id])
14
    ->andWhere(['>=', '[[pos]]', $article->pos])
15
    ->orWhere(['parent_id' => $article->id]);
16
$next = $query->one();
17
18
$query = Article::find()
19
    ->orderBy(['{{%article}}.[[pos]]' => SORT_DESC])
20
    ->andWhere(['parent_id' => $article->parent_id])
21
    ->andWhere(['<>', '[[id]]', $article->id])
22
    ->andWhere(['<=', '[[pos]]', $article->pos])
23
    ->orWhere(['id' => $article->parent_id]);
24
$prev = $query->one();
25
26
27
Panel::begin();
28
if ($prev) {
0 ignored issues
show
$prev is of type carono\exchange1c\models\Article, thus it always evaluated to true.
Loading history...
29
    $options = ['class' => 'btn btn-primary'];
30
    echo Html::a('Читать ранее: ' . $prev->name, ['article/view', 'id' => $prev->id], $options);
31
}
32
if ($next) {
0 ignored issues
show
$next is of type carono\exchange1c\models\Article, thus it always evaluated to true.
Loading history...
33
    $options = ['class' => 'btn btn-primary pull-right'];
34
    echo Html::a('Читать далее: ' . $next->name, ['article/view', 'id' => $next->id], $options);
35
}
36
Panel::end();