1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link http://www.writesdown.com/ |
4
|
|
|
* @author Agiel K. Saputra <[email protected]> |
5
|
|
|
* @copyright Copyright (c) 2015 WritesDown |
6
|
|
|
* @license http://www.writesdown.com/license/ |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
use common\models\Option; |
10
|
|
|
use common\models\Taxonomy; |
11
|
|
|
use yii\helpers\Html; |
12
|
|
|
use yii\widgets\LinkPager; |
13
|
|
|
|
14
|
|
|
/* @var $this yii\web\View */ |
15
|
|
|
/* @var $term common\models\Term */ |
16
|
|
|
/* @var $posts common\models\Post[] */ |
17
|
|
|
/* @var $tags common\models\Term[] */ |
18
|
|
|
/* @var $pages yii\data\Pagination */ |
19
|
|
|
|
20
|
|
|
$this->title = Html::encode($term->taxonomy->singular_name . ': ' . $term->name . ' - ' . Option::get('sitetitle')); |
21
|
|
|
$this->params['breadcrumbs'][] = Html::encode($term->name); |
22
|
|
|
?> |
23
|
|
|
<div class="archive term-view"> |
24
|
|
|
<header id="archive-header" class="archive-header page-header"> |
25
|
|
|
<h1><?= Html::encode($term->taxonomy->singular_name . ': ' . $term->name) ?></h1> |
26
|
|
|
|
27
|
|
|
<?php if ($term->description): ?> |
28
|
|
|
<div class="description term-description"><?= $term->description ?></div> |
29
|
|
|
<?php endif ?> |
30
|
|
|
</header> |
31
|
|
|
|
32
|
|
View Code Duplication |
<?php if ($posts): ?> |
|
|
|
|
33
|
|
|
<?php foreach ($posts as $post): ?> |
34
|
|
|
<article class="hentry"> |
35
|
|
|
<header class="entry-header page-header"> |
36
|
|
|
<h2 class="entry-title"><?= Html::a(Html::encode($post->title), $post->url) ?></h2> |
37
|
|
|
|
38
|
|
|
<?php $updated = new \DateTime($post->modified, new DateTimeZone(Yii::$app->timeZone)) ?> |
39
|
|
|
<div class="entry-meta"> |
40
|
|
|
<span class="entry-date"> |
41
|
|
|
<span aria-hidden="true" class="glyphicon glyphicon-time"></span> |
42
|
|
|
<a rel="bookmark" href="<?= $post->url ?>"> |
43
|
|
|
<time datetime="<?= $updated->format('c') ?>" class="entry-date"> |
44
|
|
|
<?= Yii::$app->formatter->asDate($post->date) ?> |
45
|
|
|
</time> |
46
|
|
|
</a> |
47
|
|
|
</span> |
48
|
|
|
<span class="byline"> |
49
|
|
|
<span class="author vcard"> |
50
|
|
|
<span aria-hidden="true" class="glyphicon glyphicon-user"></span> |
51
|
|
|
<a rel="author" href="<?= $post->postAuthor->url ?>" class="url fn"> |
52
|
|
|
<?= $post->postAuthor->display_name ?> |
53
|
|
|
</a> |
54
|
|
|
</span> |
55
|
|
|
</span> |
56
|
|
|
<span class="comments-link"> |
57
|
|
|
<span aria-hidden="true" class="glyphicon glyphicon-comment"></span> |
58
|
|
|
<a title="<?= Yii::t( |
59
|
|
|
'writesdown', 'Comment on {postTitle}', |
60
|
|
|
['postTitle' => $post->title] |
61
|
|
|
) ?>" href="<?= $post->url ?>#respond"><?= Yii::t('writesdown', 'Leave a comment') ?></a> |
62
|
|
|
</span> |
63
|
|
|
</div> |
64
|
|
|
</header> |
65
|
|
|
<div class="entry-summary"> |
66
|
|
|
<?= $post->excerpt ?>... |
67
|
|
|
</div> |
68
|
|
|
<footer class="footer-meta"> |
69
|
|
|
<?php $tags = $post->getTerms() |
70
|
|
|
->innerJoinWith([ |
71
|
|
|
'taxonomy' => function ($query) { |
72
|
|
|
/** @var $query \yii\db\ActiveQuery */ |
73
|
|
|
return $query->from(['taxonomy' => Taxonomy::tableName()]); |
74
|
|
|
}, |
75
|
|
|
]) |
76
|
|
|
->where(['taxonomy.name' => 'tag']) |
77
|
|
|
->all() ?> |
78
|
|
|
|
79
|
|
|
<?php if ($tags): ?> |
80
|
|
|
<h3> |
81
|
|
|
<?php foreach ($tags as $tag): ?> |
82
|
|
|
<?= Html::a($tag->name, $tag->url, [ |
83
|
|
|
'class' => 'btn btn-xs btn-success', |
84
|
|
|
]) . "\n" ?> |
85
|
|
|
<?php endforeach ?> |
86
|
|
|
</h3> |
87
|
|
|
<?php endif; ?> |
88
|
|
|
|
89
|
|
|
</footer> |
90
|
|
|
</article> |
91
|
|
|
<?php endforeach ?> |
92
|
|
|
<nav id="archive-pagination"> |
93
|
|
|
<?= LinkPager::widget([ |
94
|
|
|
'pagination' => $pages, |
95
|
|
|
'activePageCssClass' => 'active', |
96
|
|
|
'disabledPageCssClass' => 'disabled', |
97
|
|
|
'options' => ['class' => 'pagination'], |
98
|
|
|
]) ?> |
99
|
|
|
</nav> |
100
|
|
|
<?php endif ?> |
101
|
|
|
|
102
|
|
|
</div> |
103
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.