/** * @return string */ public function actionIndex() { /* @var $lastPost \common\models\Post */ $response = Yii::$app->response; $response->headers->set('Content-Type', 'text/xml; charset=UTF-8'); $response->format = $response::FORMAT_RAW; $lastPost = Post::find()->where(['post_status' => 'publish'])->orderBy(['id' => SORT_DESC])->one(); return $this->renderPartial('index', ['title' => Option::get('sitetitle'), 'description' => Option::get('tagline'), 'link' => Yii::$app->request->absoluteUrl, 'lastBuildDate' => new \DateTime($lastPost->post_date, new \DateTimeZone(Option::get('time_zone'))), 'postTypes' => PostType::find()->all(), 'language' => Yii::$app->language, 'generator' => 'http://www.writesdown.com']); }
/** * Get menu dropdown for post type. * * @return array */ protected function getPostTypeMenu() { /* @var $urlManagerBack \yii\web\UrlManager */ /* @var $postTypes \common\models\PostType[] */ $urlManagerBack = Yii::$app->urlManagerBack; $menuItems = []; $postTypes = PostType::find()->select(['id', 'post_type_sn', 'post_type_permission'])->all(); foreach ($postTypes as $postType) { $menuItems[] = ['label' => $postType->post_type_sn, 'url' => $urlManagerBack->createUrl(['/post/create', 'post_type' => $postType->id]), 'visible' => Yii::$app->user->can($postType->post_type_permission)]; } return $menuItems; }
/** * 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()) { 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; }
/** * 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()) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'menu_builder' => $this->menu_builder]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'icon', $this->icon])->andFilterWhere(['like', 'singular_name', $this->singular_name])->andFilterWhere(['like', 'plural_name', $this->plural_name])->andFilterWhere(['like', 'permission', $this->permission]); return $dataProvider; }
/** * 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; }
/** * Displays menu page consists of CRUD for Menu and MenuItem model. * * @param null $id * @return mixed */ public function actionIndex($id = null) { $model = new Menu(); $postTypes = PostType::find()->where(['menu_builder' => PostType::MENU_BUILDER])->all(); $taxonomies = Taxonomy::find()->where(['menu_builder' => Taxonomy::MENU_BUILDER])->all(); if ($available = ArrayHelper::map(Menu::find()->all(), 'id', 'title')) { if ($id === null && $available) { reset($available); $id = key($available); } $selected = $this->findModel($id); } return $this->render('index', ['model' => $model, 'available' => $available, 'selected' => isset($selected) ? $selected : null, 'postTypes' => $postTypes, 'taxonomies' => $taxonomies]); }
/** * Generates menu page consists of CRUD Menu and MenuItem model. * * @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) { reset($availableMenu); $id = key($availableMenu); } $selectedMenu = $this->findModel($id); } return $this->render('index', ['model' => $model, 'availableMenu' => $availableMenu, 'selectedMenu' => isset($selectedMenu) ? $selectedMenu : null, 'postTypes' => $postTypes, 'taxonomies' => $taxonomies]); }
/** * @inheritdoc */ public function beforeAction($action) { /* @var $postType \common\models\PostType */ /* @var $taxonomy \common\models\Taxonomy */ if (parent::beforeAction($action)) { $this->_defaultOption['enable_sitemap'] = 1; $this->_defaultOption['entries_per_page'] = 1000; // Home $this->_defaultOption['home'] = ['priority' => '1.0', 'changefreq' => 'daily']; // Post type default option foreach (PostType::find()->all() as $postType) { $this->_defaultOption['post_type'][$postType->id] = ['enable' => 1, 'priority' => '0.6', 'changefreq' => 'weekly']; } // Taxonomy default option foreach (Taxonomy::find()->all() as $taxonomy) { $this->_defaultOption['taxonomy'][$taxonomy->id] = ['enable' => 1, 'priority' => '0.2', 'changefreq' => 'weekly']; } // Media default option $this->_defaultOption['media'] = ['enable' => 0, 'priority' => '0.2', 'changefreq' => 'monthly']; return true; } return false; }
/** * Finds the Post model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param $postType * * @throws \yii\web\NotFoundHttpException * @return PostType the loaded model */ protected function findPostTypeBySlug($postType) { $model = PostType::findOne(['post_type_slug' => $postType]); if ($model) { return $model; } throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.')); }
<p><?php echo Yii::$app->user->identity->username; ?> </p> <?php echo Html::a('<i class="fa fa-circle text-success"></i>' . Yii::t('writesdown', 'Online'), ['/user/profile']); ?> </div> </div> <?php } ?> <?php $admin_site_menu[0] = ['label' => Yii::t('writesdown', 'MAIN NAVIGATION'), 'options' => ['class' => 'header'], 'template' => '{label}']; $admin_site_menu[1] = ['label' => Yii::t('writesdown', 'Dashboard'), 'icon' => '<i class="fa fa-dashboard"></i>', 'options' => ['class' => 'treeview'], 'items' => [['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'Home'), 'url' => ['/site/index']]]]; $admin_site_menu[10] = ['label' => Yii::t('writesdown', 'Media'), 'icon' => '<i class="fa fa-picture-o"></i>', 'options' => ['class' => 'treeview'], 'items' => [['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'All Media'), 'url' => ['/media/index']], ['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'Add New Media'), 'url' => ['/media/create']], ['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'Comments'), 'url' => ['/media-comment/index'], 'visible' => Yii::$app->user->can('editor')]], 'visible' => Yii::$app->user->can('author')]; $admin_site_menu[20] = ['label' => Yii::t('writesdown', 'Appearance'), 'icon' => '<i class="fa fa-paint-brush"></i>', 'options' => ['class' => 'treeview'], 'items' => [['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'Menus'), 'url' => ['/menu']], ['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'Themes'), 'url' => ['/theme']]], 'visible' => Yii::$app->user->can('administrator')]; $admin_site_menu[23] = ['label' => Yii::t('writesdown', 'Modules'), 'icon' => '<i class="fa fa-laptop"></i>', 'options' => ['class' => 'treeview'], 'items' => [['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'All Modules'), 'url' => ['/module']], ['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'Add New Module'), 'url' => ['/module/create']]], 'visible' => Yii::$app->user->can('administrator')]; $admin_site_menu[30] = ['label' => Yii::t('writesdown', 'Post Types'), 'icon' => '<i class="fa fa-files-o"></i>', 'options' => ['class' => 'treeview'], 'items' => [['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'All Post Types'), 'url' => ['/post-type/index/']], ['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'Add New Post Type'), 'url' => ['/post-type/create/']]], 'visible' => Yii::$app->user->can('administrator')]; $admin_site_menu[40] = ['label' => Yii::t('writesdown', 'Taxonomies'), 'icon' => '<i class="fa fa-tags"></i>', 'options' => ['class' => 'treeview'], 'items' => [['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'All Taxonomies'), 'url' => ['/taxonomy/index/']], ['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'Add New Taxonomy'), 'url' => ['/taxonomy/create/']]], 'visible' => Yii::$app->user->can('administrator')]; $admin_site_menu[50] = ['label' => Yii::t('writesdown', 'Users'), 'icon' => '<i class="fa fa-user"></i>', 'options' => ['class' => 'treeview'], 'items' => [['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'All User'), 'url' => ['/user/index/'], 'visible' => Yii::$app->user->can('administrator')], ['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'Add New User'), 'url' => ['/user/create/'], 'visible' => Yii::$app->user->can('administrator')], ['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'My Profile'), 'url' => ['/user/profile/'], 'visible' => Yii::$app->user->can('subscriber')], ['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'Reset Password'), 'url' => ['/user/reset-password/'], 'visible' => Yii::$app->user->can('subscriber')]]]; $admin_site_menu[70] = ['label' => Yii::t('writesdown', 'Tools'), 'icon' => '<i class="fa fa-wrench"></i>', 'options' => ['class' => 'treeview'], 'items' => [['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'Export'), 'url' => ['/site/not-found/'], 'visible' => Yii::$app->user->can('superadmin')], ['icon' => '<i class="fa fa-circle-o"></i>', 'label' => Yii::t('writesdown', 'Import'), 'url' => ['/site/not-found/'], 'visible' => Yii::$app->user->can('superadmin')]]]; $admin_site_menu = ArrayHelper::merge($admin_site_menu, PostType::getMenu(2)); $admin_site_menu = ArrayHelper::merge($admin_site_menu, Option::getMenu(60)); ksort($admin_site_menu); echo MainSidebar::widget(['options' => ['class' => 'sidebar-menu'], 'labelTemplate' => '<a href="#">{icon}<span>{label}</span>{right-icon}{badge}</a>', 'linkTemplate' => '<a href="{url}">{icon}<span>{label}</span>{right-icon}{badge}</a>', 'submenuTemplate' => "\n<ul class=\"treeview-menu\">\n{items}\n</ul>\n", 'activateParents' => true, 'items' => $admin_site_menu]); ?> </section> </aside>
/** * @param string $type * @param string $slug * @param int $page * * @return string */ public function actionView($type, $slug, $page = 1) { /* @var $taxonomy Taxonomy */ /* @var $postType PostType */ /* @var $posts Post[] */ /* @var $images Media[] */ /* @var $terms Term[] */ /* @var $mediaSet Media[] */ /* @var $post Post */ $page--; $items = []; $response = Yii::$app->response; $response->headers->set('Content-Type', 'text/xml; charset=UTF-8'); $response->format = $response::FORMAT_RAW; if ($type === 'h') { $item['loc'] = Yii::$app->urlManager->hostInfo . Yii::$app->urlManager->baseUrl; $item['changefreq'] = $this->_option['home']['changefreq']; $item['priority'] = $this->_option['home']['priority']; return $this->renderPartial('home', ['item' => $item]); } elseif ($type === 'p') { $postType = PostType::find()->where(['post_type_slug' => $slug])->one(); $posts = $postType->getPosts()->andWhere(['post_status' => 'publish'])->offset($page * $this->_option['entries_per_page'])->limit($this->_option['entries_per_page'])->all(); foreach ($posts as $post) { $lastmod = new \DateTime($post->post_modified, new \DateTimeZone(Option::get('time_zone'))); $items[$post->id]['loc'] = $post->url; $items[$post->id]['lastmod'] = $lastmod->format('r'); $items[$post->id]['changefreq'] = $this->_option['post_type'][$postType->id]['changefreq']; $items[$post->id]['priority'] = $this->_option['post_type'][$postType->id]['priority']; if ($images = $post->getMedia()->where(['LIKE', 'media_mime_type', 'image/'])->all()) { foreach ($images as $image) { $metadata = $image->getMeta('metadata'); $items[$post->id]['image'][$image->id]['loc'] = $image->uploadUrl . $metadata['media_versions']['full']['url']; $items[$post->id]['image'][$image->id]['title'] = $image->media_title ? $image->media_title : null; $items[$post->id]['image'][$image->id]['caption'] = $image->media_excerpt ? $image->media_excerpt : null; } } } return $this->renderPartial('post-type', ['items' => $items]); } elseif ($type === 'c') { $taxonomy = Taxonomy::find()->where(['taxonomy_slug' => $slug])->one(); $terms = $taxonomy->getTerms()->offset($page * $this->_option['entries_per_page'])->limit($this->_option['entries_per_page'])->all(); foreach ($terms as $term) { $post = $term->getPosts()->andWhere(['post_status' => 'publish'])->orderBy(['id' => SORT_DESC])->one(); if ($post) { $lastmod = new \DateTime($post->post_modified, new \DateTimeZone(Option::get('time_zone'))); $items[$term->id]['loc'] = $term->url; $items[$term->id]['lastmod'] = $lastmod->format('r'); $items[$term->id]['changefreq'] = $this->_option['taxonomy'][$taxonomy->id]['changefreq']; $items[$term->id]['priority'] = $this->_option['taxonomy'][$taxonomy->id]['priority']; } } return $this->renderPartial('taxonomy', ['items' => $items]); } elseif ($type === 'm') { $mediaSet = Media::find()->offset($page * $this->_option['entries_per_page'])->limit($this->_option['entries_per_page'])->all(); foreach ($mediaSet as $media) { $lastmod = new \DateTime($media->media_modified, new \DateTimeZone(Option::get('time_zone'))); $items[$media->id]['loc'] = $media->url; $items[$media->id]['lastmod'] = $lastmod->format('r'); $items[$media->id]['changefreq'] = $this->_option['media']['changefreq']; $items[$media->id]['priority'] = $this->_option['media']['priority']; } return $this->renderPartial('media', ['items' => $items]); } return $this->redirect(['/site/not-found']); }
/** * 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; } throw new NotFoundHttpException('The requested page does not exist.'); }
<div class="form-group"> <?php echo Html::label(Yii::t('writesdown', 'Front page displays'), null, ['class' => 'col-sm-2 control-label']); ?> <div class="col-sm-7"> <?php echo Html::radioList('Option[show_on_front][value]', $model->show_on_front->value, ['posts' => Yii::t('writesdown', 'Latest posts')], ['separator' => '<br />', 'class' => 'radio']); ?> <?php echo Html::label(Yii::t('writesdown', 'Front page: '), 'option-front_page'); ?> <?php echo Html::dropDownList('Option[front_post_type][value]', $model->front_post_type->value, ArrayHelper::merge(['all' => 'All'], ArrayHelper::map(PostType::find()->all(), 'name', 'singular_name')), ['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][value]', $model->show_on_front->value, ['page' => Yii::t('writesdown', 'Static page')], ['separator' => '<br />', 'class' => 'radio']); ?> <?php echo Html::label(Yii::t('writesdown', 'Front page: '), 'option-front_page'); ?> <?php
/** * @return \yii\db\ActiveQuery */ public function getPostTypes() { return $this->hasMany(PostType::className(), ['id' => 'post_type_id'])->viaTable('{{%post_type_taxonomy}}', ['taxonomy_id' => 'id']); }
/** * 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 findModel($id) { if (($model = PostType::findOne($id)) !== null) { return $model; } throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.')); }
/** * @param AcceptanceTester $I */ public function testUpdate(AcceptanceTester $I) { $I->wantTo('ensure that create post-type works'); $updatePage = UpdatePage::openBy($I); $I->see('Update Post Type: Post', 'h1'); // Only run for selenium if (method_exists($I, 'executeJS')) { $I->amGoingTo('submit taxonomy with no data'); $updatePage->submitTaxonomy([]); $I->expectTo('see validation errors'); $I->see('Name cannot be blank.', '.help-block'); $I->see('Singular Name cannot be blank.', '.help-block'); $I->see('Plural Name cannot be blank.', '.help-block'); $I->amGoingTo('submit taxonomy with correct data'); $updatePage->submitTaxonomy(['taxonomy_name' => 'test-taxonomy', 'taxonomy_sn' => 'Test Taxonomy', 'taxonomy_pn' => 'Test Taxonomies']); $I->expect('new taxonomy saved'); $I->see('test-taxonomy', '#taxonomy_list'); $I->dontSee('Name cannot be blank.', '.help-block'); $I->dontSee('Singular Name cannot be blank.', '.help-block'); $I->dontSee('Plural Name cannot be blank.', '.help-block'); } // Test update data $I->amGoingTo('submit post-type form with correct data'); $I->checkOption('#posttype-post_type_smb'); $I->selectOption('#posttype-post_type_permission', 'subscriber'); $updatePage->submitPostType(['post_type_description' => 'New post-type description']); $I->expectTo('post-type updated'); $I->see('View Post Type: Post', 'h1'); PostType::findOne(1)->update(['post_type_smb' => '0', 'post_type_permission' => 'contributor', 'post_type_description' => '']); Taxonomy::deleteAll(['taxonomy_name' => 'test-taxonomy']); }
echo Yii::$app->user->identity->username; ?> </p> <?php echo Html::a('<i class="fa fa-circle text-success"></i>' . Yii::t('writesdown', 'Online'), ['/user/profile']); ?> </div> </div> <?php } ?> <?php $adminMenu[0] = ['label' => Yii::t('writesdown', 'MAIN NAVIGATION'), 'options' => ['class' => 'header'], 'template' => '{label}']; $adminMenu[1] = ['label' => Yii::t('writesdown', 'Dashboard'), 'icon' => 'fa fa-dashboard', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Home'), 'url' => ['/site/index']]]]; $adminMenu = ArrayHelper::merge($adminMenu, PostType::getMenus(2)); $adminMenu[10] = ['label' => Yii::t('writesdown', 'Media'), 'icon' => 'fa fa-picture-o', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Media'), 'url' => ['/media/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New Media'), 'url' => ['/media/create']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Comments'), 'url' => ['/media-comment/index'], 'visible' => Yii::$app->user->can('editor')]], 'visible' => Yii::$app->user->can('author')]; $adminMenu[20] = ['label' => Yii::t('writesdown', 'Appearance'), 'icon' => 'fa fa-paint-brush', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Menus'), 'url' => ['/menu/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Themes'), 'url' => ['/theme/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Widgets'), 'url' => ['/widget/index']]], 'visible' => Yii::$app->user->can('administrator')]; $adminMenu[30] = ['label' => Yii::t('writesdown', 'Modules'), 'icon' => 'fa fa-laptop', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Modules'), 'url' => ['/module/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New Module'), 'url' => ['/module/create']]], 'visible' => Yii::$app->user->can('administrator')]; $adminMenu[40] = ['label' => Yii::t('writesdown', 'Post Types'), 'icon' => 'fa fa-files-o', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Post Types'), 'url' => ['/post-type/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New Post Type'), 'url' => ['/post-type/create']]], 'visible' => Yii::$app->user->can('administrator')]; $adminMenu[50] = ['label' => Yii::t('writesdown', 'Taxonomies'), 'icon' => 'fa fa-tags', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Taxonomies'), 'url' => ['/taxonomy/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New Taxonomy'), 'url' => ['/taxonomy/create']]], 'visible' => Yii::$app->user->can('administrator')]; $adminMenu[60] = ['label' => Yii::t('writesdown', 'Users'), 'icon' => 'fa fa-user', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Users'), 'url' => ['/user/index'], 'visible' => Yii::$app->user->can('administrator')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New User'), 'url' => ['/user/create'], 'visible' => Yii::$app->user->can('administrator')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'My Profile'), 'url' => ['/user/profile'], 'visible' => Yii::$app->user->can('subscriber')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Reset Password'), 'url' => ['/user/reset-password'], 'visible' => Yii::$app->user->can('subscriber')]]]; $adminMenu = ArrayHelper::merge($adminMenu, Option::getMenus(70)); if ($userAdminMenu = ArrayHelper::getValue(Yii::$app->params, 'adminMenu', [])) { $adminMenu = ArrayHelper::merge($adminMenu, $userAdminMenu); } ksort($adminMenu); echo Menu::widget(['items' => $adminMenu]); ?> </section>
/** * @return \yii\db\ActiveQuery */ public function getPostType() { return $this->hasOne(PostType::className(), ['id' => 'post_type']); }
/** * @param FunctionalTester $I */ public function testUpdate(FunctionalTester $I) { $I->wantTo('ensure that create post-type works'); $updatePage = UpdatePage::openBy($I); $I->see('Update Post Type: Post', 'h1'); $I->amGoingTo('submit post-type form with correct data'); $I->checkOption('#posttype-post_type_smb'); $I->selectOption('#posttype-post_type_permission', 'subscriber'); $updatePage->submitPostType(['post_type_description' => 'New post-type description']); $I->expectTo('post-type updated'); // $I->see('View Post Type: Post', 'h1'); $I->see('View Post Type: Post'); PostType::findOne(1)->update(['post_type_smb' => '0', 'post_type_permission' => 'contributor', 'post_type_description' => '']); Taxonomy::deleteAll(['taxonomy_name' => 'test-taxonomy']); }
</p> <?php echo Html::a('<i class="fa fa-circle text-success"></i>' . Yii::t('writesdown', 'Online'), ['/user/profile']); ?> </div> </div> <?php } ?> <?php $adminSiteMenu[0] = ['label' => Yii::t('writesdown', 'MAIN NAVIGATION'), 'options' => ['class' => 'header'], 'template' => '{label}']; $adminSiteMenu[1] = ['label' => Yii::t('writesdown', 'Dashboard'), 'icon' => 'fa fa-dashboard', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Home'), 'url' => ['/site/index']]]]; $adminSiteMenu[10] = ['label' => Yii::t('writesdown', 'Media'), 'icon' => 'fa fa-picture-o', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Media'), 'url' => ['/media/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New Media'), 'url' => ['/media/create']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Comments'), 'url' => ['/media-comment/index'], 'visible' => Yii::$app->user->can('editor')]], 'visible' => Yii::$app->user->can('author')]; $adminSiteMenu[20] = ['label' => Yii::t('writesdown', 'Appearance'), 'icon' => 'fa fa-paint-brush', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Menus'), 'url' => ['/menu/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Themes'), 'url' => ['/theme/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Widgets'), 'url' => ['/widget/index']]], 'visible' => Yii::$app->user->can('administrator')]; $adminSiteMenu[23] = ['label' => Yii::t('writesdown', 'Modules'), 'icon' => 'fa fa-laptop', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Modules'), 'url' => ['/module/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New Module'), 'url' => ['/module/create']]], 'visible' => Yii::$app->user->can('administrator')]; $adminSiteMenu[30] = ['label' => Yii::t('writesdown', 'Post Types'), 'icon' => 'fa fa-files-o', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Post Types'), 'url' => ['/post-type/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New Post Type'), 'url' => ['/post-type/create']]], 'visible' => Yii::$app->user->can('administrator')]; $adminSiteMenu[40] = ['label' => Yii::t('writesdown', 'Taxonomies'), 'icon' => 'fa fa-tags', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Taxonomies'), 'url' => ['/taxonomy/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New Taxonomy'), 'url' => ['/taxonomy/create']]], 'visible' => Yii::$app->user->can('administrator')]; $adminSiteMenu[50] = ['label' => Yii::t('writesdown', 'Users'), 'icon' => 'fa fa-user', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Users'), 'url' => ['/user/index'], 'visible' => Yii::$app->user->can('administrator')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New User'), 'url' => ['/user/create'], 'visible' => Yii::$app->user->can('administrator')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'My Profile'), 'url' => ['/user/profile'], 'visible' => Yii::$app->user->can('subscriber')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', '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']); } ksort($adminSiteMenu); echo MainSidebar::widget(['items' => $adminSiteMenu]); ?> </section> </aside>
/** * 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::find()->andWhere(['post_type_slug' => $post_type])->one(); if ($model) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }