You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
4.1 KiB

6 years ago
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use common\modules\banners\entities\BannerPlace;
use common\modules\banners\helpers\BannerHelper;
/* @var $this yii\web\View */
/* @var $place \common\modules\banners\entities\BannerPlace */
$this->title = $place->title;
6 years ago
$this->params['breadcrumbs'][] = ['label' => Yii::t('banners', 'Places'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$js2 = <<<JS2
$("#copyEditorCodeButton").on('click', function(){
CopyToClipboard($('#code_editor'));
});
$("#copyTemplateCodeButton").on('click', function(){
CopyToClipboard($('#code_template'));
});
JS2;
$this->registerJs($js2, $this::POS_READY);
$js = <<<JS
function CopyToClipboard(selector) {
var body = $("body");
selector.select();
document.execCommand("copy");
}
JS;
$this->registerJs($js, $this::POS_HEAD);
6 years ago
?>
<div class="place-view">
<p>
<?= Html::a(Yii::t('banners', 'Places'), ['index'], ['class' => 'btn btn-default']) ?>
6 years ago
<?= Html::a(Yii::t('buttons', 'Edit'), ['update', 'id' => $place->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'id' => $place->id], [
'class' => 'btn btn-danger',
'data' => [
6 years ago
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'),
'method' => 'post',
6 years ago
],
]) ?>
</p>
<div class="row">
<div class="col-md-9">
<div class="box">
<div class="box-body">
<?= DetailView::widget([
'model' => $place,
'attributes' => [
'id',
'title',
'width',
'height',
[
'attribute' => 'active',
'format' => 'raw',
'value' => function (BannerPlace $place) {
return BannerHelper::statusLabel($place->active);
}
],
],
]) ?>
</div>
</div>
</div>
6 years ago
<div class="col-md-3">
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('banners', 'Insert Code') ?></div>
<div class="box-body">
6 years ago
<?php
$code = "<?= \common\modules\\banners\widgets\BannerWidget::widget(['id' => " . $place->id . ']) ?>';
?>
<p><?= Yii::t('banners', 'For template') ?></p>
<div class="input-group">
<?= Html::input('text', 'code_template', $code, [
'class' => 'form-control',
'id' => 'code_template',
]) ?>
<span class="input-group-btn">
<button id="copyTemplateCodeButton" type="button" class="btn btn-primary btn-flat"><i class="fa fa-files-o" aria-hidden="true"></i></button>
</span>
</div>
6 years ago
<?php
$code = "[?= \common\modules\\banners\widgets\BannerWidget::widget(['id' => " . $place->id . ']) ?]';
?>
<p><?= Yii::t('banners', 'For editor') ?></p>
<div class="input-group">
<?= Html::input('text', 'code_editor', $code, [
'class' => 'form-control',
'id' => 'code_editor',
]) ?>
<span class="input-group-btn">
<button id="copyEditorCodeButton" type="button" class="btn btn-primary btn-flat"><i class="fa fa-files-o" aria-hidden="true"></i></button>
</span>
</div>
6 years ago
</div>
</div>
</div>
</div>
6 years ago
</div>