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\ActiveForm; |
13
|
|
|
|
14
|
|
|
/* @var $this yii\web\View */ |
15
|
|
|
/* @var $post common\models\Post */ |
16
|
|
|
/* @var $comment common\models\PostComment */ |
17
|
|
|
/* @var $category common\models\Term */ |
18
|
|
|
|
19
|
|
|
$this->title = Html::encode($post->title . ' - ' . Option::get('sitetitle')); |
20
|
|
|
$this->params['breadcrumbs'][] = [ |
21
|
|
|
'label' => Html::encode($post->postType->singular_name), |
22
|
|
|
'url' => ['/post/index', 'id' => $post->postType->id], |
23
|
|
|
]; |
24
|
|
|
$category = $post->getTerms() |
25
|
|
|
->innerJoinWith([ |
26
|
|
|
'taxonomy' => function ($query) { |
27
|
|
|
/* @var $query \yii\db\ActiveQuery */ |
28
|
|
|
$query->from(['taxonomy' => Taxonomy::tableName()]); |
29
|
|
|
}, |
30
|
|
|
]) |
31
|
|
|
->andWhere(['taxonomy.name' => 'category']) |
32
|
|
|
->one(); |
33
|
|
|
|
34
|
|
View Code Duplication |
if ($category) { |
|
|
|
|
35
|
|
|
$this->params['breadcrumbs'][] = ['label' => Html::encode($category->name), 'url' => $category->url]; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
$this->params['breadcrumbs'][] = Html::encode($post->title); |
39
|
|
|
?> |
40
|
|
|
|
41
|
|
|
<div class="single post-protected"> |
42
|
|
|
<article class="hentry"> |
43
|
|
|
<header class="entry-header page-header"> |
44
|
|
|
<h1 class="entry-title"><?= Html::encode($post->title) ?></h1> |
45
|
|
|
|
46
|
|
|
</header> |
47
|
|
|
<div class="entry-content"> |
48
|
|
|
<?php $form = ActiveForm::begin() ?> |
49
|
|
|
|
50
|
|
|
<p> |
51
|
|
|
<?= Yii::t( |
52
|
|
|
'writesdown', |
53
|
|
|
'{title} is protected, please submit the right password to view the {type}.', |
54
|
|
|
[ |
55
|
|
|
'title' => Html::encode($post->title), |
56
|
|
|
'type' => Html::encode($post->postType->singular_name), |
57
|
|
|
] |
58
|
|
|
) ?> |
59
|
|
|
|
60
|
|
|
</p> |
61
|
|
|
<div class="form-group field-post-password required"> |
62
|
|
|
<?= Html::label( |
63
|
|
|
Yii::t('writesdown', 'Password'), |
64
|
|
|
'post-password', |
65
|
|
|
['class' => 'control-label'] |
66
|
|
|
) ?> |
67
|
|
|
|
68
|
|
|
<?= Html::passwordInput('password', null, [ |
69
|
|
|
'class' => 'form-control', |
70
|
|
|
'id' => 'post-password', |
71
|
|
|
]) ?> |
72
|
|
|
|
73
|
|
|
</div> |
74
|
|
|
|
75
|
|
|
<div class="form-group"> |
76
|
|
|
<?= Html::submitButton( |
77
|
|
|
Yii::t('writesdown', 'Submit Password'), |
78
|
|
|
['class' => 'btn btn-flat btn-primary'] |
79
|
|
|
) ?> |
80
|
|
|
|
81
|
|
|
</div> |
82
|
|
|
|
83
|
|
|
<?php ActiveForm::end() ?> |
84
|
|
|
</div> |
85
|
|
|
</article> |
86
|
|
|
</div> |
87
|
|
|
|
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.