Esempio n. 1
0
 public function init()
 {
     $arrayOfId = $this->grid->dataProvider->getKeys();
     $whereConfig = array('and', 'id_photogallery_object=:id_photogallery_object', array('in', 'id_photogallery_instance', $arrayOfId));
     $data = Yii::app()->db->createCommand()->select('id_photogallery_instance AS id, count(*) AS cnt')->from(PhotogalleryPhoto::model()->tableName())->where($whereConfig)->group('id_photogallery_instance')->queryAll(true, array(':id_photogallery_object' => $this->object->id_object));
     foreach ($data as $row) {
         $this->photoCountList[$row['id']] = $row['cnt'];
     }
 }
Esempio n. 2
0
 public function run()
 {
     $model = PhotogalleryPhoto::model()->find(array('order' => 'RAND()'));
     //если фоток нет, то выходим
     if ($model == null) {
         return;
     }
     $preview = null;
     if ($model->image) {
         $preview = $model->image->getPreview($this->width, $this->height, $this->postfix, $this->cropType, $this->quality, $this->resize);
     }
     $galleryLink = $photoLink = '#';
     if (Photogallery::model()->count() > 1) {
         $galleryLink = Yii::app()->createUrl(PhotogalleryModule::ROUTE_GALLERY_LIST);
     } else {
         $galleryLink = Yii::app()->createUrl(PhotogalleryModule::ROUTE_GALLERY_VIEW, array('idGallery' => $model->id_photogallery_instance));
     }
     if ($preview !== null) {
         $photoLink = Yii::app()->createUrl(PhotogalleryModule::ROUTE_GALLERY_VIEW, array('idGallery' => $model->id_photogallery_instance));
     }
     $this->render('randomPhoto', array('photo' => $preview, 'galleryLink' => $galleryLink, 'photoLink' => $photoLink));
 }