Optimizer_Page.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. public function __construct(){
  30. $this->view = PATH::VIEW . "optimizer.php";
  31. $s = $this->build_query();
  32. $q = get_context()->get_db()->query($s);
  33. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  34. array_push($this->teams, new Team($r["id"]));
  35. }
  36. $s = "
  37. SELECT id
  38. FROM unit
  39. WHERE player = '" . get_context()->get_player()->get_id() . "';
  40. ";
  41. $this->title = "Optmizer - SWDB";
  42. $this->description = "Optimizer";
  43. $this->canonical = URL::BASE . "optmizer/";
  44. }
  45. /**
  46. * Builds the query to the rune table using the selected or default
  47. * filters.
  48. *
  49. * @return string The query to be executed.
  50. */
  51. private function build_query(){
  52. $s = "
  53. SELECT id
  54. FROM team
  55. WHERE player = '" . get_context()->get_player()->get_id() . "'
  56. ORDER BY
  57. area_type,
  58. area
  59. ";
  60. return $s;
  61. }
  62. }
  63. ?>