|
|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
|
|
|
|
require_once($path["page"] . "Page.php");
|
|
|
+ require_once($path["entity"] . "Custom_Filter.php");
|
|
|
require_once($path["entity"] . "Rune.php");
|
|
|
require_once($path["entity"] . "Unit.php");
|
|
|
|
|
|
@@ -16,6 +17,11 @@
|
|
|
*/
|
|
|
public $runes = [];
|
|
|
|
|
|
+ /**
|
|
|
+ * Custom filters for this page.
|
|
|
+ */
|
|
|
+ public $custom_filters = [];
|
|
|
+
|
|
|
/**
|
|
|
* The filters the page can handle.
|
|
|
*/
|
|
|
@@ -50,10 +56,17 @@
|
|
|
public function __construct($db){
|
|
|
global $path;
|
|
|
global $root;
|
|
|
+ global $UID;
|
|
|
parent::__construct($db);
|
|
|
$this->view = $path["view"] . "runes.php";
|
|
|
$this->parse_filters();
|
|
|
- $s = $this->build_query();
|
|
|
+ if (!isset($_GET["custom_filter"])){
|
|
|
+ $s = $this->build_query();
|
|
|
+ $this->filters["group"] = 1;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ $s = $this->build_custom_query($_GET["custom_filter"]);
|
|
|
+ }
|
|
|
$q = $this->db->query($s);
|
|
|
while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
$rune = new Rune($db, $r["id"]);
|
|
|
@@ -61,7 +74,18 @@
|
|
|
$rune->assigned_to = new Unit($this->db, $rune->assigned_to, false);
|
|
|
}
|
|
|
array_push($this->runes, $rune);
|
|
|
- }
|
|
|
+ }
|
|
|
+ $s = "
|
|
|
+ SELECT id
|
|
|
+ FROM filter
|
|
|
+ WHERE
|
|
|
+ uid = '$UID' AND
|
|
|
+ page = 'RUNES';
|
|
|
+ ";
|
|
|
+ $q = $this->db->query($s);
|
|
|
+ while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
+ array_push($this->custom_filters, new Custom_Filter($this->db, $r["id"]));
|
|
|
+ }
|
|
|
$this->title = "Runes - SWDB";
|
|
|
$this->description = "Rune inventory";
|
|
|
$this->canonical = $root . "runes/";
|
|
|
@@ -144,6 +168,38 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Builds the query to the rune table using the a custom filter.
|
|
|
+ *
|
|
|
+ * @param int $filter Custom filter ID.
|
|
|
+ * @return The query to be executed.
|
|
|
+ */
|
|
|
+ private function build_custom_query($filter){
|
|
|
+ global $UID;
|
|
|
+ $s = "
|
|
|
+ SELECT condition
|
|
|
+ FROM filter
|
|
|
+ WHERE
|
|
|
+ uid = '$UID' AND
|
|
|
+ id = $filter;
|
|
|
+ ";
|
|
|
+ $q = $this->db->query($s);
|
|
|
+ $r = $q->fetchArray(SQLITE3_ASSOC);
|
|
|
+ $cond = $r["condition"];
|
|
|
+ $s = "
|
|
|
+ SELECT
|
|
|
+ id,
|
|
|
+ assigned_to
|
|
|
+ FROM rune
|
|
|
+ WHERE uid = '$UID' AND (
|
|
|
+ $cond
|
|
|
+ )
|
|
|
+ ORDER BY slot, type, stars DESC, original_quality DESC, quality DESC, level;
|
|
|
+ ";
|
|
|
+ error_log("CUSTOM QUERY: " . $s);
|
|
|
+ return $s;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Builds the query to the rune table using the selected or default
|
|
|
* filters.
|