Comment.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 Comment {
  19. private string $Id;
  20. private string $UserId;
  21. private string $Summary;
  22. private string $Date;
  23. private string $Content;
  24. public function __construct(string $Id, string $UserId, string $Summary, string $Date, string $Content) {
  25. $this->Id = $Id;
  26. $this->UserId = $UserId;
  27. $this->Summary = $Summary;
  28. $this->Date = $Date;
  29. $this->Content = $Content;
  30. }
  31. public function GetId(): string {
  32. return $this->Id;
  33. }
  34. public function GetUserId(): string {
  35. return $this->UserId;
  36. }
  37. public function GetSummary(): string {
  38. return $this->Summary;
  39. }
  40. public function GetDate(): string {
  41. return $this->Date;
  42. }
  43. public function GetContent(): string {
  44. return $this->Content;
  45. }
  46. public function SetId(string $Id): void {
  47. $this->Id = $Id;
  48. }
  49. public function SetUserId(string $UserId): void {
  50. $this->UserId = $UserId;
  51. }
  52. public function SetSummary(string $Summary): void {
  53. $this->Summary = $Summary;
  54. }
  55. public function SetDate(string $Date): void {
  56. $this->Date = $Date;
  57. }
  58. public function SetContent(string $Content): void {
  59. $this->Content = $Content;
  60. }
  61. public function Render(string $UserName): string {
  62. $HTML = '';
  63. $HTML .= '<div>' . PHP_EOL;
  64. $HTML .= '<span><a href=".?user=' . $this->UserId . '">' . $UserName . '</a></span>' . PHP_EOL;
  65. $HTML .= '<span>' . $this->Date . '</span>' . PHP_EOL;
  66. $HTML .= '<strong>' . $this->Summary . '</strong>' . PHP_EOL;
  67. $HTML .= '<div>' . PHP_EOL;
  68. $HTML .= $this->Content . PHP_EOL;
  69. $HTML .= '</div>' . PHP_EOL;
  70. $HTML .= '</div>' . PHP_EOL;
  71. return $HTML;
  72. }
  73. }