| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- <?php
- /**
- * Artifacts view.
- *
- * Contains the view layout and code to present the data.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package SWDB
- * @category View
- * @property Artifacts_Page $page The page model.
- * @var Artifacts_Page $page The page model.
- */
- ?>
- <!DOCTYPE html>
- <html lang='en'>
- <head>
- <?=$page->generate_head()?>
- <script>
- /**
- * Hack to treat all type selects as one.
- *
- * @param clicked Numeric order of the select clicked.
- * @param event onMouseDown event.
- */
- function fixTypeSelect(clicked, event){
- if (!event.ctrlKey){
- // If controll was not being held, clean all other selects
- const selects = document.querySelectorAll('.select_type');
- Array.from(selects).forEach((element, index) => {
- if (element.id != "select_type_" + clicked){
- element.selectedIndex = -1;
- }
- });
- }
- }
- /**
- * Hack to treat all main stat selects as one.
- *
- * @param clicked Numeric order of the select clicked.
- * @param event onMouseDown event.
- */
- function fixMainSelect(clicked, event){
- if (!event.ctrlKey){
- // If controll was not being held, clean all other selects
- const selects = document.querySelectorAll('.select_main');
- Array.from(selects).forEach((element, index) => {
- if (element.id != "select_main_" + clicked){
- element.selectedIndex = -1;
- }
- });
- }
- }
- </script>
- </head>
- <body>
- <header>
- <?php
- include __DIR__ . "/inc/header_app.php";
- include __DIR__ . "/inc/header_player.php";
- ?>
- </header>
- <aside class='filters'>
- <h2>
- Enchantments
- </h2>
- <p>
- Manage your enchantments
- </p>
- <form action='/player/<?=get_context()->get_player()->get_id()?>/enchantments/' method='get' id='filter_artifacts' class='filter'>
- <table>
- <tr>
- <td class='label'>
- Type:
- </td>
- <td>
- <select multiple name='type[]' id='filter_type'>
- <?php
- $selected = "";
- if (in_array("GRI", $page->get_filter("TYPE"))){
- $selected = "selected='selected'";
- }
- ?>
- <option value='GRI' <?=$selected?>>Grindstone</option>
- <?php
- $selected = "";
- if (in_array("GEM", $page->get_filter("TYPE"))){
- $selected = "selected='selected'";
- }
- ?>
- <option value='GEM' <?=$selected?>>Gem</option>
- </select>
- </td>
- </tr>
- <tr>
- <td class='label'>
- Quality:
- </td>
- <td>
- <?php
- $selected = Array("", "", "", "", "");
- $selected[$page->get_filter("MIN_QUALITY") - 1] = "selected";
- ?>
- <select name='min_quality' id='filter_quality_min'>
- <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
- <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
- <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
- <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
- <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
- </select>
- -
- <?php
- $selected = Array("", "", "", "", "");
- $selected[$page->get_filter("MAX_QUALITY") - 1] = "selected";
- ?>
- <select name='max_quality' id='filter_quality_max'>
- <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
- <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
- <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
- <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
- <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
- </select>
- </td>
- </tr>
- <tr>
- <td class='label'>
- Rune:
- </td>
- <td class='rune'>
- <div>
- <select multiple name='rune[]' id='filter_rune'>
- <?php
- $reflect = new ReflectionClass("RUNE_SET_ID");
- $i = 0;
- $j = 1;
- foreach($reflect->getConstants() as $name => $id){
- $selected = "";
- if (in_array($id, $page->get_filter("RUNE"))){
- $selected = "selected='selected'";
- }
- $name_format = ucwords(strtolower($name));
- if (strlen($name_format) > 9){
- $name_format = substr($name_format, 0, 9) . ".";
- }
- ?>
- <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
- <?php
- if (($i + 1) % 6 == 0 && ($i + 1) < sizeof($reflect->getConstants())){
- ?>
- </select><select multiple name='type[]' class='select_type' id='select_type_<?=$j?>' onMouseDown='fixTypeSelect(<?=$j?>, event);'>
- <?php
- $j ++;
- }
- $i ++;
- }
- ?>
- </select>
- </div>
- </td>
- </tr>
- <tr>
- <td class='label'>
- Stat:
- </td>
- <td class='stats'>
- <div>
- <select multiple name='stat[]' id='filter_stat'>
- <?php
- $reflect = new ReflectionClass("RUNE_STAT_ID");
- $i = 0;
- $j = 1;
- foreach($reflect->getConstants() as $name => $id){
- $selected = "";
- if (in_array($id, $page->get_filter("STAT"))){
- $selected = "selected='selected'";
- }
- $name_format = ucwords(str_replace("_P", "%", $name));
- ?>
- <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
- <?php
- if (($i + 1) % 2 == 0){
- ?>
- </select><select multiple name='main_stat[]' class='select_sub' id='filter_sub_stat_<?=$j?>' onMouseDown='fixSubSelect(<?=$j?>, event);'>
- <?php
- $j ++;
- }
- $i ++;
- }
- ?>
- </select>
- </div>
- </td>
- </tr>
- </table>
- <div id='filter_apply'>
- <input type='submit' value='Apply'/>
- </div>
- </form>
- </aside> <!-- #filters -->
- <main>
- <section class='content' id='enchantments'>
- <h2>
- Enchantments
- </h2>
- <table>
- <?php
- $prev_group = "";
- $group = "";
- $group_title = "";
- $group_image = "";
- foreach ($page->get_enchantments() as $enchantment){
- $group = ($enchantment->is_inmemorial() ? "I" : $enchantment->get_rune_set()->get_id()) . "-" . $enchantment->is_inmemorial();
- if ($prev_group != $group){
- if ($enchantment->is_inmemorial()){
- $group_title = "Inmemorial";
- $group_image = URL::IMG["ICON"] . "star.png";
- }
- else{
- $group_title = $enchantment->get_rune_set()->get_name();
- $group_image = URL::IMG["RUNE"] . str_pad($enchantment->get_rune_set()->get_id(), 2, '0', STR_PAD_LEFT) . ".png";
- }
- if ($prev_group == ""){
- ?>
- <tr>
- <td class='header'>
- <?php
- }
- else{
- ?>
- </td>
- </tr>
- <tr>
- <td class='header'>
- <?php
- }
- $prev_group = $group;
- ?>
- <img class='group_image_<?=$group?>' alt='<?=$group_title?>' src='<?=$group_image?>'>
- <span>
- <?=$group_title?>
- </span>
- </td>
- </tr>
- <tr>
- <td>
- <?php
- }
- ?>
- <?=HTML::enchantment_panel($enchantment)?>
- <?php
- }
- ?>
- </td> <!-- Close last group -->
- </tr>
- </table>
- </section>
- </main>
- <?php
- include __DIR__ . "/inc/footer.php";
- ?>
- </body>
- </html>
|