Optimizer_Page.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * Optimizer team list 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 . "Team.php");
  14. /**
  15. * Optimizer team list page model.
  16. *
  17. * @category Page
  18. */
  19. class Optimizer_Page extends Page{
  20. /**
  21. * @var \Team[] Teams to show.
  22. */
  23. public $teams = [];
  24. /**
  25. * Constructor.
  26. *
  27. * Retrieves the data and initializes the variables.
  28. *
  29. * @global int Player ID.
  30. * @global resource Database connection.
  31. */
  32. public function __construct(){
  33. global $UID;
  34. global $db;
  35. $this->view = PATH::VIEW . "optimizer.php";
  36. $s = $this->build_query();
  37. $q = $db->query($s);
  38. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  39. array_push($this->teams, new Team($r["id"]));
  40. }
  41. $s = "
  42. SELECT id
  43. FROM unit
  44. WHERE unit.uid = '$UID';
  45. ";
  46. $this->title = "Optmizer - SWDB";
  47. $this->description = "Optimizer";
  48. $this->canonical = URL::BASE . "optmizer/";
  49. }
  50. /**
  51. * Builds the query to the rune table using the selected or default
  52. * filters.
  53. *
  54. * @return string The query to be executed.
  55. */
  56. private function build_query(){
  57. global $UID;
  58. $s = "
  59. SELECT id
  60. FROM team
  61. WHERE uid = '$UID'
  62. ORDER BY
  63. area_type,
  64. area
  65. ";
  66. return $s;
  67. }
  68. }
  69. ?>