123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- <?php
- /*
- * Copyright (C) 2021 Echedey López Romero <elr@disroot.org>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- class Movie {
- private $Id;
- private $Title;
- private $Poster;
- private $Rate;
- private $Release;
- private $Genres;
- private $Plot;
- private $Cast;
- private $ImageURL;
- private $DefaultImage;
- public function __construct($Id, $Title, $Poster, $Rate, $Release, $Genres,
- $Plot, $Cast, $ImageURL, $DefaultImage) {
- $this->Id = $Id;
- $this->Title = $Title;
- $this->Poster = $Poster;
- $this->Rate = $Rate;
- $this->Release = $Release;
- $this->Genres = $Genres;
- $this->Plot = $Plot;
- $this->Cast = $Cast;
- $this->ImageURL = $ImageURL;
- $this->DefaultImage = $DefaultImage;
- }
- public function RenderCard() {
- $HTML = '';
- $HTML .= '<div class="col mb-3 mx-auto">' . PHP_EOL;
- $HTML .= '<div class="card">' . PHP_EOL;
- if ($this->Poster !== null && $this->Poster !== '') {
- $HTML .= '<img src="' . $this->ImageURL . $this->Poster
- . '" class="card-img-top" alt="' . $this->Title . '"/>'
- . PHP_EOL;
- } else {
- $HTML .= '<img src="' . $this->DefaultImage . '" '
- . 'class="card-img-top" alt="Not specified"/>' . PHP_EOL;
- }
- $HTML .= '<div class="card-body">' . PHP_EOL;
- $HTML .= '<div class="card-title">' . PHP_EOL;
- $HTML .= '<div class="container-fluid">' . PHP_EOL;
- $HTML .= '<div class="row mb-2">' . PHP_EOL;
- $HTML .= '<span class="col-5 d-block mx-auto px-0 border '
- . 'border-secondary rounded-pill font-weight-bold text-center '
- . 't-large">' . $this->Rate . '</span>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
-
- $HTML .= '<div class="row">' . PHP_EOL;
- $HTML .= '<span class="col-12 d-block px-0 t-large">'
- . $this->Title . '</span>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
-
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '<a class="btn btn-block btn-lg btn-primary" href=".?movie='
- . $this->Id . '">Show details</a>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- return $HTML;
- }
- public function RenderContent() {
- $HTML = '';
- $HTML .= '<div class="col-lg-10 col-12 mx-auto px-0">' . PHP_EOL;
- $HTML .= '<div class="container-fluid border border-primary rounded">'
- . PHP_EOL;
- $HTML .= '<div class="row my-3">' . PHP_EOL;
- $HTML .= '<div class="col"></div>' . PHP_EOL;
- $HTML .= '<h2 class="col-xl-6 col-lg-4 col-md-5 col-12 mb-lg-0 mb-2 '
- . 'text-center">Movie</h2>' . PHP_EOL;
- $HTML .= '<div class="col text-center">' . PHP_EOL;
- $HTML .= '<a class="h-100 btn btn-block btn-secondary t-large" '
- . 'href=".">Return</a>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '<div class="row">' . PHP_EOL;
- $HTML .= '<div class="col-lg-4 col-md-6 col-12 mx-auto mb-3">'
- . PHP_EOL;
- if ($this->Poster !== null && $this->Poster !== '') {
- $HTML .= '<img src="' . $this->ImageURL . $this->Poster . '" '
- . 'class="d-block w-100 mx-auto" alt="' . $this->Title
- . '"/>' . PHP_EOL;
- } else {
- $HTML .= '<img src="' . $this->DefaultImage . '" class="d-block '
- . 'w-100 mx-auto" alt="Not specified"/>' . PHP_EOL;
- }
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '<div class="col-lg-8 col-12 mb-3">' . PHP_EOL;
- $HTML .= '<div class="container-fluid border border-secondary rounded">'
- . PHP_EOL;
- $HTML .= '<div class="row my-3">' . PHP_EOL;
- $HTML .= '<h3 class="col-12 mb-0">' . PHP_EOL;
- $HTML .= $this->Title . PHP_EOL;
- $HTML .= '</h3>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
-
- $HTML .= '<div class="row mb-3">' . PHP_EOL;
- $HTML .= '<span class="col-sm-6 col-12 mb-sm-0 mb-3"><span '
- . 'class="t-large">Rate:</span> ' . PHP_EOL;
- $HTML .= $this->Rate . PHP_EOL;
- $HTML .= '</span>' . PHP_EOL;
- $HTML .= '<span class="col-sm-6 col-12"><span class="t-large">'
- . 'Release:</span> ' . PHP_EOL;
- if ($this->Release !== null && $this->Release !== '') {
- $HTML .= date("d/m/Y",
- strtotime(str_replace('-"', '/', $this->Release)))
- . PHP_EOL;
- } else {
- $HTML .= 'Not specified' . PHP_EOL;
- }
- $HTML .= '</span>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '<div class="row mb-3">' . PHP_EOL;
- $HTML .= '<div class="col-12">' . PHP_EOL;
- $HTML .= '<div class="container">' . PHP_EOL;
- $HTML .= '<div class="row mb-2">' . PHP_EOL;
- $HTML .= '<h4 class="col-12 mb-0 px-0">Genres</h4>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '<div class="row">' . PHP_EOL;
- $HTML .= '<p class="col-12 mb-0 px-0">' . PHP_EOL;
- if ($this->Genres !== null && count($this->Genres) !== 0) {
- for ($Position = 0; $Position < count($this->Genres); $Position++) {
- if ($Position !== count($this->Genres) - 1) {
- $HTML .= $this->Genres[$Position] . ', ';
- } else {
- $HTML .= $this->Genres[$Position] . PHP_EOL;
- }
- }
- } else {
- $HTML .= 'Not specified' . PHP_EOL;
- }
- $HTML .= '</p>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '<div class="row mb-3">' . PHP_EOL;
- $HTML .= '<div class="col-12">' . PHP_EOL;
- $HTML .= '<div class="container">' . PHP_EOL;
- $HTML .= '<div class="row mb-2">' . PHP_EOL;
- $HTML .= '<h4 class="col-12 mb-0 px-0">Plot<h4>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '<div class="row">' . PHP_EOL;
- $HTML .= '<p class="col-12 mb-0 px-0">' . PHP_EOL;
- if ($this->Plot !== null && $this->Plot !== '') {
- $HTML .= $this->Plot . PHP_EOL;
- } else {
- $HTML .= 'Not specified' . PHP_EOL;
- }
- $HTML .= '</p>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '<div class="row mb-3">' . PHP_EOL;
- $HTML .= '<div class="col-12">' . PHP_EOL;
- $HTML .= '<div class="container">' . PHP_EOL;
- $HTML .= '<div class="row mb-2">' . PHP_EOL;
- $HTML .= '<h4 class="col-12 mb-0 px-0">Cast</h4>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '<div class="row">' . PHP_EOL;
- $HTML .= '<p class="col-12 mb-0 px-0">' . PHP_EOL;
- if ($this->Cast !== null && count($this->Cast) !== 0) {
- for ($Position = 0; $Position < count($this->Cast); $Position++) {
- if ($this->Cast[$Position]['name'] !== null && $this->Cast[$Position]['character'] !== '') {
- $HTML .= $this->Cast[$Position]['character'];
- } else {
- $HTML .= 'Not specified';
- }
- $HTML .= ' (<a href=".?person=' . $this->Cast[$Position]['id']
- . '">' . $this->Cast[$Position]['name'] . '</a>)';
- if ($Position !== count($this->Cast) - 1) {
- $HTML .= ', ' . PHP_EOL;
- } else {
- $HTML .= '.' . PHP_EOL;
- }
- }
- } else {
- $HTML .= 'Not specified' . PHP_EOL;
- }
- $HTML .= '</p>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- $HTML .= '</div>' . PHP_EOL;
- return $HTML;
- }
- }
|