public function actionDelete()
 {
     $page = Page::findOne(['id' => Yii::$app->request->get('id')]);
     if ($page !== null) {
         $page->delete();
     }
     return $this->redirect(['index']);
 }
 public static function onAccountMenuInit($event)
 {
     foreach (Page::findAll(['navigation_class' => Page::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->in_new_window ? '_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));
     }
 }
 /**
  * @inheritdoc
  */
 public function disable()
 {
     foreach (Page::find()->all() as $page) {
         $page->delete();
     }
     foreach (ContainerPage::find()->all() as $page) {
         $page->delete();
     }
     parent::disable();
 }
 public function actionIndex()
 {
     $page = Page::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 == Page::NAV_CLASS_ACCOUNTNAV) {
         $this->subLayout = "@humhub/modules/user/views/account/_layout";
     }
     if ($page->type == Page::TYPE_HTML) {
         return $this->render('html', array('html' => $page->content, 'title' => $page->title));
     } elseif ($page->type == Page::TYPE_IFRAME) {
         return $this->render('iframe', array('url' => $page->content, 'navigationClass' => $page->navigation_class));
     } elseif ($page->type == Page::TYPE_LINK) {
         return $this->redirect($page->content);
     } elseif ($page->type == Page::TYPE_MARKDOWN) {
         return $this->render('markdown', array('md' => $page->content, 'navigationClass' => $page->navigation_class, 'title' => $page->title));
     } else {
         throw new HttpException('500', 'Invalid page type!');
     }
 }
</div>
    <div class="panel-body">

        <?php 
echo Html::a(Yii::t('CustomPagesModule.base', 'Create new Page'), ['add'], array('class' => 'btn btn-primary'));
?>

        <p />
        <p />

        <?php 
if (count($pages) != 0) {
    ?>
            <?php 
    $classes = Page::getNavigationClasses();
    $types = Page::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>
    echo $form->labelEx($page, 'url');
    ?>
                <?php 
    echo $form->textField($page, 'url', array('class' => 'form-control', 'placeholder' => Yii::t('CustomPagesModule.views_admin_edit', 'URL')));
    ?>
            </div>
        <?php 
}
?>

        <div class="form-group">
            <?php 
echo $form->labelEx($page, 'navigation_class');
?>
            <?php 
echo $form->dropdownList($page, 'navigation_class', Page::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>