Error_Page.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Landing (login) page file.
  4. *
  5. * Provides a class with all the properties and methods to display the page.
  6. *
  7. * @category Page
  8. */
  9. /**
  10. * Require dependent files if not present.
  11. */
  12. require_once(PATH::PAGE . "Page.php");
  13. /**
  14. * Error page model.
  15. *
  16. * @category Page
  17. */
  18. class Error_Page extends Page{
  19. /**
  20. * @var int Error code.
  21. *
  22. * HTTP status code.
  23. */
  24. public $code = 500;
  25. /**
  26. * Constructor.
  27. *
  28. * Retrieves the data and initializes the variables.
  29. *
  30. * @param int code Error code. Optional.
  31. */
  32. public function __construct($code = null){
  33. $this->view = PATH::VIEW . "error.php";
  34. $this->title = "Error - SWDB";
  35. if (null == $code || intval($code) < 200 || intval($code) > 599){
  36. $code = 500;
  37. }
  38. switch(intval($code)){
  39. case 400:
  40. $this->description = "Invalid request";
  41. break;
  42. case 404:
  43. $this->description = "Not found";
  44. break;
  45. case 500:
  46. $this->description = "Server error";
  47. break;
  48. default:
  49. $this->description = "Unknown error";
  50. }
  51. $this->code = intval($code);
  52. }
  53. }
  54. ?>