Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PostTypeModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'post_type_smb' => $this->post_type_smb]);
     $query->andFilterWhere(['like', 'post_type_name', $this->post_type_name])->andFilterWhere(['like', 'post_type_slug', $this->post_type_slug])->andFilterWhere(['like', 'post_type_description', $this->post_type_description])->andFilterWhere(['like', 'post_type_icon', $this->post_type_icon])->andFilterWhere(['like', 'post_type_sn', $this->post_type_sn])->andFilterWhere(['like', 'post_type_pn', $this->post_type_pn])->andFilterWhere(['like', 'post_type_permission', $this->post_type_permission]);
     return $dataProvider;
 }
 /**
  * Lists all Menu models.
  *
  * @param null $id
  *
  * @return mixed
  */
 public function actionIndex($id = null)
 {
     $model = new Menu();
     // list all post types
     $postTypes = PostType::find()->where(['post_type_smb' => 1])->all();
     // list all taxonomies
     $taxonomies = Taxonomy::find()->where(['taxonomy_smb' => 1])->all();
     // get available menu
     if ($availableMenu = ArrayHelper::map(Menu::find()->all(), 'id', 'menu_title')) {
         if ($id === null && $availableMenu) {
             foreach ($availableMenu as $key => $menu) {
                 $id = $key;
                 break;
             }
         }
         $selectedMenu = $this->findModel($id);
     }
     return $this->render('index', ['model' => $model, 'availableMenu' => $availableMenu, 'selectedMenu' => isset($selectedMenu) ? $selectedMenu : null, 'postTypes' => $postTypes, 'taxonomies' => $taxonomies]);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPostType()
 {
     return $this->hasOne(PostType::className(), ['id' => 'post_type_id']);
 }
Beispiel #4
0
$form = ActiveForm::begin(['id' => 'option-reading-form', 'options' => ['class' => 'form-horizontal']]);
?>

        <div class="form-group">
            <?php 
echo Html::label(Yii::t('content', 'Front page displays'), null, ['class' => 'col-sm-2 control-label']);
?>
            <div class="col-sm-7">
                <?php 
echo Html::radioList('Option[show_on_front][option_value]', $model->show_on_front->option_value, ['posts' => Yii::t('content', 'Latest posts')], ['separator' => '<br />', 'class' => 'radio']);
?>
                <?php 
echo Html::label(Yii::t('content', 'Front page: '), 'option-front_page');
?>
                <?php 
echo Html::dropDownList('Option[front_post_type][option_value]', $model->front_post_type->option_value, ArrayHelper::merge(['all' => 'All'], ArrayHelper::map(PostType::find()->all(), 'post_type_name', 'post_type_sn')), ['class' => 'form-control']);
?>
            </div>

        </div>

        <div class="form-group">
            <div class="col-sm-7 col-sm-push-2">
                <?php 
echo Html::radioList('Option[show_on_front][option_value]', $model->show_on_front->option_value, ['page' => Yii::t('content', 'Static page')], ['separator' => '<br />', 'class' => 'radio']);
?>
                <?php 
echo Html::label(Yii::t('content', 'Front page: '), 'option-front_page');
?>
                <?php 
echo Html::dropDownList('Option[front_page][option_value]', $model->front_page->option_value, Post::findOne($model->front_page->option_value) ? ArrayHelper::map(Post::find()->select(['id', 'post_title'])->where(['id' => $model->front_page->option_value])->all(), 'id', 'post_title') : [], ['class' => 'search-post', 'disabled']);
    ?>
</p>
                    <?php 
    echo Html::a('<i class="fa fa-circle text-success"></i>' . Yii::t('content', 'Online'), ['/user/profile']);
    ?>
                </div>
            </div>
        <?php 
}
?>

        <?php 
$adminSiteMenu[0] = ['label' => Yii::t('content', 'MAIN NAVIGATION'), 'options' => ['class' => 'header'], 'template' => '{label}'];
$adminSiteMenu[1] = ['label' => Yii::t('content', 'Dashboard'), 'icon' => 'fa fa-dashboard', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Home'), 'url' => ['/site/index']]]];
$adminSiteMenu[10] = ['label' => Yii::t('content', 'Media'), 'icon' => 'fa fa-picture-o', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'All Media'), 'url' => ['/media/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Add New Media'), 'url' => ['/media/create']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Comments'), 'url' => ['/media-comment/index'], 'visible' => Yii::$app->user->can('editor')]], 'visible' => Yii::$app->user->can('author')];
$adminSiteMenu[20] = ['label' => Yii::t('content', 'Appearance'), 'icon' => 'fa fa-paint-brush', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Menus'), 'url' => ['/menu/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Themes'), 'url' => ['/theme/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Widgets'), 'url' => ['/widget/index']]], 'visible' => Yii::$app->user->can('administrator')];
$adminSiteMenu[23] = ['label' => Yii::t('content', 'Modules'), 'icon' => 'fa fa-laptop', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'All Modules'), 'url' => ['/module/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Add New Module'), 'url' => ['/module/create']]], 'visible' => Yii::$app->user->can('administrator')];
$adminSiteMenu[30] = ['label' => Yii::t('content', 'Post Types'), 'icon' => 'fa fa-files-o', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'All Post Types'), 'url' => ['/post-type/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Add New Post Type'), 'url' => ['/post-type/create']]], 'visible' => Yii::$app->user->can('administrator')];
$adminSiteMenu[40] = ['label' => Yii::t('content', 'Taxonomies'), 'icon' => 'fa fa-tags', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'All Taxonomies'), 'url' => ['/taxonomy/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Add New Taxonomy'), 'url' => ['/taxonomy/create']]], 'visible' => Yii::$app->user->can('administrator')];
$adminSiteMenu[50] = ['label' => Yii::t('content', 'Users'), 'icon' => 'fa fa-user', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'All Users'), 'url' => ['/user/index'], 'visible' => Yii::$app->user->can('administrator')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Add New User'), 'url' => ['/user/create'], 'visible' => Yii::$app->user->can('administrator')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'My Profile'), 'url' => ['/user/profile'], 'visible' => Yii::$app->user->can('subscriber')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Reset Password'), 'url' => ['/user/reset-password'], 'visible' => Yii::$app->user->can('subscriber')]]];
$adminSiteMenu = ArrayHelper::merge($adminSiteMenu, PostType::getMenu(2));
$adminSiteMenu = ArrayHelper::merge($adminSiteMenu, Option::getMenu(60));
if (isset(Yii::$app->params['adminSiteMenu']) && is_array(Yii::$app->params['adminSiteMenu'])) {
    $adminSiteMenu = ArrayHelper::merge($adminSiteMenu, Yii::$app->params['adminSiteMenu']);
}
// Short menu by index
ksort($adminSiteMenu);
echo MainSidebar::widget(['items' => $adminSiteMenu]);
?>
    </section>
</aside>
 /**
  * Finds the PostType model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param integer $id
  *
  * @return PostType the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findPostType($id)
 {
     if (($model = PostType::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('content', 'The requested page does not exist.'));
     }
 }
 /**
  * Finds the Post model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param $post_type
  *
  * @throws \yii\web\NotFoundHttpException
  * @return PostType the loaded model
  */
 protected function findPostTypeBySlug($post_type)
 {
     $model = PostType::findOne(['post_type_slug' => $post_type]);
     if ($model) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPostTypes()
 {
     return $this->hasMany(PostType::className(), ['id' => 'post_type_id'])->viaTable('{{%post_type_taxonomy}}', ['taxonomy_id' => 'id']);
 }