enchantments.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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. <meta content='text/html; charset=utf-8' http-equiv='content-type'/>
  19. <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'/>
  20. <title><?=$page->get_title()?></title>
  21. <link rel='shortcut icon' href='<?=$page->get_favicon()?>'/>
  22. <!-- CSS files -->
  23. <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
  24. <?php
  25. if (get_context()->get_game_mode() == GAME_MODE_ID::RTA){
  26. ?>
  27. <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui-rta.css'/>
  28. <?php
  29. }
  30. ?>
  31. <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>enchantments.css'/>
  32. <!-- Meta tags -->
  33. <link rel='canonical' href='<?=$page->get_canonical()?>'/>
  34. <link rel='author' href='<?=$page->get_author()?>'/>
  35. <link rel='publisher' href='<?=$page->get_author()?>'/>
  36. <meta name='description' content='<?=$page->get_description()?>'/>
  37. <meta property='og:title' content='<?=$page->get_title()?>'/>
  38. <meta property='og:url' content='<?=$page->get_canonical()?>'/>
  39. <meta property='og:description' content='<?=$page->get_description()?>'/>
  40. <meta property='og:image' content='<?=$page->get_icon()?>'/>
  41. <meta property='og:site_name' content='<?=$page->get_name()?>?>'/>
  42. <meta property='og:type' content='website'/>
  43. <meta property='og:locale' content='en'/>
  44. <meta name='twitter:card' content='summary'/>
  45. <meta name='twitter:title' content='<?=$page->get_title()?>'/>
  46. <meta name='twitter:description' content='<?=$page->get_description()?>'/>
  47. <meta name='twitter:image' content='<?=$page->get_icon()?>'/>
  48. <meta name='twitter:url' content='<?=$page->get_canonical()?>'/>
  49. <meta name='robots' content='index follow'/>
  50. <script>
  51. /**
  52. * Hack to treat all type selects as one.
  53. *
  54. * @param clicked Numeric order of the select clicked.
  55. * @param event onMouseDown event.
  56. */
  57. function fixTypeSelect(clicked, event){
  58. if (!event.ctrlKey){
  59. // If controll was not being held, clean all other selects
  60. const selects = document.querySelectorAll('.select_type');
  61. Array.from(selects).forEach((element, index) => {
  62. if (element.id != "select_type_" + clicked){
  63. element.selectedIndex = -1;
  64. }
  65. });
  66. }
  67. }
  68. /**
  69. * Hack to treat all main stat selects as one.
  70. *
  71. * @param clicked Numeric order of the select clicked.
  72. * @param event onMouseDown event.
  73. */
  74. function fixMainSelect(clicked, event){
  75. if (!event.ctrlKey){
  76. // If controll was not being held, clean all other selects
  77. const selects = document.querySelectorAll('.select_main');
  78. Array.from(selects).forEach((element, index) => {
  79. if (element.id != "select_main_" + clicked){
  80. element.selectedIndex = -1;
  81. }
  82. });
  83. }
  84. }
  85. </script>
  86. </head>
  87. <body>
  88. <?php
  89. include __DIR__ . "/inc/header.php";
  90. ?>
  91. <aside class='filters'>
  92. <h2>
  93. Enchantments
  94. </h2>
  95. <p>
  96. Manage your enchantments
  97. </p>
  98. <form action='/<?=get_context()->get_player()->get_id()?>/enchantments/' method='get' id='filter_artifacts' class='filter'>
  99. <table>
  100. <tr>
  101. <td class='label'>
  102. Type:
  103. </td>
  104. <td>
  105. <select multiple name='type[]' id='filter_type'>
  106. <?php
  107. $selected = "";
  108. if (in_array("GRI", $page->get_filter("TYPE"))){
  109. $selected = "selected='selected'";
  110. }
  111. ?>
  112. <option value='GRI' <?=$selected?>>Grindstone</option>
  113. <?php
  114. $selected = "";
  115. if (in_array("GEM", $page->get_filter("TYPE"))){
  116. $selected = "selected='selected'";
  117. }
  118. ?>
  119. <option value='GEM' <?=$selected?>>Gem</option>
  120. </select>
  121. </td>
  122. </tr>
  123. <tr>
  124. <td class='label'>
  125. Quality:
  126. </td>
  127. <td>
  128. <?php
  129. $selected = Array("", "", "", "", "");
  130. $selected[$page->get_filter("MIN_QUALITY") - 1] = "selected";
  131. ?>
  132. <select name='min_quality' id='filter_quality_min'>
  133. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  134. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  135. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  136. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  137. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  138. </select>
  139. -
  140. <?php
  141. $selected = Array("", "", "", "", "");
  142. $selected[$page->get_filter("MAX_QUALITY") - 1] = "selected";
  143. ?>
  144. <select name='max_quality' id='filter_quality_max'>
  145. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  146. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  147. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  148. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  149. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  150. </select>
  151. </td>
  152. </tr>
  153. <tr>
  154. <td class='label'>
  155. Rune:
  156. </td>
  157. <td class='rune'>
  158. <div>
  159. <select multiple name='rune[]' id='filter_rune'>
  160. <?php
  161. $reflect = new ReflectionClass("RUNE_SET_ID");
  162. $i = 0;
  163. $j = 1;
  164. foreach($reflect->getConstants() as $name => $id){
  165. $selected = "";
  166. if (in_array($id, $page->get_filter("RUNE"))){
  167. $selected = "selected='selected'";
  168. }
  169. $name_format = ucwords(strtolower($name));
  170. if (strlen($name_format) > 9){
  171. $name_format = substr($name_format, 0, 9) . ".";
  172. }
  173. ?>
  174. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  175. <?php
  176. if (($i + 1) % 6 == 0 && ($i + 1) < sizeof($reflect->getConstants())){
  177. ?>
  178. </select><select multiple name='type[]' class='select_type' id='select_type_<?=$j?>' onMouseDown='fixTypeSelect(<?=$j?>, event);'>
  179. <?php
  180. $j ++;
  181. }
  182. $i ++;
  183. }
  184. ?>
  185. </select>
  186. </div>
  187. </td>
  188. </tr>
  189. <tr>
  190. <td class='label'>
  191. Stat:
  192. </td>
  193. <td class='stats'>
  194. <div>
  195. <select multiple name='stat[]' id='filter_stat'>
  196. <?php
  197. $reflect = new ReflectionClass("RUNE_STAT_ID");
  198. $i = 0;
  199. $j = 1;
  200. foreach($reflect->getConstants() as $name => $id){
  201. $selected = "";
  202. if (in_array($id, $page->get_filter("STAT"))){
  203. $selected = "selected='selected'";
  204. }
  205. $name_format = ucwords(str_replace("_P", "%", $name));
  206. ?>
  207. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  208. <?php
  209. if (($i + 1) % 2 == 0){
  210. ?>
  211. </select><select multiple name='main_stat[]' class='select_sub' id='filter_sub_stat_<?=$j?>' onMouseDown='fixSubSelect(<?=$j?>, event);'>
  212. <?php
  213. $j ++;
  214. }
  215. $i ++;
  216. }
  217. ?>
  218. </select>
  219. </div>
  220. </td>
  221. </tr>
  222. </table>
  223. <div id='filter_apply'>
  224. <input type='submit' value='Apply'/>
  225. </div>
  226. </form>
  227. </aside> <!-- #filters -->
  228. <main>
  229. <section class='content' id='enchantments'>
  230. <h2>
  231. Enchantments
  232. </h2>
  233. <table>
  234. <?php
  235. $prev_group = "";
  236. $group = "";
  237. $group_title = "";
  238. $group_image = "";
  239. foreach ($page->get_enchantments() as $enchantment){
  240. $group = ($enchantment->is_inmemorial() ? "I" : $enchantment->get_rune_set()->get_id()) . "-" . $enchantment->is_inmemorial();
  241. if ($prev_group != $group){
  242. if ($enchantment->is_inmemorial()){
  243. $group_title = "Inmemorial";
  244. $group_image = URL::IMG["ICON"] . "star.png";
  245. }
  246. else{
  247. $group_title = $enchantment->get_rune_set()->get_name();
  248. $group_image = URL::IMG["RUNE"] . str_pad($enchantment->get_rune_set()->get_id(), 2, '0', STR_PAD_LEFT) . ".png";
  249. }
  250. if ($prev_group == ""){
  251. ?>
  252. <tr>
  253. <td class='header'>
  254. <?php
  255. }
  256. else{
  257. ?>
  258. </td>
  259. </tr>
  260. <tr>
  261. <td class='header'>
  262. <?php
  263. }
  264. $prev_group = $group;
  265. ?>
  266. <img class='group_image_<?=$group?>' alt='<?=$group_title?>' src='<?=$group_image?>'>
  267. <span>
  268. <?=$group_title?>
  269. </span>
  270. </td>
  271. </tr>
  272. <tr>
  273. <td>
  274. <?php
  275. }
  276. ?>
  277. <?=HTML::enchantment_panel($enchantment)?>
  278. <?php
  279. }
  280. ?>
  281. </td> <!-- Close last group -->
  282. </tr>
  283. </table>
  284. </section>
  285. </main>
  286. <?php
  287. include __DIR__ . "/inc/footer.php";
  288. ?>
  289. </body>
  290. </html>