Fusion_Page.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. require_once($path["page"] . "Page.php");
  3. require_once($path["entity"] . "Fusion.php");
  4. require_once($path["entity"] . "Collection.php");
  5. /**
  6. * Fusion page model.
  7. */
  8. class Fusion_Page extends Page{
  9. /**
  10. * List of fusions.
  11. */
  12. public $fusion = [];
  13. /**
  14. * {@see Collection} of owned monsters.
  15. */
  16. public $collection = [];
  17. /**
  18. * Constructor.
  19. *
  20. * Retrieves the data and initializes the variables.
  21. *
  22. * @param SQLite3 $db Connection to the database.
  23. */
  24. public function __construct($db){
  25. global $path;
  26. global $root;
  27. parent::__construct($db);
  28. $this->view = $path["view"] . "fusion.php";
  29. $s =
  30. "SELECT DISTINCT target " .
  31. "FROM fusion " .
  32. "ORDER BY target_stars DESC; ";
  33. $q = $this->db->query($s);
  34. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  35. array_push($this->fusion, new Fusion($this->db, $r["target"]));
  36. }
  37. $s =
  38. "SELECT id " .
  39. "FROM collection " .
  40. "WHERE level <> 0 " .
  41. "ORDER BY " .
  42. " stars DESC, " .
  43. " level DESC; ";
  44. $q = $this->db->query($s);
  45. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  46. array_push($this->collection, new Collection($this->db, $r["id"]));
  47. }
  48. $this->title = "Fusion - SWDB";
  49. $this->description = "Fusion chart";
  50. $this->canonical = $root . "fusion/";
  51. }
  52. }
  53. ?>