Movie.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <?php
  2. /*
  3. * Copyright (C) 2021 Echedey López Romero <elr@disroot.org>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. class Movie {
  19. private $Id;
  20. private $Title;
  21. private $Poster;
  22. private $Rate;
  23. private $Release;
  24. private $Genres;
  25. private $Plot;
  26. private $Cast;
  27. private $ImageURL;
  28. private $DefaultImage;
  29. public function __construct($Id, $Title, $Poster, $Rate, $Release, $Genres,
  30. $Plot, $Cast, $ImageURL, $DefaultImage) {
  31. $this->Id = $Id;
  32. $this->Title = $Title;
  33. $this->Poster = $Poster;
  34. $this->Rate = $Rate;
  35. $this->Release = $Release;
  36. $this->Genres = $Genres;
  37. $this->Plot = $Plot;
  38. $this->Cast = $Cast;
  39. $this->ImageURL = $ImageURL;
  40. $this->DefaultImage = $DefaultImage;
  41. }
  42. public function RenderCard() {
  43. $HTML = '';
  44. $HTML .= '<div class="col mb-3 mx-auto">' . PHP_EOL;
  45. $HTML .= '<div class="card">' . PHP_EOL;
  46. if ($this->Poster !== null && $this->Poster !== '') {
  47. $HTML .= '<img src="' . $this->ImageURL . $this->Poster
  48. . '" class="card-img-top" alt="' . $this->Title . '"/>'
  49. . PHP_EOL;
  50. } else {
  51. $HTML .= '<img src="' . $this->DefaultImage . '" '
  52. . 'class="card-img-top" alt="Not specified"/>' . PHP_EOL;
  53. }
  54. $HTML .= '<div class="card-body">' . PHP_EOL;
  55. $HTML .= '<div class="card-title">' . PHP_EOL;
  56. $HTML .= '<div class="container-fluid">' . PHP_EOL;
  57. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  58. $HTML .= '<span class="col-5 d-block mx-auto px-0 border '
  59. . 'border-secondary rounded-pill font-weight-bold text-center '
  60. . 't-large">' . $this->Rate . '</span>' . PHP_EOL;
  61. $HTML .= '</div>' . PHP_EOL;
  62. $HTML .= '<div class="row">' . PHP_EOL;
  63. $HTML .= '<span class="col-12 d-block px-0 t-large">'
  64. . $this->Title . '</span>' . PHP_EOL;
  65. $HTML .= '</div>' . PHP_EOL;
  66. $HTML .= '</div>' . PHP_EOL;
  67. $HTML .= '</div>' . PHP_EOL;
  68. $HTML .= '<a class="btn btn-block btn-lg btn-primary" href=".?movie='
  69. . $this->Id . '">Show details</a>' . PHP_EOL;
  70. $HTML .= '</div>' . PHP_EOL;
  71. $HTML .= '</div>' . PHP_EOL;
  72. $HTML .= '</div>' . PHP_EOL;
  73. return $HTML;
  74. }
  75. public function RenderContent() {
  76. $HTML = '';
  77. $HTML .= '<div class="col-lg-10 col-12 mx-auto px-0">' . PHP_EOL;
  78. $HTML .= '<div class="container-fluid border border-primary rounded">'
  79. . PHP_EOL;
  80. $HTML .= '<div class="row my-3">' . PHP_EOL;
  81. $HTML .= '<div class="col"></div>' . PHP_EOL;
  82. $HTML .= '<h2 class="col-xl-6 col-lg-4 col-md-5 col-12 mb-lg-0 mb-2 '
  83. . 'text-center">Movie</h2>' . PHP_EOL;
  84. $HTML .= '<div class="col text-center">' . PHP_EOL;
  85. $HTML .= '<a class="h-100 btn btn-block btn-secondary t-large" '
  86. . 'href=".">Return</a>' . PHP_EOL;
  87. $HTML .= '</div>' . PHP_EOL;
  88. $HTML .= '</div>' . PHP_EOL;
  89. $HTML .= '<div class="row">' . PHP_EOL;
  90. $HTML .= '<div class="col-lg-4 col-md-6 col-12 mx-auto mb-3">'
  91. . PHP_EOL;
  92. if ($this->Poster !== null && $this->Poster !== '') {
  93. $HTML .= '<img src="' . $this->ImageURL . $this->Poster . '" '
  94. . 'class="d-block w-100 mx-auto" alt="' . $this->Title
  95. . '"/>' . PHP_EOL;
  96. } else {
  97. $HTML .= '<img src="' . $this->DefaultImage . '" class="d-block '
  98. . 'w-100 mx-auto" alt="Not specified"/>' . PHP_EOL;
  99. }
  100. $HTML .= '</div>' . PHP_EOL;
  101. $HTML .= '<div class="col-lg-8 col-12 mb-3">' . PHP_EOL;
  102. $HTML .= '<div class="container-fluid border border-secondary rounded">'
  103. . PHP_EOL;
  104. $HTML .= '<div class="row my-3">' . PHP_EOL;
  105. $HTML .= '<h3 class="col-12 mb-0">' . PHP_EOL;
  106. $HTML .= $this->Title . PHP_EOL;
  107. $HTML .= '</h3>' . PHP_EOL;
  108. $HTML .= '</div>' . PHP_EOL;
  109. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  110. $HTML .= '<span class="col-sm-6 col-12 mb-sm-0 mb-3"><span '
  111. . 'class="t-large">Rate:</span> ' . PHP_EOL;
  112. $HTML .= $this->Rate . PHP_EOL;
  113. $HTML .= '</span>' . PHP_EOL;
  114. $HTML .= '<span class="col-sm-6 col-12"><span class="t-large">'
  115. . 'Release:</span> ' . PHP_EOL;
  116. if ($this->Release !== null && $this->Release !== '') {
  117. $HTML .= date("d/m/Y",
  118. strtotime(str_replace('-"', '/', $this->Release)))
  119. . PHP_EOL;
  120. } else {
  121. $HTML .= 'Not specified' . PHP_EOL;
  122. }
  123. $HTML .= '</span>' . PHP_EOL;
  124. $HTML .= '</div>' . PHP_EOL;
  125. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  126. $HTML .= '<div class="col-12">' . PHP_EOL;
  127. $HTML .= '<div class="container">' . PHP_EOL;
  128. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  129. $HTML .= '<h4 class="col-12 mb-0 px-0">Genres</h4>' . PHP_EOL;
  130. $HTML .= '</div>' . PHP_EOL;
  131. $HTML .= '<div class="row">' . PHP_EOL;
  132. $HTML .= '<p class="col-12 mb-0 px-0">' . PHP_EOL;
  133. if ($this->Genres !== null && count($this->Genres) !== 0) {
  134. for ($Position = 0; $Position < count($this->Genres); $Position++) {
  135. if ($Position !== count($this->Genres) - 1) {
  136. $HTML .= $this->Genres[$Position] . ', ';
  137. } else {
  138. $HTML .= $this->Genres[$Position] . PHP_EOL;
  139. }
  140. }
  141. } else {
  142. $HTML .= 'Not specified' . PHP_EOL;
  143. }
  144. $HTML .= '</p>' . PHP_EOL;
  145. $HTML .= '</div>' . PHP_EOL;
  146. $HTML .= '</div>' . PHP_EOL;
  147. $HTML .= '</div>' . PHP_EOL;
  148. $HTML .= '</div>' . PHP_EOL;
  149. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  150. $HTML .= '<div class="col-12">' . PHP_EOL;
  151. $HTML .= '<div class="container">' . PHP_EOL;
  152. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  153. $HTML .= '<h4 class="col-12 mb-0 px-0">Plot<h4>' . PHP_EOL;
  154. $HTML .= '</div>' . PHP_EOL;
  155. $HTML .= '<div class="row">' . PHP_EOL;
  156. $HTML .= '<p class="col-12 mb-0 px-0">' . PHP_EOL;
  157. if ($this->Plot !== null && $this->Plot !== '') {
  158. $HTML .= $this->Plot . PHP_EOL;
  159. } else {
  160. $HTML .= 'Not specified' . PHP_EOL;
  161. }
  162. $HTML .= '</p>' . PHP_EOL;
  163. $HTML .= '</div>' . PHP_EOL;
  164. $HTML .= '</div>' . PHP_EOL;
  165. $HTML .= '</div>' . PHP_EOL;
  166. $HTML .= '</div>' . PHP_EOL;
  167. $HTML .= '<div class="row mb-3">' . PHP_EOL;
  168. $HTML .= '<div class="col-12">' . PHP_EOL;
  169. $HTML .= '<div class="container">' . PHP_EOL;
  170. $HTML .= '<div class="row mb-2">' . PHP_EOL;
  171. $HTML .= '<h4 class="col-12 mb-0 px-0">Cast</h4>' . PHP_EOL;
  172. $HTML .= '</div>' . PHP_EOL;
  173. $HTML .= '<div class="row">' . PHP_EOL;
  174. $HTML .= '<p class="col-12 mb-0 px-0">' . PHP_EOL;
  175. if ($this->Cast !== null && count($this->Cast) !== 0) {
  176. for ($Position = 0; $Position < count($this->Cast); $Position++) {
  177. if ($this->Cast[$Position]['name'] !== null && $this->Cast[$Position]['character'] !== '') {
  178. $HTML .= $this->Cast[$Position]['character'];
  179. } else {
  180. $HTML .= 'Not specified';
  181. }
  182. $HTML .= ' (<a href=".?person=' . $this->Cast[$Position]['id']
  183. . '">' . $this->Cast[$Position]['name'] . '</a>)';
  184. if ($Position !== count($this->Cast) - 1) {
  185. $HTML .= ', ' . PHP_EOL;
  186. } else {
  187. $HTML .= '.' . PHP_EOL;
  188. }
  189. }
  190. } else {
  191. $HTML .= 'Not specified' . PHP_EOL;
  192. }
  193. $HTML .= '</p>' . PHP_EOL;
  194. $HTML .= '</div>' . PHP_EOL;
  195. $HTML .= '</div>' . PHP_EOL;
  196. $HTML .= '</div>' . PHP_EOL;
  197. $HTML .= '</div>' . PHP_EOL;
  198. $HTML .= '</div>' . PHP_EOL;
  199. $HTML .= '</div>' . PHP_EOL;
  200. $HTML .= '</div>' . PHP_EOL;
  201. $HTML .= '</div>' . PHP_EOL;
  202. $HTML .= '</div>' . PHP_EOL;
  203. $HTML .= '</div>' . PHP_EOL;
  204. return $HTML;
  205. }
  206. }