Error_Page.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. require_once(PATH::PAGE . "Page.php");
  3. /**
  4. * Error page model.
  5. */
  6. class Error_Page extends Page{
  7. public $code = "";
  8. public $error_description = "";
  9. public $advice = "";
  10. public $solution = [];
  11. /**
  12. * Constructor.
  13. *
  14. * Retrieves the data and initializes the page.
  15. *
  16. * @param MySQL_connection $db Connection to the database.
  17. * @param string $lang Lowercase, two-letter language code.
  18. */
  19. public function __construct($db, $lang){
  20. global $path;
  21. global $base_url;
  22. parent::__construct($db, $lang);
  23. $this->view = PATH::VIEW . "error.php";
  24. $this->set_view("error.php");
  25. $this->code = http_response_code();
  26. if (in_array($this->code, array(400, 401, 403, 404, 500))){
  27. $err = $this->code;
  28. }
  29. else{
  30. $err = "XXX";
  31. }
  32. $this->error_description = Text::get("ERROR_" . $err . "_DESCRIPTION");
  33. $this->advice = Text::get("ERROR_" . $err . "_SOLUTION");
  34. array_push($this->solution, Text::get("ERROR_" . $err . "_SOLUTION_0"));
  35. array_push($this->solution, Text::get("ERROR_" . $err . "_SOLUTION_1"));
  36. array_push($this->solution, Text::get("ERROR_" . $err . "_SOLUTION_2"));
  37. $this->title = Text::get("ERROR_TITLE") . " " . $this->code . " - " . Text::get("USER_NAME");
  38. $this->description = Text::get("ERROR_TITLE") . " " . $this->code . " - " . Text::get("USER_NAME");
  39. }
  40. }
  41. ?>