Ejemplo n.º 1
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(Carousel::tableName(), ['carousel_id' => 'pk', 'image' => Schema::TYPE_STRING . '(128) NOT NULL', 'link' => Schema::TYPE_STRING . '(255) NOT NULL', 'title' => Schema::TYPE_STRING . '(128) DEFAULT NULL', 'text' => Schema::TYPE_TEXT . ' DEFAULT NULL', 'order_num' => Schema::TYPE_INTEGER, 'status' => Schema::TYPE_BOOLEAN . " DEFAULT '1'"], $tableOptions)->execute();
 }
Ejemplo n.º 2
0
 public function init()
 {
     parent::init();
     $this->_items = Data::cache(CarouselModel::CACHE_KEY, 3600, function () {
         $items = [];
         foreach (CarouselModel::find()->status(CarouselModel::STATUS_ON)->sort()->all() as $item) {
             $items[] = new CarouselObject($item);
         }
         return $items;
     });
 }
Ejemplo n.º 3
0
 public function init()
 {
     parent::init();
     $data = Data::cache(CarouselModel::CACHE_KEY, 3600, function () {
         return CarouselModel::find()->status(CarouselModel::STATUS_ON)->sort()->asArray()->all();
     });
     foreach ($data as $item) {
         $temp = ['content' => '<img src="' . $item['image'] . '"/>', 'caption' => ''];
         if ($item['title']) {
             $temp['caption'] .= '<h3>' . $item['title'] . '</h3>';
         }
         if ($item['text']) {
             $temp['caption'] .= '<p>' . $item['text'] . '</p>';
         }
         $this->_items[] = $temp;
     }
 }
Ejemplo n.º 4
0
 public function actionDelete($id)
 {
     if ($model = Carousel::findOne($id)) {
         $model->delete();
     } else {
         $this->error = Yii::t('easyii', 'Not found');
     }
     return $this->formatResponse(Yii::t('easyii/carousel', 'Carousel item deleted'));
 }
 public function insertCarousel()
 {
     if (Carousel::find()->count()) {
         return '`<b>' . Carousel::tableName() . '</b>` table is not empty, skipping...';
     }
     $this->db->createCommand('TRUNCATE TABLE `' . Carousel::tableName() . '`')->query();
     (new Carousel(['image' => '/uploads/carousel/1.jpg', 'title' => 'Ut enim ad minim veniam, quis nostrud exercitation', 'text' => 'Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.']))->save();
     (new Carousel(['image' => '/uploads/carousel/2.jpg', 'title' => 'Sed do eiusmod tempor incididunt ut labore et', 'text' => 'Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.']))->save();
     (new Carousel(['image' => '/uploads/carousel/3.jpg', 'title' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'text' => 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.']))->save();
     return 'Carousel data inserted.';
 }
Ejemplo n.º 6
0
 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());
 }