Beispiel #1
0
 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;
 }
Beispiel #2
0
 public function getPhotos()
 {
     return $this->hasMany(Photo::className(), ['item_id' => 'album_id'])->where(['model' => Album::className()])->sort();
 }
Beispiel #3
0
 public function behaviors()
 {
     return [['class' => SortableController::className(), 'model' => Album::className()], ['class' => StatusController::className(), 'model' => Album::className()]];
 }