* @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3 * @package SWDB */ require_once(PATH::PAGE . "Page.php"); require_once(PATH::ENTITY . "Team.php"); /** * Optimizer team list page model. * * @category Page */ class Optimizer_Page extends Page{ /** * @var Team[] Teams to show. */ private $teams = []; /** * Constructor. * * Retrieves the data and initializes the variables. */ public function __construct(){ parent::__construct(); $this->set_public(false); $this->set_view("optimizer.php"); $this->set_title("Optimizer"); $this->set_description("Rune optimizer"); $this->set_canonical(get_context()->get_player()->get_id() . "/optimizer/"); $this->add_css("optimizer.css"); // Get teams $statement = get_context()->get_db()->prepare(" SELECT id FROM team WHERE player = :player ORDER BY area_type, area"); $statement->bindValue(":player", get_context()->get_player()->get_id(), SQLITE3_TEXT); $result_set = $statement->execute(); while ($result = $result_set->fetchArray(SQLITE3_ASSOC)){ array_push($this->teams, new Team($result["id"])); } $this->set_code(200); $this->set_message("OK"); } /** * Retrieves the player teams. * * @return Team[] Player teams. */ public function get_teams(){ return $this->teams; } }