Album.php 721 B

123456789101112131415161718192021222324252627
  1. <?php
  2. class Album extends DBObject implements JsonSerializable {
  3. public $Images=array();
  4. public function __construct($id=0,$forceUrl=false) {
  5. $repo=new ImageRepository();
  6. $field="album_id";
  7. if ($forceUrl || !is_numeric($id))
  8. $field="album_url";
  9. parent::__construct("albums", $field, $id);
  10. $this->Images=$repo->GetImagesByAlbum($this->AlbumId);
  11. }
  12. public function Save() {
  13. if (!isset($this->AlbumUrl) || $this->AlbumUrl==null || $this->AlbumUrl=="")
  14. $this->AlbumUrl=Utils::MakeUniqueURL("albums", "album_url", $this->AlbumTitle);
  15. parent::Save();
  16. }
  17. public function jsonSerialize() {
  18. $obj= parent::jsonSerialize();
  19. $obj->Images=$this->Images;
  20. return $obj;
  21. }
  22. }