コード例 #1
0
ファイル: SeoBehavior.php プロジェクト: nanodesu88/easyii
 public function afterUpdate()
 {
     try {
         if ($this->seoText->load(Yii::$app->request->post())) {
             $this->seoText->setAttributes(['_image' => UploadedFile::getInstance($this->seoText, '_image')]);
             // if(!$this->seoText->isEmpty()){
             if ($this->seoText->save()) {
                 if ($this->seoText->_image) {
                     $old = $this->seoText->ogImage;
                     $photo = new Photo();
                     $photo->class = get_class($this->seoText);
                     $photo->item_id = $this->seoText->seotext_id;
                     $photo->image = $this->seoText->_image;
                     if ($photo->image && $photo->validate(['image'])) {
                         $photo->image = Image::upload($photo->image, 'photos', Photo::PHOTO_MAX_WIDTH);
                         if ($photo->image) {
                             if ($photo->save()) {
                                 $old->delete();
                             } else {
                                 @unlink(Yii::getAlias('@webroot') . str_replace(Url::base(true), '', $photo->image));
                             }
                         } else {
                         }
                     }
                 }
             }
         }
     } catch (UnknownMethodException $e) {
     }
 }
コード例 #2
0
ファイル: NewsObject.php プロジェクト: engmohamedamer/testone
 public function getPhotos()
 {
     if (!$this->_photos) {
         $this->_photos = [];
         foreach (Photo::find()->where(['class' => NewsModel::className(), 'item_id' => $this->id])->sort()->all() as $model) {
             $this->_photos[] = new PhotoObject($model);
         }
     }
     return $this->_photos;
 }
コード例 #3
0
 public function photos($options = [])
 {
     if (!$this->_photos) {
         $this->_photos = [];
         $query = Photo::find()->where(['class' => Category::className(), 'item_id' => $this->id])->sort();
         if (!empty($options['where'])) {
             $query->andFilterWhere($options['where']);
         }
         $this->_adp = new ActiveDataProvider(['query' => $query, 'pagination' => !empty($options['pagination']) ? $options['pagination'] : []]);
         foreach ($this->_adp->models as $model) {
             $this->_photos[] = new PhotoObject($model);
         }
     }
     return $this->_photos;
 }
コード例 #4
0
ファイル: Gallery.php プロジェクト: radiegtya/easyii
 private function findAlbum($id_slug)
 {
     $album = Album::find()->where(['or', 'album_id=:id_slug', 'slug=:id_slug'], [':id_slug' => $id_slug])->one();
     if (!$album) {
         return $this->notFound($id_slug);
     }
     if ($album->status != Album::STATUS_ON) {
         return Yii::$app->user->isGuest ? $this->createObject('') : $this->createObject($this->errorText('ALBUM IS OFF'));
     }
     $this->_adp = new ActiveDataProvider(['query' => Photo::find()->where(['model' => Album::className(), 'item_id' => $album->primaryKey])->sort(), 'pagination' => ['pageSize' => $this->_albumOptions['pageSize']]]);
     $albumObject = $this->parseAlbum($album);
     $albumObject->photos = $this->parsePhotos($this->_adp->models);
     $albumObject->seo_h1 = $album->seo_h1;
     $albumObject->seo_title = $album->seo_title;
     $albumObject->seo_keywords = $album->seo_keywords;
     $albumObject->seo_description = $album->seo_description;
     return $albumObject;
 }
コード例 #5
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(Category::tableName());
     $this->dropTable(Item::tableName());
     $this->dropTable(Feedback::tableName());
     $this->dropTable(File::tableName());
     $this->dropTable(Album::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());
 }
コード例 #6
0
ファイル: PhotosController.php プロジェクト: radiegtya/easyii
 public function actionDelete($id)
 {
     if ($model = Photo::findOne($id)) {
         $model->delete();
     } else {
         $this->error = Yii::t('easyii', 'Not found');
     }
     return $this->formatResponse(Yii::t('easyii', 'Photo deleted'));
 }
コード例 #7
0
ファイル: Item.php プロジェクト: DenisCherniatev/easyii
 public function getPhotos()
 {
     return $this->hasMany(Photo::className(), ['item_id' => 'item_id'])->where(['class' => self::className()])->sort();
 }
コード例 #8
0
ファイル: Photos.php プロジェクト: radiegtya/easyii
 public function run()
 {
     $photos = Photo::find()->where(['model' => get_class($this->model), 'item_id' => $this->model->primaryKey])->sort()->all();
     echo $this->render('photos', ['photos' => $photos]);
 }
コード例 #9
0
ファイル: Album.php プロジェクト: radiegtya/easyii
 public function getPhotos()
 {
     return $this->hasMany(Photo::className(), ['item_id' => 'album_id'])->where(['model' => Album::className()])->sort();
 }
コード例 #10
0
ファイル: Catalog.php プロジェクト: radiegtya/easyii
 public function api_photo($id)
 {
     $photo = Photo::findOne($id);
     return $photo ? $photo->image : null;
 }
コード例 #11
0
ファイル: Gallery.php プロジェクト: Brother-Simon/easyii
 private function findPhoto($id)
 {
     return Photo::findOne($id);
 }
コード例 #12
0
ファイル: ItemObject.php プロジェクト: nanodesu88/easyii
 public function getPhotos($index = null)
 {
     if (!$this->_photos) {
         $this->_photos = [];
         foreach (Photo::find()->where(['class' => Item::className(), 'item_id' => $this->id])->sort()->all() as $model) {
             $this->_photos[] = new PhotoObject($model);
         }
     }
     if (is_numeric($index)) {
         if (isset($this->_photos[$index])) {
             return $this->_photos[$index];
         } else {
             return null;
         }
     }
     return $this->_photos;
 }
コード例 #13
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());
     $this->dropTable(Menu::tableName());
     $this->dropTable(MenuItem::tableName());
 }