MS-Tropical/app/models/Show.php

82 lines
1.6 KiB
PHP
Raw Permalink Normal View History

<?php
class Show
{
private $ID;
private $Title;
private $ShowID;
private $Thumbnail;
private $Description;
private $EpisodeArray;
private $EpisodeComments;
private $ThumbPath = "/assets/images/Thumbs/Show/";
public string $CommentBox;
public string $CommentForm;
public function __construct($id)
{
$this->ShowID = $id;
$this->CommentForm = render('comments/commentform');
$this->getData();
$this->GetEpisodeList();
}
private function getData()
{
$get = Database::select('projects', '*', 'WHERE showid = :id', data: [':id' => $this->ShowID]);
$data = $get->fetch();
$this->ID = $data["id"];
$this->Title = $data["title"];
$this->Thumbnail = $this->ThumbPath . $data["thumbnail"];
$this->Description = $data["desc"];
}
public function __get($what)
{
return property_exists($this, $what) ? $this->{$what} : null;
}
public function GetEpisodeList()
{
$get = Database::select('episodes', '*', 'WHERE `show` = :s', 'id DESC', data: [':s' => $this->ShowID]);
$episodes = $get->fetchAll();
$this->EpisodeArray = $episodes;
}
public function GetEpisodeComments($id)
{
$get = Database::select('episodecomments', '*', 'WHERE showID = :id', data: [':id' => $id]);
$data = $get->fetchAll();
$list = [];
foreach ($data as $ID) {
$comment = new EpisodeComment($ID['id']);
$poster = new User($comment->Author);
$list[] = render('comments/commentbox', [
'a' => $poster->Avatar,
'u' => $poster->Username,
'c' => BBCode(magicClean($comment->Content)),
'd' => $comment->PostDate
]);
}
return $list;
}
}