Guild_Page.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * Guild 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. require_once(PATH::ENTITY . "Guild.php");
  14. require_once(PATH::ENTITY . "Guild_Skill_Group.php");
  15. /**
  16. * Guild page model.
  17. *
  18. * @category Page
  19. */
  20. class Guild_Page extends Page{
  21. /**
  22. * @var Guild Player guild.
  23. */
  24. public $guild;
  25. /**
  26. * @var \Guild_Skill_Group[] List of Guild skill groups.
  27. */
  28. public $skill_groups = [];
  29. /**
  30. * Constructor.
  31. *
  32. * Retrieves the data and initializes the variables.
  33. *
  34. * @global Player Currenty selected player.
  35. * @global resource Connection to the database.
  36. */
  37. public function __construct(){
  38. global $PLAYER;
  39. global $db;
  40. $this->view = PATH::VIEW . "guild.php";
  41. $s = "
  42. SELECT id
  43. FROM guild
  44. WHERE id = (SELECT guild FROM guild_member WHERE member = '" . $PLAYER->id . "');
  45. ";
  46. $q = $db->query($s);
  47. $r = $q->fetchArray(SQLITE3_ASSOC);
  48. if ($r){
  49. $guild_id = $r["id"];
  50. $this->guild = new Guild($guild_id);
  51. $this->title = $this->guild->name . " - SWDB";
  52. $this->description = $this->guild->name . " Guild details";
  53. $s = "
  54. SELECT id
  55. FROM guild_skill_group
  56. ORDER BY id;
  57. ";
  58. $q = $db->query($s);
  59. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  60. array_push($this->skill_groups, new Guild_Skill_Group($r["id"]));
  61. }
  62. }
  63. else{
  64. $this->title = "Guild - SWDB";
  65. $this->description = "No guild";
  66. }
  67. $this->canonical = URL::BASE . "guild/";
  68. }
  69. }
  70. ?>