Optimizer_Page.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. * @author Iñigo Valentin <i@inigovalentin.com>
  8. * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
  9. * @package SWDB
  10. */
  11. require_once(PATH::PAGE . "Page.php");
  12. require_once(PATH::ENTITY . "Team.php");
  13. /**
  14. * Optimizer team list page model.
  15. *
  16. * @category Page
  17. */
  18. class Optimizer_Page extends Page{
  19. /**
  20. * @var Team[] Teams to show.
  21. */
  22. private $teams = [];
  23. /**
  24. * Constructor.
  25. *
  26. * Retrieves the data and initializes the variables.
  27. */
  28. public function __construct(){
  29. $this->view = PATH::VIEW . "optimizer.php";
  30. $this->title = "Optimizer - SWDB";
  31. $this->description = "Optimizer";
  32. $this->canonical = URL::BASE . "optimizer/";
  33. // Get teams
  34. $statement = get_context()->get_db()->prepare("
  35. SELECT id FROM team WHERE player = :player ORDER BY area_type, area");
  36. $statement->bindValue(":player", get_context()->get_player()->get_id(), SQLITE3_TEXT);
  37. $result_set = $statement->execute();
  38. while ($result = $result_set->fetchArray(SQLITE3_ASSOC)){
  39. array_push($this->teams, new Team($result["id"]));
  40. }
  41. }
  42. /**
  43. * Retrieves the player teams.
  44. *
  45. * @return Team[] Player teams.
  46. */
  47. public function get_teams(){
  48. return $this->teams;
  49. }
  50. }