Album.php 1009 B

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