Guild_Page.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. public function __construct(){
  35. $this->view = PATH::VIEW . "guild.php";
  36. $s = "
  37. SELECT id
  38. FROM guild
  39. WHERE id = (SELECT guild FROM guild_member WHERE member = '" . get_context()->get_player()->get_id() . "');
  40. ";
  41. $q = get_context()->get_db()->query($s);
  42. $r = $q->fetchArray(SQLITE3_ASSOC);
  43. if ($r){
  44. $guild_id = $r["id"];
  45. $this->guild = new Guild($guild_id);
  46. $this->title = $this->guild->get_name() . " - SWDB";
  47. $this->description = $this->guild->get_name() . " Guild details";
  48. $s = "
  49. SELECT id
  50. FROM guild_skill_group
  51. ORDER BY id;
  52. ";
  53. $q = get_context()->get_db()->query($s);
  54. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  55. array_push($this->skill_groups, new Guild_Skill_Group($r["id"]));
  56. }
  57. }
  58. else{
  59. $this->title = "Guild - SWDB";
  60. $this->description = "No guild";
  61. }
  62. $this->canonical = URL::BASE . "guild/";
  63. }
  64. }
  65. ?>