Optimizer_Page.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 Player Currently selected player.
  30. * @global resource Database connection.
  31. */
  32. public function __construct(){
  33. global $PLAYER;
  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 player = '" . $PLAYER->id . "';
  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. * @global Player Currently selected player.
  56. */
  57. private function build_query(){
  58. global $PLAYER;
  59. $s = "
  60. SELECT id
  61. FROM team
  62. WHERE player = '" . $PLAYER->id . "'
  63. ORDER BY
  64. area_type,
  65. area
  66. ";
  67. return $s;
  68. }
  69. }
  70. ?>