/** * List of items for backend side menu * * @return array */ public static function getSideMenuItems() { $output = ['17' => ['label' => '<i class="fa fa-pagelines"></i> ' . ContentModule::t('app', 'Page templates'), 'url' => ['/content/content-template/index'], 'visible' => Yii::$app->getModule('content')->enableTemplates && User::canRoute(['/content/content-template/index'])], '18' => ['label' => '<i class="fa fa-code-fork"></i> ' . ContentModule::t('app', 'Template widgets'), 'url' => ['/content/content-template-widget/index'], 'visible' => Yii::$app->getModule('content')->enableTemplates && User::canRoute(['/content/content-template-widget/index'])], '19' => ['label' => '<i class="fa fa-table"></i> ' . ContentModule::t('app', 'Manage menus'), 'url' => ['/content/content-menu/index']]]; $menus = ContentMenu::getListOfMenus(); krsort($menus); foreach ($menus as $menu) { array_unshift($output, $menu); } return $output; }
/** * @inheritdoc */ public function actionCreate($type = null, $menuId = null) { if (!in_array($type, [ContentPage::TYPE_TEXT, ContentPage::TYPE_INTERNAL_LINK, ContentPage::TYPE_EXTERNAL_LINK])) { throw new NotSupportedException('Type = ' . $type . ' is not supported'); } $menuName = ContentMenu::withoutMenuName(); $hasMenuImage = false; if ($menuId) { $contentMenu = ContentMenu::find()->andWhere(['id' => $menuId, 'active' => 1])->one(); if (!$contentMenu) { throw new NotFoundHttpException(ContentModule::t('app', 'Menu not found')); } $menuName = $contentMenu->name; $hasMenuImage = $contentMenu->has_menu_image === 1; } $model = new ContentPage(['type' => $type, 'content_menu_id' => $menuId]); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['tree', 'menuId' => $model->content_menu_id]); } return $this->renderIsAjax('create', compact('model', 'menuName', 'hasMenuImage')); }
/** * Displays a single model * * @param integer $id * * @return mixed */ public function actionView($id) { $model = $this->findModel($id); if (isset($_POST['form-submitted'])) { ContentTemplateHasWidget::deleteAll(['content_template_id' => $id]); if (isset($_POST['sorted-widgets'])) { foreach ($_POST['sorted-widgets'] as $position => $widgets) { $sorter = 0; foreach ($widgets as $widgetId) { $layoutWidget = new ContentTemplateHasWidget(); $layoutWidget->content_template_id = $id; $layoutWidget->content_template_widget_id = $widgetId; $layoutWidget->position = $position; $layoutWidget->sorter = $sorter; $layoutWidget->save(false); $sorter++; } } } Yii::$app->session->setFlash('success', ContentModule::t('app', 'Saved')); return $this->refresh(); } return $this->renderIsAjax('view', compact('model')); }
<div id="<?php echo $uuid; ?> "> <?php echo $this->render('_widgetElement', compact('widget', 'position')); ?> </div> </div> <div class="col-sm-3 text-right"> <span class="btn btn-sm btn-info select-widget-btn" data-widget-uuid="<?php echo $uuid; ?> " data-widget-position="<?php echo $position; ?> "> <?php echo ContentModule::t('app', 'Add widget'); ?> </span> </div> </div> </div> <?php } ?> </div>
<div class="form-group"> <div class="col-sm-offset-3 col-sm-9"> <?php if ($model->isNewRecord) { ?> <?php echo Html::submitButton('<span class="glyphicon glyphicon-plus-sign"></span> ' . ContentModule::t('app', 'Create'), ['class' => 'btn btn-success']); ?> <?php } else { ?> <?php echo Html::submitButton('<span class="glyphicon glyphicon-ok"></span> ' . ContentModule::t('app', 'Save'), ['class' => 'btn btn-primary']); ?> <?php } ?> <?php echo Html::a(ContentModule::t('app', 'Cancel'), ['index'], ['class' => 'btn btn-default']); ?> </div> </div> <?php ActiveForm::end(); ?> </div> <?php BootstrapSwitch::widget();
<?php /** * @var yii\web\View $this * @var webvimark\ybc\content\models\ContentMenu $model */ use webvimark\ybc\content\ContentModule; $this->title = ContentModule::t('app', 'Creating') . " " . ContentModule::t('app', 'menu'); $this->params['breadcrumbs'][] = ['label' => ContentModule::t('app', 'Manage menus'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="content-menu-create"> <div class="panel panel-default"> <div class="panel-body"> <?php echo $this->render('_form', compact('model')); ?> </div> </div> </div>
use webvimark\ybc\content\models\ContentMenu; use webvimark\ybc\content\models\ContentPage; use webvimark\ybc\content\models\ContentTemplate; use yii\helpers\Html; use yii\helpers\Url; use yii\helpers\ArrayHelper; use yii\widgets\Pjax; use webvimark\extensions\GridBulkActions\GridBulkActions; use webvimark\extensions\GridPageSize\GridPageSize; use yii\grid\GridView; /** * @var yii\web\View $this * @var yii\data\ActiveDataProvider $dataProvider * @var webvimark\ybc\content\models\search\ContentPageSearch $searchModel */ $this->title = ContentModule::t('app', 'Pages'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="content-page-index"> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <div class="panel panel-default"> <div class="panel-body"> <div class="row"> <div class="col-xs-6"> <p> <?php
/** * @inheritdoc */ public function attributeLabels() { return ['id' => 'ID', 'active' => ContentModule::t('app', 'Active'), 'single_per_page' => ContentModule::t('app', 'Single per page'), 'name' => ContentModule::t('app', 'Name'), 'code' => ContentModule::t('app', 'Code'), 'position' => ContentModule::t('app', 'Position'), 'positionIds' => ContentModule::t('app', 'Position'), 'widget_class' => ContentModule::t('app', 'Widget class'), 'widget_options' => ContentModule::t('app', 'Widget options'), 'has_settings' => ContentModule::t('app', 'Has settings'), 'link_to_settings' => ContentModule::t('app', 'Link to settings'), 'created_at' => ContentModule::t('app', 'Created'), 'updated_at' => ContentModule::t('app', 'Updated')]; }
<?php echo JQTreeWidget::widget(['models' => $pages, 'modelName' => 'webvimark\\ybc\\content\\models\\ContentPage', 'parentIdField' => 'parent_id', 'statusField' => 'active', 'orderField' => 'sorter', 'showExpandAndCollapse' => false, 'withChildren' => $hasSubmenu === 1, 'leafName' => function (ContentPage $model) { $pageName = $model->is_main == 1 ? '<span style="color:green; font-style: italic;">' . $model->name . '</span>' : $model->name; if ($model->type == ContentPage::TYPE_TEXT) { $pageType = ' <span class="page-tree-type">' . ContentModule::t('app', 'Text page') . '</span>'; if ($model->is_main == 1) { $viewUrl = Yii::$app->homeUrl; } else { $viewUrl = ['/content/default/view', 'slug' => $model->slug]; } } elseif ($model->type == ContentPage::TYPE_INTERNAL_LINK) { $pageType = ' <span class="page-tree-type">' . ContentModule::t('app', 'Internal link') . '</span>'; if (is_numeric($model->slug)) { $page = ContentPage::find()->andWhere(['id' => $model->slug])->one(); $viewUrl = $page ? ['/content/default/view', 'slug' => $page->slug] : Yii::$app->homeUrl; } else { $viewUrl = Yii::$app->homeUrl . $model->slug; } } else { $pageType = ' <span class="page-tree-type">' . ContentModule::t('app', 'External link') . '</span>'; $viewUrl = $model->slug; } $editLink = Html::a($pageName . $pageType, ['/content/content-page/update', 'id' => $model->id]); $viewLink = Html::a('<i class="fa fa-eye"></i>', $viewUrl, ['target' => '_blank']); return $editLink . ' ' . $viewLink; }]); ?> </div> </div>
?> </div> </div> <?php echo Html::endForm(); ?> <?php Modal::begin(['options' => ['class' => 'fire'], 'header' => ContentModule::t('app', 'Available widgets'), 'id' => 'add-widget-modal']); Modal::end(); $availableWidgetUrl = Url::to(['available-widgets', 'id' => $model->id]); $existingWidgetUrl = Url::to(['existing-widgets', 'id' => $model->id]); $addWidgetText = ContentModule::t('app', 'Add widget'); $js = <<<JS var elementsWithWidgets = \$('[data-position]'); elementsWithWidgets.each(function(){ \tvar _t = \$(this); \t\$.get('{$existingWidgetUrl}', { position: _t.data('position') }) \t\t.success(function(data){ \t\t\t_t.append(data); \t\t\telementsWithWidgets.sortable(); \t\t}); });
$this->params['breadcrumbs'][] = $this->title; ?> <div class="content-menu-index"> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <div class="panel panel-default"> <div class="panel-body"> <div class="row"> <div class="col-xs-6"> <p> <?php echo Html::a('<span class="glyphicon glyphicon-plus-sign"></span> ' . ContentModule::t('app', 'Create'), ['create'], ['class' => 'btn btn-success']); ?> </p> </div> <div class="col-xs-6 text-right"> <?php echo GridPageSize::widget(['pjaxId' => 'content-menu-grid-pjax']); ?> </div> </div> <?php Pjax::begin(['id' => 'content-menu-grid-pjax']); ?>
use yii\widgets\DetailView; /** * @var yii\web\View $this * @var webvimark\ybc\content\models\ContentPage $model */ switch ($model->type) { case ContentPage::TYPE_INTERNAL_LINK: $pageTypeText = ContentModule::t('app', 'internal link'); break; case ContentPage::TYPE_EXTERNAL_LINK: $pageTypeText = ContentModule::t('app', 'external link'); break; default: $pageTypeText = ContentModule::t('app', 'text page'); } $this->title = ContentModule::t('app', 'Details of the') . " " . $pageTypeText . ': ' . $model->name; $this->params['breadcrumbs'][] = ['label' => $model->contentMenu->name, 'url' => ['tree', 'menuId' => $model->content_menu_id]]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="content-page-view"> <div class="panel panel-default"> <div class="panel-body"> <p> <?php echo Html::a(Yii::t('app', 'Edit'), ['update', 'id' => $model->id], ['class' => 'btn btn-sm btn-primary']); ?> <?php echo Html::a(Yii::t('app', 'Create'), ['create'], ['class' => 'btn btn-sm btn-success']);
?> </div> </div> <?php Pjax::begin(['id' => 'content-template-grid-pjax']); ?> <?php echo GridView::widget(['id' => 'content-template-grid', 'dataProvider' => $dataProvider, 'pager' => ['options' => ['class' => 'pagination pagination-sm'], 'hideOnSinglePage' => true, 'lastPageLabel' => '>>', 'firstPageLabel' => '<<'], 'layout' => '{items}<div class="row"><div class="col-sm-8">{pager}</div><div class="col-sm-4 text-right">{summary}' . GridBulkActions::widget(['gridId' => 'content-template-grid']) . '</div></div>', 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'options' => ['style' => 'width:10px']], ['attribute' => 'name', 'value' => function ($model) { return Html::a($model->name, ['view', 'id' => $model->id], ['data-pjax' => 0]); }, 'format' => 'raw'], ['attribute' => 'layout', 'value' => function (ContentTemplate $model) { return Html::a(Html::img($model->getLayoutImageFromAssets(), ['style' => 'max-height:200px; max-width:300px !important']), ['view', 'id' => $model->id], ['data-pjax' => 0]); }, 'options' => ['style' => 'text-align:center'], 'format' => 'raw'], ['value' => function ($model) { return Html::tag('span', ContentModule::t('app', 'Copy') . ' <i class="fa fa-copy"></i>', ['class' => 'btn btn-default btn-sm clone-btn', 'data-clone-id' => $model->id]); }, 'options' => ['width' => '10px'], 'format' => 'raw'], ['class' => 'webvimark\\components\\StatusColumn', 'attribute' => 'can_be_deleted', 'toggleUrl' => Url::to(['toggle-attribute', 'attribute' => 'can_be_deleted', 'id' => '_id_']), 'visible' => Yii::$app->user->isSuperadmin], ['class' => 'webvimark\\components\\StatusColumn', 'attribute' => 'active', 'toggleUrl' => Url::to(['toggle-attribute', 'attribute' => 'active', 'id' => '_id_'])], ['class' => 'yii\\grid\\CheckboxColumn', 'options' => ['style' => 'width:10px']], ['class' => 'yii\\grid\\ActionColumn', 'buttons' => ['delete' => function ($url, ContentTemplate $model) { if ($model->can_be_deleted != 1) { return ''; } else { return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0']); } }], 'contentOptions' => ['style' => 'width:70px; text-align:center;']]]]); ?> <?php Pjax::end(); ?> </div> </div> </div>
<?php /** * @var yii\web\View $this * @var webvimark\ybc\content\models\ContentTemplateWidget $model */ use webvimark\ybc\content\ContentModule; $this->title = Yii::t('app', 'Creating') . " " . ContentModule::t('app', 'template widget'); $this->params['breadcrumbs'][] = ['label' => ContentModule::t('app', 'Template widgets'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="content-template-widget-create"> <div class="panel panel-default"> <div class="panel-body"> <?php echo $this->render('_form', compact('model')); ?> </div> </div> </div>
/** * @inheritdoc */ public function attributeLabels() { return ['id' => 'ID', 'active' => ContentModule::t('app', 'Active'), 'can_be_deleted' => ContentModule::t('app', 'Can be deleted'), 'name' => ContentModule::t('app', 'Name'), 'layout' => ContentModule::t('app', 'Layout'), 'created_at' => ContentModule::t('app', 'Created'), 'updated_at' => ContentModule::t('app', 'Updated')]; }
*/ $this->title = Yii::t('app', 'Details of the') . " " . ContentModule::t('app', 'template widget') . ': ' . $model->name; $this->params['breadcrumbs'][] = ['label' => ContentModule::t('app', 'Template widgets'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="content-template-widget-view"> <div class="panel panel-default"> <div class="panel-body"> <p> <?php echo Html::a(ContentModule::t('app', 'Edit'), ['update', 'id' => $model->id], ['class' => 'btn btn-sm btn-primary']); ?> <?php echo Html::a(ContentModule::t('app', 'Create'), ['create'], ['class' => 'btn btn-sm btn-success']); ?> <?php echo Html::a(Yii::t('yii', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-sm btn-danger pull-right', 'data' => ['confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'active', 'value' => $model->active == 1 ? '<span class="label label-success">' . Yii::t('yii', 'Yes') . '</span>' : '<span class="label label-warning">' . Yii::t('yii', 'No') . '</span>', 'format' => 'raw'], 'name', ['attribute' => 'position', 'value' => $model->showNicePositions(), 'format' => 'raw'], ['attribute' => 'single_per_page', 'value' => $model->single_per_page == 1 ? '<span class="label label-success">' . Yii::t('yii', 'Yes') . '</span>' : '<span class="label label-warning">' . Yii::t('yii', 'No') . '</span>', 'format' => 'raw'], 'widget_class', ['attribute' => 'widget_options', 'format' => 'raw', 'value' => '<pre>' . var_export(@unserialize($model->widget_options), true) . '</pre>'], ['attribute' => 'has_settings', 'value' => $model->has_settings == 1 ? '<span class="label label-success">' . Yii::t('yii', 'Yes') . '</span>' : '<span class="label label-warning">' . Yii::t('yii', 'No') . '</span>', 'format' => 'raw'], 'link_to_settings', 'created_at:datetime', 'updated_at:datetime']]); ?> </div> </div> </div>
<?php echo $form->field($model->loadDefaultValues(), 'is_main', ['template' => '<div class="row"><div class="col-sm-6 text-right" style="margin-top: 5px">{label}</div><div class="col-sm-6">{input}{error}{hint}</div></div>'])->checkbox(['class' => 'b-switch'], false); ?> <!-- --><?php //endif; ?> <?php } else { ?> <div class="alert alert-info text-center"> <?php echo ContentModule::t('app', 'Main page'); ?> </div> <?php } ?> <?php echo $form->field($model->loadDefaultValues(), 'open_in_new_tab', ['template' => '<div class="row"><div class="col-sm-6 text-right" style="margin-top: 5px">{label}</div><div class="col-sm-6">{input}{error}{hint}</div></div>'])->checkbox(['class' => 'b-switch'], false); ?> </div> <div class="col-sm-6">
/** * @inheritdoc */ public function attributeLabels() { return ['id' => 'ID', 'active' => ContentModule::t('app', 'Active'), 'sorter' => ContentModule::t('app', 'Sorter'), 'is_main' => ContentModule::t('app', 'Main page'), 'open_in_new_tab' => ContentModule::t('app', 'Open in new tab'), 'type' => ContentModule::t('app', 'Type'), 'name' => ContentModule::t('app', 'Name'), 'slug' => ContentModule::t('app', 'Slug'), 'menu_image' => ContentModule::t('app', 'Menu image'), 'meta_title' => 'Title', 'meta_keywords' => 'Keywords', 'meta_description' => 'Description', 'body' => ContentModule::t('app', 'Text'), 'parent_id' => 'Parent', 'content_template_id' => ContentModule::t('app', 'Template'), 'content_menu_id' => ContentModule::t('app', 'Menu'), 'created_at' => ContentModule::t('app', 'Created'), 'updated_at' => ContentModule::t('app', 'Updated')]; }
<?php /** * @var yii\web\View $this * @var webvimark\ybc\content\models\ContentTemplateWidget $model */ use webvimark\ybc\content\ContentModule; $this->title = ContentModule::t('app', 'Editing') . " " . ContentModule::t('app', 'template widget') . ': ' . $model->name; $this->params['breadcrumbs'][] = ['label' => ContentModule::t('app', 'Template widgets'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = ContentModule::t('app', 'Editing'); ?> <div class="content-template-widget-update"> <div class="panel panel-default"> <div class="panel-body"> <?php echo $this->render('_form', compact('model')); ?> </div> </div> </div>
<?php use webvimark\modules\UserManagement\UserManagementModule; use webvimark\ybc\content\ContentModule; //You can user float numbers as array keys for menu elements //Like '27.5'=> ['some element'] return ['0' => ['label' => '<i class="fa fa-dashboard"></i> Dashboard', 'url' => ['/dashboard/index']], '10' => ['label' => '<i class="fa fa-book"></i> ' . Yii::t('app', 'Content') . ' <i class="fa pull-right fa-angle-left"></i>', 'options' => ['class' => 'treeview'], 'url' => '#', 'items' => ContentModule::getSideMenuItems()], '20' => ['label' => '<i class="fa fa-users"></i> ' . Yii::t('app', "Users") . ' <i class="fa pull-right fa-angle-left"></i>', 'options' => ['class' => 'treeview'], 'url' => '#', 'items' => UserManagementModule::menuItems()], '30' => ['label' => '<i class="fa fa-cogs"></i> ' . Yii::t('app', "Settings") . ' <i class="fa pull-right fa-angle-left"></i>', 'options' => ['class' => 'treeview'], 'url' => '#', 'items' => ['31' => ['label' => '<i class="fa fa-pagelines"></i> ' . Yii::t('app', 'General'), 'url' => ['/settings/manage/index']], '32' => ['label' => '<i class="fa fa-line-chart"></i> SEO', 'url' => ['/settings/manage/seo']]]], '40' => ['label' => '<i class="fa fa-code"></i> Modules <i class="fa pull-right fa-angle-left"></i>', 'options' => ['class' => 'treeview'], 'url' => '#', 'items' => []], '999999' => ['label' => '<i class="fa fa-wrench"></i> ' . Yii::t('app', 'Dev junk') . ' <i class="fa pull-right fa-angle-left"></i>', 'options' => ['class' => 'treeview'], 'url' => '#', 'items' => [['label' => '<i class="fa fa-random"></i> Migrations', 'url' => ['/migrations/default/index']], ['label' => '<i class="fa fa-gears"></i> Gii', 'url' => ['/gii/default/index'], 'visible' => YII_ENV_DEV && Yii::$app->user->isSuperadmin]]]];
<?php echo $form->field($model, 'has_menu_image'); ?> <?php echo $form->field($model, 'name'); ?> <?php // echo $form->field($model, 'created_at') ?> <?php // echo $form->field($model, 'updated_at') ?> <div class="form-group"> <?php echo Html::submitButton(ContentModule::t('app', 'Search'), ['class' => 'btn btn-primary']); ?> <?php echo Html::resetButton(ContentModule::t('app', 'Reset'), ['class' => 'btn btn-default']); ?> </div> <?php ActiveForm::end(); ?> </div>
use webvimark\ybc\content\ContentModule; use webvimark\ybc\content\models\ContentTemplateWidget; use yii\helpers\Html; use yii\helpers\Url; use yii\helpers\ArrayHelper; use yii\widgets\Pjax; use webvimark\extensions\GridBulkActions\GridBulkActions; use webvimark\extensions\GridPageSize\GridPageSize; use yii\grid\GridView; /** * @var yii\web\View $this * @var yii\data\ActiveDataProvider $dataProvider * @var webvimark\ybc\content\models\search\ContentTemplateWidgetSearch $searchModel */ $this->title = ContentModule::t('app', 'Template widgets'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="content-template-widget-index"> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <div class="panel panel-default"> <div class="panel-body"> <div class="row"> <div class="col-xs-6"> <p> <?php
* @var string $menuName * @var webvimark\ybc\content\models\ContentPage $model */ use webvimark\ybc\content\ContentModule; use webvimark\ybc\content\models\ContentPage; switch ($model->type) { case ContentPage::TYPE_INTERNAL_LINK: $pageTypeText = ContentModule::t('app', 'internal link for'); break; case ContentPage::TYPE_EXTERNAL_LINK: $pageTypeText = ContentModule::t('app', 'external link for'); break; default: $pageTypeText = ContentModule::t('app', 'text page for'); } $this->title = ContentModule::t('app', 'Creating') . " " . $pageTypeText . ' - ' . $menuName; $this->params['breadcrumbs'][] = ['label' => $menuName, 'url' => ['tree', 'menuId' => $model->content_menu_id]]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="content-page-create"> <div class="panel panel-default"> <div class="panel-body"> <?php echo $this->render('_form', compact('model', 'menuName', 'hasMenuImage')); ?> </div> </div> </div>
/** * @inheritdoc */ public function attributeLabels() { return ['id' => 'ID', 'active' => ContentModule::t('app', 'Active'), 'has_submenu' => ContentModule::t('app', 'Has submenu'), 'has_menu_image' => ContentModule::t('app', 'Has menu image'), 'positionIds' => ContentModule::t('app', 'Position'), 'name' => ContentModule::t('app', 'Name'), 'code' => ContentModule::t('app', 'Code'), 'sorter' => ContentModule::t('app', 'Sorter'), 'created_at' => ContentModule::t('app', 'Created'), 'updated_at' => ContentModule::t('app', 'Updated')]; }