Landing_Page.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. * @author Iñigo Valentin <i@inigovalentin.com>
  8. * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
  9. * @package SWDB
  10. */
  11. require_once(PATH::PAGE . "Page.php");
  12. /**
  13. * Landing (login) page model.
  14. *
  15. * @category Page
  16. */
  17. class Landing_Page extends Page{
  18. /**
  19. * @var bool Indicates if the user has been redirected to this page after an error.
  20. */
  21. private $is_error = false;
  22. /**
  23. * @var string Error message to show when login was unsuccesfull and
  24. * the user is back in the login page
  25. */
  26. private $error_message = "";
  27. /**
  28. * Constructor.
  29. *
  30. * Retrieves the data and initializes the variables.
  31. */
  32. public function __construct(){
  33. $this->view = PATH::VIEW . "landing.php";
  34. $this->title = "Login - SWDB";
  35. $this->description = "Login to SWDB";
  36. $this->canonical = URL::BASE . "landing/";
  37. if (http_response_code() == 401){
  38. $this->is_error = true;
  39. $this->error_message = "Invalid credentials";
  40. }
  41. }
  42. /**
  43. * Checks if a error has redirected the user to shis page.
  44. *
  45. * @return bool True if there was an error, false otherwise
  46. */
  47. public function is_error(){
  48. return $this->is_error;
  49. }
  50. /**
  51. * Retrieves the error message to show.
  52. *
  53. * @return string Error message.
  54. */
  55. public function get_error_message(){
  56. return $this->error_message;
  57. }
  58. }