| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- /**
- * Fusion page file.
- *
- * Provides a class with all the properties and methods to display the page.
- *
- * @category Page
- */
- /**
- * Require dependent files if not present.
- */
- require_once(PATH::PAGE . "Page.php");
- require_once(PATH::ENTITY . "Fusion.php");
- require_once(PATH::ENTITY . "K_Unit.php");
- /**
- * Fusion page model.
- */
- class Fusion_Page extends Page{
- /**
- * @var \Fusion[] List of top-level fusions to display.
- */
- public $fusion = [];
- /**
- * @var \K_Unit[] List of top-level fuseable units (for filter).
- */
- public $products = [];
- /**
- * Constructor.
- *
- * Retrieves the data and initializes the variables.
- *
- * @global int User ID.
- * @global resource Connection to the database.
- */
- public function __construct(){
- global $UID;
- global $db;
- $this->view = PATH::VIEW . "fusion.php";
- $this->parse_filters();
- $s =
- "SELECT DISTINCT product " .
- "FROM k_fusion " .
- "WHERE stars = 5 " .
- "ORDER BY stars DESC; ";
- $q = $db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->products, new K_Unit($r["product"], false));
- }
- $s = $this->build_query();
- $q = $db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->fusion, new Fusion($r["product"], $UID));
- }
- $this->title = "Fusion - SWDB";
- $this->description = "Fusion chart";
- $this->canonical = URL::BASE . "fusion/";
- }
- /**
- * Parses the request looking for the selected filters, validates them
- * and adds them to the $filters array.
- */
- private function parse_filters(){
- $this->filters = FILTER::FUSION;
- if (isset($_GET["product"]) && intval($_GET["product"]) > 0){
- $this->filters["PRODUCT"] = $_GET["product"];
- }
- return;
- }
- /**
- * Builds the query to the rune table using the selected or default
- * filters.
- *
- * @return string The query to be executed.
- */
- private function build_query(){
- $s =
- "SELECT DISTINCT product " .
- "FROM k_fusion " .
- "WHERE stars = 5 ";
- if ($this->filters["PRODUCT"] > 0){
- $s = $s . " AND product = " . $this->filters["PRODUCT"] . " ";
- }
- $s = $s . "ORDER BY stars DESC;";
- return $s;
- }
- }
- ?>
|