Album.php 967 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. class Album extends DBObject {
  3. public $Images=array();
  4. public static function GetAlbums($includeHidden=false, $includeEmpty=false) {
  5. $albums=array();
  6. $hidden=$includeHidden?" AND album_hidden=1":"";
  7. $albumIds=self::$PDO->query("SELECT album_id FROM albums WHERE album_deleted=0".$hidden);
  8. while ($albumId=$albumIds->fetchColumn()){
  9. $album=new Album($albumId);
  10. if ($includeEmpty || count($album->Images)>0)
  11. $albums[]=$album;
  12. }
  13. return $albums;
  14. }
  15. public function __construct($id=0,$forceUrl=false) {
  16. $field="album_id";
  17. if ($forceUrl || !is_numeric($id))
  18. $field="album_url";
  19. parent::__construct("albums", $field, $id);
  20. $this->Images=Image::GetImagesByAlbum($this->AlbumId);
  21. }
  22. public function Save() {
  23. if (!isset($this->AlbumUrl) || $this->AlbumUrl==null || $this->AlbumUrl=="")
  24. $this->AlbumUrl=Utils::MakeUniqueURL("albums", "album_url", $this->AlbumTitle);
  25. parent::Save();
  26. }
  27. }