Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Asset::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['Id' => $this->Id, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy, 'createdOn' => $this->createdOn, 'modifiedOn' => $this->modifiedOn, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'filename', $this->filename])->andFilterWhere(['like', 'path', $this->path])->andFilterWhere(['like', 'uri', $this->uri])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'mimetype', $this->mimetype])->andFilterWhere(['like', 'source', $this->source])->andFilterWhere(['like', 'embedcode', $this->embedcode])->andFilterWhere(['like', 'mediahash', $this->mediahash])->andFilterWhere(['like', 'metainfo', $this->metainfo])->andFilterWhere(['like', 'ip', $this->ip]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function afterDelete()
 {
     Tagging::deleteAll(['taggable_type' => Tagging::TAGGABLE_VIDEO, 'taggable_id' => $this->id]);
     Relation::deleteAll(['relationable_type' => Relation::RELATIONABLE_VIDEO, 'relationable_id' => $this->id]);
     Comment::deleteAll(['commentable_type' => Comment::COMMENTABLE_VIDEO, 'commentable_id' => $this->id]);
     CommentCount::deleteAll(['commentable_type' => CommentCount::COMMENTABLE_VIDEO, 'commentable_id' => $this->id]);
     $assets = Asset::find()->where(['assetable_type' => Asset::ASSETABLE_VIDEO, 'assetable_id' => $this->id])->orWhere(['assetable_type' => Asset::ASSETABLE_VIDEOFILE, 'assetable_id' => $this->id])->all();
     foreach ($assets as $asset) {
         $asset->delete();
     }
 }
Ejemplo n.º 3
0
 /**
  * Get all assets file for assetable entity
  *
  * @param int $assetableId
  * @param string $assetableType
  * @param string $thumbnail
  * @param boolean $single
  *
  * @return array[Asset] or Asset if $single == true
  */
 public static function getAssets($assetableId, $assetableType, $thumbnail = null, $single = false)
 {
     $query = Asset::find()->where(['assetable_id' => $assetableId, 'assetable_type' => $assetableType]);
     if (isset($thumbnail)) {
         if ($thumbnail === false) {
             $query->andWhere(['thumbnail' => null]);
         } else {
             $query->andWhere(['thumbnail' => $thumbnail]);
         }
     }
     if (!$single) {
         return $query->all();
     }
     $asset = $query->one();
     if (isset($asset)) {
         return $asset;
     } else {
         $asset = new Asset();
         $asset->assetable_type = $assetableType;
         return $asset;
     }
 }
Ejemplo n.º 4
0
 /**
  * Get amount of photos in album
  * @return int
  */
 public function getPhotosCount()
 {
     $count = Asset::find()->where(['assetable_id' => $this->id, 'assetable_type' => Asset::ASSETABLE_ALBUM, 'parent_id' => null])->count();
     return $count;
 }
Ejemplo n.º 5
0
 /**
  * Url: /album/{$album_id}-{$slug}/{$photo_id}
  * @param int $album_id Album id
  * @param string $slug Album slug
  * @param $photo_id
  * @return mixed Content
  * @throws NotFoundHttpException
  */
 public function actionPhoto($album_id, $slug, $photo_id)
 {
     $album = Album::find()->where(['id' => $album_id, 'is_public' => 1])->one();
     if (!isset($album)) {
         throw new NotFoundHttpException('Страница не найдена.');
     }
     $photo = Asset::find()->where(['id' => $photo_id, 'thumbnail' => Asset::THUMBNAIL_CONTENT])->one();
     if (!isset($photo)) {
         $photo = Asset::find()->where(['id' => $photo_id])->one();
     }
     if (!isset($photo)) {
         throw new NotFoundHttpException('Страница не найдена.');
     }
     return $this->render('@frontend/views/site/index', ['templateType' => 'col2', 'title' => 'Dynamomania.com | Фотоальбом: ' . $album->title, 'columnFirst' => ['content' => ['view' => '@frontend/views/site/photo_single', 'data' => compact('album', 'photo')], 'comments' => Comment::getCommentsBlock($photo->id, Comment::COMMENTABLE_PHOTO)], 'columnSecond' => ['short_news' => SiteBlock::getshortNews(50)]]);
 }
Ejemplo n.º 6
0
 /**
  * @inheritdoc
  */
 public function afterDelete()
 {
     $this->updateCacheBlocks();
     Tagging::deleteAll(['taggable_type' => Tagging::TAGGABLE_POST, 'taggable_id' => $this->id]);
     Relation::deleteAll(['relationable_type' => Relation::RELATIONABLE_POST, 'relationable_id' => $this->id]);
     Comment::deleteAll(['commentable_type' => Comment::COMMENTABLE_POST, 'commentable_id' => $this->id]);
     CommentCount::deleteAll(['commentable_type' => CommentCount::COMMENTABLE_POST, 'commentable_id' => $this->id]);
     SelectedBlog::deleteAll(['post_id' => $this->id]);
     $assets = Asset::find()->where(['assetable_type' => Asset::ASSETABLE_POST, 'assetable_id' => $this->id])->all();
     foreach ($assets as $asset) {
         $asset->delete();
     }
 }