Home_Page.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. require_once($path["page"] . "Page.php");
  3. require_once($path["entity"] . "Unit.php");
  4. /**
  5. * Home page model.
  6. */
  7. class Home_Page extends Page{
  8. /**
  9. * Player ID.
  10. */
  11. public $uid;
  12. /**
  13. * Player name.
  14. */
  15. public $name;
  16. /**
  17. * Player country (XX).
  18. */
  19. public $country;
  20. /**
  21. * Total experience.
  22. */
  23. public $experience;
  24. /**
  25. * Representative {@see Unit}.
  26. */
  27. public $rep;
  28. /**
  29. * Currency
  30. */
  31. public $currency = [
  32. "mana" => 0,
  33. "crystal" => 0,
  34. "energy" => 0,
  35. "energy_max" => 0,
  36. "arena_energy" => 0,
  37. "arena_energy_max" => 0,
  38. "darkportal_energy" => 0,
  39. "darkportal_energy_max" => 0,
  40. "dimension_energy" => 0,
  41. "dimension_energy_max" => 0,
  42. "honor_point" => 0,
  43. "guild_point" => 0,
  44. "honor_medal" => 0,
  45. "honor_mark" => 0,
  46. "event_coin" => 0,
  47. "social_point" => 0,
  48. "ancient_stone" => 0,
  49. "costume_point" => 0,
  50. ];
  51. /**
  52. * Constructor.
  53. *
  54. * Retrieves the data and initializes the variables.
  55. *
  56. * @param SQLite3 $db Connection to the database.
  57. * @param string $lang Lowercase, two-letter language code.
  58. */
  59. public function __construct($db){
  60. global $path;
  61. global $root;
  62. parent::__construct($db);
  63. $this->view = $path["view"] . "home.php";
  64. // TODO:Filter by player?
  65. $s =
  66. "SELECT " .
  67. " uid, " .
  68. " name, " .
  69. " country, " .
  70. " experience, " .
  71. " rep, " .
  72. " mana, " .
  73. " crystal, " .
  74. " energy, " .
  75. " energy_max, " .
  76. " arena_energy, " .
  77. " arena_energy_max, " .
  78. " darkportal_energy, " .
  79. " darkportal_energy_max, " .
  80. " dimension_energy, " .
  81. " dimension_energy_max, " .
  82. " honor_point, " .
  83. " guild_point, " .
  84. " honor_medal, " .
  85. " honor_mark, " .
  86. " event_coin, " .
  87. " social_point, " .
  88. " costume_point " .
  89. "FROM player ";
  90. $q = $this->db->query($s);
  91. $r = $q->fetchArray(SQLITE3_ASSOC);
  92. if ($r){
  93. $this->uid = $r["uid"];
  94. $this->name = $r["name"];
  95. $this->country = $r["country"];
  96. $this->experience = $r["experience"];
  97. if (strlen($r["rep"]) > 0){
  98. $this->rep = new Unit($this->db, $r["rep"]);
  99. }
  100. $this->currency["mana"] = $r["mana"];
  101. $this->currency["crystal"] = $r["crystal"];
  102. $this->currency["energy"] = $r["energy"];
  103. $this->currency["energy_max"] = $r["energy_max"];
  104. $this->currency["arena_energy"] = $r["arena_energy"];
  105. $this->currency["arena_energy_max"] = $r["arena_energy_max"];
  106. $this->currency["darkportal_energy"] = $r["darkportal_energy"];
  107. $this->currency["darkportal_energy_max"] = $r["darkportal_energy_max"];
  108. $this->currency["dimension_energy"] = $r["dimension_energy"];
  109. $this->currency["dimension_energy_max"] = $r["dimension_energy_max"];
  110. $this->currency["honor_point"] = $r["honor_point"];
  111. $this->currency["guild_point"] = $r["guild_point"];
  112. $this->currency["honor_medal"] = $r["honor_medal"];
  113. $this->currency["honor_mark"] = $r["honor_mark"];
  114. $this->currency["event_coin"] = $r["event_coin"];
  115. $this->currency["social_point"] = $r["social_point"];
  116. $this->currency["costume_point"] = $r["costume_point"];
  117. }
  118. $this->title = "SWDB";
  119. $this->description = "Summoners War DataBase";
  120. $this->canonical = $root;
  121. }
  122. }
  123. ?>