MS-Tropical/app/classes/Show.php

109 lines
2.0 KiB
PHP
Raw Normal View History

<?php
class Show {
2024-06-29 08:07:30 -05:00
private $ID;
private $Title;
private $ShowID;
private $Thumbnail;
private $Description;
private $EpisodeArray;
2024-06-29 08:07:30 -05:00
private $EpisodeComments;
2024-06-29 08:07:30 -05:00
private $db;
2024-06-29 08:07:30 -05:00
private $ThumbPath = "http://localhost:8888/Resources/Images/Thumbs/Show/";
2024-06-29 08:07:30 -05:00
public function __construct($id) {
2024-06-29 08:07:30 -05:00
$DBM = new DatabaseModule();
$this->db = $DBM->Handle;
2024-06-29 08:07:30 -05:00
$this->ShowID = $id;
2024-06-29 08:07:30 -05:00
$this->CommentBox = GetTemplate('comments/commentbox');
$this->CommentForm = GetTemplate('comments/commentform');
2024-06-29 08:07:30 -05:00
$this->getData();
$this->GetEpisodeList();
2024-06-29 08:07:30 -05:00
}
2024-06-29 08:07:30 -05:00
private function getData() {
2024-06-29 08:07:30 -05:00
$get = $this->db->prepare('SELECT * FROM ms_projects WHERE showid = :id');
$get->bindValue(':id', $this->ShowID, PDO::PARAM_INT); // bind $id to the placeholder
$get->execute();
2024-06-29 08:07:30 -05:00
$data = $get->fetch();
2024-06-29 08:07:30 -05:00
$get->closeCursor();
2024-06-29 08:07:30 -05:00
$this->ID = $data["id"];
$this->Title = $data["title"];
$this->Thumbnail = $this->ThumbPath . $data["thumbnail"];
$this->Description = $data["desc"];
2024-06-29 08:07:30 -05:00
}
2024-06-29 08:07:30 -05:00
public function __get($what) {
2024-06-29 08:07:30 -05:00
if(property_exists($this, $what)) {
2024-06-29 08:07:30 -05:00
return $this->{$what};
2024-06-29 08:07:30 -05:00
} else {
2024-06-29 08:07:30 -05:00
return null;
2024-06-29 08:07:30 -05:00
}
2024-06-29 08:07:30 -05:00
}
2024-06-29 08:07:30 -05:00
public function GetEpisodeList() {
2024-06-29 08:07:30 -05:00
$get = $this->db->prepare("SELECT * FROM episodes WHERE `show` = :s ORDER BY id DESC");
$get->bindValue(':s', $this->ShowID, PDO::PARAM_INT);
$get->execute();
2024-06-29 08:07:30 -05:00
$episodes = $get->fetchAll();
2024-06-29 08:07:30 -05:00
$get->closeCursor();
2024-06-29 08:07:30 -05:00
$this->EpisodeArray = $episodes;
2024-06-29 08:07:30 -05:00
}
2024-06-29 08:07:30 -05:00
public function GetEpisodeComments($id) {
2024-06-29 08:07:30 -05:00
$get = $this->db->prepare('SELECT * FROM episodecomments WHERE showID = :id');
$get->bindValue(':id', $id, PDO::PARAM_INT);
$get->execute();
2024-06-29 08:07:30 -05:00
$data = $get->fetchAll();
2024-06-29 08:07:30 -05:00
$list = array();
2024-06-29 08:07:30 -05:00
foreach($data as $ID) {
2024-06-29 08:07:30 -05:00
$comment = new EpisodeComment($ID['id']);
$poster = new User($comment->Author);
2024-06-29 08:07:30 -05:00
$list[] = ParseTemplate($this->CommentBox, array('a' => $poster->Avatar, 'u' => $poster->Username, 'c' => BBCode(magicClean($comment->Content)), 'd' => $comment->PostDate));
2024-06-29 08:07:30 -05:00
}
2024-06-29 08:07:30 -05:00
return $list;
2024-06-29 08:07:30 -05:00
}
2024-06-29 08:07:30 -05:00
}
2024-06-29 08:07:30 -05:00
?>