示例#1
0
 public function actionDelete($id)
 {
     if ($model = Page::findOne($id)) {
         $model->delete();
     } else {
         $this->error = Yii::t('easyii', 'Not found');
     }
     return $this->formatResponse(Yii::t('easyii/page', 'Page deleted'));
 }
示例#2
0
文件: Page.php 项目: mluludk/easyii
 private function findPage($id_slug)
 {
     //aslinya            $page = PageModel::find()->where(['or', 'page_id=:id_slug', 'slug=:id_slug'], [':id_slug' => $id_slug])->one();
     if (is_integer($id_slug)) {
         $page = PageModel::find()->where('page_id=:id_slug', [':id_slug' => $id_slug])->one();
     } else {
         $page = PageModel::find()->where('slug=:id_slug', [':id_slug' => $id_slug])->one();
     }
     return $page ? new PageObject($page) : $this->notFound($id_slug);
 }
示例#3
0
 public function dbInstall()
 {
     $db = Yii::$app->db;
     $tableOptions = null;
     if ($db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM';
     }
     $db->createCommand()->createTable(Page::tableName(), ['page_id' => 'pk', 'title' => Schema::TYPE_STRING . '(128) NOT NULL', 'text' => Schema::TYPE_TEXT . ' NOT NULL', 'slug' => Schema::TYPE_STRING . '(128) DEFAULT NULL'], $tableOptions)->execute();
     $db->createCommand()->createIndex('slug', Page::tableName(), 'slug', true)->execute();
 }
示例#4
0
 public function actionPage($slug)
 {
     $menuItems = [];
     foreach (Page::find()->all() as $model) {
         $menuItems[] = ['label' => $model->title, 'url' => ['site/page', 'slug' => $model->slug]];
     }
     $page = Page::findOne(['slug' => $slug]);
     if (!$page) {
         throw new NotFoundHttpException();
     }
     return $this->render('page', ['page' => $page, 'menuItems' => $menuItems]);
 }
示例#5
0
文件: Page.php 项目: radiegtya/easyii
 private function findPage($id_slug)
 {
     $page = PageModel::find()->where(['or', 'page_id=:id_slug', 'slug=:id_slug'], [':id_slug' => $id_slug])->one();
     if ($page) {
         $result = $this->parsePage($page);
         $result->seo_h1 = $page->seo_h1;
         $result->seo_title = $page->seo_title;
         $result->seo_keywords = $page->seo_keywords;
         $result->seo_description = $page->seo_description;
         return $result;
     } else {
         return $this->notFound($id_slug);
     }
 }
示例#6
0
 public function init()
 {
     $items = [['label' => 'Главная', 'url' => '/']];
     $page = Page::find()->one();
     if ($page) {
         $items[] = ['label' => 'О компании', 'url' => ['site/page', 'slug' => $page->slug]];
     }
     foreach (Article::tree() as $articleCategory) {
         $item['label'] = $articleCategory->title;
         if (count($articleCategory->children) > 0) {
             $item['url'] = ['site/article', 'category' => $articleCategory->children[0]->slug];
         } else {
             $item['url'] = ['site/article', 'category' => $articleCategory->slug];
         }
         $items[] = $item;
     }
     $items[] = ['label' => 'Новостная лента', 'url' => ['site/news']];
     $this->items = $items;
 }
 public function insertPages()
 {
     if (Page::find()->count()) {
         return '`<b>' . Page::tableName() . '</b>` table is not empty, skipping...';
     }
     $this->db->createCommand('TRUNCATE TABLE `' . Page::tableName() . '`')->query();
     $page1 = new Page(['title' => 'Index', 'text' => '<p><strong>All elements are live-editable, switch on Live Edit button to see this feature.</strong>&nbsp;</p><p>Dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.&nbsp;Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>', 'slug' => 'page-index']);
     $page1->save();
     $this->attachSeo($page1, '', 'EasyiiCMS demo', 'yii2, easyii, admin');
     $page2 = new Page(['title' => 'Shop', 'text' => '', 'slug' => 'page-shop']);
     $page2->save();
     $this->attachSeo($page2, 'Shop categories', 'Extended shop title');
     $page3 = new Page(['title' => 'Shop search', 'text' => '', 'slug' => 'page-shop-search']);
     $page3->save();
     $this->attachSeo($page3, 'Shop search results', 'Extended shop search title');
     $page4 = new Page(['title' => 'Shopping cart', 'text' => '', 'slug' => 'page-shopcart']);
     $page4->save();
     $this->attachSeo($page4, 'Shopping cart H1', 'Extended shopping cart title');
     $page5 = new Page(['title' => 'Order created', 'text' => '<p>Your order successfully created. Our manager will contact you as soon as possible.</p>', 'slug' => 'page-shopcart-success']);
     $page5->save();
     $this->attachSeo($page5, 'Success', 'Extended order success title');
     $page6 = new Page(['title' => 'News', 'text' => '', 'slug' => 'page-news']);
     $page6->save();
     $this->attachSeo($page6, 'News H1', 'Extended news title');
     $page7 = new Page(['title' => 'Articles', 'text' => '', 'slug' => 'page-articles']);
     $page7->save();
     $this->attachSeo($page7, 'Articles H1', 'Extended articles title');
     $page8 = new Page(['title' => 'Gallery', 'text' => '', 'slug' => 'page-gallery']);
     $page8->save();
     $this->attachSeo($page8, 'Photo gallery', 'Extended gallery title');
     $page9 = new Page(['title' => 'Guestbook', 'text' => '', 'slug' => 'page-guestbook']);
     $page9->save();
     $this->attachSeo($page9, 'Guestbook H1', 'Extended guestbook title');
     $page10 = new Page(['title' => 'FAQ', 'text' => '', 'slug' => 'page-faq']);
     $page10->save();
     $this->attachSeo($page10, 'Frequently Asked Question', 'Extended faq title');
     $page11 = new Page(['title' => 'Contact', 'text' => '<p><strong>Address</strong>: Dominican republic, Santo Domingo, Some street 123</p><p><strong>ZIP</strong>: 123456</p><p><strong>Phone</strong>: +1 234 56-78</p><p><strong>E-mail</strong>: demo@example.com</p>', 'slug' => 'page-contact']);
     $page11->save();
     $this->attachSeo($page11, 'Contact us', 'Extended contact title');
     return 'Page data inserted.';
 }
 public function down()
 {
     $this->dropTable(models\Admin::tableName());
     $this->dropTable(models\LoginForm::tableName());
     $this->dropTable(models\Module::tableName());
     $this->dropTable(models\Photo::tableName());
     $this->dropTable(models\Setting::tableName());
     $this->dropTable(Carousel::tableName());
     $this->dropTable(catalog\models\Category::tableName());
     $this->dropTable(catalog\models\Item::tableName());
     $this->dropTable(article\models\Category::tableName());
     $this->dropTable(article\models\Item::tableName());
     $this->dropTable(Feedback::tableName());
     $this->dropTable(File::tableName());
     $this->dropTable(gallery\models\Category::tableName());
     $this->dropTable(Guestbook::tableName());
     $this->dropTable(News::tableName());
     $this->dropTable(Page::tableName());
     $this->dropTable(Subscriber::tableName());
     $this->dropTable(History::tableName());
     $this->dropTable(Text::tableName());
 }
示例#9
0
 private function findPage($id_slug)
 {
     $page = PageModel::find()->where(['or', 'page_id=:id_slug', 'slug=:id_slug'], [':id_slug' => $id_slug])->one();
     return $page ? new PageObject($page) : $this->notFound($id_slug);
 }