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.
 
 
 
 
 

170 lines
6.2 KiB

<?php
/**
* Created by Error202
* Date: 10.07.2018
*/
use kartik\form\ActiveForm;
use yii\helpers\Html;
/**
* @var $this \yii\web\View
* @var $model \core\forms\menu\MenuSelectForm
* @var $menus \core\entities\menu\Menu[]
* @var $menu \core\entities\menu\Menu
* @var $creator array
*/
$this->title = Yii::t('menu', 'Menu');
$this->params['breadcrumbs'][] = Html::encode(isset($menu->translation) ? $menu->translation->name : Yii::t('menu', 'Not set'));
$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);
?>
<div class="menu">
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('menu', 'Current Menu') ?></div>
<div class="box-body">
<div class="row">
<div class="col-md-6">
<?php $form = ActiveForm::begin([
'enableClientValidation' => false,
'method' => 'get',
'id' => 'select_menu',
]); ?>
<?= $form->field($model, 'id')->dropDownList($menus, [
//'prompt' => Yii::t('menu', 'Select menu...'),
'value' => $menu->id,
'onchange' => 'this.form.submit()',
])->label(false) ?>
<?php ActiveForm::end(); ?>
</div>
<div class="col-md-6">
<?= Html::a(Yii::t('menu', 'Create Menu'), ['menu/create'], [
'class' => 'btn btn-success',
]) ?>
<?= Html::a(Yii::t('menu', 'Update Menu'), ['menu/update', 'id' => $menu->id], [
'class' => 'btn btn-primary',
]) ?>
<?= Html::a(Yii::t('menu', 'Delete Menu'), ['menu/delete', 'id' => $menu->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('menu', 'Available Blocks') ?></div>
<div class="box-body">
<div class="panel-group" id="accordion">
<?php foreach ($creator as $item) : ?>
<div class="panel panel-default">
<div class="panel-heading" style="padding-left: 0">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion"
href="#collapse<?= $item['id'] ?>"><?= $item['title'] ?>
<i class="fa fa-angle-down pull-right" aria-hidden="true"></i></a>
</h4>
</div>
<div id="collapse<?= $item['id'] ?>" class="panel-collapse collapse">
<div class="panel-body">
<?= $item['content'] ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('menu', 'Menu Items') ?></div>
<div class="box-body">
<?= \backend\components\menu\widgets\MenuEditorWidget::widget([
'menu_id' => $menu->id
]) ?>
</div>
</div>
</div>
<div class="col-md-3">
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('menu', 'Insert Code') ?></div>
<div class="box-body">
<?php
$code = "<?= \core\widgets\menu\MenuWidget::widget(['menu_id' => " . $menu->id . ']) ?>';
?>
<p><?= Yii::t('menu', '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>
<?php
$code = "[?= \core\widgets\menu\MenuWidget::widget(['menu_id' => " . $menu->id . ']) ?]';
?>
<p><?= Yii::t('menu', '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>
</div>
</div>
</div>
</div>