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 frontend\assets\CommentAsset; |
11
|
|
|
use yii\helpers\Html; |
12
|
|
|
|
13
|
|
|
/* @var $this yii\web\View */ |
14
|
|
|
/* @var $media common\models\Media */ |
15
|
|
|
/* @var $metadata [] */ |
16
|
|
|
/* @var $comment common\models\MediaComment */ |
17
|
|
|
|
18
|
|
|
$this->title = Html::encode($media->title . ' - ' . Option::get('sitetitle')); |
19
|
|
|
|
20
|
|
View Code Duplication |
if ($media->mediaPost) { |
|
|
|
|
21
|
|
|
$this->params['breadcrumbs'][] = [ |
22
|
|
|
'label' => Html::encode($media->mediaPost->title), |
23
|
|
|
'url' => $media->mediaPost->url, |
24
|
|
|
]; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
$this->params['breadcrumbs'][] = Html::encode($media->title); |
28
|
|
|
CommentAsset::register($this); |
29
|
|
|
?> |
30
|
|
|
<div class="single media-view"> |
31
|
|
|
<article class="hentry"> |
32
|
|
|
<header class="entry-header page-header"> |
33
|
|
|
<h1 class="entry-title"><?= Html::encode($media->title) ?></h1> |
34
|
|
|
|
35
|
|
|
<?php $updated = new \DateTime($media->modified, new DateTimeZone(Yii::$app->timeZone)) ?> |
36
|
|
|
<div class="entry-meta"> |
37
|
|
|
<span class="entry-date"> |
38
|
|
|
<span aria-hidden="true" class="glyphicon glyphicon-time"></span> |
39
|
|
|
<a rel="bookmark" href="<?= $media->url ?>"> |
40
|
|
|
<time datetime="<?= $updated->format('c') ?>" class="entry-date"> |
41
|
|
|
<?= Yii::$app->formatter->asDate($media->date) ?> |
42
|
|
|
</time> |
43
|
|
|
</a> |
44
|
|
|
</span> |
45
|
|
|
<span class="byline"> |
46
|
|
|
<span class="author vcard"> |
47
|
|
|
<span aria-hidden="true" class="glyphicon glyphicon-user"></span> |
48
|
|
|
<a rel="author" href="<?= $media->mediaAuthor->url ?>" class="url fn"> |
49
|
|
|
<?= $media->mediaAuthor->display_name ?> |
50
|
|
|
</a> |
51
|
|
|
</span> |
52
|
|
|
</span> |
53
|
|
|
<span class="comments-link"> |
54
|
|
|
<span aria-hidden="true" class="glyphicon glyphicon-comment"></span> |
55
|
|
|
<a title="<?= Yii::t( |
56
|
|
|
'writesdown', 'Comment on {mediaTitle}', |
57
|
|
|
['mediaTitle' => $media->title] |
58
|
|
|
) ?>" href="<?= $media->url ?>#respond"><?= Yii::t('writesdown', 'Leave a comment') ?></a> |
59
|
|
|
</span> |
60
|
|
|
</div> |
61
|
|
|
</header> |
62
|
|
|
|
63
|
|
|
<div class="entry-content"> |
64
|
|
|
<?= $media->content ?> |
65
|
|
|
|
66
|
|
|
<?= Html::a($media->title, $media->uploadUrl . $metadata['versions']['full']['url']) ?> |
67
|
|
|
|
68
|
|
|
<?= $media->mediaPost |
69
|
|
|
? Html::tag('h3', Html::a('<span aria-hidden="true" class="glyphicon glyphicon-menu-left"></span>' |
70
|
|
|
. Yii::t('writesdown', 'Back to ') |
71
|
|
|
. $media->mediaPost->title, $media->mediaPost->url)) |
72
|
|
|
: '' ?> |
73
|
|
|
|
74
|
|
|
</div> |
75
|
|
|
</article> |
76
|
|
|
<?= $this->render('/media-comment/comments', ['media' => $media, 'comment' => $comment]) ?> |
77
|
|
|
</div> |
78
|
|
|
|
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.