public function actionView($idGallery)
 {
     $currentGallery = $this->loadModelOr404('Photogallery', $idGallery);
     $childGallery = Photogallery::model()->byParent($currentGallery->id_photogallery)->with('countPhoto')->findAll();
     $arr = array();
     $tmp = $currentGallery;
     while ($tmp != null) {
         $arr[$tmp->name] = $tmp->getUrl();
         $tmp = $tmp->getParent();
     }
     if (count($arr) > 0) {
         $this->breadcrumbs = array_merge($this->breadcrumbs, array_reverse($arr));
     }
     $this->render('/photogallery', array('currentGallery' => $currentGallery, 'childGallery' => $childGallery));
 }
Exemple #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));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Photogallery::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }