| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- /**
- * Building list page file.
- *
- * Provides a class with all the properties and methods to display the page.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @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 . "Buildable.php");
- require_once(PATH::ENTITY . "Decorative.php");
- /**
- * Building list page model.
- *
- * @category Page
- */
- class Buildings_Page extends Page{
- /**
- * @var Buildable[] List of buildables to show.
- */
- private $buildables = [];
-
- /**
- * @var Decorative[] List of decoratives to show.
- */
- private $decoratives = [];
-
- /**
- * @var Decorative[] List of Guild Flags to show.
- */
- private $flags = [];
- /**
- * Constructor.
- *
- * Retrieves the data and initializes the variables.
- */
- public function __construct(){
- parent::__construct();
- $this->set_public(true);
- $this->set_view("buildings.php");
- $this->set_title("Buildings");
- $this->set_description("List of all buildings");
- $this->set_canonical("buildings/");
- $this->add_css("buildings.css");
-
- // Buildings
- $statement = get_context()->get_db()->prepare("SELECT id FROM buildable;");
- $result_set = $statement->execute();
- while ($result = $result_set->fetchArray(SQLITE3_ASSOC)){
- array_push($this->buildables, new Buildable($result["id"]));
- }
-
- // Decorations
- $statement = get_context()->get_db()->prepare("SELECT id FROM decorative WHERE area != :guild;");
- $statement->bindValue(":guild", EFFECT_AREA_ID::GUILD);
- $result_set = $statement->execute();
- while ($result = $result_set->fetchArray(SQLITE3_ASSOC)){
- array_push($this->decoratives, new Decorative($result["id"]));
- }
- // Flags
- $statement = get_context()->get_db()->prepare("SELECT id FROM decorative WHERE area = :guild;");
- $statement->bindValue(":guild", EFFECT_AREA_ID::GUILD);
- $result_set = $statement->execute();
- while ($result = $result_set->fetchArray(SQLITE3_ASSOC)){
- array_push($this->flags, new Decorative($result["id"]));
- }
- $this->set_code(200);
- $this->set_message("OK");
- }
- /**
- * Retrieves the buildings to display
- *
- * @return Buildable[] Selected buildables.
- */
- public function get_buildables(){
- return $this->buildables;
- }
- /**
- * Retrieves the decorations to display, excluding Guild Flags
- *
- * @return Decorative[] Selected decoratives.
- */
- public function get_decoratives(){
- return $this->decoratives;
- }
- /**
- * Retrieves the Guild Flags to display
- *
- * @return Decorative[] Selected flags.
- */
- public function get_flags(){
- return $this->flags;
- }
-
- }
|