name = $name;
if (!file_exists($this->get_path())) {
$this->invalidate();
} else {
$this->read();
}
}
private function read() {
$content = file_get_contents($this->get_path() . '/data.json');
if ($content == null) {
$this->invalidate();
return;
}
$root = json_decode($content);
if ($root == null) {
$this->invalidate();
return;
}
$this->title = $root->{'title'};
$this->thumbnail = $root->{'thumbnail'};
$this->images = $root->{'images'};
if (property_exists($root, 'metadata')) {
$this->metadata;
}
}
private function invalidate() {
$this->title = null;
$this->thumbnail = null;
$this->images = null;
}
function is_valid() {
if ($this->title == null || $this->thumbnail == null || $this->images == null) {
return false;
}
if (!is_string($this->title) || !is_string($this->thumbnail) || !is_array($this->images)) {
return false;
}
foreach ($this->images as $image) {
if (!is_string($image)) {
return false;
}
}
unset($image);
return true;
}
function get_name() {
return $this->name;
}
function get_path() {
return AM_OPTIONS['root'] . '/' . $this::PATH_PREFIX . '/'
. $this->name;
}
function get_title() {
return $this->title;
}
function get_thumbnail() {
return $this->get_path() . '/' . $this->thumbnail;
}
function get_small_thumbnail() {
return $this::THUMB_PREFIX . '/small/' . $this->get_name() . '/' . $this->thumbnail;
}
function get_images() {
return $this->images;
}
function get_html() {
$out = '';
if (file_exists($this->get_thumbnail())) {
$type = mime_content_type($this->get_thumbnail());
}
$category = explode('/', $type)[0];
if (!file_exists($this->get_thumbnail())) {
$out .= '';
} else if ($category == 'audio') {
$out .= '';
} else {
$out .= '';
}
$album_len = count($this->get_images());
if ($album_len == 1) {
$out .= '