AlbumRepository.php 956 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. class AlbumRepository extends BaseRepository implements IAlbumRepository {
  3. /**
  4. * @var IImageRepository
  5. */
  6. private $_imageRepo;
  7. public function __construct() {
  8. parent::__construct();
  9. $this->_imageRepo=new ImageRepository();
  10. }
  11. public function GetAlbums($includeHidden=false, $includeEmpty=false, $includeOrphanImages=false) {
  12. if ($includeOrphanImages){
  13. $noAlbum=new Album();
  14. $noAlbum->AlbumId=0;
  15. $noAlbum->AlbumTitle="No Album";
  16. $noAlbum->AlbumDescription="Images without an album";
  17. $noAlbum->Images=$this->_imageRepo->GetImagesByAlbum(0);
  18. $albums=array(
  19. $noAlbum
  20. );
  21. }
  22. $hidden=$includeHidden?" OR album_hidden=1":"";
  23. $albumIds=self::$PDO->query("SELECT album_id FROM albums WHERE album_deleted=0 AND album_hidden=0".$hidden);
  24. while ($albumId=$albumIds->fetchColumn()){
  25. $album=new Album($albumId);
  26. if ($includeEmpty || count($album->Images)>0)
  27. $albums[]=$album;
  28. }
  29. return $albums;
  30. }
  31. }