Guild_Page.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 . "K_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 \K_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. * @param resource $db Connection to the database.
  35. * @global int Player id.
  36. */
  37. public function __construct($db){
  38. global $UID;
  39. parent::__construct($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 id = '$UID');
  45. ";
  46. // TODO: Where guild.member.player = ...
  47. $q = $this->db->query($s);
  48. $r = $q->fetchArray(SQLITE3_ASSOC);
  49. if ($r){
  50. $guild_id = $r["id"];
  51. $this->guild = new Guild($db, $guild_id);
  52. $this->title = $this->guild->name . " - SWDB";
  53. $this->description = $this->guild->name . " Guild details";
  54. $s = "
  55. SELECT id
  56. FROM k_guild_skill_group
  57. ORDER BY id;
  58. ";
  59. $q = $this->db->query($s);
  60. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  61. array_push($this->skill_groups, new K_Guild_Skill_Group($db, $r["id"]));
  62. }
  63. }
  64. else{
  65. $this->title = "Guild - SWDB";
  66. $this->description = "No guild";
  67. }
  68. $this->canonical = URL::BASE . "guild/";
  69. }
  70. }
  71. ?>