Пример #1
0
 public function actionMedia($type, $cat = 0, $order = 'date', $asc = 'desc', $name = "", $desp = "", $author = "")
 {
     $query;
     $typeid;
     if ($type == 'album') {
         $query = Album::find();
         $typeid = 0;
     } else {
         if ($type == 'video') {
             $query = Video::find();
             $typeid = 1;
         } else {
             $query = Message::find();
             $typeid = 2;
         }
     }
     $pagination = new Pagination(['defaultPageSize' => 30, 'totalCount' => $query->count()]);
     $query->distinct();
     $catArr = [];
     if ($cat) {
         $query->joinWith("category");
         $catArr = explode(',', $cat);
         $query->andWhere(['or', ['bnm_category_relationships.category' => $catArr]]);
     }
     $query->joinWith("editor");
     $query->andFilterWhere(['like', 'bnm_media.name', $name]);
     $query->andFilterWhere(['like', 'bnm_media.desp', $desp]);
     $query->orderBy($order . ' ' . $asc)->offset($pagination->offset)->limit($pagination->limit);
     //->asArray()
     //
     $catQuery = Category::find()->joinWith("categoryRelationship")->andWhere(['bnm_category_relationships.type' => $typeid])->distinct();
     return $this->render('media', ['media' => $query->all(), 'categories' => $catQuery->all(), 'pagination' => $pagination, 'catArr' => $catArr, 'catUrl' => $cat, 'oldCat' => ['cat' => $cat], 'oldOrder' => ['order' => $order, 'asc' => $asc], 'oldSearch' => ['name' => $name, 'desp' => $desp, 'author' => $author], 'type' => $type, 'typeid' => $typeid, 'asc' => $asc, 'order' => $order, 'name' => $name, 'desp' => $desp, 'author' => $author]);
 }
Пример #2
0
 public function testSync()
 {
     $this->expectsEvents(LibraryChanged::class);
     $media = new Media();
     $media->sync($this->mediaPath);
     // Standard mp3 files under root path should be recognized
     $this->seeInDatabase('songs', ['path' => $this->mediaPath . '/full.mp3']);
     // Ogg files and audio files in subdirectories should be recognized
     $this->seeInDatabase('songs', ['path' => $this->mediaPath . '/subdir/back-in-black.ogg']);
     // File search shouldn't be case-sensitive.
     $this->seeInDatabase('songs', ['path' => $this->mediaPath . '/subdir/no-name.MP3']);
     // Non-audio files shouldn't be recognized
     $this->notSeeInDatabase('songs', ['path' => $this->mediaPath . '/rubbish.log']);
     // Broken/corrupted audio files shouldn't be recognized
     $this->notSeeInDatabase('songs', ['path' => $this->mediaPath . '/fake.mp3']);
     // Artists should be created
     $this->seeInDatabase('artists', ['name' => 'Cuckoo']);
     $this->seeInDatabase('artists', ['name' => 'Koel']);
     // Albums should be created
     $this->seeInDatabase('albums', ['name' => 'Koel Testing Vol. 1']);
     // Albums and artists should be correctly linked
     $album = Album::whereName('Koel Testing Vol. 1')->first();
     $this->assertEquals('Koel', $album->artist->name);
     $currentCover = $album->cover;
     $song = Song::orderBy('id', 'desc')->first();
     // Modified file should be recognized
     touch($song->path, $time = time());
     $media->sync($this->mediaPath);
     $song = Song::find($song->id);
     $this->assertEquals($time, $song->mtime);
     // Albums with a non-default cover should have their covers overwritten
     $this->assertEquals($currentCover, Album::find($album->id)->cover);
 }
 public function delete(Request $request)
 {
     $album = Album::find($request->input('id'));
     foreach ($album->photos as $photo) {
         if (File::exists($photo->image_url)) {
             File::delete($photo->image_url);
         }
     }
     $album->delete();
     return response()->json(['message' => 'Альбом удален.']);
 }
 /**
  * Create new photo and add it to the album.
  *
  * @param Request $request
  * @return mixed
  */
 public function create(Request $request)
 {
     //get the file from the post request
     $file = $request->file('file');
     //set file name
     $filename = uniqid() . $file->getClientOriginalName();
     //move the file to correct location
     $file->move('uploads/albums', $filename);
     //save the image details to the database
     $album = Album::find($request->input('album_id'));
     $photo = $album->photos()->create(['title' => $filename, 'image_url' => 'uploads/albums/' . $filename]);
     return $photo;
 }
Пример #5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Album::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'fecha_lanzamiento' => $this->fecha_lanzamiento]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'artista', $this->artista]);
     return $dataProvider;
 }
Пример #6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Album::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('subTag')->joinWith('mainTag')->andFilterWhere(['id' => $this->id, 'article_type_id' => $this->article_type_id, 'sub_tag' => $this->sub_tag, 'main_tag' => $this->main_tag, 'create_date' => $this->create_date])->andFilterWhere(['like', 'album_name_ar', $this->album_name_ar])->andFilterWhere(['like', 'album_name_en', $this->album_name_en])->andFilterWhere(['like', 'status', $this->status]);
     //->andFilterWhere(['like', 'CONCAT(full_name,username)', $this->created_by]);
     return $dataProvider;
 }
Пример #7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Album::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_dt' => $this->created_dt]);
     $query->andFilterWhere(['like', 'ref', $this->ref])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Пример #8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Album::find();
     $query->joinWith(['editor']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['editor'] = ['asc' => ['bnm_users.name' => SORT_ASC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['ID' => $this->ID, 'user' => $this->user, 'date' => $this->date, 'type' => $this->type]);
     $query->andFilterWhere(['like', 'bnm_media.name', $this->name])->andFilterWhere(['like', 'desp', $this->desp])->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'bnm_users.name', $this->editor])->andFilterWhere(['like', 'thumbnail', $this->thumbnail]);
     return $dataProvider;
 }
Пример #9
0
 public function testSync()
 {
     $this->expectsEvents(LibraryChanged::class);
     $media = new Media();
     $media->sync($this->mediaPath);
     // Standard mp3 files under root path should be recognized
     $this->seeInDatabase('songs', ['path' => $this->mediaPath . '/full.mp3', 'track' => 5]);
     // Ogg files and audio files in subdirectories should be recognized
     $this->seeInDatabase('songs', ['path' => $this->mediaPath . '/subdir/back-in-black.ogg']);
     // GitHub issue #380. folder.png should be copied and used as the cover for files
     // under subdir/
     $song = Song::wherePath($this->mediaPath . '/subdir/back-in-black.ogg')->first();
     $this->assertNotNull($song->album->cover);
     // File search shouldn't be case-sensitive.
     $this->seeInDatabase('songs', ['path' => $this->mediaPath . '/subdir/no-name.MP3']);
     // Non-audio files shouldn't be recognized
     $this->notSeeInDatabase('songs', ['path' => $this->mediaPath . '/rubbish.log']);
     // Broken/corrupted audio files shouldn't be recognized
     $this->notSeeInDatabase('songs', ['path' => $this->mediaPath . '/fake.mp3']);
     // Artists should be created
     $this->seeInDatabase('artists', ['name' => 'Cuckoo']);
     $this->seeInDatabase('artists', ['name' => 'Koel']);
     // Albums should be created
     $this->seeInDatabase('albums', ['name' => 'Koel Testing Vol. 1']);
     // Albums and artists should be correctly linked
     $album = Album::whereName('Koel Testing Vol. 1')->first();
     $this->assertEquals('Koel', $album->artist->name);
     // Compilation albums, artists and songs must be recognized
     $song = Song::whereTitle('This song belongs to a compilation')->first();
     $this->assertNotNull($song->contributing_artist_id);
     $this->assertTrue($song->album->is_compilation);
     $this->assertEquals(Artist::VARIOUS_ID, $song->album->artist_id);
     $currentCover = $album->cover;
     $song = Song::orderBy('id', 'desc')->first();
     // Modified file should be recognized
     touch($song->path, $time = time());
     $media->sync($this->mediaPath);
     $song = Song::find($song->id);
     $this->assertEquals($time, $song->mtime);
     // Albums with a non-default cover should have their covers overwritten
     $this->assertEquals($currentCover, Album::find($album->id)->cover);
 }
Пример #10
0
      <?php 
echo $form->field($model, 'name');
?>

      <p><?php 
echo Yii::t('yii', 'Альбом');
?>
</p>
      <div class="select_albums">
        <?php 
if ($sAlbum != "") {
    $model->id_album = $sAlbum;
}
?>
        <?php 
echo $form->field($model, 'id_album')->dropDownList(ArrayHelper::map($albums = \app\models\Album::find()->where(['id_user' => Yii::$app->user->getId()])->asArray()->all(), 'id', 'name'), ['prompt' => Yii::t('yii', 'Выберите альбом')]);
?>
          <a href='/album_add' class="select_albums_edit"><?php 
echo Yii::t('yii', 'Создать альбом');
?>
</a>
        </div>


        <p><?php 
echo Yii::t('yii', 'Метки');
?>
</p>
        <div data-choices-marks></div>
        <div class='row'>
          <div class='col_8'>
Пример #11
0
 public function actionIndex()
 {
     $albums = Album::find()->select(['*'])->joinWith($this->_getClassBaseName(new Photos()))->where(['main_photo' => 1])->asArray()->all();
     return $this->render('albums', compact('albums'));
 }
Пример #12
0
        </div>
        <div class="left_settings || album_add_left">
        <p><?php 
echo Yii::t('yii', 'Название альбома');
?>
</p>
            <?php 
echo $form->field($model, 'name')->textInput();
?>
            <div class="album_add_row">
                <p><?php 
echo Yii::t('yii', 'Выберите родительский альбом');
?>
</p>
                <?php 
echo $form->field($model, 'parent_id')->dropDownList(\yii\helpers\ArrayHelper::map(\app\models\Album::find()->select('id, name')->where(['id_user' => Yii::$app->user->getId()])->andWhere(['parent_id' => 0])->all(), 'id', 'name'), ['prompt' => Yii::t('yii', 'Нет родительского альбома')]);
?>
                    </div>
                    <div class="album_privacy_type">
                        <div class="album_add_row">
                            <input type="radio" class="custom-element" name="custom-radio" checked id="regular_mode" />
                            <label for="regular_mode"><?php 
echo Yii::t('yii', 'Обычный режим');
?>
</label>
                        </div>
                        <div class="album_add_row">
                           <input type="radio" class="custom-element" name="custom-radio" id="for_friends" />
                           <label for="for_friends" class="for_friends"><?php 
echo Yii::t('yii', 'Для друзей');
?>
Пример #13
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $album = Album::find($id);
     $album->delete();
     return Redirect::route('/albums');
 }