Page.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * Page superclass.
  4. *
  5. * Every visitable page type must inherit from this one.
  6. */
  7. abstract class Page{
  8. /**
  9. * Database connection.
  10. */
  11. public $db;
  12. /**
  13. * View associated with the page.
  14. */
  15. public $view;
  16. /**
  17. * Language the page will be served on (lowercase, two-letter
  18. * language code).
  19. */
  20. public $lang;
  21. /**
  22. * List of available {@see Lang}uages (lowercase, two-letter language code).
  23. */
  24. public $available_langs = [];
  25. /**
  26. * Title of the page, in the defined language.
  27. */
  28. public $title;
  29. /**
  30. * Site name.
  31. */
  32. public $name;
  33. /**
  34. * Page description, in the defined language.
  35. */
  36. public $description;
  37. /**
  38. * Path to the site favicon.
  39. */
  40. public $favicon;
  41. /**
  42. * Path to the page icon or main image.
  43. */
  44. public $icon;
  45. /**
  46. * Canonical URL.
  47. */
  48. public $canonical;
  49. /**
  50. * Author URL.
  51. */
  52. public $author;
  53. /**
  54. * Constructor.
  55. *
  56. * @param MySQL_connection $db Connection to the database.
  57. * @param string $lang Lowercase, two-letter language code.
  58. */
  59. public function __construct($db, $lang){
  60. global $static;
  61. global $base_url;
  62. $this->db = $db;
  63. $this->lang = $lang;
  64. $s_lang =
  65. "SELECT code AS id " .
  66. "FROM lang " .
  67. "WHERE active = 1; ";
  68. $q_lang = mysqli_query($db, $s_lang);
  69. while($r_lang = mysqli_fetch_array($q_lang)){
  70. array_push($this->available_langs, new Lang($db, $r_lang["id"]));
  71. }
  72. $this->favicon = $static["layout"] . "logo/logo.svg";
  73. $this->icon = $static["layout"] . "logo/logo.svg";
  74. $this->name = text($this, "USER_NAME");
  75. $this->author = $base_url;
  76. $this->name = text($this, "USER_NAME");
  77. }
  78. }
  79. ?>