* @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; } }