enchantments.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <?php
  2. /**
  3. * Artifacts view.
  4. *
  5. * Contains the view layout and code to present the data.
  6. *
  7. * @author Iñigo Valentin <i@inigovalentin.com>
  8. * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
  9. * @package SWDB
  10. * @category View
  11. * @property Artifacts_Page $page The page model.
  12. * @var Artifacts_Page $page The page model.
  13. */
  14. ?>
  15. <!DOCTYPE html>
  16. <html lang='en'>
  17. <head>
  18. <?=$page->generate_head()?>
  19. <script>
  20. /**
  21. * Hack to treat all type selects as one.
  22. *
  23. * @param clicked Numeric order of the select clicked.
  24. * @param event onMouseDown event.
  25. */
  26. function fixTypeSelect(clicked, event){
  27. if (!event.ctrlKey){
  28. // If controll was not being held, clean all other selects
  29. const selects = document.querySelectorAll('.select_type');
  30. Array.from(selects).forEach((element, index) => {
  31. if (element.id != "select_type_" + clicked){
  32. element.selectedIndex = -1;
  33. }
  34. });
  35. }
  36. }
  37. /**
  38. * Hack to treat all main stat selects as one.
  39. *
  40. * @param clicked Numeric order of the select clicked.
  41. * @param event onMouseDown event.
  42. */
  43. function fixMainSelect(clicked, event){
  44. if (!event.ctrlKey){
  45. // If controll was not being held, clean all other selects
  46. const selects = document.querySelectorAll('.select_main');
  47. Array.from(selects).forEach((element, index) => {
  48. if (element.id != "select_main_" + clicked){
  49. element.selectedIndex = -1;
  50. }
  51. });
  52. }
  53. }
  54. </script>
  55. </head>
  56. <body>
  57. <header>
  58. <?php
  59. include __DIR__ . "/inc/header_app.php";
  60. include __DIR__ . "/inc/header_player.php";
  61. ?>
  62. </header>
  63. <aside class='filters'>
  64. <h2>
  65. Enchantments
  66. </h2>
  67. <p>
  68. Manage your enchantments
  69. </p>
  70. <form action='/player/<?=get_context()->get_player()->get_id()?>/enchantments/' method='get' id='filter_artifacts' class='filter'>
  71. <table>
  72. <tr>
  73. <td class='label'>
  74. Type:
  75. </td>
  76. <td>
  77. <select multiple name='type[]' id='filter_type'>
  78. <?php
  79. $selected = "";
  80. if (in_array("GRI", $page->get_filter("TYPE"))){
  81. $selected = "selected='selected'";
  82. }
  83. ?>
  84. <option value='GRI' <?=$selected?>>Grindstone</option>
  85. <?php
  86. $selected = "";
  87. if (in_array("GEM", $page->get_filter("TYPE"))){
  88. $selected = "selected='selected'";
  89. }
  90. ?>
  91. <option value='GEM' <?=$selected?>>Gem</option>
  92. </select>
  93. </td>
  94. </tr>
  95. <tr>
  96. <td class='label'>
  97. Quality:
  98. </td>
  99. <td>
  100. <?php
  101. $selected = Array("", "", "", "", "");
  102. $selected[$page->get_filter("MIN_QUALITY") - 1] = "selected";
  103. ?>
  104. <select name='min_quality' id='filter_quality_min'>
  105. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  106. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  107. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  108. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  109. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  110. </select>
  111. -
  112. <?php
  113. $selected = Array("", "", "", "", "");
  114. $selected[$page->get_filter("MAX_QUALITY") - 1] = "selected";
  115. ?>
  116. <select name='max_quality' id='filter_quality_max'>
  117. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  118. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  119. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  120. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  121. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  122. </select>
  123. </td>
  124. </tr>
  125. <tr>
  126. <td class='label'>
  127. Rune:
  128. </td>
  129. <td class='rune'>
  130. <div>
  131. <select multiple name='rune[]' id='filter_rune'>
  132. <?php
  133. $reflect = new ReflectionClass("RUNE_SET_ID");
  134. $i = 0;
  135. $j = 1;
  136. foreach($reflect->getConstants() as $name => $id){
  137. $selected = "";
  138. if (in_array($id, $page->get_filter("RUNE"))){
  139. $selected = "selected='selected'";
  140. }
  141. $name_format = ucwords(strtolower($name));
  142. if (strlen($name_format) > 9){
  143. $name_format = substr($name_format, 0, 9) . ".";
  144. }
  145. ?>
  146. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  147. <?php
  148. if (($i + 1) % 6 == 0 && ($i + 1) < sizeof($reflect->getConstants())){
  149. ?>
  150. </select><select multiple name='type[]' class='select_type' id='select_type_<?=$j?>' onMouseDown='fixTypeSelect(<?=$j?>, event);'>
  151. <?php
  152. $j ++;
  153. }
  154. $i ++;
  155. }
  156. ?>
  157. </select>
  158. </div>
  159. </td>
  160. </tr>
  161. <tr>
  162. <td class='label'>
  163. Stat:
  164. </td>
  165. <td class='stats'>
  166. <div>
  167. <select multiple name='stat[]' id='filter_stat'>
  168. <?php
  169. $reflect = new ReflectionClass("RUNE_STAT_ID");
  170. $i = 0;
  171. $j = 1;
  172. foreach($reflect->getConstants() as $name => $id){
  173. $selected = "";
  174. if (in_array($id, $page->get_filter("STAT"))){
  175. $selected = "selected='selected'";
  176. }
  177. $name_format = ucwords(str_replace("_P", "%", $name));
  178. ?>
  179. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  180. <?php
  181. if (($i + 1) % 2 == 0){
  182. ?>
  183. </select><select multiple name='main_stat[]' class='select_sub' id='filter_sub_stat_<?=$j?>' onMouseDown='fixSubSelect(<?=$j?>, event);'>
  184. <?php
  185. $j ++;
  186. }
  187. $i ++;
  188. }
  189. ?>
  190. </select>
  191. </div>
  192. </td>
  193. </tr>
  194. </table>
  195. <div id='filter_apply'>
  196. <input type='submit' value='Apply'/>
  197. </div>
  198. </form>
  199. </aside> <!-- #filters -->
  200. <main>
  201. <section class='content' id='enchantments'>
  202. <h2>
  203. Enchantments
  204. </h2>
  205. <table>
  206. <?php
  207. $prev_group = "";
  208. $group = "";
  209. $group_title = "";
  210. $group_image = "";
  211. foreach ($page->get_enchantments() as $enchantment){
  212. $group = ($enchantment->is_inmemorial() ? "I" : $enchantment->get_rune_set()->get_id()) . "-" . $enchantment->is_inmemorial();
  213. if ($prev_group != $group){
  214. if ($enchantment->is_inmemorial()){
  215. $group_title = "Inmemorial";
  216. $group_image = URL::IMG["ICON"] . "star.png";
  217. }
  218. else{
  219. $group_title = $enchantment->get_rune_set()->get_name();
  220. $group_image = URL::IMG["RUNE"] . str_pad($enchantment->get_rune_set()->get_id(), 2, '0', STR_PAD_LEFT) . ".png";
  221. }
  222. if ($prev_group == ""){
  223. ?>
  224. <tr>
  225. <td class='header'>
  226. <?php
  227. }
  228. else{
  229. ?>
  230. </td>
  231. </tr>
  232. <tr>
  233. <td class='header'>
  234. <?php
  235. }
  236. $prev_group = $group;
  237. ?>
  238. <img class='group_image_<?=$group?>' alt='<?=$group_title?>' src='<?=$group_image?>'>
  239. <span>
  240. <?=$group_title?>
  241. </span>
  242. </td>
  243. </tr>
  244. <tr>
  245. <td>
  246. <?php
  247. }
  248. ?>
  249. <?=HTML::enchantment_panel($enchantment)?>
  250. <?php
  251. }
  252. ?>
  253. </td> <!-- Close last group -->
  254. </tr>
  255. </table>
  256. </section>
  257. </main>
  258. <?php
  259. include __DIR__ . "/inc/footer.php";
  260. ?>
  261. </body>
  262. </html>