The followings are the available columns in table 'ImageToGallery':
Inheritance: extends CActiveRecord
Esempio n. 1
0
 public function actionDeleteImage($id)
 {
     if (Yii::app()->request->isPostRequest) {
         ImageToGallery::model()->findByPk((int) $id)->delete();
         if (!isset($_GET['ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
Esempio n. 2
0
 public function addImage(Image $image)
 {
     $im2g = new ImageToGallery();
     $im2g->setAttributes(['image_id' => $image->id, 'gallery_id' => $this->id]);
     return $im2g->save();
 }
Esempio n. 3
0
 public function addImage(Image $image)
 {
     $im2g = new ImageToGallery();
     $im2g->setAttributes(array('image_id' => $image->id, 'galleryId' => $this->id));
     return $im2g->save() ? true : false;
 }
Esempio n. 4
0
 /**
  * Отображение изображений галереи:
  *
  * @param int $id - id-галереи
  *
  * @return void
  **/
 public function actionImages($id)
 {
     if (($gallery = Gallery::model()->findByPk($id)) === null) {
         throw new CHttpException(404, Yii::t('GalleryModule.gallery', 'Page was not found!'));
     }
     $image = new Image();
     if (Yii::app()->getRequest()->getIsPostRequest() && ($imageData = Yii::app()->getRequest()->getPost('Image')) !== null) {
         $this->_addImage($image, $imageData, $gallery);
     }
     $criteria = new CDbCriteria();
     $criteria->condition = 't.gallery_id = :gallery_id';
     $criteria->order = 't.position';
     $criteria->with = 'image';
     $criteria->params = [':gallery_id' => $gallery->id];
     $this->render('images', ['dataProvider' => ImageToGallery::model()->findAll($criteria), 'image' => $image, 'model' => $gallery, 'tab' => !($errors = $image->getErrors()) ? '_images_show' : '_image_add']);
 }