Page.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. require_once($path["entity"] . "Sponsor.php");
  3. /**
  4. * Page superclass.
  5. *
  6. * Every visitable page type must inherit from this one.
  7. */
  8. abstract class Page{
  9. /**
  10. * Database connection.
  11. */
  12. public $db;
  13. /**
  14. * Template associated with the page.
  15. */
  16. public $template;
  17. /**
  18. * Language the page will be served on (lowercase, two-letter
  19. * language code).
  20. */
  21. public $lang;
  22. /**
  23. * Title of the page, in the defined language.
  24. */
  25. public $title;
  26. /**
  27. * Site name.
  28. */
  29. public $name;
  30. /**
  31. * Page description, in the defined language.
  32. */
  33. public $description;
  34. /**
  35. * Path to the site favicon.
  36. */
  37. public $favicon;
  38. /**
  39. * Path to the page icon or main image.
  40. */
  41. public $icon;
  42. /**
  43. * Canonical URL.
  44. */
  45. public $canonical;
  46. /**
  47. * Author URL.
  48. */
  49. public $author;
  50. /**
  51. * String array for the layout texts
  52. */
  53. public $string;
  54. /**
  55. * List of {@see Sponsor}.
  56. */
  57. public $sponsor = [];
  58. /**
  59. * Constructor.
  60. *
  61. * @param db Connection to the database.
  62. * @param lang Lowercase, two-letter language code.
  63. */
  64. public function __construct($db, $lang){
  65. global $static;
  66. global $base_url;
  67. global $path;
  68. global $data;
  69. $this->db = $db;
  70. $this->lang = $lang;
  71. require_once($path["string"] . "lang_" . $lang . ".php");
  72. $this->string = $string;
  73. $this->favicon = $static["layout"] . "logo/logo.svg";
  74. $this->icon = $static["layout"] . "logo/logo.svg";
  75. $this->name = $data["name"];
  76. $this->author = $data["name"];
  77. $s_sponsor =
  78. "SELECT id " .
  79. "FROM sponsor " .
  80. "WHERE ammount > 0 " .
  81. "ORDER BY ammount DESC;";
  82. $q_sponsor = mysqli_query($this->db, $s_sponsor);
  83. while($r_sponsor = mysqli_fetch_array($q_sponsor)){
  84. array_push($this->sponsor, new Sponsor($this->db, $this->lang, $r_sponsor["id"]));
  85. }
  86. }
  87. }
  88. ?>