/** * @inheritdoc */ public function disable() { foreach (CustomPage::find()->all() as $entry) { $entry->delete(); } parent::disable(); }
public function actionDelete() { $page = CustomPage::findOne(['id' => Yii::$app->request->get('id')]); if ($page !== null) { $page->delete(); } return $this->redirect(['index']); }
public static function onAccountMenuInit($event) { foreach (CustomPage::findAll(['navigation_class' => CustomPage::NAV_CLASS_ACCOUNTNAV]) as $page) { // Admin only if ($page->admin_only == 1 && !Yii::$app->user->isAdmin()) { continue; } $event->sender->addItem(array('label' => $page->title, 'url' => Url::to(['/custom_pages/view', 'id' => $page->id]), 'target' => $page->type == CustomPage::TYPE_LINK ? '_blank' : '', 'icon' => '<i class="fa ' . $page->icon . '"></i>', 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'custom_pages' && Yii::$app->controller->id == 'view' && Yii::$app->request->get('id') == $page->id, 'sortOrder' => $page->sort_order != '' ? $page->sort_order : 1000)); } }
public function actionIndex() { $page = CustomPage::findOne(['id' => Yii::$app->request->get('id')]); if ($page === null) { throw new HttpException('404', 'Could not find requested page'); } if ($page->admin_only == 1 && !Yii::$app->user->isAdmin()) { throw new HttpException(403, 'Access denied!'); } if ($page->navigation_class == CustomPage::NAV_CLASS_ACCOUNTNAV) { $this->subLayout = "@humhub/modules/user/views/account/_layout"; } if ($page->type == CustomPage::TYPE_HTML) { return $this->render('html', array('html' => $page->content)); } elseif ($page->type == CustomPage::TYPE_IFRAME) { return $this->render('iframe', array('url' => $page->content, 'navigationClass' => $page->navigation_class)); } elseif ($page->type == CustomPage::TYPE_LINK) { return $this->redirect($page->content); } elseif ($page->type == CustomPage::TYPE_MARKDOWN) { return $this->render('markdown', array('md' => $page->content, 'navigationClass' => $page->navigation_class)); } else { throw new HttpException('500', 'Invalid page type!'); } }
<div class="form-group" id="url_field"> <?php echo $form->labelEx($page, 'url'); ?> <?php echo $form->textField($page, 'url', array('class' => 'form-control', 'placeholder' => Yii::t('CustomPagesModule.views_admin_edit', 'URL'))); ?> </div> <div class="form-group"> <?php echo $form->labelEx($page, 'navigation_class'); ?> <?php echo $form->dropdownList($page, 'navigation_class', CustomPage::getNavigationClasses(), array('class' => 'form-control', 'rows' => '5', 'placeholder' => Yii::t('CustomPagesModule.views_admin_edit', 'Content'))); ?> </div> <div class="form-group"> <?php echo $form->labelEx($page, 'sort_order'); ?> <?php echo $form->textField($page, 'sort_order', array('class' => 'form-control', 'placeholder' => Yii::t('CustomPagesModule.views_admin_edit', 'Sort Order'))); ?> <p class="help-block"><?php echo Yii::t('CustomPagesModule.views_admin_edit', 'Default sort orders scheme: 100, 200, 300, ...'); ?> </p>
</div> <div class="panel-body"> <?php echo Html::a(Yii::t('CustomPagesModule.base', 'Create new Page'), ['edit'], array('class' => 'btn btn-primary')); ?> <p /> <p /> <?php if (count($pages) != 0) { ?> <?php $classes = CustomPage::getNavigationClasses(); $types = CustomPage::getPageTypes(); ?> <table class="table"> <tr> <th><?php echo Yii::t('CustomPagesModule.base', 'Title'); ?> </th> <th><?php echo Yii::t('CustomPagesModule.base', 'Navigation'); ?> </th> <th><?php echo Yii::t('CustomPagesModule.base', 'Type'); ?> </th>