| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- require_once($path["frame"] . "Frame.php");
- /**
- * Catalog's page monster list.
- */
- class Catalog_List_Frame extends Frame{
- /**
- * List of all the monsters in the database.
- */
- public $entry = [];
- /**
- * Constructor.
- *
- * Retrieves the data and initializes the variables.
- *
- * @param SQLite3 $db Connection to the database.
- * @param Array $params Parameters array. May contain the 'selected' parameter
- * to mark a monster as selected.
- */
- public function __construct($db, $params){
- global $path;
- parent::__construct($db);
- $this->view = $path["view"] . "frame/catalog_list.php";
- $w_name = "1 = 1";
- $w_type = "1 = 1";
- $w_element = "1 = 1";
- $w_min_stars = "1 = 1";
- $w_max_stars = "1 = 1";
- if (isset($params["name"])){
- $w_name = "(name LIKE '%" . $params["name"] . "%' OR name_aw LIKE '%" . $params["name"] . "%')";
- }
- if (isset($params["type"])){
- $w_type = "type = '" . $params["type"] . "'";
- }
- if (isset($params["element"])){
- $w_element = "element = '" . $params["element"] . "'";
- }
- if (isset($params["minstars"]) && intval($params["minstars"]) > 0 && intval($params["minstars"]) < 7){
- $w_min_stars = "stars >= " . $params["minstars"];
- }
- if (isset($params["maxstars"]) && intval($params["maxstars"]) > 0 && intval($params["maxstars"]) < 7){
- $w_max_stars = "stars <= " . $params["maxstars"];
- }
- $s =
- "SELECT id, " .
- " element, " .
- " name, " .
- " img, " .
- " img_aw, " .
- " stars, " .
- " awakeable, " .
- " ( " .
- " SELECT count(id) > 0 " .
- " FROM monster_collection " .
- " WHERE monster = monster.id " .
- " ) AS owned " .
- "FROM monster " .
- "WHERE " .
- " $w_name AND " .
- " $w_type AND " .
- " $w_element AND " .
- " $w_min_stars AND " .
- " $w_max_stars " .
- "ORDER BY " .
- " element, " .
- " stars, " .
- " awakeable ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- $mon = [
- "id" => $r["id"],
- "element" => $r["element"],
- "name" => $r["name"],
- "image" => $path["img"]["monster"] . $r["img"],
- "image_aw" => $path["img"]["monster"] . $r["img_aw"],
- "stars" => $r["stars"],
- "awakeable" => $r["awakeable"],
- "owned" => $r["owned"],
- ];
- array_push($this->entry, $mon);
- }
- }
- }
- ?>
|