Collection_Collection_Frame.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. require_once($path["frame"] . "Frame.php");
  3. require_once($path["entity"] . "Monster_Collection.php");
  4. /**
  5. * Collection's page monster list.
  6. */
  7. class Collection_Collection_Frame extends Frame{
  8. /**
  9. * {@see Monster_Collection} of owned monsters.
  10. */
  11. public $collection = [];
  12. /**
  13. * Monster to mark as selected
  14. */
  15. public $selected = -1;
  16. /**
  17. * Constructor.
  18. *
  19. * Retrieves the data and initializes the variables.
  20. *
  21. * @param SQLite3 $db Connection to the database.
  22. * @param Array $params Parameters array. May contain the 'selected' parameter
  23. * to mark a monster as selected.
  24. */
  25. public function __construct($db, $params){
  26. global $path;
  27. parent::__construct($db);
  28. $this->view = $path["view"] . "frame/collection.php";
  29. if (isset($params["selected"])){
  30. $this->selected = $params["selected"];
  31. }
  32. $s =
  33. "SELECT id " .
  34. "FROM monster_collection " .
  35. "WHERE level <> 0 " .
  36. "ORDER BY " .
  37. " stars DESC, " .
  38. " level DESC; ";
  39. $q = $this->db->query($s);
  40. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  41. array_push($this->collection, new Monster_Collection($this->db, $r["id"]));
  42. }
  43. }
  44. }
  45. ?>