Guild_Page.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. require_once($path["page"] . "Page.php");
  3. require_once($path["entity"] . "Guild.php");
  4. require_once($path["entity"] . "K_Guild_Skill_Group.php");
  5. /**
  6. * Guild page.
  7. */
  8. class Guild_Page extends Page{
  9. /**
  10. * @{see Guild}.
  11. */
  12. public $guild = [];
  13. /**
  14. * List of {@see K_Guild_Skill_Group}s.
  15. */
  16. public $skill_groups = [];
  17. /**
  18. * Constructor.
  19. *
  20. * Retrieves the data and initializes the variables.
  21. *
  22. * @param SQLite3 $db Connection to the database.
  23. */
  24. public function __construct($db){
  25. global $path;
  26. global $root;
  27. parent::__construct($db);
  28. $this->view = $path["view"] . "guild.php";
  29. $s =
  30. "SELECT DISTINCT guild AS id " .
  31. "FROM " .
  32. " guild_member " .
  33. " guild; ";
  34. // TODO: Where guild.member.player = ...
  35. $q = $this->db->query($s);
  36. $r = $q->fetchArray(SQLITE3_ASSOC);
  37. if ($r){
  38. $this->guild = new Guild($db, $r["id"]);
  39. $this->title = $this->guild->name . " - SWDB";
  40. $this->description = $this->guild->name . " Guild details";
  41. $s =
  42. "SELECT id " .
  43. "FROM k_guild_skill_group " .
  44. "ORDER BY id; ";
  45. $q = $this->db->query($s);
  46. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  47. array_push($this->skill_groups, new K_Guild_Skill_Group($db, $r["id"]));
  48. }
  49. }
  50. else{
  51. $this->title = "Guild - SWDB";
  52. $this->description = "No guild";
  53. }
  54. $this->canonical = $root . "guild/";
  55. }
  56. }
  57. ?>