Optimizer_Page.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. parent::__construct();
  30. $this->set_public(false);
  31. $this->set_view("optimizer.php");
  32. $this->set_title("Optimizer");
  33. $this->set_description("Rune optimizer");
  34. $this->set_canonical("player/" . get_context()->get_player()->get_id() . "/optimizer/");
  35. $this->add_css("optimizer.css");
  36. // Get teams
  37. $statement = get_context()->get_db()->prepare("
  38. SELECT id FROM team WHERE player = :player ORDER BY area_type, area");
  39. $statement->bindValue(":player", get_context()->get_player()->get_id(), SQLITE3_TEXT);
  40. $result_set = $statement->execute();
  41. while ($result = $result_set->fetchArray(SQLITE3_ASSOC)){
  42. array_push($this->teams, new Team($result["id"]));
  43. }
  44. $this->set_code(200);
  45. $this->set_message("OK");
  46. }
  47. /**
  48. * Retrieves the player teams.
  49. *
  50. * @return Team[] Player teams.
  51. */
  52. public function get_teams(){
  53. return $this->teams;
  54. }
  55. }