Переглянути джерело

Better code organization. Added project documentation.

Iñigo Valentin 6 роки тому
батько
коміт
d31cfa4511
100 змінених файлів з 6050 додано та 2876 видалено
  1. 1 0
      .gitignore
  2. 1782 352
      application/Constant.php
  3. 50 32
      application/Controller.php
  4. 0 149
      application/Filter.php
  5. 28 17
      application/action/edit_profile.php
  6. 22 0
      application/action/login.php
  7. 19 0
      application/action/logout.php
  8. 49 17
      application/action/new_team.php
  9. 22 0
      application/action/save_run_team.php
  10. 135 44
      application/config.php
  11. 18 7
      application/entity/Building.php
  12. 21 9
      application/entity/Custom_Filter.php
  13. 18 8
      application/entity/Decoration.php
  14. 12 2
      application/entity/Entity.php
  15. 32 19
      application/entity/Fusion.php
  16. 28 17
      application/entity/Guild.php
  17. 26 16
      application/entity/Guild_Member.php
  18. 32 26
      application/entity/Inventory.php
  19. 92 86
      application/entity/K_Area.php
  20. 23 15
      application/entity/K_Building.php
  21. 30 22
      application/entity/K_Decoration.php
  22. 25 17
      application/entity/K_Effect.php
  23. 19 8
      application/entity/K_Guild_Skill.php
  24. 26 18
      application/entity/K_Guild_Skill_Group.php
  25. 40 32
      application/entity/K_Leader_Skill.php
  26. 26 18
      application/entity/K_Rune_Set.php
  27. 36 28
      application/entity/K_Skill.php
  28. 18 7
      application/entity/K_Skill_Level.php
  29. 24 16
      application/entity/K_Source.php
  30. 82 70
      application/entity/K_Unit.php
  31. 25 19
      application/entity/K_Unit_Transformation.php
  32. 48 37
      application/entity/Run.php
  33. 89 65
      application/entity/Rune.php
  34. 49 36
      application/entity/Rune_Craft.php
  35. 32 15
      application/entity/Team.php
  36. 86 68
      application/entity/Unit.php
  37. 45 0
      application/helper/DB_Helper.php
  38. 469 0
      application/helper/HTML_Helper.php
  39. 19 0
      application/helper/Helper.php
  40. 61 0
      application/helper/NET_Helper.php
  41. 110 0
      application/helper/TEXT_Helper.php
  42. 0 27
      application/helper/db.php
  43. 0 444
      application/helper/html.php
  44. 0 117
      application/helper/net.php
  45. 0 87
      application/helper/text.php
  46. 39 36
      application/page/Catalog_Page.php
  47. 22 18
      application/page/Fusion_Page.php
  48. 24 13
      application/page/Guild_Page.php
  49. 40 30
      application/page/Home_Page.php
  50. 17 7
      application/page/Landing_Page.php
  51. 22 11
      application/page/Monster_Info_Page.php
  52. 30 21
      application/page/Monster_Page.php
  53. 39 35
      application/page/Monsters_Page.php
  54. 36 16
      application/page/Page.php
  55. 29 7
      application/page/Profile_Page.php
  56. 21 9
      application/page/Report_Page.php
  57. 31 28
      application/page/Report_Runecraft_Page.php
  58. 35 49
      application/page/Report_Runeupgrade_Page.php
  59. 21 26
      application/page/Report_Skillup_Page.php
  60. 33 44
      application/page/Runes_Page.php
  61. 23 19
      application/page/Runs_Page.php
  62. 24 20
      application/page/Teams_Page.php
  63. 19 6
      application/view/catalog.php
  64. 46 33
      application/view/fusion.php
  65. 46 39
      application/view/guild.php
  66. 15 2
      application/view/help.php
  67. 34 25
      application/view/home.php
  68. 20 10
      application/view/inc/filter_catalog.php
  69. 16 2
      application/view/inc/filter_fusion.php
  70. 22 12
      application/view/inc/filter_monsters.php
  71. 68 59
      application/view/inc/filter_report_runecraft.php
  72. 59 48
      application/view/inc/filter_report_runeupgrade.php
  73. 23 10
      application/view/inc/filter_report_skillup.php
  74. 53 46
      application/view/inc/filter_runes.php
  75. 31 21
      application/view/inc/filter_runs.php
  76. 25 14
      application/view/inc/filter_teams.php
  77. 12 4
      application/view/inc/footer.php
  78. 12 1
      application/view/inc/header.php
  79. 14 2
      application/view/landing.php
  80. 17 4
      application/view/monster.php
  81. 15 6
      application/view/monster_info.php
  82. 16 6
      application/view/monsters.php
  83. 15 2
      application/view/profile.php
  84. 19 12
      application/view/report.php
  85. 17 8
      application/view/report_runecraft.php
  86. 17 9
      application/view/report_runeupgrade.php
  87. 17 5
      application/view/report_skillup.php
  88. 19 7
      application/view/runes.php
  89. 40 20
      application/view/runs.php
  90. 111 107
      application/view/teams.php
  91. 5 0
      doc/.htaccess
  92. 108 0
      doc/classes/APP.html
  93. 108 0
      doc/classes/ARCHETYPE_ID.html
  94. 108 0
      doc/classes/AREA_TYPE_ID.html
  95. 108 0
      doc/classes/ARENA_RANKING_POINTS.html
  96. 108 0
      doc/classes/ARENA_RANKING_RANK.html
  97. 108 0
      doc/classes/BUILDING_ID.html
  98. 108 0
      doc/classes/Building.html
  99. 108 0
      doc/classes/CRAFT_ID.html
  100. 108 0
      doc/classes/Catalog_Page.html

+ 1 - 0
.gitignore

@@ -6,6 +6,7 @@ data/*.sqlite
 # Autogenerated files
 .php_pid
 *.log
+doc/.tmp
 
 #IDE / OS files
 .kateproject.d/

+ 1782 - 352
application/Constant.php

@@ -1,357 +1,1787 @@
 <?php
+    /**
+     * Provides constants.
+     *
+     * Usefull data to be used across the site.
+     *
+     * @category Data
+     */
 
-    $DIFFICULTY = [
-        "EASY" => 0,
-        "NORMAL" => 1,
-        "HARD" => 2,
-        "HELL" => 3,
-    ];
-
-    $SOURCE = [
-        "SCROLL_UNKNOWN" => 1,
-        "SCROLL_MYSTICAL" => 2,
-        "SCROLL_LIGHT_AND_DARK" => 3,
-        "SCROLL_WATER" => 4,
-        "SCROLL_FIRE" => 5,
-        "SCROLL_WIND" => 6,
-        "SCROLL_LEGENDARY" => 7,
-        "SUMMON_EXCLUSIVE" => 8,
-        "SUMMON_LEGENDARY_PIECES" => 9,
-        "SUMMON_LIGHT_AND_DARK_PIECES" => 10,
-        "SCROLL_TRANSCENDANCE" => 11,
-        "SCROLL_LEGENDARY_WATER" => 12,
-        "SCROLL_LEGENDARY_FIRE" => 13,
-        "SCROLL_LEGENDARY_WIND" => 14,
-    ];
-
-    // TODO => Move these definitions to the models if not already done, delete this file.
-
-    $ELEMENT = [
-        "WATER" => 1,
-        "FIRE" => 2,
-        "WIND" => 3,
-        "LIGHT" => 4,
-        "DARK" => 5,
-        "PURE" => 6,
-    ];
-
-    $ARCHETYPE = [
-        "NONE" => 0,
-        "ATTACK" => 1,
-        "DEFENSE" => 2,
-        "HP" => 3,
-        "SUPPORT" => 4,
-        "MATERIAL" => 5
-    ];
-
-    $STAT = [
-        "HP" => 1,
-        "ATK" => 2,
-        "DEF" => 3,
-        "SPD" => 4,
-        "CRIT_RATE" => 5,
-        "CRIT_DMG" => 6,
-        "RESIST" => 7,
-        "ACCURACY" => 8,
-    ];
-
-    $EFFECT_AREA = [
-        "GENERAL" => 1,
-        "ARENA" => 3,
-        "DUNGEON" => 2,
-        "GUILD" => 5,
-    ];
-
-    $AREA_TYPE = [
-        'SCENARIO' => 1,
-        'CAIROS_DUNGEON' => 2,
-        'RIFT_DUNGEON' => 3,
-        'RIFT_RAID' => 4,
-        'DIMENSIONAL_HOLE' => 5,
-        'ARENA' => 6,
-        'GUILD_WAR' => 7,
-        'GUILD_SIEGE' => 8,
-        'TARTARUS_LABYRINTH' => 9,
-        'TRIAL_OF_ASCENSION' => 10,
-        'WORLD_BOSS' => 11,
-        'DIMENSIONAL_RIFT' => 12,
-    ];
-
-    $SCENARIO = [
-        'GAREN_FOREST' => 1,
-        'MT_SIZ' => 2,
-        'KABIR_RUINS' => 3,
-        'MT_WHITE_RAGON' => 4,
-        'TELAIN_FOREST' => 5,
-        'HYDENI_RUINS' => 6,
-        'TAMOR_DESERT' => 7,
-        'VROFAGUS_RUINS' => 8,
-        'FAIMON_VOLCANO' => 9,
-        'AIDEN_FOREST' => 10,
-        'FERUN_CASTLE' => 11,
-        'MT_RUNAR' => 12,
-        'CHIRUKA_REMAINS' => 13,
-    ];
-
-    $DUNGEON = [
-        'HALL_OF_DARK' => 1001,
-        'SANCTUARY_OF_DREAMING_FAIRIES' => 1101,
-        'ELLUNIA_REMAINS_FAIRY' => 1201,
-        'ELLUNIA_REMAINS_PIXIE' => 1202,
-        'HALL_OF_FIRE' => 2001,
-        'FOREST_OF_ROARING_BEASTS' => 2101,
-        'KARZHAN_REMAINS_WARBEAR' => 2201,
-        'KARZHAN_REMAINS_INUGAMI' => 2202,
-        'HALL_OF_WATER' => 3001,
-        'HALL_OF_WIND' => 4001,
-        'HALL_OF_MAGIC' => 5001,
-        'NECROPOLIS' => 6001,
-        'HALL_OF_LIGHT' => 7001,
-        'GIANTS_KEEP' => 8001,
-        'DRAGONS_LAIR' => 9001,
+     /**
+      * Stage difficulty constants.
+      *
+      * @category Data
+      */
+    final class DIFFICULTY_ID{
+
+        /**
+         * Difficulty EASY (Tartarus Labyrinth only).
+         */
+        const EASY = 0;
+
+        /**
+         * Difficulty EASY (Scenario, TOA, Labyrinth).
+         */
+        const NORMAL = 0;
+
+        /**
+         * Difficulty EASY (Scenario, TOA, Labyrinth).
+         */
+        const HARD = 0;
+
+        /**
+         * Difficulty EASY (Scenario, Labyrinth).
+         */
+        const HELL = 0;
+    };
+
+    /**
+     * Unit source constants.
+     *
+     * @category Data
+     */
+    final class SOURCE_ID{
+
+        /**
+         * Unknown Scroll (elemental 1-3*).
+         */
+        const SCROLL_UNKNOWN = 1;
+
+        /**
+         * Mystical Scroll (elemental 3-5*).
+         */
+        const SCROLL_MYSTICAL = 2;
+
+        /**
+         * Light and Darkness Scroll (LD 3-5*).
+         */
+        const SCROLL_LIGHT_AND_DARK = 3;
+
+        /**
+         * Water scroll (water 3-5*)
+         */
+        const SCROLL_WATER = 4;
+
+        /**
+         * Fire scroll (fire 3-5*)
+         */
+        const SCROLL_FIRE = 5;
+
+        /**
+         * Wind scroll (wind 3-5*)
+         */
+        const SCROLL_WIND = 6;
+
+        /**
+         * Legendary Scroll (elemental 4-5*)
+         */
+        const SCROLL_LEGENDARY = 7;
+
+        /**
+         * Summon Stones (elemental 3-5*)
+         */
+        const SUMMON_EXCLUSIVE = 8;
+
+        /**
+         * Legendary Summoning Pieces (4-5*)
+         */
+        const SUMMON_LEGENDARY_PIECES = 9;
+
+        /**
+         * Light and Darkness Scroll (LD 3-5*).
+         */
+        const SUMMON_LIGHT_AND_DARK_PIECES = 10;
+
+        /**
+         * Transcendance Scroll (elemental 5*)
+         */
+        const SCROLL_TRANSCENDANCE = 11;
+
+        /**
+         * Legendary Water Scroll (water 4-5*)
+         */
+        const SCROLL_LEGENDARY_WATER = 12;
+
+        /**
+         * Legendary Fire Scroll (fire 4-5*)
+         */
+        const SCROLL_LEGENDARY_FIRE = 13;
+
+        /**
+         * Legendary Wind Scroll (wind 4-5*)
+         */
+        const SCROLL_LEGENDARY_WIND = 14;
+    };
+
+    /**
+     * Element constants.
+     *
+     * @category Data
+     */
+    final class ELEMENT_ID{
+
+        /**
+         * Water
+         */
+        const WATER = 1;
+
+        /**
+         * Fire
+         */
+        const FIRE = 2;
+
+        /**
+         * Wind
+         */
+        const WIND = 3;
+
+        /**
+         * Light
+         */
+        const LIGHT = 4;
+
+        /**
+         * Dark
+         */
+        const DARK = 5;
+
+        /**
+         * Pure
+         */
+        const PURE = 6;
+    };
+
+    /**
+     * Unit archetype constants.
+     *
+     * @category Data
+     */
+    final class ARCHETYPE_ID{
+
+        /**
+         * None
+         */
+        const NONE = 0;
+
+        /**
+         * Attack
+         */
+        const ATTACK = 1;
+
+        /**
+         * Defense
+         */
+        const DEFENSE = 2;
+
+        /**
+         * HP
+         */
+        const HP = 3;
+
+        /**
+         * Support
+         */
+        const SUPPORT = 4;
+
+        /**
+         * Material
+         */
+        const MATERIAL = 5;
+    };
+
+    /**
+     * Stat constants.
+     *
+     * Used for unit stats, for rune stat types, see {@see RUNE_STAT_ID}
+     *
+     * @category Data
+     */
+    final class STAT_ID{
+
+        /**
+         * HP
+         */
+        const HP = 1;
+
+        /**
+         * ATK
+         */
+        const ATK = 2;
+
+        /**
+         * DEF
+         */
+        const DEF = 3;
+
+        /**
+         * SPD
+         */
+        const SPD = 4;
+
+        /**
+         * CRIT_RATE
+         */
+        const CRIT_RATE = 5;
+
+        /**
+         * CRIT_DMG
+         */
+        const CRIT_DMG = 6;
+
+        /**
+         * RESIST
+         */
+        const RESIST = 7;
+
+        /**
+         * ACCURACY
+         */
+        const ACCURACY = 8;
+    };
+
+    /**
+     * Leadr skill area constants.
+     *
+     * @category Data
+     */
+    final class EFFECT_AREA_ID{
+
+        /**
+         * General (all areas).
+         */
+        const GENERAL = 1;
+
+        /**
+         * Arena (offense and defense).
+         */
+        const ARENA = 3;
+
+        /**
+         * Dungeon (Cairos, elemental Rifts, Dimensinal Hole).
+         */
+        const DUNGEON = 2;
+
+        /**
+         * Guild content (battle, siege, Labyrinth).
+         */
+        const GUILD = 5;
+    };
+
+    /**
+     * Playable area group constants.
+     *
+     * @category Data
+     */
+    final class AREA_TYPE_ID{
+
+        /**
+         * Scenario.
+         */
+        const SCENARIO = 1;
+
+        /**
+         * Cairos Dungeon.
+         */
+        const CAIROS_DUNGEON = 2;
+
+        /**
+         * Elemental Rift Dungeons.
+         */
+        const RIFT_DUNGEON = 3;
+
+        /**
+         * Rift Raid.
+         */
+        const RIFT_RAID = 4;
+
+        /**
+         * Dimensional Hole.
+         */
+        const DIMENSIONAL_HOLE = 5;
+
+        /**
+         * Arena.
+         */
+        const ARENA = 6;
+
+        /**
+         * Guild War.
+         */
+        const GUILD_WAR = 7;
+
+        /**
+         * Guild Siege.
+         */
+        const GUILD_SIEGE = 8;
+
+        /**
+         * Tartarus Labyrinth.
+         */
+        const TARTARUS_LABYRINTH = 9;
+
+        /**
+         * Trial of Ascension.
+         */
+        const TRIAL_OF_ASCENSION = 10;
+
+        /**
+         * World Boss.
+         */
+        const WORLD_BOSS = 11;
+
+        /**
+         * Dimensional Rift.
+         */
+        const DIMENSIONAL_RIFT = 12;
+    };
+
+    /**
+     * Scenario area constants.
+     *
+     * @category Data
+     */
+    final class SCENARIO_ID{
+
+        /**
+         * Garen Forest.
+         */
+        const GAREN_FOREST = 1;
+
+        /**
+         * Mt. Siz.
+         */
+        const MT_SIZ = 2;
+
+        /**
+         * Kabir Ruins.
+         */
+        const KABIR_RUINS = 3;
+
+        /**
+         * Mt. White Ragon.
+         */
+        const MT_WHITE_RAGON = 4;
+
+        /**
+         * Telain Forest.
+         */
+        const TELAIN_FOREST = 5;
+
+        /**
+         * Hydeni Ruins.
+         */
+        const HYDENI_RUINS = 6;
+
+        /**
+         * Tamor Desert.
+         */
+        const TAMOR_DESERT = 7;
+
+        /**
+         * Vrofagus Ruins.
+         */
+        const VROFAGUS_RUINS = 8;
+
+        /**
+         * Faimon Volcano.
+         */
+        const FAIMON_VOLCANO = 9;
+
+        /**
+         * Aiden Forest.
+         */
+        const AIDEN_FOREST = 10;
+
+        /**
+         * Ferun Castle.
+         */
+        const FERUN_CASTLE = 11;
+
+        /**
+         * Mt Runar.
+         */
+        const MT_RUNAR = 12;
+
+        /**
+         * Chiruka Remains.
+         */
+        const CHIRUKA_REMAINS = 13;
+    };
+
+    /**
+     * Dungeon section constants.
+     *
+     * Includes Cairos Dungeons and Dimension Hole Dungeons.
+     *
+     * @category Data
+     */
+    final class DUNGEON_ID{
+
+        /**
+         * Hall of Dark.
+         */
+        const HALL_OF_DARK = 1001;
+
+        /**
+         * Sanctuary of Dreaming Fairies.
+         */
+        const SANCTUARY_OF_DREAMING_FAIRIES = 1101;
+
+        /**
+         * Ellunia Remains (Fairy).
+         */
+        const ELLUNIA_REMAINS_FAIRY = 1201;
+
+        /**
+         * Ellunia Remains (Pixie).
+         */
+        const ELLUNIA_REMAINS_PIXIE = 1202;
+
+        /**
+         * Hall of Fire.
+         */
+        const HALL_OF_FIRE = 2001;
+
+        /**
+         * Forest of Roaring Beasts.
+         */
+        const FOREST_OF_ROARING_BEASTS = 2101;
+
+        /**
+         * Karzhan Remains (Warbear).
+         */
+        const KARZHAN_REMAINS_WARBEAR = 2201;
+
+        /**
+         * Karzhan Remains (Inugami).
+         */
+        const KARZHAN_REMAINS_INUGAMI = 2202;
+
+        /**
+         * Hall of water.
+         */
+        const HALL_OF_WATER = 3001;
+
+        /**
+         * Hall of Wind.
+         */
+        const HALL_OF_WIND = 4001;
+
+        /**
+         * Hall of Magic.
+         */
+        const HALL_OF_MAGIC = 5001;
+
+        /**
+         * Necropolis.
+         */
+        const NECROPOLIS = 6001;
+
+        /**
+         * Hall of Light.
+         */
+        const HALL_OF_LIGHT = 7001;
+
+        /**
+         * Giants Keep.
+         */
+        const GIANTS_KEEP = 8001;
+
+        /**
+         * Dragons Lair.
+         */
+        const DRAGONS_LAIR = 9001;
         // TODO: Lumel
-    ];
-
-    $ELEMENTAL_RIFT_DUNGEON = [
-        'ICE_BEAST' => 1001,
-        'FIRE_BEAST' => 2001,
-        'WIND_BEAST' => 3001,
-        'LIGHT_BEAST' => 4001,
-        'DARK_BEAST' => 5001,
-    ];
-
-    $RAID_RIFT_DUNGEON = [
-        'LEVEL_1' => 1,
-        'LEVEL_2' => 2,
-        'LEVEL_3' => 3,
-        'LEVEL_4' => 4,
-        'LEVEL_5' => 5,
-    ];
-
-    $LABYRINTH_STAGES = [
-        'TARTARUS' => 1,
-        'KOTTOS' => 2,
-        'LEOS' => 3,
-        'AQUILES' => 4,
-        'NORMAL' => 5,
-        'RESCUE' => 6,
-        'EXPLODE' => 7,
-        'COOL_TIME' => 8,
-        'SPEED_LIMIT' => 9,
-        'TIME_LIMIT' => 10
-    ];
-
-    $BUILDING = [
-        'SUMMONERS_TOWER' => 1,
-        'SUMMONHENGE' => 2,
-        'POND_OF_MANA' => 3,
-        'CRYSTAL_MINE' => 4,
-        'GATEWAY' => 8,
-        'TEMPLE_OF_WISHES' => 10,
-        'MAGIC_SHOP' => 11,
-        'ANCIENT_STONES' => 12,
-        'ARCANE_TOWER' => 14,
-        'CRYSTAL_TITAN' => 15,
-        'FUSION_HEXAGRAM' => 16,
-        'FUSE_CENTER' => 17,
-        'POWER_UP_CIRCLE' => 20,
-        'TRANQUIL_FOREST' => 22,
-        'GUSTY_CLIFFS' => 23,
-        'DEEP_FOREST_ENT' => 24,
-        'MONSTER_STORAGE' => 25,
-        'TRANSMOGRIFICATION_BUILDING' => 27,
-    ];
-
-    $DECORATION = [
-        'GUARDSTONE' => 4,
-        'MANA_FOUNTAIN' => 5,
-        'SKY_TRIBE_TOTEM' => 6,
-        'ARCANE_BOOSTER_TOWER' => 7,
-        'CRYSTAL_ALTAR' => 8,
-        'ANCIENT_SWORD' => 9,
-        'SANCTUM_OF_ENERGY' => 10,
-        'MYSTERIOUS_PLANT' => 11,
-        'FIRE_SANCTUARY' => 15,
-        'WATER_SANCTUARY' => 16,
-        'WIND_SANCTUARY' => 17,
-        'LIGHT_SANCTUARY' => 18,
-        'DARK_SANCTUARY' => 19,
-        'FALLEN_ANCIENT_GUARDIAN' => 31,
-        'CRYSTAL_ROCK' => 34,
-        'FAIRY_TREE' => 35,
-        'FLAG_OF_BATTLE' => 36,
-        'FLAG_OF_RAGE' => 37,
-        'FLAG_OF_HOPE' => 38,
-        'FLAG_OF_WILL' => 39,
-    ];
-
-    $INVENTORY_TYPE = [
-        'MONSTER' => 1,
-        'CURRENCY' => 6,
-        'RUNE' => 8,
-        'SCROLL' => 9,
-        'BOOSTER' => 10,
-        'ESSENCES' => 11,
-        'MONSTER_PIECE' => 12,
-        # '' => 15, Unknown. Appears in inventory_info with qty 0
-        'GUILD_MONSTER_PIECE' => 19,
-        'RAINBOWMON' => 25,   # Possibly material monsters in general. Appears when wish returns a rainbowmon.
-        'RUNE_CRAFT' => 27,
-        'CRAFT_STUFF' => 29,
-        'ENHANCING_MONSTER' => 61,
-    ];
-
-    $INVENTORY = [
-        "ESSENCE_MAGIC_LOW" => 11006,
-        "ESSENCE_MAGIC_MID" => 12006,
-        "ESSENCE_MAGIC_HIGH" => 13006,
-        "ESSENCE_WATER_LOW" => 11001,
-        "ESSENCE_WATER_MID" => 12001,
-        "ESSENCE_WATER_HIGH" => 13001,
-        "ESSENCE_FIRE_LOW" => 11002,
-        "ESSENCE_FIRE_MID" => 12002,
-        "ESSENCE_FIRE_HIGH" => 13002,
-        "ESSENCE_WIND_LOW" => 11003,
-        "ESSENCE_WIND_MID" => 12003,
-        "ESSENCE_WIND_HIGH" => 13003,
-        "ESSENCE_LIGHT_LOW" => 11004,
-        "ESSENCE_LIGHT_MID" => 12004,
-        "ESSENCE_LIGHT_HIGH" => 13004,
-        "ESSENCE_DARK_LOW" => 11005,
-        "ESSENCE_DARK_MID" => 12005,
-        "ESSENCE_DARK_HIGH" => 13005,
-        "WOOD" => 1001,
-        "LEATHER" => 1002,
-        "ROCK" => 1003,
-        "ORE" => 1004,
-        "MITHRIL" => 1005,
-        "CLOTH" => 1006,
-        "RUNE_PIECE" => 2001,
-        "POWDER" => 3001,
-        "SYMBOL_HARMONY" => 4001,
-        "SYMBOL_TRANSCENDANCE" => 4002,
-        "SYMBOL_CHAOS" => 4003,
-        "CRYSTAL_WATER" => 5001,
-        "CRYSTAL_FIRE" => 5002,
-        "CRYSTAL_WIND" => 5003,
-        "CRYSTAL_LIGHT" => 5004,
-        "CRYSTAL_DARK" => 5005,
-        "CRYSTAL_MAGIC" => 6001,
-        "CRYSTAL_PURE" => 7001,
-    ];
-
-    $ENHANCE_MONSTER = [
-        "WATER_ANGELMON" => 142110115,
-        "FIRE_ANGELMON" => 142120115,
-        "WIND_ANGELMON" => 142130115,
-        "LIGHT_ANGELMON" => 142140115,
-        "DARK_ANGELMON" => 142150115,
-        "WATER_KING_ANGELMON" => 182110115,
-        "FIRE_KING_ANGELMON" => 182120115,
-        "WIND_KING_ANGELMON" => 182130115,
-        "LIGHT_KING_ANGELMON" => 182140115,
-        "DARK_KING_ANGELMON" => 182150115,
-        "RAINBOWMON_2_20" => 143140220,
-        "RAINBOWMON_3_1" => 143140301,
-        "RAINBOWMON_3_25" => 143140325,
-        "RAINBOWMON_4_1" => 143140401,
-        "RAINBOWMON_4_30" => 143140430,
-        "RAINBOWMON_5_1" => 143140501,
-        "DEVILMON" => 151050101,
-        "SUPER_ANGELMON" => 217140115
-    ];
-
-    $RUNE_SET = [
-        "ENERGY" => 1,
-        "GUARD" => 2,
-        "SWIFT" => 3,
-        "BLADE" => 4,
-        "RAGE" => 5,
-        "FOCUS" => 6,
-        "ENDURE" => 7,
-        "FATAL" => 8,
-        "DESPAIR" => 10,
-        "VAMPIRE" => 11,
-        "VIOLENT" => 13,
-        "NEMESIS" => 14,
-        "WILL" => 15,
-        "SHIELD" => 16,
-        "REVENGE" => 17,
-        "DESTROY" => 18,
-        "FIGHT" => 19,
-        "DETERMINATION" => 20,
-        "ENHANCE" => 21,
-        "ACCURACY" => 22,
-        "TOLERANCE" => 23,
-    ];
-
-    $RUNE_STAT = [
-        "HP" => 1,
-        "HP%" => 2,
-        "ATK" => 3,
-        "ATK%" => 4,
-        "DEF" => 5,
-        "DEF%" => 6,
-        "SPD" => 8,
-        "CRR" => 9,
-        "CRD" => 10,
-        "RES" => 11,
-        "ACC" => 12,
-    ];
-
-    $QUALITY = [
-        "NORMAL" => 1,
-        "MAGIC" => 2,
-        "RARE" => 3,
-        "HERO" => 4,
-        "LEGEND" => 5,
-    ];
-
-    $CRAFT = [
-        "ENCHANT_GEM" => 1,
-        "GRINDSTONE" => 2,
-        "IMMEMORIAL_GEM" => 3,
-        "IMMEMORIAL_GRINDSTONE" => 4,
-    ];
-
-    $GUILD_MEMBER_GRADE = [
-        "LEADER" => 1,
-        "VICELEADER" => 3,
-        "NORMAL" => 2
-    ];
-
-    $ARENA_RANKING_POINTS = [
-        "BEGINER" => 0,
-        "CHALLENGER_1" => 900,
-        "CHALLENGER_2" => 1000,
-        "CHALLENGER_3" => 1100,
-        "FIGHTER_1" => 1200,
-        "FIGHTER_2" => 1300,
-        "FIGHTER_3" => 1400,
-        "CONQUEROR_1" => 1500,
-        "CONQUEROR_2" => 1600,
-        "CONQUEROR_3" => 1700,
-        "GUARDIAN_1" => 1700,
-        "GUARDIAN_2" => 1700,
-        "GUARDIAN_3" => 1700,
-        "LEGEND" => 1700,
-    ];
-
-    $ARENA_RANKING_RANK = [
-        "BEGINER" => null,
-        "CHALLENGER_1" => null,
-        "CHALLENGER_2" => null,
-        "CHALLENGER_3" => null,
-        "FIGHTER_1" => null,
-        "FIGHTER_2" => null,
-        "FIGHTER_3" => null,
-        "CONQUEROR_1" => 10000,
-        "CONQUEROR_2" => 3000,
-        "CONQUEROR_3" => 1000,
-        "GUARDIAN_1" => 300,
-        "GUARDIAN_2" => 100,
-        "GUARDIAN_3" => 30,
-        "LEGEND" => 1,
-    ];
+    };
+
+    /**
+     * Elemental Rift Dungeon constants.
+     *
+     * @category Data
+     */
+    final class ELEMENTAL_RIFT_DUNGEON_ID{
+
+        /**
+         * Ice Beast.
+         */
+        const ICE_BEAST = 1001;
+
+        /**
+         * Fire Beast.
+         */
+        const FIRE_BEAST = 2001;
+
+        /**
+         * Wind Beast.
+         */
+        const WIND_BEAST = 3001;
+
+        /**
+         * Light Beast.
+         */
+        const LIGHT_BEAST = 4001;
+
+        /**
+         * Dark Beast.
+         */
+        const DARK_BEAST = 5001;
+    };
+
+    /**
+     * Rift raid level constants.
+     *
+     * @category Data
+     */
+    final class RAID_RIFT_DUNGEON_ID{
+
+        /**
+         * Level 1.
+         */
+        const LEVEL_1 = 1;
+
+        /**
+         * Level 2.
+         */
+        const LEVEL_2 = 2;
+
+        /**
+         * Level 3.
+         */
+        const LEVEL_3 = 3;
+
+        /**
+         * Level 4.
+         */
+        const LEVEL_4 = 4;
+
+        /**
+         * Level 5.
+         */
+        const LEVEL_5 = 5;
+    };
+
+    /**
+     * Constants for all the types of stages in the Tartarus Labyrinth.
+     *
+     * @category Data
+     */
+    final class LABYRINTH_STAGES_ID{
+
+        /**
+         * Tartarus (Labyrinth Guardian).
+         */
+        const TARTARUS = 1;
+
+        /**
+         * Kottos (Fire Gaurdian).
+         */
+        const KOTTOS = 2;
+
+        /**
+         * Leos (Waer Guardian).
+         */
+        const LEOS = 3;
+
+        /**
+         * Aquiles (Wind Guardian).
+         */
+        const AQUILES = 4;
+
+        /**
+         * Normal stage.
+         */
+        const NORMAL = 5;
+
+        /**
+         * Rescue stage.
+         */
+        const RESCUE = 6;
+
+        /**
+         * Explode stage.
+         */
+        const EXPLODE = 7;
+
+        /**
+         * Cool Time UP stage.
+         */
+        const COOL_TIME = 8;
+
+        /**
+         * Speed Limit stage.
+         */
+        const SPEED_LIMIT = 9;
+
+        /**
+         * Time Limit stage.
+         */
+        const TIME_LIMIT = 10;
+    };
+
+    /**
+     * Building constants.
+     *
+     * @category Data
+     */
+    final class BUILDING_ID{
+
+        /**
+         * Summoners Tower.
+         */
+        const SUMMONERS_TOWER = 1;
+
+        /**
+         * Summonhenge.
+         */
+        const SUMMONHENGE = 2;
+
+        /**
+         * Pond of Mana.
+         */
+        const POND_OF_MANA = 3;
+
+        /**
+         * Crystal Mine.
+         */
+        const CRYSTAL_MINE = 4;
+
+        /**
+         * Gateway.
+         */
+        const GATEWAY = 8;
+
+        /**
+         * Temple of Wishes.
+         */
+        const TEMPLE_OF_WISHES = 10;
+
+        /**
+         * Magic Shop.
+         */
+        const MAGIC_SHOP = 11;
+
+        /**
+         * Ancient Stones.
+         */
+        const ANCIENT_STONES = 12;
+
+        /**
+         * Arcane Tower.
+         */
+        const ARCANE_TOWER = 14;
+
+        /**
+         * Crystal Titan.
+         */
+        const CRYSTAL_TITAN = 15;
+
+        /**
+         * Fusion Hexagram.
+         */
+        const FUSION_HEXAGRAM = 16;
+
+        /**
+         * Fuse Center.
+         */
+        const FUSE_CENTER = 17;
+
+        /**
+         * Power Up Circle.
+         */
+        const POWER_UP_CIRCLE = 20;
+
+        /**
+         * Tranquil Forest.
+         */
+        const TRANQUIL_FOREST = 22;
+
+        /**
+         * Gusty Cliffs.
+         */
+        const GUSTY_CLIFFS = 23;
+
+        /**
+         * Deep Forest Ent.
+         */
+        const DEEP_FOREST_ENT = 24;
+
+        /**
+         * Monster Storage.
+         */
+        const MONSTER_STORAGE = 25;
+
+        /**
+         * Transmogrification Building.
+         */
+        const TRANSMOGRIFICATION_BUILDING = 27;
+    };
+
+    /**
+     * Decoration constants.
+     *
+     * @category Data
+     */
+    final class DECORATION_ID{
+
+        /**
+         * Guardstone.
+         */
+        const GUARDSTONE = 4;
+
+        /**
+         * Mana Fountain.
+         */
+        const MANA_FOUNTAIN = 5;
+
+        /**
+         * Sky Tribe Totem.
+         */
+        const SKY_TRIBE_TOTEM = 6;
+
+        /**
+         * Arcane Booster Tower.
+         */
+        const ARCANE_BOOSTER_TOWER = 7;
+
+        /**
+         * Crystal Altar.
+         */
+        const CRYSTAL_ALTAR = 8;
+
+        /**
+         * Ancient Sword.
+         */
+        const ANCIENT_SWORD = 9;
+
+        /**
+         * Sanctum of Energy.
+         */
+        const SANCTUM_OF_ENERGY = 10;
+
+        /**
+         * Mysterious Plant.
+         */
+        const MYSTERIOUS_PLANT = 11;
+
+        /**
+         * Fire Sanctuary.
+         */
+        const FIRE_SANCTUARY = 15;
+
+        /**
+         * Water Sanctuary.
+         */
+        const WATER_SANCTUARY = 16;
+
+        /**
+         * Wind Sanctuary.
+         */
+        const WIND_SANCTUARY = 17;
+
+        /**
+         * Light Sanctuary.
+         */
+        const LIGHT_SANCTUARY = 18;
+
+        /**
+         * Dark Sanctuary.
+         */
+        const DARK_SANCTUARY = 19;
+
+        /**
+         * Fallen Ancient Guardian.
+         */
+        const FALLEN_ANCIENT_GUARDIAN = 31;
+
+        /**
+         * Crystal Rock.
+         */
+        const CRYSTAL_ROCK = 34;
+
+        /**
+         * Fairy Tree.
+         */
+        const FAIRY_TREE = 35;
+
+        /**
+         * Flag of Battle.
+         */
+        const FLAG_OF_BATTLE = 36;
+
+        /**
+         * Flag of Rage.
+         */
+        const FLAG_OF_RAGE = 37;
+
+        /**
+         * Flag of Hope.
+         */
+        const FLAG_OF_HOPE = 38;
+
+        /**
+         * Flag of Will.
+         */
+        const FLAG_OF_WILL = 39;
+    };
+
+    /**
+     * Inventory categories constants.
+     *
+     * @category Data
+     */
+    final class INVENTORY_TYPE_ID{
+
+        /**
+         * Monster.
+         */
+        const MONSTER = 1;
+
+        /**
+         * Currency.
+         */
+        const CURRENCY = 6;
+
+        /**
+         * Rune.
+         */
+        const RUNE = 8;
+
+        /**
+         * Scroll.
+         */
+        const SCROLL = 9;
+
+        /**
+         * Booster.
+         */
+        const BOOSTER = 10;
+
+        /**
+         * Essences.
+         */
+        const ESSENCES = 11;
+
+        /**
+         * Monster Piece.
+         */
+        const MONSTER_PIECE = 12;
+
+        // '' => 15, Unknown. Appears in inventory_info with qty 0
+
+        /**
+         * Guild Monster piece.
+         */
+        const GUILD_MONSTER_PIECE = 19;
+
+        /**
+         * Rainbowmon.
+         */
+        const RAINBOWMON = 25;   # Possibly material monsters in general. Appears when wish returns a rainbowmon.
+
+        /**
+         * Rune Craft.
+         */
+        const RUNE_CRAFT = 27;
+
+        /**
+         * Craft Stuff.
+         */
+        const CRAFT_STUFF = 29;
+
+        /**
+         * Enhancing Monster.
+         */
+        const ENHANCING_MONSTER = 61;
+    };
+
+    /**
+     * Items constants.
+     *
+     * @category Data
+     */
+    final class INVENTORY_ID{
+
+        /**
+         * Essence of Magic (Low).
+         */
+        const ESSENCE_MAGIC_LOW = 11006;
+
+        /**
+         * Essence of Magic (Mid).
+         */
+        const ESSENCE_MAGIC_MID = 12006;
+
+        /**
+         * Essence of Magic (High).
+         */
+        const ESSENCE_MAGIC_HIGH = 13006;
+
+        /**
+         * Essence of Water (Low).
+         */
+        const ESSENCE_WATER_LOW = 11001;
+
+        /**
+         * Essence of Water (Mid).
+         */
+        const ESSENCE_WATER_MID = 12001;
+
+        /**
+         * Essence of Water (High).
+         */
+        const ESSENCE_WATER_HIGH = 13001;
+
+        /**
+         * Essence of Fire (Low).
+         */
+        const ESSENCE_FIRE_LOW = 11002;
+
+        /**
+         * Essence of Fire (Mid).
+         */
+        const ESSENCE_FIRE_MID = 12002;
+
+        /**
+         * Essence of Fire (High).
+         */
+        const ESSENCE_FIRE_HIGH = 13002;
+
+        /**
+         * Essence of Wind (Low).
+         */
+        const ESSENCE_WIND_LOW = 11003;
+
+        /**
+         * Essence of Wind (Mid).
+         */
+        const ESSENCE_WIND_MID = 12003;
+
+        /**
+         * Essence of Wind (High).
+         */
+        const ESSENCE_WIND_HIGH = 13003;
+
+        /**
+         * Essence of Light (Low).
+         */
+        const ESSENCE_LIGHT_LOW = 11004;
+
+        /**
+         * Essence of Light (Mid).
+         */
+        const ESSENCE_LIGHT_MID = 12004;
+
+        /**
+         * Essence of Light (High).
+         */
+        const ESSENCE_LIGHT_HIGH = 13004;
+
+        /**
+         * Essence of Dark (Low).
+         */
+        const ESSENCE_DARK_LOW = 11005;
+
+        /**
+         * Essence of Dark (Mid).
+         */
+        const ESSENCE_DARK_MID = 12005;
+
+        /**
+         * Essence of Dark (High).
+         */
+        const ESSENCE_DARK_HIGH = 13005;
+
+        /**
+         * Wood.
+         */
+        const WOOD = 1001;
+
+        /**
+         * Leather.
+         */
+        const LEATHER = 1002;
+
+        /**
+         * Rock.
+         */
+        const ROCK = 1003;
+
+        /**
+         * Ore.
+         */
+        const ORE = 1004;
+
+        /**
+         * Mithril.
+         */
+        const MITHRIL = 1005;
+
+        /**
+         * Cloth.
+         */
+        const CLOTH = 1006;
+
+        /**
+         * Rune Piece.
+         */
+        const RUNE_PIECE = 2001;
+
+        /**
+         * Powder.
+         */
+        const POWDER = 3001;
+
+        /**
+         * Symbol of Harmony.
+         */
+        const SYMBOL_HARMONY = 4001;
+
+        /**
+         * Symbol of Transcendance.
+         */
+        const SYMBOL_TRANSCENDANCE = 4002;
+
+        /**
+         * Symbol of Chaos.
+         */
+        const SYMBOL_CHAOS = 4003;
+
+        /**
+         * Frozen Water Crystal.
+         */
+        const CRYSTAL_WATER = 5001;
+
+        /**
+         * Flaming Fire Crystal.
+         */
+        const CRYSTAL_FIRE = 5002;
+
+        /**
+         * Whirling Wind Crystal.
+         */
+        const CRYSTAL_WIND = 5003;
+
+        /**
+         * Shiny Light Crystal.
+         */
+        const CRYSTAL_LIGHT = 5004;
+
+        /**
+         * Pitch-Black Dark Crystal.
+         */
+        const CRYSTAL_DARK = 5005;
+
+        /**
+         * Condensed Magic Crystal.
+         */
+        const CRYSTAL_MAGIC = 6001;
+
+        /**
+         * Pure Crystal.
+         */
+        const CRYSTAL_PURE = 7001;
+    };
+
+    /**
+     * Storage-able enhance monster constants.
+     *
+     * @category Data
+     */
+    final class ENHANCE_MONSTER_ID{
+
+        /**
+         * Water Angelmon.
+         */
+        const WATER_ANGELMON = 142110115;
+
+        /**
+         * Fire Angelmon.
+         */
+        const FIRE_ANGELMON = 142120115;
+
+        /**
+         * Wind Angelmon.
+         */
+        const WIND_ANGELMON = 142130115;
+
+        /**
+         * Light Angelmon.
+         */
+        const LIGHT_ANGELMON = 142140115;
+
+        /**
+         * Dark Angelmon.
+         */
+        const DARK_ANGELMON = 142150115;
+
+        /**
+         * Water King Angelmon.
+         */
+        const WATER_KING_ANGELMON = 182110115;
+
+        /**
+         * Fire King Angelmon.
+         */
+        const FIRE_KING_ANGELMON = 182120115;
+
+        /**
+         * Wind King Angelmon.
+         */
+        const WIND_KING_ANGELMON = 182130115;
+
+        /**
+         * Light King Angelmon.
+         */
+        const LIGHT_KING_ANGELMON = 182140115;
+
+        /**
+         * Dark King Angelmon.
+         */
+        const DARK_KING_ANGELMON = 182150115;
+
+        /**
+         * 2* Rainbowmon (Lv. 20).
+         */
+        const RAINBOWMON_2_20 = 143140220;
+
+        /**
+         * 3* Rainbowmon (Lv. 1).
+         */
+        const RAINBOWMON_3_1 = 143140301;
+
+        /**
+         * 3* Rainbowmon (Lv. 25).
+         */
+        const RAINBOWMON_3_25 = 143140325;
+
+        /**
+         * 4* Rainbowmon (Lv. 1).
+         */
+        const RAINBOWMON_4_1 = 143140401;
+
+        /**
+         * 4* Rainbowmon (Lv. 30).
+         */
+        const RAINBOWMON_4_30 = 143140430;
+
+        /**
+         * 5* Rainbowmon (Lv. 1).
+         */
+        const RAINBOWMON_5_1 = 143140501;
+
+        /**
+         * Devilmon.
+         */
+        const DEVILMON = 151050101;
+        
+        /**
+         * Super Angelmon.
+         */
+        const SUPER_ANGELMON = 217140115;
+    };
+
+    /**
+     * Rune set constants.
+     *
+     * @category Data
+     */
+    final class RUNE_SET_ID{
+
+        /**
+         * Energy.
+         */
+        const ENERGY = 1;
+
+        /**
+         * Guard.
+         */
+        const GUARD = 2;
+
+        /**
+         * Swift.
+         */
+        const SWIFT = 3;
+
+        /**
+         * Blade.
+         */
+        const BLADE = 4;
+
+        /**
+         * Rage.
+         */
+        const RAGE = 5;
+
+        /**
+         * Focus.
+         */
+        const FOCUS = 6;
+
+        /**
+         * Endure.
+         */
+        const ENDURE = 7;
+
+        /**
+         * Fatal.
+         */
+        const FATAL = 8;
+
+        /**
+         * Despair.
+         */
+        const DESPAIR = 10;
+
+        /**
+         * Vampire.
+         */
+        const VAMPIRE = 11;
+
+        /**
+         * Violent.
+         */
+        const VIOLENT = 13;
+
+        /**
+         * Nemesis.
+         */
+        const NEMESIS = 14;
+
+        /**
+         * Will.
+         */
+        const WILL = 15;
+
+        /**
+         * Shield.
+         */
+        const SHIELD = 16;
+
+        /**
+         * Revenge.
+         */
+        const REVENGE = 17;
+
+        /**
+         * Destroy.
+         */
+        const DESTROY = 18;
+
+        /**
+         * Fight.
+         */
+        const FIGHT = 19;
+
+        /**
+         * Determination.
+         */
+        const DETERMINATION = 20;
+
+        /**
+         * Enhance.
+         */
+        const ENHANCE = 21;
+
+        /**
+         * Accuracy.
+         */
+        const ACCURACY = 22;
+
+        /**
+         * Tolerance.
+         */
+        const TOLERANCE = 23;
+    };
+
+    /**
+     * Rune stat constants.
+     *
+     * Includes all stats a rune can have. For unit stats, see{@see $STAT_ID}.
+     *
+     * @category Data
+     */
+    final class RUNE_STAT_ID{
+
+        /**
+         * HP (flat).
+         */
+        const HP = 1;
+
+        /**
+         * HP (percent).
+         */
+        const HP_P = 2;
+
+        /**
+         * Attack  (flat).
+         */
+        const ATK = 3;
+
+        /**
+         * Attack (percent).
+         */
+        const ATK_P = 4;
+
+        /**
+         * Defense  (flat).
+         */
+        const DEF = 5;
+
+        /**
+         * Defense (percent).
+         */
+        const DEF_P = 6;
+
+        /**
+         * Speed.
+         */
+        const SPD = 8;
+
+        /**
+         * Critical Rate.
+         */
+        const CRR = 9;
+
+        /**
+         * Critical Damage.
+         */
+        const CRD = 10;
+
+        /**
+         * Resistance.
+         */
+        const RES = 11;
+
+        /**
+         * Accuracy.
+         */
+        const ACC = 12;
+    };
+
+    /**
+     * Rune (and other items) quality constants.
+     *
+     * @category Data
+     */
+    final class QUALITY_ID{
+
+        /**
+         * Normal.
+         */
+        const NORMAL = 1;
+
+        /**
+         * Magic.
+         */
+        const MAGIC = 2;
+
+        /**
+         * Rare.
+         */
+        const RARE = 3;
+
+        /**
+         * Hero.
+         */
+        const HERO = 4;
+
+        /**
+         * Legend.
+         */
+        const LEGEND = 5;
+    };
+
+    /**
+     * Craft items constants.
+     *
+     * @category Data
+     */
+    final class CRAFT_ID{
+
+        /**
+         * Enchant Gem.
+         */
+        const ENCHANT_GEM = 1;
+
+        /**
+         * Grindstone.
+         */
+        const GRINDSTONE = 2;
+
+        /**
+         * Immemorial Gem.
+         */
+        const IMMEMORIAL_GEM = 3;
+
+        /**
+         * Immemorial Grindstone.
+         */
+        const IMMEMORIAL_GRINDSTONE = 4;
+    };
+
+    /**
+     * Guild member rank constants.
+     *
+     * @category Data
+     */
+    final class GUILD_MEMBER_GRADE_ID{
+
+        /**
+         * Leader.
+         */
+        const LEADER = 1;
+
+        /**
+         * Viceleader.
+         */
+        const VICELEADER = 3;
+
+        /**
+         * Normal member.
+         */
+        const NORMAL = 2;
+    };
+
+    /**
+     * Arena ranking constant.
+     *
+     * Each element contains the minimum points for a rank. To calculate rank,
+     * @{see ARENA_RANKING_RANK} is neeeded too.
+     *
+     * @category Data
+     */
+    final class ARENA_RANKING_POINTS{
+
+        /**
+         * Beginer.
+         */
+        const BEGINER = 0;
+
+        /**
+         * Challenger 1.
+         */
+        const CHALLENGER_1 = 900;
+
+        /**
+         * Challenger 2.
+         */
+        const CHALLENGER_2 = 1000;
+
+        /**
+         * Challenger 3.
+         */
+        const CHALLENGER_3 = 1100;
+
+        /**
+         * Fighter 1.
+         */
+        const FIGHTER_1 = 1200;
+
+        /**
+         * Fighter 2.
+         */
+        const FIGHTER_2 = 1300;
+
+        /**
+         * Fighter 3.
+         */
+        const FIGHTER_3 = 1400;
+
+        /**
+         * Conqueror 1.
+         */
+        const CONQUEROR_1 = 1500;
+
+        /**
+         * Conqueror 2.
+         */
+        const CONQUEROR_2 = 1600;
+
+        /**
+         * Conqueror 3.
+         */
+        const CONQUEROR_3 = 1700;
+
+        /**
+         * Guardian 1.
+         */
+        const GUARDIAN_1 = 1700;
+
+        /**
+         * Guardian 2.
+         */
+        const GUARDIAN_2 = 1700;
+
+        /**
+         * Guardian 3.
+         */
+        const GUARDIAN_3 = 1700;
+
+        /**
+         * Legend.
+         */
+        const LEGEND = 1700;
+    };
+
+    /**
+     * Arena ranking constant.
+     *
+     * Each element contains the minimum top needed for a rank. A null value
+     * indicates that there is no top requeriment.To calculate rank,
+     * @{see ARENA_RANKING_POINTS} is neeeded too.
+     *
+     * @category Data
+     */
+    final class ARENA_RANKING_RANK{
+
+        /**
+         * Beginer.
+         */
+        const BEGINER = null;
+
+        /**
+         * Challenger 1.
+         */
+        const CHALLENGER_1 = null;
+
+        /**
+         * Challenger 2.
+         */
+        const CHALLENGER_2 = null;
+
+        /**
+         * Challenger 3.
+         */
+        const CHALLENGER_3 = null;
+
+        /**
+         * Fighter 1.
+         */
+        const FIGHTER_1 = null;
+
+        /**
+         * Fighter 2.
+         */
+        const FIGHTER_2 = null;
+
+        /**
+         * Fighter 3.
+         */
+        const FIGHTER_3 = null;
+
+        /**
+         * Conqueror 1.
+         */
+        const CONQUEROR_1 = 10000;
+
+        /**
+         * Conqueror 2.
+         */
+        const CONQUEROR_2 = 3000;
+
+        /**
+         * Conqueror 3.
+         */
+        const CONQUEROR_3 = 1000;
+
+        /**
+         * Guardian 1.
+         */
+        const GUARDIAN_1 = 300;
+
+        /**
+         * Guardian 2.
+         */
+        const GUARDIAN_2 = 100;
+
+        /**
+         * Guardian 3.
+         */
+        const GUARDIAN_3 = 30;
+
+        /**
+         * Legend.
+         */
+        const LEGEND = 1;
+    };
+
+    /**
+     * Default filter values;
+     * 
+     * @category Data
+     */
+    final class FILTER{
+
+        /**
+         * Default values for the catalog filters.
+         */
+        const CATALOG = [
+            "ELEMENT" => 0,
+            "NAME" => "",
+            "MIN_STARS" => 1,
+            "MAX_STARS" => 5
+        ];
+
+        /**
+         * Default values for the fusion filters.
+         */
+        const FUSION = [
+            "PRODUCT" => 0
+        ];
+
+        /**
+         * Default values for the monster filters.
+         */
+        const MONSTER = [
+            "ELEMENT" => 0,
+            "NAME" => "",
+            "MIN_STARS" => 1,
+            "MAX_STARS" => 6,
+            "IN_STORAGE" => false,
+            "WITHOUT_RUNES" => false
+        ];
+
+        /**
+         * Default values for the rune craft report filters.
+         */
+        const RUNECRAFT = [
+            "MONSTER_NAME" => "",
+            "MONSTER_MIN_STARS" => 5,
+            "MONSTER_MAX_STARS" => 6,
+            "MONSTER_IN_STORAGE" => false,
+            "RUNE_MIN_STARS" => 5,
+            "RUNE_MAX_STARS" => 6,
+            "RUNE_MIN_LEVEL" => 0,
+            "RUNE_MAX_LEVEL" => 15,
+            "RUNE_MIN_QUALITY" => QUALITY_ID::HERO,
+            "RUNE_MAX_QUALITY" => QUALITY_ID::LEGEND,
+            "RUNE_MIN_ORIGINAL_QUALITY" => QUALITY_ID::HERO,
+            "RUNE_MAX_ORIGINAL_QUALITY" => QUALITY_ID::LEGEND,
+            "RUNE_MIN_EFFICIENCY" => 0,
+            "RUNE_MAX_EFFICIENCY" => 100,
+            "RUNE_MIN_MAX_EFFICIENCY" => 0,
+            "RUNE_MAX_MAX_EFFICIENCY" => 100,
+            "RUNE_SLOT" => [],
+            "GRIND" => 1,
+            "GRIND_MIN_QUALITY" => QUALITY_ID::RARE,
+            "GRIND_STAT" => [
+                RUNE_STAT_ID::HP_P,
+                RUNE_STAT_ID::ATK_P,
+                RUNE_STAT_ID::DEF_P,
+                RUNE_STAT_ID::SPD,
+                RUNE_STAT_ID::CRD,
+                RUNE_STAT_ID::CRR,
+                RUNE_STAT_ID::ACC
+            ],
+            "GEM" => 1,
+            "GEM_MIN_QUALITY" => QUALITY_ID::RARE,
+            "GEM_STAT_FROM" => [
+                RUNE_STAT_ID::HP,
+                RUNE_STAT_ID::ATK,
+                RUNE_STAT_ID::DEF,
+                RUNE_STAT_ID::RES
+            ],
+            "GEM_STAT_TO" => [
+                RUNE_STAT_ID::HP_P,
+                RUNE_STAT_ID::ATK_P,
+                RUNE_STAT_ID::DEF_P,
+                RUNE_STAT_ID::SPD,
+                RUNE_STAT_ID::CRD,
+                RUNE_STAT_ID::CRR,
+                RUNE_STAT_ID::ACC
+            ]
+        ];
+
+        /**
+         * Default values for the rune upgrade report filters.
+         */
+        const RUNEUPGRADE = [
+            "MONSTER_MIN_STARS" => 5,
+            "MONSTER_MAX_STARS" => 6,
+            "MONSTER_NAME" => "",
+            "MONSTER_IN_STORAGE" => false,
+            "RUNE_MIN_STARS" => 5,
+            "RUNE_MAX_STARS" => 6,
+            "RUNE_MIN_LEVEL" => 0,
+            "RUNE_MAX_LEVEL" => 15,
+            "RUNE_MIN_QUALITY" => QUALITY_ID::NORMAL,
+            "RUNE_MAX_QUALITY" => QUALITY_ID::LEGEND,
+            "RUNE_MIN_ORIGINAL_QUALITY" => QUALITY_ID::NORMAL,
+            "RUNE_MAX_ORIGINAL_QUALITY" => QUALITY_ID::LEGEND,
+            "RUNE_MIN_EFFICIENCY" => 0,
+            "RUNE_MAX_EFFICIENCY" => 100,
+            "RUNE_MIN_MAX_EFFICIENCY" => 0,
+            "RUNE_MAX_MAX_EFFICIENCY" => 100,
+            "RUNE_SLOT" => [],
+            "ALTERNATIVE_MIN_STARS" => 5,
+            "ALTERNATIVE_MIN_ORIGINAL_QUALITY" => 0,
+            "ALTERNATIVE_MIN_LEVEL" => 0,
+            "ALTERNATIVE_CONDITION" => 3,
+            "ALTERNATIVE_SOURCE" => 0
+        ];
+
+        /**
+         * Default values for the skill-up report filters.
+         */
+        const SKILLUP = [
+            "MIN_STARS" => 5,
+            "MAX_STARS" => 6,
+            "MIN_NATURAL_STARS" => 5,
+            "MAX_NATURAL_STARS" => 5,
+            "IN_STORAGE" => false,
+            "WITHOUT_RUNES" => false,
+            "FAMILY" => false,
+            "MAXED" => false,
+            "2A" => false,
+            "HOMUNCULUS" => false
+        ];
+
+        /**
+         * Default values for the rune filters.
+         */
+        const RUNE = [
+            "TYPE" => [],
+            "MAIN" => [],
+            "SUB" => [],
+            "SLOT" => [],
+            "MIN_QUALITY" => QUALITY_ID::NORMAL,
+            "MAX_QUALITY" => QUALITY_ID::LEGEND,
+            "MIN_ORIGINAL_QUALITY" => QUALITY_ID::NORMAL,
+            "MAX_ORIGINAL_QUALITY" => QUALITY_ID::LEGEND,
+            "MIN_STARS" => 1,
+            "MAX_STARS" => 6,
+            "MIN_LEVEL" => 0,
+            "MAX_LEVEL" => 15,
+            "MIN_EFFICIENCY" => 0,
+            "MAX_EFFICIENCY" => 100,
+            "MIN_MAX_EFFICIENCY" => 0,
+            "MAX_MAX_EFFICIENCY" => 100,
+            "ASSIGNED" => 1,
+            "GROUP" => "SLOT"
+        ];
+
+        /**
+         * Default values for the run filters.
+         */
+        const RUN = [
+            "AREA_TYPE" => 0,
+            "AREA" => 0,
+            "STAGE" => 0,
+            "DIFFICULTY" => 0,
+            "DATE_MIN" => null,
+            "DATE_MAX" => null,
+            "DEFEAT" => false,
+            "HELPER" => false,
+            "NUMBER" => 20,
+        ];
+
+        /**
+         * Default values for the rune team filters.
+         */
+        const TEAM = [
+            "NAME" => "",
+            "AREA" => null
+        ];
+    };
 
 ?>

+ 50 - 32
application/Controller.php

@@ -1,13 +1,26 @@
 <?php
 
+    /**
+     * Controller file.
+     *
+     * Provides a class to handle all posible request.
+     * 
+     * @category Constroller
+     */
+
+    /**
+     * Include some required files.
+     */
     require_once(__DIR__ . "/config.php");
-    require_once($path["helper"] . "db.php");
-    require_once($path["helper"] . "text.php");
-    require_once($path["helper"] . "net.php");
-    require_once($path["helper"] . "html.php");
+    require_once(PATH::HELPER . "DB_Helper.php");
+    require_once(PATH::HELPER . "TEXT_Helper.php");
+    require_once(PATH::HELPER . "NET_Helper.php");
+    require_once(PATH::HELPER . "HTML_Helper.php");
     require_once(__DIR__ . "/Constant.php");
-    require_once(__DIR__ . "/Filter.php");
 
+    /**
+     * @global int $UID.
+     */
     $UID = 0;
 
     /**
@@ -15,6 +28,8 @@
      *
      * Handles every request, creating the required models and selecting the
      * view.
+     *
+     * @category Controller
      */
     class Controller {
 
@@ -24,16 +39,17 @@
          * Handles every request, creating the required models and selecting the
          * view.
          *
-         * @param Array $params POST parameters of the request.
+         * @param mixed[] $params POST parameters of the request.
+         * @return int HTTP status codes 200 or 404;
+         * @global int User ID.
          */
         public function __construct($params){
 
-            global $path;
             global $UID;
             $page;
 
             session_start();
-            $db = start_db();
+            $db = DB::start();
 
             // Parse parameters, get lang and build the route.
             $pars = [];
@@ -48,27 +64,27 @@
             if (count($pars) > 1 && strtoupper($pars[0]) == "ACTION"){
                 switch (strtoupper($pars[1])){
                     case "LOGIN":
-                        require_once($path["action"] . "login.php");
+                        require_once(PATH::ACTION . "login.php");
                         action($db);
                         return;
                         break;
                     case "LOGOUT":
-                        require_once($path["action"] . "logout.php");
+                        require_once(PATH::ACTION . "logout.php");
                         action($db);
                         return;
                         break;
                     case "NEW_TEAM":
-                        require_once($path["action"] . "new_team.php");
+                        require_once(PATH::ACTION . "new_team.php");
                         action($db);
                         return;
                         break;
                     case "SAVE_RUN_TEAM":
-                        require_once($path["action"] . "save_run_team.php");
+                        require_once(PATH::ACTION . "save_run_team.php");
                         action($db);
                         return;
                         break;
                     case "EDIT_PROFILE":
-                        require_once($path["action"] . "edit_profile.php");
+                        require_once(PATH::ACTION . "edit_profile.php");
                         $response = action($db);
                         if (strlen($response) > 1){
                             echo($response);
@@ -79,7 +95,7 @@
                         }
                         break;
                     default:
-                        require_once($path["page"] . "Error_Page.php");
+                        require_once(PATH::PAGE . "Error_Page.php");
                         $page = new Error_Page($db, 404);
                         http_response_code(404);
                 }
@@ -90,7 +106,7 @@
                 setcookie("uid", "", time() - 3600);
                 $_SESSION["session"] = false;
                 $_SESSION["uid"] = "";
-                require_once($path["page"] . "Landing_Page.php");
+                require_once(PATH::PAGE . "Landing_Page.php");
                 $page = new Landing_Page($db);
                 require_once($page->view);
                 return;
@@ -108,7 +124,7 @@
             $q = $db->query("SELECT count(uid) AS c FROM player WHERE uid = '$UID';");
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r["c"] == 0){
-                require_once($path["page"] . "Landing_Page.php");
+                require_once(PATH::PAGE . "Landing_Page.php");
                 $page = new Landing_Page($db);
                 require_once($page->view);
                 return;
@@ -135,69 +151,69 @@
             // Select the model to load.
             array_shift($pars); // Remove first one, should be UID
             if (sizeof($pars) == 0){
-                require_once($path["page"] . "Home_Page.php");
+                require_once(PATH::PAGE . "Home_Page.php");
                 $page = new Home_Page($db);
             }
             else{
                 if (strtoupper($pars[0]) == "FUSION"){
-                    require_once($path["page"] . "Fusion_Page.php");
+                    require_once(PATH::PAGE . "Fusion_Page.php");
                     $page = new Fusion_Page($db);
                 }
                 elseif (strtoupper($pars[0]) == "RUNES"){
-                    require_once($path["page"] . "Runes_Page.php");
+                    require_once(PATH::PAGE . "Runes_Page.php");
                     $page = new Runes_Page($db);
                 }
                 elseif (strtoupper($pars[0]) == "GUILD"){
-                    require_once($path["page"] . "Guild_Page.php");
+                    require_once(PATH::PAGE . "Guild_Page.php");
                     $page = new Guild_Page($db);
                 }
                 elseif (strtoupper($pars[0]) == "RUNS"){
-                    require_once($path["page"] . "Runs_Page.php");
+                    require_once(PATH::PAGE . "Runs_Page.php");
                     $page = new Runs_Page($db);
                 }
                 elseif (strtoupper($pars[0]) == "TEAMS"){
-                    require_once($path["page"] . "Teams_Page.php");
+                    require_once(PATH::PAGE . "Teams_Page.php");
                     $page = new Teams_Page($db);
                 }
                 elseif (strtoupper($pars[0]) == "PROFILE"){
-                    require_once($path["page"] . "Profile_Page.php");
+                    require_once(PATH::PAGE . "Profile_Page.php");
                     $page = new Profile_Page($db);
                 }
                 elseif (strtoupper($pars[0]) == "MONSTERS"){
                     if (count($pars) == 1){
-                        require_once($path["page"] . "Monsters_Page.php");
+                        require_once(PATH::PAGE . "Monsters_Page.php");
                         $page = new Monsters_Page($db);
                     }
                     else{
-                        require_once($path["page"] . "Monster_Page.php");
+                        require_once(PATH::PAGE . "Monster_Page.php");
                         $page = new Monster_Page($db, $pars[1]);
                     }
                 }
                 elseif (strtoupper($pars[0]) == "CATALOG"){
                     if (count($pars) == 1){
-                        require_once($path["page"] . "Catalog_Page.php");
+                        require_once(PATH::PAGE . "Catalog_Page.php");
                         $page = new Catalog_Page($db);
                     }
                     else{
-                        require_once($path["page"] . "Monster_Info_Page.php");
+                        require_once(PATH::PAGE . "Monster_Info_Page.php");
                         $page = new Monster_Info_Page($db, $pars[1]);
                     }
                 }
                 elseif (strtoupper($pars[0]) == "REPORT"){
                     if (count($pars) == 1){
-                        require_once($path["page"] . "Report_Page.php");
+                        require_once(PATH::PAGE . "Report_Page.php");
                         $page = new Report_Page($db);
                     }
                     elseif (strtoupper($pars[1]) == "SKILLUP"){
-                        require_once($path["page"] . "Report_Skillup_Page.php");
+                        require_once(PATH::PAGE . "Report_Skillup_Page.php");
                         $page = new Report_Skillup_Page($db, $pars[1]);
                     }
                     elseif (strtoupper($pars[1]) == "RUNEUPGRADE"){
-                        require_once($path["page"] . "Report_Runeupgrade_Page.php");
+                        require_once(PATH::PAGE . "Report_Runeupgrade_Page.php");
                         $page = new Report_Runeupgrade_Page($db, $pars[1]);
                     }
                     elseif (strtoupper($pars[1]) == "RUNECRAFT"){
-                        require_once($path["page"] . "Report_Runecraft_Page.php");
+                        require_once(PATH::PAGE . "Report_Runecraft_Page.php");
                         $page = new Report_Runecraft_Page($db, $pars[1]);
                     }
 
@@ -206,11 +222,13 @@
             // Load the view, or set an error code.
             if (isset($page)){
                 require_once($page->view);
+                return 200;
             }
             else{
-                require_once($path["page"] . "Error_Page.php");
+                require_once(PATH::PAGE . "Error_Page.php");
                 $page = new Error_Page($db, 404);
                 http_response_code(404);
+                return 404;
             }
         }
     }

+ 0 - 149
application/Filter.php

@@ -1,149 +0,0 @@
-<?php
-
-    global $QUALITY;
-    global $RUNE_STAT;
-
-    $FILTER_CATALOG = [
-        "element" => 0,
-        "name" => "",
-        "min_stars" => 1,
-        "max_stars" => 5
-    ];
-
-    $FILTER_FUSION = [
-        "product" => 0
-    ];
-
-    $FILTER_MONSTER = [
-        "element" => 0,
-        "name" => "",
-        "min_stars" => 1,
-        "max_stars" => 6,
-        "in_storage" => false,
-        "without_runes" => false
-    ];
-
-    $FILTER_RUNECRAFT = [
-        "monster_name" => "",
-        "monster_min_stars" => 5,
-        "monster_max_stars" => 6,
-        "monster_in_storage" => false,
-        "rune_min_stars" => 5,
-        "rune_max_stars" => 6,
-        "rune_min_level" => 0,
-        "rune_max_level" => 15,
-        "rune_min_quality" => $QUALITY["HERO"],
-        "rune_max_quality" => $QUALITY["LEGEND"],
-        "rune_min_original_quality" => $QUALITY["HERO"],
-        "rune_max_original_quality" => $QUALITY["LEGEND"],
-        "rune_min_efficiency" => 0,
-        "rune_max_efficiency" => 100,
-        "rune_min_max_efficiency" => 0,
-        "rune_max_max_efficiency" => 100,
-        "rune_slot" => [],
-        "grind" => 1,
-        "grind_min_quality" => $QUALITY["RARE"],
-        "grind_stat" => [
-            $RUNE_STAT["HP%"],
-            $RUNE_STAT["ATK%"],
-            $RUNE_STAT["DEF%"],
-            $RUNE_STAT["SPD"],
-            $RUNE_STAT["CRD"],
-            $RUNE_STAT["CRR"],
-            $RUNE_STAT["ACC"]
-        ],
-        "gem" => 1,
-        "gem_min_quality" => $QUALITY["RARE"],
-        "gem_stat_from" => [
-            $RUNE_STAT["HP"],
-            $RUNE_STAT["ATK"],
-            $RUNE_STAT["DEF"],
-            $RUNE_STAT["RES"]
-        ],
-        "gem_stat_to" => [
-            $RUNE_STAT["HP%"],
-            $RUNE_STAT["ATK%"],
-            $RUNE_STAT["DEF%"],
-            $RUNE_STAT["SPD"],
-            $RUNE_STAT["CRD"],
-            $RUNE_STAT["CRR"],
-            $RUNE_STAT["ACC"]
-        ]
-    ];
-
-    $FILTER_RUNEUPGRADE = [
-        "monster_min_stars" => 5,
-        "monster_max_stars" => 6,
-        "monster_name" => "",
-        "monster_in_storage" => false,
-        "rune_min_stars" => 5,
-        "rune_max_stars" => 6,
-        "rune_min_level" => 0,
-        "rune_max_level" => 15,
-        "rune_min_quality" => $QUALITY["NORMAL"],
-        "rune_max_quality" => $QUALITY["LEGEND"],
-        "rune_min_original_quality" => $QUALITY["NORMAL"],
-        "rune_max_original_quality" => $QUALITY["LEGEND"],
-        "rune_min_efficiency" => 0,
-        "rune_max_efficiency" => 100,
-        "rune_min_max_efficiency" => 0,
-        "rune_max_max_efficiency" => 100,
-        "rune_slot" => [],
-        "alternative_min_stars" => 5,
-        "alternative_min_original_quality" => 0,
-        "alternative_min_level" => 0,
-        "alternative_condition" => 3,
-        "alternative_source" => 0
-    ];
-
-    $FILTER_SKILLUP = [
-        "min_stars" => 5,
-        "max_stars" => 6,
-        "min_natural_stars" => 5,
-        "max_natural_stars" => 5,
-        "in_storage" => false,
-        "without_runes" => false,
-        "family" => false,
-        "maxed" => false,
-        "2a" => false,
-        "homunculus" => false
-    ];
-
-    $FILTER_RUNE = [
-        "type" => [],
-        "main" => [],
-        "sub" => [],
-        "slot" => [],
-        "min_quality" => $QUALITY["NORMAL"],
-        "max_quality" => $QUALITY["LEGEND"],
-        "min_original_quality" => $QUALITY["NORMAL"],
-        "max_original_quality" => $QUALITY["LEGEND"],
-        "min_stars" => 1,
-        "max_stars" => 6,
-        "min_level" => 0,
-        "max_level" => 15,
-        "min_efficiency" => 0,
-        "max_efficiency" => 100,
-        "min_max_efficiency" => 0,
-        "max_max_efficiency" => 100,
-        "assigned" => 1,
-        "group" => "SLOT"
-    ];
-
-    $FILTER_RUN = [
-        "area_type" => 0,
-        "area" => 0,
-        "stage" => 0,
-        "difficulty" => 0,
-        "date_min" => null,
-        "date_max" => null,
-        "defeat" => false,
-        "helper" => false,
-        "number" => 20,
-    ];
-
-    $FILTER_TEAM = [
-        "name" => "",
-        "area" => null
-    ];
-?>

+ 28 - 17
application/action/edit_profile.php

@@ -1,23 +1,29 @@
 <?php
 
-    function generateApi($length = 16) {
-        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
-        $charactersLength = strlen($characters);
-        $randomString = '';
-        for ($i = 0; $i < $length; $i++) {
-            $randomString .= $characters[rand(0, $charactersLength - 1)];
-        }
-        return $randomString;
-    }
+    /**
+     * File for the profile edit action.
+     *
+     * Implements an action function to be called from the {@see Controller}.
+     * 
+     * @category Action
+     */
 
+    /**
+     * Executes the profile update.
+     *
+     * Reads the POST parameters looking for the following KEYS:
+     *  mail
+     *  pass + currentPass
+     *  api
+     * Then it updates the selected info with the prameter vlue. Multiple
+     * itemas can be updated at the same time.
+     * 
+     * @param resource $db Database connection. 
+     * @return int|string 0 on success, negative values on error. If the API
+     * key has been updated, the new key.
+     * @category Action
+     */
     function action($db = null){
-        global $AREA_TYPE;
-        global $DIFFICULTY;
-        global $SCENARIO;
-        global $DUNGEON;
-        global $ELEMENTAL_RIFT_DUNGEON;
-        global $LABYRINTH_STAGES;
-        global $UID;
 
         $response = null;
 
@@ -48,7 +54,12 @@
         }
 
         if (filter_input(INPUT_POST, "api")){
-            $api = generateApi();
+            $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+            $charactersLength =16;
+            $api = '';
+            for ($i = 0; $i < $length; $i++) {
+                $api .= $characters[rand(0, $charactersLength - 1)];
+            }
             $s = $db->prepare('UPDATE player SET api_key = :api WHERE uid = :uid;');
             $s->bindValue(':uid', $player);
             $s->bindValue(':api', $api);

+ 22 - 0
application/action/login.php

@@ -1,4 +1,26 @@
 <?php
+
+    /**
+     * File for the login action.
+     *
+     * Implements an action function to be called from the {@see Controller}.
+     * 
+     * @category Action
+     */
+
+    /**
+     * Logs the user in.
+     *
+     * Reads the POST parameters looking for the following KEYS:
+     *  uname
+     *  password
+     * If there is a match, it sets cookies and session variables, and
+     * redirects to the user homepage.
+     * 
+     * @param resource $db Database connection. 
+     * @return int 0 on success, negative values on error.
+     * @category Action
+     */
     function action($db = null){
         if (!isset($_POST['uname'], $_POST['password'])){
             return -1;

+ 19 - 0
application/action/logout.php

@@ -1,4 +1,23 @@
 <?php
+
+    /**
+     * File for the login action.
+     *
+     * Implements an action function to be called from the {@see Controller}.
+     * 
+     * @category Action
+     */
+
+    /**
+     * Logs the user out and redirects to the login page.
+     *
+     * Invalidates cookies and session variables.
+     * 
+     * @param resource $db Database connection. 
+     * @return int 0.
+     * @category Action
+     * @global int The user id.
+     */
     function action($db = null){
         global $UID;
         $UID = null;

+ 49 - 17
application/action/new_team.php

@@ -1,12 +1,44 @@
 <?php
+
+    /**
+     * File for the team creation action.
+     *
+     * Implements an action function to be called from the {@see Controller}.
+     * 
+     * @category Action
+     */
+
+    // TODO: Replace in_array for property_exists
+
+    /**
+     * Logs the user out and redirects to the login page.
+     *
+     * Reads the POST parameters looking for the following KEYS:
+     *  uid
+     *  area_type
+     *  area
+     *  stage
+     *  difficulty
+     *  ids
+     *  name
+     *  description
+     * Validates the data and creates the team in the database.
+     * 
+     * @param resource $db Database connection. 
+     * @return int 0 on success, negative values on error.
+     * @category Action
+     * @global int[] Area types.
+     * @global int[] Difficulty levels.
+     * @global int[] Scenario areas.
+     * @global int[] Dungeon sections.
+     * @global int[] Elemental rift dungeons.
+     * @global int[] Labyrinth stage types.
+     */
     function action($db = null){
-        global $AREA_TYPE;
-        global $DIFFICULTY;
         global $SCENARIO;
         global $DUNGEON;
         global $ELEMENTAL_RIFT_DUNGEON;
         global $LABYRINTH_STAGES;
-        global $UID;
 
         //$player = SQLite3::escapeString($_POST["uid"]);
         $player = filter_input(INPUT_POST, 'uid');
@@ -23,11 +55,11 @@
             return -1;
         }
         switch ($area_type){
-            case $AREA_TYPE["SCENARIO"]:
+            case AREA_TYPE::SCENARIO:
                 if ($stage < 0 || $stage > 7){
                     return -31;
                 }
-                if (!($difficulty == 0 || in_array($difficulty, $DIFFICULTY) || $difficulty == $DIFFICULTY["EASY"])){
+                if (!($difficulty == 0 || in_array($difficulty, $DIFFICULTY) || $difficulty == DIFFICULTY::EASY)){
                     return -32;
                 }
                 if ($id_count < 1 || $id_count > 4){
@@ -37,7 +69,7 @@
                     return -34;
                 }
                 break;
-            case $AREA_TYPE["CAIROS_DUNGEON"]:
+            case AREA_TYPE::CAIROS_DUNGEON:
                 if ($stage < 0 || $stage > 10){
                     return -35;
                 }
@@ -49,7 +81,7 @@
                     return -37;
                 }
                 break;
-            case $AREA_TYPE["RIFT_DUNGEON"]:
+            case AREA_TYPE::RIFT_DUNGEON:
                 $stage = null;
                 $difficulty = null;
                 if ($id_count < 1 || $id_count > 6){
@@ -59,7 +91,7 @@
                     return -40;
                 }
                 break;
-            case $AREA_TYPE["RIFT_RAID"]:
+            case AREA_TYPE::RIFT_RAID:
                 if ($stage < 0 || $stage > 5){
                     return -41;
                 }
@@ -69,22 +101,22 @@
                 }
                 $area = null;
                 break;
-            case $AREA_TYPE["ARENA"]:
+            case AREA_TYPE::ARENA:
                 $area = null;
                 $stage = null;
                 $difficulty = null;
                 break;
-            case $AREA_TYPE["GUILD_WAR"]:
+            case AREA_TYPE::GUILD_WAR:
                 $area = null;
                 $stage = null;
                 $difficulty = null;
                 break;
-            case $AREA_TYPE["GUILD_SIEGE"]:
+            case AREA_TYPE::GUILD_SIEGE:
                 $area = null;
                 $stage = null;
                 $difficulty = null;
                 break;
-            case $AREA_TYPE["TARTARUS_LABYRINTH"]:
+            case AREA_TYPE::TARTARUS_LABYRINTH:
                 $stage = null;
                 if ($difficulty < 0 || !in_array($difficulty, $DIFFICULTY)){
                     return -43;
@@ -96,8 +128,8 @@
                     return -45;
                 }
                 break;
-            case $AREA_TYPE["TRIAL_OF_ASCENSION"]:
-                if ($difficulty != 0 && $difficulty != $DIFFICULTY["NORMAL"] && $difficulty != $DIFFICULTY["HARD"]){
+            case AREA_TYPE::TRIAL_OF_ASCENSION:
+                if ($difficulty != 0 && $difficulty != DIFFICULTY::NORMAL && $difficulty != DIFFICULTY::HARD){
                     return -46;
                 }
                 $stage = null;
@@ -106,7 +138,7 @@
                 }
                 $area = null;
                 break;
-            case $AREA_TYPE["DIMENSIONAL_HOLE"]:
+            case AREA_TYPE::DIMENSIONAL_HOLE:
                 if ($stage < 0 || $stage > 5){
                     return -48;
                 }
@@ -118,8 +150,8 @@
                     return -50;
                 }
                 break;
-            case $AREA_TYPE["DIMENSIONAL_RIFT"]:
-                if ($difficulty != 0 && $difficulty != $DIFFICULTY["NORMAL"] && $difficulty != $DIFFICULTY["HARD"]){
+            case AREA_TYPE::DIMENSIONAL_RIFT:
+                if ($difficulty != 0 && $difficulty != DIFFICULTY::NORMAL && $difficulty != DIFFICULTY::HARD){
                     return -51;
                 }
                 $stage = null;

+ 22 - 0
application/action/save_run_team.php

@@ -1,4 +1,26 @@
 <?php
+    /**
+     * File for the run team saving action.
+     *
+     * Implements an action function to be called from the {@see Controller}.
+     * 
+     * @category Action
+     */
+
+    /**
+     * Saves a run party as a team.
+     *
+     * Reads the POST parameters looking for the following KEYS:
+     *  uid
+     *  run
+     *  name
+     *  description
+     * Validates the data and creates the team in the database.
+     * 
+     * @param resource $db Database connection. 
+     * @return int 0 on success, negative values on error.
+     * @category Action
+     */
     function action($db = null){
         $player = filter_input(INPUT_POST, 'uid');
         $run = filter_input(INPUT_POST, 'run');

+ 135 - 44
application/config.php

@@ -1,49 +1,140 @@
 <?php
+    /**
+     * Configuration variables.
+     *
+     * Not meant to be edited by the user.
+     *
+     * @category Data
+     */
 
-    require_once(__DIR__ . "/helper/net.php");
-
-    $app_version = "2";
-
-    $root = get_protocol() . $_SERVER["HTTP_HOST"] . "/";
-
-    $base_dir = $_SERVER["DOCUMENT_ROOT"] . "/";
-
-    $path = [
-        "img" => [
-            "root" => $root . "img/",
-            "icon" => $root . "img/icon/",
-            "logo" => $root . "img/logo/",
-            "currency" => $root . "img/currency/",
-            "unit" => $root . "img/unit/",
-            "area" => $root . "img/area/",
-            "skill" => $root . "img/skill/",
-            "essence" => $root . "img/essence/",
-            "rune" => $root . "img/rune/",
-            "grind" => $root . "img/grind/",
-            "element" => $root . "img/element/",
-            "skill_guild" => $root . "img/skill_guild/",
-            "decoration" => $root . "img/decoration/",
-            "source" => $root . "img/source/",
-            "skill_leader" => $root . "img/skill_leader/",
-            "inventory" => $root . "img/inventory/",
-            "effect" => $root . "img/effect/",
-            "building" => $root . "img/building/",
-        ],
-        "fonts" => $root . "fonts/",
-        "css" => $root . "css/",
-        "js" => $root . "script/",
-        "application" => "$base_dir../application/",
-        "controller" => "$base_dir../application/Controller.php",
-        "entity" => "$base_dir../application/entity/",
-        "page" => "$base_dir../application/page/",
-        "action" => "$base_dir../application/action/",
-        "frame" => "$base_dir../application/page/frame/",
-        "handler" => "$base_dir../application/handler/",
-        "view" => "$base_dir../application/view/",
-        "helper" => "$base_dir../application/helper/",
-        "db_key" => "$base_dir../application/sw.sqlite",
-        "db_data" => "$base_dir../data/sw.sqlite",
-    ];
+    /**
+     * Define constant and includesome helpers.
+     */
+    define('BASE_PATH', $_SERVER["DOCUMENT_ROOT"] . "/");
+    require_once(__DIR__ . "/helper/NET_Helper.php");
+    define('BASE_URL', NET::get_protocol() . $_SERVER["HTTP_HOST"] . "/");
+
+    /**
+     * App related constants.
+     *
+     * @category Data
+     */
+    final class APP{
+
+        /**
+         * App version.
+         *
+         * Can be any string, not just numbers.
+         */
+        const VERSION = "2";
+    }
+
+    /**
+     * In-app URLs.
+     *
+     * @category Data
+     */
+    final class URL{
+
+        /**
+         * Domain, with protcol (includes final '/').
+         */
+        const BASE = BASE_URL;
+
+        /**
+         * Fonts full url (includes final '/').
+         */
+        const FONTS = BASE_URL . "/fonts/";
+
+        /**
+         * CSS full url (includes final '/').
+         */
+        const CSS = BASE_URL . "/css/";
+
+        /**
+         * Paths to image resources.
+         */
+        const IMG = array(
+            "BASE" => BASE_URL . "img/",
+            "UNKNOWN" => BASE_URL . "img/unknown.png",
+            "ICON" => BASE_URL . "img/icon/",
+            "LOGO" => BASE_URL . "img/logo/",
+            "CURRENCY" => BASE_URL . "img/currency/",
+            "UNIT" => BASE_URL . "img/unit/",
+            "AREA" => BASE_URL . "img/area/",
+            "SKILL" => BASE_URL . "img/skill/",
+            "ESSENCE" => BASE_URL . "img/essence/",
+            "RUNE" => BASE_URL . "img/rune/",
+            "GRIND" => BASE_URL . "img/grind/",
+            "ELEMENT" => BASE_URL . "img/element/",
+            "SKILL_GUILD" => BASE_URL . "img/skill_guild/",
+            "DECORATION" => BASE_URL . "img/decoration/",
+            "SOURCE" => BASE_URL . "img/source/",
+            "SKILL_LEADER" => BASE_URL . "img/skill_leader/",
+            "INVENTORY" => BASE_URL . "img/inventory/",
+            "EFFECT" => BASE_URL . "img/effect/",
+            "BUILDING" => BASE_URL . "img/building/",
+        );
+    }
+
+    /**
+     * In-app directories (filesystem, not url).
+     *
+     * @category Data
+     */
+    final class PATH{
+
+        /**
+         * Path to the application direcory.
+         */
+        const APPLICATION = BASE_PATH . "../application/";
+
+        /**
+         * Path to the public direcory.
+         */
+        const BASE = BASE_PATH;
+
+        /**
+         * Path to the controller file.
+         */
+        const CONTROLLER = BASE_PATH . "../application/Controller.php";
+
+        /**
+         * Path to the entity files.
+         */
+        const ENTITY = BASE_PATH . "../application/entity/";
+
+        /**
+         * Path to the page files.
+         */
+        const PAGE = BASE_PATH . "../application/page/";
+
+        /**
+         * Path to the action files.
+         */
+        const ACTION = BASE_PATH . "../application/action/";
+
+        /**
+         * Path to the view files.
+         */
+        const VIEW = BASE_PATH . "../application/view/";
+
+        /**
+         * Path to the helper files.
+         */
+        const HELPER = BASE_PATH . "../application/helper/";
+
+        /**
+         * Path to the db_key files.
+         */
+        const DB_KEY = BASE_PATH . "../application/sw.sqlite";
+
+        /**
+         * Path to the db_data files.
+         */
+        const DB_DATA = BASE_PATH . "../data/sw.sqlite";
+
+    }
 
 ?>
 

+ 18 - 7
application/entity/Building.php

@@ -1,28 +1,40 @@
 <?php
 
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "K_Building.php");
+    /**
+     * Building entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
+    require_once(PATH::ENTITY . "K_Building.php");
 
     /**
      * A Building.
      *
      * Represents an object from the table 'building'.
+     *
+     * @category Entity
      */
     class Building extends Entity{
 
         /**
-         * Owner identifier.
+         * @var int Owner identifier.
          */
         public $uid;
 
         /**
-         * {@see K_Building}.
+         * @var K_Building Base building.
          */
         public $building;
 
         /**
-         * I honestly don't know what the gin is.
+         * @var int Gain per horu.
          */
         public $gain;
 
@@ -32,11 +44,10 @@
          * Searches the database and retrieves the information about the
          * building, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Building identifier.
          */
         public function __construct($db, $id){
-            global $path;
             parent::__construct($db);
             $s = "
                 SELECT

+ 21 - 9
application/entity/Custom_Filter.php

@@ -1,41 +1,53 @@
 <?php
+    /**
+     * Custom filter entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
 
     /**
      * A custom_Filter.
      *
      * Represents an object from the table 'filter'.
+     *
+     * @category Entity
      */
     class Custom_Filter extends Entity{
 
         /**
-         * Player identifier.
+         * @var int Player identifier.
          */
         public $uid;
 
         /**
-         * Filter identifier.
+         * @var int Filter identifier.
          */
         public $id;
 
         /**
-         * Name of the pge the filter is for.
+         * @var string Name of the pge the filter is for.
          */
         public $page;
 
         /**
-         * Filter name.
+         * @var string Filter name.
          */
         public $name;
 
         /**
-         * Filter description.
+         * @var string Filter description.
          */
         public $description;
 
         /**
-         * Filter condition.
+         * @var string Filter condition (sql where clause).
          */
         public $condition;
 
@@ -45,7 +57,7 @@
          * Searches the database and retrieves the information about the
          * run, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Filter identifier.
          */
         public function __construct($db, $id){
@@ -66,7 +78,7 @@
             $this->id = $r["id"];
             $this->uid = $r["uid"];
             $this->page = $r["page"];
-            $this->name = e($r["name"]);
+            $this->name = HTML::e($r["name"]);
             $this->description = $r["description"]; // Must be properly formated!
             $this->condition = $r["condition"];
         }

+ 18 - 8
application/entity/Decoration.php

@@ -1,28 +1,39 @@
 <?php
+    /**
+     * Decoration entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "K_Decoration.php");
-
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
+    require_once(PATH::ENTITY . "K_Decoration.php");
 
     /**
      * A Decoration.
      *
      * Represents an object from the table 'decoration'.
+     *
+     * @category Entity
      */
     class Decoration extends Entity{
 
         /**
-         * Owner identifier.
+         * @var int player identifier.
          */
         public $uid;
 
         /**
-         * {@see K_Decoration}.
+         * @var K_Decoration Base decoration.
          */
         public $decoration;
 
         /**
-         * I honestly don't know what the gin is.
+         * @var int decoration level.
          */
         public $level;
 
@@ -32,11 +43,10 @@
          * Searches the database and retrieves the information about the
          * decoration, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Building identifier.
          */
         public function __construct($db, $id){
-            global $path;
             parent::__construct($db);
             $s = "
                 SELECT

+ 12 - 2
application/entity/Entity.php

@@ -1,15 +1,25 @@
 <?php
+    /**
+     * Base entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
     /**
      * Entity superclass.
      *
      * Every other entity must inherit from this one. It represents a database
      * entity.
+     * 
+     * @abstract
+     * @category Entity
      */
     abstract class Entity{
 
         /**
-         * Database connection.
+         * @var resource Database connection.
          */
         public $db;
 
@@ -18,7 +28,7 @@
          *
          * Sets the database conection and the language.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          */
         public function __construct($db){
             $this->db = $db;

+ 32 - 19
application/entity/Fusion.php

@@ -1,17 +1,29 @@
 <?php
+    /**
+     * Fusion entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "K_Unit.php");
-    require_once($path["entity"] . "Unit.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
+    require_once(PATH::ENTITY . "K_Unit.php");
+    require_once(PATH::ENTITY . "Unit.php");
 
     /**
-     * Extension of {@see K_Unit} that also stores information about owned
+     * Extension of K_Unit that also stores information about owned
      * monsters.
+     * 
+     * @category Entity
      */
     class Monster_Fusion extends K_Unit{
 
         /**
-         * All owned {@see Monster}s of this type.
+         * @var \Unit[] All owned units of this type.
          */
         public $owned = [];
 
@@ -21,11 +33,11 @@
          * Searches the database and retrieves the information about the
          * fusion, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
-         * @param int $id Monster id.
+         * @param resource $db Connection to the database.
+         * @param int $id Unit id.
+         * @param int $uid Player id.
          */
         public function __construct($db, $id, $uid){
-            global $path;
             parent::__construct($db, $id, false);
             $s = "
               SELECT unit.id AS id
@@ -53,46 +65,48 @@
      * Fusion.
      *
      * Represents an object from the table 'fusion'.
+     *
+     * @category Entity
      */
     class Fusion extends Entity{
 
         /**
-         * {@see K_Unit} to fuse.
+         * @var K_Unit K_Unit to fuse.
          */
         public $product;
 
         /**
-         * {@see K_Unit} to fuse (awakened).
+         * @var K_Unit K_Unit to fuse (awakened).
          */
         public $product_awaken;
 
         /**
-         * {@see K_Unit} to fuse (awakened).
+         * @var K_Unit K_Unit to fuse (unawakened).
          */
         public $product_unawaken;
 
         /**
-         * Fusions required to create ingredients.
+         * @var Monster_Fusion Fusions required to create ingredients.
          */
         public $fusion = [];
 
         /**
-         * List of unfuseable {@see K_Unit} material.
+         * @var \K_Unit[] List of unfuseable K_Unit material.
          */
         public $ingredient = [];
 
         /**
-         * List of unfuseable {@see K_Unit} material (awakened).
+         * @var \K_Unit[] List of unfuseable K_Unit material. (unawakened).
          */
         public $ingredient_unawaken = [];
 
         /**
-         * Stars of the monster to fuse.
+         * @var int Stars of the monster to fuse.
          */
         public $stars;
 
         /**
-         * Fusion cost.
+         * @var int Fusion cost.
          */
         public $cost;
 
@@ -102,12 +116,11 @@
          * Searches the database and retrieves the information about the
          * fusion, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Product monster id.
-         * @param int $uid User id (optional)
+         * @param int $uid User id.
          */
         public function __construct($db, $id, $uid = null){
-            global $path;
             parent::__construct($db);
             $s = "
               SELECT DISTINCT

+ 28 - 17
application/entity/Guild.php

@@ -1,63 +1,74 @@
 <?php
+    /**
+     * Guild entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "Guild_Member.php");
-
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
+    require_once(PATH::ENTITY . "Guild_Member.php");
 
     /**
      * Guild.
      *
      * Represents an object from the table 'guild'.
+     *
+     * @category Entity
      */
     class Guild extends Entity{
 
         /**
-         * Guild identifier.
+         * @var int @var int Guild identifier.
          */
         public $id;
 
         /**
-         * Guild name.
+         * @var int @var string Guild name.
          */
         public $name;
 
         /**
-         * Guild level.
+         * @var int @var int Guild level.
          */
         public $level;
 
         /**
-         * Guild total experience.
+         * @var int Guild total experience.
          */
         public $experience;
 
         /**
-         * Indicates if the guild is ecruiting.
+         * @var bool Indicates if the guild is ecruiting.
          */
         public $recruiting;
 
         /**
-         * Number of members.
+         * @var int Number of members.
          */
         public $total_members;
 
         /**
-         * Leader {@see Guild_Member}.
+         * @var GUild_Member Guild Leader.
          */
         public $leader;
 
         /**
-         * Guild comment.
+         * @var string Guild comment.
          */
         public $comment;
 
         /**
-         * Guild notice.
+         * @var string Guild notice.
          */
         public $notice;
 
         /**
-         * List of {@see Guild_Member}s.
+         * @var \Guild_Member[] List of {@see Guild_Member}s.
          */
         public $members = [];
 
@@ -67,7 +78,7 @@
          * Searches the database and retrieves the information about the
          * guild, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Guild identifier.
          */
         public function __construct($db, $id){
@@ -91,14 +102,14 @@
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
-                $this->name = e($r["name"]);
+                $this->name = HTML::e($r["name"]);
                 $this->level = $r["level"];
                 $this->experience = $r["experience"];
                 $this->recruiting = $r["recruiting"];
                 $this->total_members = $r["members"];
                 $this->leader = $r["leader"];
-                $this->comment = e($r["comment"]);
-                $this->notice = e($r["notice"]);
+                $this->comment = HTML::e($r["comment"]);
+                $this->notice = HTML::e($r["notice"]);
             }
             $s =
               "SELECT id " .

+ 26 - 16
application/entity/Guild_Member.php

@@ -1,67 +1,78 @@
 <?php
+    /**
+     * Guild member entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
-
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
 
     /**
      * Guild.
      *
      * Represents an object from the table 'guild'.
+     *
+     * @category Entity
      */
     class Guild_Member extends Entity{
 
         /**
-         * Member identifier.
+         * @var int Member identifier.
          */
         public $id;
 
         /**
-         * Guild id.
+         * @var int Guild id.
          */
         public $guild;
 
         /**
-         * Member name.
+         * @var string Member name.
          */
         public $name;
 
         /**
-         * Member level.
+         * @var int Member level.
          */
         public $level;
 
         /**
-         * Member grade.
+         * @var int Member grade.
          */
         public $grade;
 
         /**
-         * Memeber rating.
+         * @var int Memeber rating.
          */
         public $rating;
 
         /**
-         * Memebr arena score.
+         * @var int Memebr arena score.
          */
         public $arena_score;
 
         /**
-         * Timestam the user joined the guild.
+         * @var DateTime Time the user joined the guild at.
          */
         public $joined;
 
         /**
-         * Timestamp the user last log on.
+         * @var Datetime Time the user last log on at.
          */
         public $last_login;
 
         /**
-         * Indicates if the member is included in guild wars.
+         * @var bool Indicates if the member is included in guild wars.
          */
         public $in_war;
 
         /**
-         * Indicates if the member has set guild wars defenses.
+         * @var bool Indicates if the member has set guild wars defenses.
          */
         public $has_defense;
 
@@ -72,7 +83,7 @@
          * Searches the database and retrieves the information about the
          * guild, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Guild identifier.
          */
         public function __construct($db, $id){
@@ -98,7 +109,7 @@
             if ($r){
                 $this->id = $r["id"];
                 $this->guild = $r["guild"];
-                $this->name = e($r["name"]);
+                $this->name = HTML::e($r["name"]);
                 $this->level = $r["level"];
                 $this->grade = $r["grade"];
                 $this->rating = $r["rating"];
@@ -110,6 +121,5 @@
             }
         }
 
-
     }
 ?>

+ 32 - 26
application/entity/Inventory.php

@@ -1,43 +1,54 @@
 <?php
+    /**
+     * Inventory entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "K_Unit.php");
-
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
+    require_once(PATH::ENTITY . "K_Unit.php");
 
     /**
      * An inventory item.
      *
      * Represents an object from the table 'inventory'.
+     *
+     * @category Entity 
      */
     class Inventory extends Entity{
 
         /**
-         * Owner identifier.
+         * @var int Owner identifier.
          */
         public $uid;
 
         /**
-         * Item identifier. If its a monster piece, a {@see K_Monster} entity.
+         * @var int|K_Unit Item identifier. If its a monster piece, a K_Unit entity.
          */
         public $id;
 
         /**
-         * Item name.
+         * @var string Item name.
          */
         public $name;
 
         /**
-         * Item type name.
+         * @var string Item type name.
          */
         public $type;
 
         /**
-         * Item type name.
+         * @var int Item owned amount.
          */
-        public $ammount;
+        public $amount;
 
         /**
-         * Indicates if the item are monster pieces.
+         * @var bool Indicates if the item are monster pieces.
          */
         public $is_monster_pices;
 
@@ -47,13 +58,11 @@
          * Searches the database and retrieves the information about the
          * building, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Item identifier.
          * @param int $type Item type identifier. Optional, will try to guess if null.
          */
         public function __construct($db, $id, $type = null){
-            global $path;
-            global $INVENTORY_TYPE;
             parent::__construct($db);
             $s = "
                 SELECT
@@ -80,36 +89,33 @@
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->type = $r["type"];
             $this->amount = $r["amount"];
-            if ($r["type"] == $INVENTORY_TYPE["GUILD_MONSTER_PIECE"] || $r["type"] == $INVENTORY_TYPE["MONSTER_PIECE"]){
+            if ($r["type"] == INVENTORY_TYPE_ID::GUILD_MONSTER_PIECE || $r["type"] == INVENTORY_TYPE_ID::MONSTER_PIECE){
                 $this->is_monster_pices = true;
                 $this->id = new K_Unit($this->db, $r["id"]);
-                $this->name = e($this->id->title) . " Pieces";
-                $this->description = e($this->id->title) . " Pieces";
+                $this->name = HTML::e($this->id->title) . " Pieces";
+                $this->description = HTML::e($this->id->title) . " Pieces";
             }
             else{
                 $this->is_monster_pices = false;
                 $this->id = $r["id"];
-                $this->name = e($r["name"]);
-                $this->description = e($r["description"]);
+                $this->name = HTML::e($r["name"]);
+                $this->description = HTML::e($r["description"]);
             }
         }
 
         /**
          * Gets the path to the item image. The image must be in the
-         * img/content/inventory/ directory, and its name must be the monster id,
+         * img/content/inventory/ directory, and its name must be the item id,
          * padded with '0' to 9 digites, and the extension must be '.png'.
          *
-         * @return path to the image, or a path to a fixed unknown image if it
-         *         doesn't exist.
+         * @return string Image URL, or a fixed unknown image.
          */
         public function get_image(){
-            global $base_dir;
-            global $path;
-            if (file_exists($base_dir . "img/inventory/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
-                return $path["img"]["inventory"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
+            if (file_exists(PATH::BASE . "img/inventory/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
+                return URL::IMG["INVENTORY"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
             }
             else{
-                return $path["img"]["root"] . "unknown.png";
+                return PATH::IMG["UNKNOWN"];
             }
         }
     }

+ 92 - 86
application/entity/K_Area.php

@@ -1,27 +1,39 @@
 <?php
+    /**
+     * Area type entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
 
 
     /**
      * An area.
      *
      * Represents an object from the table 'k_area'.
+     *
+     * @category Entity
      */
     class K_Area extends Entity{
 
         /**
-         * Area identifier (it may not be unique!).
+         * @var int Area identifier (it may not be unique!).
          */
         public $id;
 
         /**
-         * Area type.
+         * @var int Area type.
          */
         public $type;
 
         /**
-         * Area name.
+         * @var string Area name.
          */
         public $name;
 
@@ -31,13 +43,11 @@
          * Searches the database and retrieves the information about the
          * run, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Area identifier.
          * @param int $type Area type (required).
          */
         public function __construct($db, $id, $type){
-            global $path;
-            global $AREA_TYPE;
             parent::__construct($db);
             $this->id = $id;
             $s = "
@@ -53,207 +63,203 @@
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->type = $r["type"];
-                $this->name = e($r["name"]);
+                $this->name = HTML::e($r["name"]);
             }
             elseif($this->id > 1000){
-                $this->type = $AREA_TYPE["CAIROS_DUNGEON"];
+                $this->type = $AREA_TYPE::CAIROS_DUNGEON;
                 $this->name = "Hall of Heroes";
             }
         }
 
         /**
          * Gets the path to the area image. The image must be in the
-         * img/area/ directory, and its name must be the monster id,
+         * img/area/ directory, and its name must be the area type id,
          * padded with '0' to 9 digites, and the extension must be '.png'.
          *
-         * @return path to the image, or a path to a fixed unknown image if it
-         *         doesn't exist.
+         * @param string $stage Stage number, for a better image in Cairos.
+         * @return string Image URL, or a fixed unknown image.
          */
         public function get_image($stage = null){
-            global $base_dir;
-            global $path;
-            global $AREA_TYPE;
-            global $DUNGEON;
-            if ($this->id > 10000 && file_exists($base_dir . "img/area/HOH.png")){
+            if ($this->id > 10000 && file_exists(PATH::BASE . "img/area/HOH.png")){
                 // Hall of Heroes
-                return $path["img"]["area"] . "HOH.png";
+                return URL::IMG["AREA"] . "HOH.png";
             }
             elseif (
               (
-                $this->type == $AREA_TYPE["SCENARIO"] ||
-                $this->type == $AREA_TYPE["RIFT_DUNGEON"] ||
-                $this->type == $AREA_TYPE["DIMENSIONAL_HOLE"] ||
-                $this->type == $AREA_TYPE["RIFT_RAID"] ||
-                $this->type == $AREA_TYPE["ARENA"] ||
-                $this->type == $AREA_TYPE["GUILD_WAR"] ||
-                $this->type == $AREA_TYPE["GUILD_SIEGE"] ||
-                $this->type == $AREA_TYPE["TARTARUS_LABYRINTH"] ||
-                $this->type == $AREA_TYPE["TRIAL_OF_ASCENSION"] ||
-                $this->type == $AREA_TYPE["WORLD_BOSS"] ||
-                $this->type == $AREA_TYPE["DIMENSIONAL_RIFT"]
-              ) && file_exists($base_dir . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")
+                $this->type == AREA_TYPE::SCENARIO ||
+                $this->type == AREA_TYPE::RIFT_DUNGEON ||
+                $this->type == AREA_TYPE::DIMENSIONAL_HOLE ||
+                $this->type == AREA_TYPE::RIFT_RAID ||
+                $this->type == AREA_TYPE::ARENA ||
+                $this->type == AREA_TYPE::GUILD_WAR ||
+                $this->type == AREA_TYPE::GUILD_SIEGE ||
+                $this->type == AREA_TYPE::TARTARUS_LABYRINTH ||
+                $this->type == AREA_TYPE::TRIAL_OF_ASCENSION ||
+                $this->type == AREA_TYPE::WORLD_BOSS ||
+                $this->type == AREA_TYPE::DIMENSIONAL_RIFT
+              ) && file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")
             ){
-                return $path["img"]["area"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
+                return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
             }
-            elseif ($this->type == $AREA_TYPE["CAIROS_DUNGEON"] && in_array($this->id, $DUNGEON)){
+            elseif ($this->type == AREA_TYPE::CAIROS_DUNGEON && in_array($this->id, $DUNGEON)){
                 switch ($this->id){
-                    case $DUNGEON["GIANTS_KEEP"]:
+                    case DUNGEON::GIANTS_KEEP:
                         switch ($stage){
                             case 1:
                             case 6:
                                 // Light
-                                if (file_exists($base_dir . "img/unit/00060204.png")){
-                                    return $path["img"]["unit"] . "00060204.png";
+                                if (file_exists(PATH::BASE . "img/unit/00060204.png")){
+                                    return URL::IMG["UNIT"] . "00060204.png";
                                 }
                                 break;
                                 break;
                             case 2:
                             case 7:
                                 // Dark
-                                if (file_exists($base_dir . "img/unit/00060204.png")){
-                                    return $path["img"]["unit"] . "00060204.png";
+                                if (file_exists(PATH::BASE . "img/unit/00060204.png")){
+                                    return URL::IMG["UNIT"] . "00060204.png";
                                 }
                                 break;
                             case 3:
                             case 8:
                                 // Wind
-                                if (file_exists($base_dir . "img/unit/00060203.png")){
-                                    return $path["img"]["unit"] . "00060203.png";
+                                if (file_exists(PATH::BASE . "img/unit/00060203.png")){
+                                    return URL::IMG["UNIT"] . "00060203.png";
                                 }
                                 break;
                             case 4:
                             case 9:
                                 // Fire
-                                if (file_exists($base_dir . "img/unit/00060202.png")){
-                                    return $path["img"]["unit"] . "00060202.png";
+                                if (file_exists(PATH::BASE . "img/unit/00060202.png")){
+                                    return URL::IMG["UNIT"] . "00060202.png";
                                 }
                                 break;
                             case 5:
                             case 10:
                                 // Water
-                                if (file_exists($base_dir . "img/unit/00060201.png")){
-                                    return $path["img"]["unit"] . "00060201.png";
+                                if (file_exists(PATH::BASE . "img/unit/00060201.png")){
+                                    return URL::IMG["UNIT"] . "00060201.png";
                                 }
                                 break;
                         }
                         break;
-                    case $DUNGEON["DRAGONS_LAIR"]:
+                    case DUNGEON::DRAGONS_LAIR:
                         switch ($stage){
                             case 1:
                             case 6:
                                 // Wind
-                                if (file_exists($base_dir . "img/unit/00060303.png")){
-                                    return $path["img"]["unit"] . "00060303.png";
+                                if (file_exists(PATH::BASE . "img/unit/00060303.png")){
+                                    return URL::IMG["UNIT"] . "00060303.png";
                                 }
                                 break;
                                 break;
                             case 2:
                             case 7:
                                 // Light
-                                if (file_exists($base_dir . "img/unit/00060304.png")){
-                                    return $path["img"]["unit"] . "00060304.png";
+                                if (file_exists(PATH::BASE . "img/unit/00060304.png")){
+                                    return URL::IMG["UNIT"] . "00060304.png";
                                 }
                                 break;
                             case 3:
                             case 8:
                                 // Water
-                                if (file_exists($base_dir . "img/unit/00060301.png")){
-                                    return $path["img"]["unit"] . "00060301.png";
+                                if (file_exists(PATH::BASE . "img/unit/00060301.png")){
+                                    return URL::IMG["UNIT"] . "00060301.png";
                                 }
                                 break;
                             case 4:
                             case 9:
                                 // Dark
-                                if (file_exists($base_dir . "img/unit/00060305.png")){
-                                    return $path["img"]["unit"] . "00060305.png";
+                                if (file_exists(PATH::BASE . "img/unit/00060305.png")){
+                                    return URL::IMG["UNIT"] . "00060305.png";
                                 }
                                 break;
                             case 5:
                             case 10:
                                 // Fire
-                                if (file_exists($base_dir . "img/unit/00060302.png")){
-                                    return $path["img"]["unit"] . "00060302.png";
+                                if (file_exists(PATH::BASE . "img/unit/00060302.png")){
+                                    return URL::IMG["UNIT"] . "00060302.png";
                                 }
                                 break;
                         }
                         break;
-                    case $DUNGEON["NECROPOLIS"]:
+                    case DUNGEON::NECROPOLIS:
                         switch ($stage){
                             case 1:
                             case 6:
                                 // Water
-                                if (file_exists($base_dir . "img/unit/000621301.png")){
-                                    return $path["img"]["unit"] . "000621301.png";
+                                if (file_exists(PATH::BASE . "img/unit/000621301.png")){
+                                    return URL::IMG["UNIT"] . "000621301.png";
                                 }
                                 break;
                                 break;
                             case 2:
                             case 7:
                                 // Fire
-                                if (file_exists($base_dir . "img/unit/000621302.png")){
-                                    return $path["img"]["unit"] . "000621302.png";
+                                if (file_exists(PATH::BASE . "img/unit/000621302.png")){
+                                    return URL::IMG["UNIT"] . "000621302.png";
                                 }
                                 break;
                             case 3:
                             case 8:
                                 // Wind
-                                if (file_exists($base_dir . "img/unit/000621303.png")){
-                                    return $path["img"]["unit"] . "000621303.png";
+                                if (file_exists(PATH::BASE . "img/unit/000621303.png")){
+                                    return URL::IMG["UNIT"] . "000621303.png";
                                 }
                                 break;
                             case 4:
                             case 9:
                                 // Light
-                                if (file_exists($base_dir . "img/unit/000621304.png")){
-                                    return $path["img"]["unit"] . "000621304.png";
+                                if (file_exists(PATH::BASE . "img/unit/000621304.png")){
+                                    return URL::IMG["UNIT"] . "000621304.png";
                                 }
                                 break;
                             case 5:
                             case 10:
                                 // Dark
-                                if (file_exists($base_dir . "img/unit/000621305.png")){
-                                    return $path["img"]["unit"] . "000621305.png";
+                                if (file_exists(PATH::BASE . "img/unit/000621305.png")){
+                                    return URL::IMG["UNIT"] . "000621305.png";
                                 }
                                 break;
                         }
                         break;
-                    case $DUNGEON["HALL_OF_WATER"]:
-                        if (file_exists($base_dir . "img/unit/00060101.png")){
-                            return $path["img"]["unit"] . "00060101.png";
+                    case DUNGEON::HALL_OF_WATER:
+                        if (file_exists(PATH::BASE . "img/unit/00060101.png")){
+                            return URL::IMG["UNIT"] . "00060101.png";
                         }
                         break;
-                    case $DUNGEON["HALL_OF_FIRE"]:
-                        if (file_exists($base_dir . "img/unit/00060102.png")){
-                            return $path["img"]["unit"] . "00060102.png";
+                    case DUNGEON::HALL_OF_FIRE:
+                        if (file_exists(PATH::BASE . "img/unit/00060102.png")){
+                            return URL::IMG["UNIT"] . "00060102.png";
                         }
                         break;
-                    case $DUNGEON["HALL_OF_WIND"]:
-                        if (file_exists($base_dir . "img/unit/00060103.png")){
-                            return $path["img"]["unit"] . "00060103.png";
+                    case DUNGEON::HALL_OF_WIND:
+                        if (file_exists(PATH::BASE . "img/unit/00060103.png")){
+                            return URL::IMG["UNIT"] . "00060103.png";
                         }
                         break;
-                    case $DUNGEON["HALL_OF_LIGHT"]:
-                        if (file_exists($base_dir . "img/unit/00060104.png")){
-                            return $path["img"]["unit"] . "00060104.png";
+                    case DUNGEON::HALL_OF_LIGHT:
+                        if (file_exists(PATH::BASE . "img/unit/00060104.png")){
+                            return URL::IMG["UNIT"] . "00060104.png";
                         }
                         break;
-                    case $DUNGEON["HALL_OF_DARK"]:
-                        if (file_exists($base_dir . "img/unit/00060105.png")){
-                            return $path["img"]["unit"] . "00060105.png";
+                    case DUNGEON::HALL_OF_DARK:
+                        if (file_exists(PATH::BASE . "img/unit/00060105.png")){
+                            return $PATH["IMG"]["UNIT"] . "00060105.png";
                         }
                         break;
-                    case $DUNGEON["HALL_OF_MAGIC"]:
-                        if (file_exists($base_dir . "img/unit/00062004.png")){
-                            return $path["img"]["unit"] . "00062004.png";
+                    case DUNGEON::HALL_OF_MAGIC:
+                        if (file_exists(PATH::BASE . "img/unit/00062004.png")){
+                            return URL::IMG["UNIT"] . "00062004.png";
                         }
                         break;
                     default:
-                        if (file_exists($base_dir . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
-                            return $path["img"]["area"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
+                        if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
+                            return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
                         }
                 }
             }
-            return $path["img"]["root"] . "unknown.png";
+            return URL::IMG["UNKNOWN"];
         }
 
     }

+ 23 - 15
application/entity/K_Building.php

@@ -1,27 +1,39 @@
 <?php
+    /**
+     * Building key entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
 
 
     /**
      * Building.
      *
      * Represents an object from the table 'k_building'.
+     *
+     * @category Entity
      */
     class K_Building extends Entity{
 
         /**
-         * Building identifier.
+         * @var int Building identifier.
          */
         public $id;
 
         /**
-         * Building name.
+         * @var string Building name.
          */
         public $name;
 
         /**
-         * Building description.
+         * @var string Building description.
          */
         public $description;
 
@@ -31,11 +43,10 @@
          * Searches the database and retrieves the information about the
          * building, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Building identifier.
          */
         public function __construct($db, $id){
-            global $path;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -48,8 +59,8 @@
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
-                $this->name = e($r["name"]);
-                $this->description = e($r["description"]);
+                $this->name = HTML::e($r["name"]);
+                $this->description = HTML::e($r["description"]);
             }
         }
 
@@ -58,17 +69,14 @@
          * img/building/ directory, and its name must be the monster id,
          * padded with '0' to 4 digites, and the extension must be '.png'.
          *
-         * @return path to the image, or a path to a fixed unknown image if it
-         *         doesn't exist.
+         * @return string Image URL, or a fixed unknown image.
          */
         public function get_image(){
-            global $base_dir;
-            global $path;
-            if (file_exists($base_dir . "img/building/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png")){
-                return $path["img"]["building"] . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png";
+            if (file_exists(PATH::BASE . "img/building/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png")){
+                return URL::IMG["BUILDING"] . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png";
             }
             else{
-                return $path["img"]["root"] . "unknown.png";
+                return URL::IMG["UNKNOWN"];
             }
         }
 

+ 30 - 22
application/entity/K_Decoration.php

@@ -1,52 +1,64 @@
 <?php
+    /**
+     * Decoration key entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
 
 
     /**
      * Decoration.
      *
      * Represents an object from the table 'k_decoration'.
+     *
+     * @category Entity
      */
     class K_Decoration extends Entity{
 
         /**
-         * Decoration identifier.
+         * @var int Decoration identifier.
          */
         public $id;
 
         /**
-         * Decoration name.
+         * @var string Decoration name.
          */
         public $name;
 
         /**
-         * Decoration description.
+         * @var string Decoration description.
          */
         public $description;
 
         /**
-         * Area of effect (if any).
+         * @var int Area of effect identifier (if any).
          */
         public $area;
 
         /**
-         * Affected stat (if any).
+         * @var int Affected stat id (if any).
          */
         public $stat;
 
         /**
-         * Affected element (if any).
+         * @var int Affected element  id(if any).
          */
         public $element;
 
         /**
-         * Max. level ().
+         * @var int Max. level.
          */
         public $max_level;
 
         /**
-         * Effect bonus per level.
+         * @var int[] Effect bonus per level.
          */
         public $level_bonus = [];
 
@@ -61,11 +73,10 @@
          * Searches the database and retrieves the information about the
          * decoration, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Decoration identifier.
          */
         public function __construct($db, $id){
-            global $path;
             parent::__construct($db);
             $s = "
                 SELECT
@@ -83,8 +94,8 @@
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
-                $this->name = e($r["name"]);
-                $this->description = e($r["description"]);
+                $this->name = HTML::e($r["name"]);
+                $this->description = HTML::e($r["description"]);
                 $this->area = $r["area"];
                 $this->stat = $r["affected_stat"];
                 $this->element = $r["element"];
@@ -107,20 +118,17 @@
 
         /**
          * Gets the path to the building image. The image must be in the
-         * img/content/decoration/ directory, and its name must be the monster id,
-         * padded with '0' to 4 digites, and the extension must be '.png'.
+         * img/decoration/ directory, and its name must be the decoration
+         * id, padded with '0' to 4 digites, and the extension must be '.png'.
          *
-         * @return path to the image, or a path to a fixed unknown image if it
-         *         doesn't exist.
+         * @return string Image URL, or a fixed unknown image.
          */
         public function get_image(){
-            global $base_dir;
-            global $path;
-            if (file_exists($base_dir . "img/decoration/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png")){
-                return $path["img"]["decoration"] . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png";
+            if (file_exists(PATH::BASE . "img/decoration/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png")){
+                return URL::IMG["DECORATION"] . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png";
             }
             else{
-                return $path["img"]["root"] . "unknown.png";
+                return URL::IMG["UNKNOWN"];
             }
         }
 

+ 25 - 17
application/entity/K_Effect.php

@@ -1,31 +1,43 @@
 <?php
+    /**
+     * Effect key entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
 
     /**
      * Skill effect.
      *
      * Represents an object from the table 'k_effect'.
+     *
+     * @category Entity
      */
     class K_Effect extends Entity{
 
         /**
-         * Effect identifier.
+         * @var int Effect identifier.
          */
         public $id;
 
         /**
-         * Effect name.
+         * @var string Effect name.
          */
         public $name;
 
         /**
-         * Indicates if the effect is a buff.
+         * @var bool Indicates if the effect is a buff.
          */
         public $is_buff;
 
         /**
-         * Effect description.
+         * @var string Effect description.
          */
         public $description;
 
@@ -35,11 +47,10 @@
          * Searches the database and retrieves the information about the
          * skill level, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
-         * @param int $skill Effect identifier.
+         * @param reocurce $db Connection to the database.
+         * @param int $id Effect identifier.
          */
         public function __construct($db, $id){
-            global $path;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -53,9 +64,9 @@
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
-                $this->name = e($r["name"]);
+                $this->name = HTML::e($r["name"]);
                 $this->is_buff = $r["is_buff"];
-                $this->description = e($r["description"]);
+                $this->description = HTML::e($r["description"]);
             }
         }
 
@@ -64,17 +75,14 @@
          * img/effect/ directory, and its name must be the effect id,
          * padded with '0' to 4 digits, and the extension must be '.png'.
          *
-         * @return path to the image, or a path to a fixed unknown image if it
-         *         doesn't exist.
+         * @return string Image URL, or a fixed unknown image.
          */
         public function get_image(){
-            global $base_dir;
-            global $path;
-            if (file_exists($base_dir . "img/effect/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png")){
-                return $path["img"]["effect"] . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png";
+            if (file_exists(PATH::BASE . "img/effect/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png")){
+                return URL::IMG["EFFECT"] . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png";
             }
             else{
-                return $path["img"]["root"] . "unknown.png";
+                return URL::IMG["UNKNOWN"];
             }
         }
     }

+ 19 - 8
application/entity/K_Guild_Skill.php

@@ -1,31 +1,43 @@
 <?php
+    /**
+     * Guild skill entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
 
     /**
      * Guild skill.
      *
      * Represents an object from the table 'k_guild_skill'.
+     *
+     * @category Entity
      */
     class K_Guild_Skill extends Entity{
 
         /**
-         * Skill identifier.
+         * @var int Skill identifier.
          */
         public $id;
 
         /**
-         * Skill group (id).
+         * @var int Skill group id.
          */
         public $group;
 
         /**
-         * Level at which the skill becames available.
+         * @var int Level at which the skill becames available.
          */
         public $level;
 
         /**
-         * Skill description.
+         * @var string Skill description.
          */
         public $effect;
 
@@ -35,11 +47,10 @@
          * Searches the database and retrieves the information about the
          * skill, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Skill identifier.
          */
         public function __construct($db, $id){
-            global $path;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -55,7 +66,7 @@
                 $this->id = $r["id"];
                 $this->group = $r["skill_group"];
                 $this->level = $r["level"];
-                $this->effect = e($r["effect"]);
+                $this->effect = HTML::e($r["effect"]);
             }
         }
 

+ 26 - 18
application/entity/K_Guild_Skill_Group.php

@@ -1,32 +1,44 @@
 <?php
+    /**
+     * Guild skill group entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "K_Guild_Skill.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
+    require_once(PATH::ENTITY . "K_Guild_Skill.php");
 
     /**
      * Guild skill group.
      *
      * Represents an object from the table 'k_guild_skill_group'.
+     *
+     * @category Entity
      */
     class K_Guild_Skill_Group extends Entity{
 
         /**
-         * Group identifier.
+         * @var int Group identifier.
          */
         public $id;
 
         /**
-         * Group name.
+         * @var string Group name.
          */
         public $name;
 
         /**
-         * Group description.
+         * @var string Group description.
          */
         public $description;
-        
+
         /**
-         * List of {@see K_Guild_Skill}s in the group.
+         * @var \K_Guild_Skill[] List of K_Guild_Skills in the group.
          */
         public $skills = [];
 
@@ -36,11 +48,10 @@
          * Searches the database and retrieves the information about the
          * skill group, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Skill group identifier.
          */
         public function __construct($db, $id){
-            global $path;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -53,8 +64,8 @@
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
-                $this->name = e($r["name"]);
-                $this->description = e($r["description"]);
+                $this->name = HTML::e($r["name"]);
+                $this->description = HTML::e($r["description"]);
             }
             $s =
               "SELECT id " .
@@ -71,17 +82,14 @@
          * img/skill_guild/ directory, and its name must be the monster id,
          * padded with '0' to 1 digits, and the extension must be '.png'.
          *
-         * @return path to the image, or a path to a fixed unknown image if it
-         *         doesn't exist.
+         * @return string Image URL, or a fixed unknown image.
          */
         public function get_image(){
-            global $base_dir;
-            global $path;
-            if (file_exists($base_dir . "img/skill_guild/" . str_pad($this->id, 1, '0', STR_PAD_LEFT) . ".png")){
-                return $path["img"]["skill_guild"] . str_pad($this->id, 1, '0', STR_PAD_LEFT) . ".png";
+            if (file_exists(PATH::BASE . "img/skill_guild/" . str_pad($this->id, 1, '0', STR_PAD_LEFT) . ".png")){
+                return URL::IMG["SKILL_GUILD"] . str_pad($this->id, 1, '0', STR_PAD_LEFT) . ".png";
             }
             else{
-                return $path["img"]["root"] . "unknown.png";
+                return URL::IMG["UNKNOWN"];
             }
         }
 

+ 40 - 32
application/entity/K_Leader_Skill.php

@@ -1,36 +1,48 @@
 <?php
+    /**
+     * Leader skill entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
 
     /**
      * Monster skill.
      *
      * Represents an object from the table 'k_skill'.
+     *
+     * @category Entity
      */
     class K_Leader_Skill extends Entity{
 
         /**
-         * Skill identifier.
+         * @var int Skill identifier.
          */
         public $id;
 
         /**
-         * Skill attribute.
+         * @var int Skill attribute ID.
          */
         public $attribute;
 
         /**
-         * Attribute incrrease amount.
+         * @var int Attribute increase amount.
          */
         public $amount;
 
         /**
-         * Effect area.
+         * @var int Effect area id.
          */
         public $area;
 
         /**
-         * Affected element.
+         * @var int Affected element id.
          */
         public $element;
 
@@ -40,11 +52,10 @@
          * Searches the database and retrieves the information about the
          * skill, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Skill identifier.
          */
         public function __construct($db, $id){
-            global $path;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -69,24 +80,21 @@
          * img/skill_leader/ directory, and its name must be the skill id,
          * padded with '0' to 4 digites, and the extension must be '.png'.
          *
-         * @return Path to the image, or a path to a fixed unknown image if it
-         *         doesn't exist.
+         * @return string Image URL, or a fixed unknown image.
          */
         public function get_image(){
-            global $base_dir;
-            global $path;
-            if (file_exists($base_dir . "img/content/skill_leader/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png")){
-                return $path["img"]["skill_leader"] . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png";
+            if (file_exists(PATH::BASE . "img/content/skill_leader/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png")){
+                return URL::IMG["SKILL_LEADER"] . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png";
             }
             else{
-                return $path["img"]["root"] . "unknown.png";
+                return URL::IMG["UNKNOWN"];
             }
         }
 
         /**
          * Composes a human readable description of the skill.
          *
-         * @return The description.
+         * @return string The description.
          */
         public function create_description(){
             global $STAT;
@@ -94,58 +102,58 @@
             global $EFFECT_AREA;
             $s = "Increases the ";
             switch ($this->attribute){
-                case $STAT["ATK"]:
+                case STAT::ATK:
                     $s .= "attack power";
                     break;
-                case $STAT["DEF"]:
+                case STAT::DEF:
                     $s .= "defense";
                     break;
-                case $STAT["HP"]:
+                case STAT::HP:
                     $s .= "HP";
                     break;
-                case $STAT["SPD"]:
+                case STAT::SPD:
                     $s .= "attack speed";
                     break;
-                case $STAT["CRIT_RATE"]:
+                case STAT::CRIT_RATE:
                     $s .= "critical rate";
                     break;
-                case $STAT["CRIT_DMG"]:
+                case STAT::CRIT_DMG:
                     $s .= "critical damage";
                     break;
-                case $STAT["ACC"]:
+                case STAT::ACC:
                     $s .= "accuracy";
                     break;
-                case $STAT["RES"]:
+                case STAT::RES:
                     $s .= "resistance";
                     break;
             }
             $s .= " of ally monsters ";
             switch ($this->element){
-                case $ELEMENT["WATER"]:
+                case ELEMENT_ID::WATER:
                     $s .= " with Water attribute ";
                     break;
-                case $ELEMENT["FIRE"]:
+                case ELEMENT_ID::FIRE:
                     $s .= " with Fire attribute ";
                     break;
-                case $ELEMENT["WIND"]:
+                case ELEMENT_ID::WIND:
                     $s .= " with Wind attribute ";
                     break;
-                case $ELEMENT["LIGHT"]:
+                case ELEMENT_ID::LIGHT:
                     $s .= " with Light attribute ";
                     break;
-                case $ELEMENT["DARK"]:
+                case ELEMENT_ID::DARK:
                     $s .= " with Dark attribute ";
                     break;
             }
             $s = $s . "by " . $this->amount . "%";
             switch ($this->area){
-                case $EFFECT_AREA["DUNGEON"]:
+                case EFFECT_AREA::DUNGEON:
                     $s = $s . " in the Dungeons";
                     break;
-                case $EFFECT_AREA["ARENA"]:
+                case EFFECT_AREA::ARENA:
                     $s = $s . " in the Arena";
                     break;
-                case $EFFECT_AREA["GUILD"]:
+                case EFFECT_AREA::GUILD:
                     $s = $s . " in Guild content";
                     break;
             }

+ 26 - 18
application/entity/K_Rune_Set.php

@@ -1,31 +1,43 @@
 <?php
+    /**
+     * Rune set entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
 
     /**
      * A rune set.
      *
      * Represents an object from the table 'k_rune_set'.
+     *
+     * @category Entity
      */
     class K_Rune_Set extends Entity{
 
         /**
-         * Set identifier.
+         * @var int Set identifier.
          */
         public $id;
 
         /**
-         * Set name.
+         * @var string Set name.
          */
         public $name;
 
         /**
-         * Required number of runes to activate the set.
+         * @var int Required number of runes to activate the set.
          */
         public $amount;
 
         /**
-         * Set description.
+         * @var string Set description.
          */
         public $description;
 
@@ -33,13 +45,12 @@
          * Constructor.
          *
          * Searches the database and retrieves the information about the
-         * skill level, populating it and it's items.
+         * set, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
-         * @param int $skill Effect identifier.
+         * @param resource $db Connection to the database.
+         * @param int $id Set identifier.
          */
         public function __construct($db, $id){
-            global $path;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -53,9 +64,9 @@
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
-                $this->name = e($r["name"]);
+                $this->name = HTML::e($r["name"]);
                 $this->amount = $r["amount"];
-                $this->description = e($r["description"]);
+                $this->description = HTML::e($r["description"]);
             }
         }
 
@@ -64,17 +75,14 @@
          * img/rune/ directory, and its name must be the set id,
          * padded with '0' to 2 digits, and the extension must be '.png'.
          *
-         * @return Path to the image, or a path to a fixed unknown image if it
-         *         doesn't exist.
+         * @return string Image URL, or a fixed unknown image.
          */
         public function get_image(){
-            global $base_dir;
-            global $path;
-            if (file_exists($base_dir . "img/rune/" . str_pad($this->id, 2, '0', STR_PAD_LEFT) . ".png")){
-                return $path["img"]["rune"] . str_pad($this->id, 2, '0', STR_PAD_LEFT) . ".png";
+            if (file_exists(PATH::BASE . "img/rune/" . str_pad($this->id, 2, '0', STR_PAD_LEFT) . ".png")){
+                return URL::IMG["RUNE"] . str_pad($this->id, 2, '0', STR_PAD_LEFT) . ".png";
             }
             else{
-                return $path["img"]["root"] . "unknown.png";
+                return URL::IMG["UNKNOWN"];
             }
         }
     }

+ 36 - 28
application/entity/K_Skill.php

@@ -1,79 +1,91 @@
 <?php
+    /**
+     * Skill entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "K_Skill_Level.php");
-    require_once($path["entity"] . "K_Effect.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
+    require_once(PATH::ENTITY . "K_Skill_Level.php");
+    require_once(PATH::ENTITY . "K_Effect.php");
 
 
     /**
      * Monster skill.
      *
      * Represents an object from the table 'k_skill'.
+     *
+     * @category Entity
      */
     class K_Skill extends Entity{
 
         /**
-         * Skill identifier.
+         * @var int Skill identifier.
          */
         public $id;
 
         /**
-         * Skill name.
+         * @var string Skill name.
          */
         public $name;
 
         /**
-         * Skill description.
+         * @var string Skill description.
          */
         public $description;
 
         /**
-         * Skill order.
+         * @var int Skill order.
          */
         public $slot;
 
         /**
-         * Skill cooldown turns.
+         * @var int Skill cooldown turns.
          */
         public $cooltime;
 
         /**
-         * Number of hits.
+         * @var int Number of hits.
          */
         public $hits;
 
         /**
-         * Wether the skill is passive or not.
+         * @var bool Wether the skill is passive or not.
          */
         public $passive;
 
         /**
-         * Wether the skill is AOE.
+         * @var bool Wether the skill is AOE.
          */
         public $aoe;
 
         /**
-         * Skill max level.
+         * @var int Skill max level.
          */
         public $max_level;
 
         /**
-         * Skill formula.
+         * @var string Skill formula.
          */
         public $multiplier_formula;
 
         /**
-         * The {@see Monster_Skill} upgrading this one.
+         * @var K_SKill The skill upgrading this one.
          */
         public $upgrade;
 
         /**
-         * Available {@see K_Skill_Level}
+         * @var \K_Skill_Level[] Available skill levels.
          */
         public $level = [];
 
         /**
-         * Skill {@see K_Effect}s
+         * @var \K_Effect[] Associated eeffects.
          */
         public $effect = [];
 
@@ -83,11 +95,10 @@
          * Searches the database and retrieves the information about the
          * skill, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Skill identifier.
          */
         public function __construct($db, $id){
-            global $path;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -106,15 +117,15 @@
             $q = $this->db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->id = $r["id"];
-            $this->name = e($r["name"]);
-            $this->description = e($r["description"]);
+            $this->name = HTML::e($r["name"]);
+            $this->description = HTML::e($r["description"]);
             $this->slot = $r["slot"];
             $this->cooltime = $r["cooltime"];
             $this->hits = $r["hits"];
             $this->passive = $r["passive"];
             $this->aoe = $r["aoe"];
             $this->max_level = $r["max_level"];
-            $this->multiplier_formula = e($r["multiplier_formula"]);
+            $this->multiplier_formula = HTML::e($r["multiplier_formula"]);
             $s =
               "SELECT " .
               "  skill, " .
@@ -141,17 +152,14 @@
          * img/skill/ directory, and its name must be the set id,
          * padded with '0' to 8 digits, and the extension must be '.png'.
          *
-         * @return Path to the image, or a path to a fixed unknown image if it
-         *         doesn't exist.
+         * @return string Image URL, or a fixed unknown image.
          */
         public function get_image(){
-            global $base_dir;
-            global $path;
-            if (file_exists($base_dir . "img/skill/" . str_pad($this->id, 8, '0', STR_PAD_LEFT) . ".png")){
-                return $path["img"]["skill"] . str_pad($this->id, 8, '0', STR_PAD_LEFT) . ".png";
+            if (file_exists(PATH::BASE . "img/skill/" . str_pad($this->id, 8, '0', STR_PAD_LEFT) . ".png")){
+                return URL::IMG["SKILL"] . str_pad($this->id, 8, '0', STR_PAD_LEFT) . ".png";
             }
             else{
-                return $path["img"]["root"] . "unknown.png";
+                return URL::IMG["UNKNOWN"];
             }
         }
     }

+ 18 - 7
application/entity/K_Skill_Level.php

@@ -1,26 +1,38 @@
 <?php
+    /**
+     * Skill level entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
 
     /**
      * Monster skill level.
      *
      * Represents an object from the table 'k_monster_skill_upgrade'.
+     *
+     * @category Entity
      */
     class K_Skill_Level extends Entity{
 
         /**
-         * Skill identifier.
+         * @var int Skill identifier.
          */
         public $skill;
 
         /**
-         * Skill level.
+         * @var int Skill level.
          */
         public $level;
 
         /**
-         * Upgrade description.
+         * @var string Upgrade description.
          */
         public $description;
 
@@ -30,12 +42,11 @@
          * Searches the database and retrieves the information about the
          * skill level, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $skill Skill identifier.
          * @param int $level Skill level.
          */
         public function __construct($db, $skill, $level){
-            global $path;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -51,7 +62,7 @@
             if ($r){
                 $this->skill = $r["skill"];
                 $this->level = $r["level"];
-                $this->description = e($r["description"]);
+                $this->description = HTML::e($r["description"]);
             }
         }
     }

+ 24 - 16
application/entity/K_Source.php

@@ -1,32 +1,44 @@
 <?php
+    /**
+     * Unit source entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
 
 
     /**
      * Monster source.
      *
      * Represents an object from the table 'k_source'.
+     *
+     * @category Entity
      */
     class K_Source extends Entity{
 
         /**
-         * Monster identifier.
+         * @var int Unit identifier.
          */
         public $id;
 
         /**
-         * Source name.
+         * @var string Source name.
          */
         public $name;
 
         /**
-         * Source description.
+         * @var string Source description.
          */
         public $description;
 
         /**
-         * Indicates if the source is farmable.
+         * @var bool Indicates if the source is farmable.
          */
         public $farmable;
 
@@ -36,11 +48,10 @@
          * Searches the database and retrieves the information about the
          * monster, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Monster identifier.
          */
         public function __construct($db, $id){
-            global $path;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -54,8 +65,8 @@
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
-                $this->name = e($r["name"]);
-                $this->description = e($r["description"]);
+                $this->name = HTML::e($r["name"]);
+                $this->description = HTML::e($r["description"]);
                 $this->farmable_source = $r["farmable"];
             }
         }
@@ -65,17 +76,14 @@
          * img/source/ directory, and it's name must be the source id,
          * padded with '0' to 4 digits, and the extension must be '.png'.
          *
-         * @return Path to the image, or a path to a fixed unknown image if it
-         *         doesn't exist.
+         * @return string Image URL, or a fixed unknown image.
          */
         public function get_image(){
-            global $base_dir;
-            global $path;
-            if (file_exists($base_dir . "img/source/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png")){
-                return $path["img"]["source"] . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png";
+            if (file_exists(PATH::BASE . "img/source/" . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png")){
+                return URL::IMG["SOURCE"] . str_pad($this->id, 4, '0', STR_PAD_LEFT) . ".png";
             }
             else{
-                return $path["img"]["root"] . "unknown.png";
+                return URL::IMG["UNKNOWN"];
             }
         }
 

+ 82 - 70
application/entity/K_Unit.php

@@ -1,190 +1,204 @@
 <?php
+    /**
+     * Base unit entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "K_Skill.php");
-    require_once($path["entity"] . "K_Leader_Skill.php");
-    require_once($path["entity"] . "K_Source.php");
-    require_once($path["entity"] . "K_Unit_Transformation.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
+    require_once(PATH::ENTITY . "K_Skill.php");
+    require_once(PATH::ENTITY . "K_Leader_Skill.php");
+    require_once(PATH::ENTITY . "K_Source.php");
+    require_once(PATH::ENTITY . "K_Unit_Transformation.php");
 
     /**
      * A unit.
      *
      * Represents an object from the table 'k_unit'.
+     *
+     * @category Entity
      */
     class K_Unit extends Entity{
 
         /**
-         * Unit identifier.
+         * @var int Unit identifier.
          */
         public $id;
 
         /**
-         * Unit family id.
+         * @var int Unit family id.
          */
         public $family;
 
         /**
-         * Unit name.
+         * @var string Unit name.
          */
         public $name;
 
         /**
-         * Unit element.
+         * @var int Unit element id.
          */
         public $element;
 
         /**
-         * Element name (title case)
+         * @var string Element name (title case)
          */
         public $element_name;
 
         /**
-         * Unit archetype.
+         * @var int Unit archetype id.
          */
         public $archetype;
 
         /**
-         * Archetype name (title case).
+         * @var string Archetype name (title case).
          */
         public $archetype_name;
 
         /**
-         * Default star level.
+         * @var int Default star level.
          */
         public $base_stars;
 
         /**
-         * Default star level.
+         *@var int  Default star level.
          */
         public $natural_stars;
 
         /**
-         * Indicates if the unit is obtainable.
+         * @var bool Indicates if the unit is obtainable.
          */
         public $obtainable;
 
         /**
-         * Indicates if the unit can be awakened.
+         * @var bool Indicates if the unit can be awakened.
          */
         public $can_awaken;
 
         /**
-         * Bonus when awakening.
+         * @var string Bonus when awakening.
          */
         public $awaken_bonus;
 
         /**
-         * Required skill-ups.
+         * @var int Required skill-ups.
          */
         public $skill_ups_to_max;
 
         /**
-         * @{see K_Leader_Skill} of the unit.
+         * @var K_Leader_Skill Unit's leader skill.
          */
         public $leader_skill;
 
         /**
-         * Base HP.
+         * @var int Base HP.
          */
         public $hp;
 
         /**
-         * Base ATK.
+         * @var int Base attack.
          */
         public $atk;
 
         /**
-         * Base DEF.
+         * @var int Base defense.
          */
         public $defense;
 
         /**
-         * SPD.
+         * @var int Speed.
          */
         public $speed;
 
         /**
-         * CRR.
+         * @var int Critical rate.
          */
         public $crit_rate;
 
         /**
-         * CRD.
+         * @var int Critical damage.
          */
         public $crit_damage;
 
         /**
-         * RES
+         * @var int Resistance
          */
         public $resistance;
 
         /**
-         * ACC.
+         * @var int Accuracy.
          */
         public $accuracy;
 
         /**
-         * Raw HP.
+         * @var int Raw HP.
          */
         public $raw_hp;
 
         /**
-         * Raw ATK.
+         * @var int Raw attack.
          */
         public $raw_atk;
 
         /**
-         * Raw DEF.
+         * @var int Raw Defense.
          */
         public $raw_defense;
 
         /**
-         * HP at max_level.
+         * @var int HP at max_level.
          */
         public $max_lvl_hp;
 
         /**
-         * ATK at max_level.
+         * @var int Attack at max_level.
          */
         public $max_lvl_atk;
 
         /**
-         * DEF at max_level.
+         * @var int Defense at max_level.
          */
         public $max_lvl_defense;
 
         /**
-         * @{see K_Unit} it awakens from.
+         * @var K_Unit Unit it awakens from.
          */
         public $awakens_from;
 
         /**
-         * @{see K_Unit} it awakens to.
+         * @var K_Unit Unit it awakens to.
          */
         public $awakens_to;
 
         /**
-         * Indicates if the unit is a fusion ingredient.
+         * @var bool Indicates if the unit is a fusion ingredient.
          */
         public $fusion_food;
 
         /**
-         * Indicates if the unit is homunculus.
+         * @var bool Indicates if the unit is homunculus.
          */
         public $homunculus;
 
         /**
-         * The crafting cost (homunculus only).
+         * @var int The crafting cost (homunculus only).
          */
         public $craft_cost;
 
         /**
-         * All {@see K_Unit_Skill}s.
+         * @var \K_Unit_Skill[] Unit skills.
          */
         public $skill = [];
 
         /**
-         * Required essences to awaken the unit. Formed by arrays of:
+         * @var mixed[] Required essences to awaken the unit.
+         *
+         * Formed by arrays of:
          * [
          *   "element" => "",
          *   "grade" => "",
@@ -194,19 +208,19 @@
         public $essences = [];
 
         /**
-         * {@see K_Source}s the unit can be get from.
+         * @var int \K_Source[] Sources the unit can be get from.
          */
         public $sources = [];
 
         /**
-         * Unit title.
+         * @var string Unit title.
          * If awakened, it will be the awakened from name.
          * If unawakened, it will be <element> <name>.
          */
         public $title;
 
         /**
-         * The {@see K_Unit_Transformation} the unit can undergo, or null.
+         * @var K_Unit_Transformation The transformation the unit can undergo.
          */
         public $transformation;
 
@@ -216,14 +230,11 @@
          * Searches the database and retrieves the information about the
          * unit, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resouce $db Connection to the database.
          * @param int $id Unit identifier.
-         * @param complete If false, query only k_unit.
+         * @param bool $complete If false, query only k_unit.
          */
         public function __construct($db, $id, $complete = true){
-            global $path;
-            global $ELEMENT;
-            global $ARCHETYPE;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -265,40 +276,40 @@
             if ($r){
                 $this->id = $r["id"];
                 $this->family = $r["family"];
-                $this->name = e($r["name"]);
+                $this->name = HTML::e($r["name"]);
                 $this->element = $r["element"];
                 switch($this->element){
-                    case $ELEMENT["WATER"]:
+                    case ELEMENT_ID::WATER:
                         $this->element_name = "Water";
                         break;
-                    case $ELEMENT["FIRE"]:
+                    case ELEMENT_ID::FIRE:
                         $this->element_name = "Fire";
                         break;
-                    case $ELEMENT["WIND"]:
+                    case ELEMENT_ID::WIND:
                         $this->element_name = "Wind";
                         break;
-                    case $ELEMENT["LIGHT"]:
+                    case ELEMENT_ID::LIGHT:
                         $this->element_name = "Light";
                         break;
-                    case $ELEMENT["DARK"]:
+                    case ELEMENT_ID::DARK:
                         $this->element_name = "Dark";
                         break;
                 }
                 $this->archetype = $r["archetype"];
                 switch($this->archetype){
-                    case $ARCHETYPE["ATTACK"]:
+                    case ARCHETYPE_ID::ATTACK:
                         $this->archetype_name = "Attack";
                         break;
-                    case $ARCHETYPE["DEFENSE"]:
+                    case ARCHETYPE_ID::DEFENSE:
                         $this->archetype_name = "Defense";
                         break;
-                    case $ARCHETYPE["HP"]:
+                    case ARCHETYPE_ID::HP:
                         $this->archetype_name = "HP";
                         break;
-                    case $ARCHETYPE["SUPPORT"]:
+                    case ARCHETYPE_ID::SUPPORT:
                         $this->archetype_name = "Support";
                         break;
-                    case $ARCHETYPE["MATERIAL"]:
+                    case ARCHETYPE_ID::MATERIAL:
                         $this->archetype_name = "Material";
                         break;
                 }
@@ -306,7 +317,7 @@
                 $this->natural_stars = $r["natural_stars"];
                 $this->obtainable = $r["obtainable"];
                 $this->can_awaken = $r["can_awaken"];
-                $this->awaken_bonus = e($r["awaken_bonus"]);
+                $this->awaken_bonus = HTML::e($r["awaken_bonus"]);
                 $this->skill_ups_to_max = $r["skill_ups_to_max"];
                 if (strlen($r["leader_skill"]) > 0){
                     $this->leader_skill = new K_Leader_Skill($this->db, $r["leader_skill"]);
@@ -353,6 +364,7 @@
 
         /**
          * Loads the information about the essences to awake the unit. 
+         *
          * It is autoatically called at construction time if the
          * $complete parameter is true (by default). No point in calling it
          * twice.
@@ -383,7 +395,8 @@
         }
 
         /**
-         * Loads the unit transformation. 
+         * Loads the unit transformation.
+         *
          * It is automatically called at construction time if the
          * $complete parameter is true (by default). No point in calling it
          * twice.
@@ -402,7 +415,8 @@
         }
 
         /**
-         * Loads the information about the unit skills. 
+         * Loads the information about the unit skills.
+         *
          * It is autoatically called at construction time if the
          * $complete parameter is true (by default). No point in calling it
          * twice.
@@ -426,7 +440,8 @@
         }
 
         /**
-         * Loads the information about the unit sources. 
+         * Loads the information about the unit sources.
+         *
          * It is autoatically called at construction time if the
          * $complete parameter is true (by default). No point in calling it
          * twice.
@@ -448,17 +463,14 @@
          * img/unit/ directory, and it's name must be the unit id,
          * padded with '0' to 8 digits, and the extension must be '.png'.
          *
-         * @return Path to the image, or a path to a fixed unknown image if it
-         *         doesn't exist.
+         * @return string Image URL, or a fixed unknown image.
          */
         public function get_image(){
-            global $dir;
-            global $path;
-            if (file_exists($dir . "img/unit/" . str_pad($this->id, 8, '0', STR_PAD_LEFT) . ".png")){
-                return $path["img"]["unit"] . str_pad($this->id, 8, '0', STR_PAD_LEFT) . ".png";
+            if (file_exists(PATH::BASE . "img/unit/" . str_pad($this->id, 8, '0', STR_PAD_LEFT) . ".png")){
+                return URL::IMG["UNIT"] . str_pad($this->id, 8, '0', STR_PAD_LEFT) . ".png";
             }
             else{
-                return $path["img"]["root"] . "unknown.png";
+                return URL::IMG["UNKNOWN"];
             }
         }
 

+ 25 - 19
application/entity/K_Unit_Transformation.php

@@ -1,35 +1,47 @@
 <?php
+    /**
+     * Transformation entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "K_Skill.php");
-    require_once($path["entity"] . "K_Leader_Skill.php");
-    require_once($path["entity"] . "K_Source.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
+    require_once(PATH::ENTITY . "K_Skill.php");
+    require_once(PATH::ENTITY . "K_Leader_Skill.php");
+    require_once(PATH::ENTITY . "K_Source.php");
 
 
     /**
      * Unit transformation.
      *
      * Represents an object from the table 'k_unit_transformation'.
+     *
+     * @category Entity
      */
     class K_Unit_Transformation extends Entity{
 
         /**
-         * Transformed unit identifier.
+         * @var int Transformed unit identifier.
          */
         public $id;
 
         /**
-         * Transformed unit family id.
+         * @var int Transformed unit family id.
          */
         public $family;
 
         /**
-         * ID of the unit that transformes into this. Not a instance of K_Unit.
+         * @var int ID of the unit that transformes into this.
          */
         public $unit;
 
         /**
-         * All {@see K_Monster_Skill}s in the transformed form.
+         * @var \K_Monster_Skill[] Skills in the transformed form.
          */
         public $skill = [];
 
@@ -39,13 +51,10 @@
          * Searches the database and retrieves the information about the
          * trnsformed unit, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id TRansformed unit identifier.
          */
         public function __construct($db, $id){
-            global $path;
-            global $ELEMENT;
-            global $ARCHETYPE;
             parent::__construct($db);
             $s = "
               SELECT
@@ -91,17 +100,14 @@
          * img/unit/ directory, and it's name must be the unit id,
          * padded with '0' to 8 digits, and the extension must be '.png'.
          *
-         * @return Path to the image, or a path to a fixed unknown image if it
-         *         doesn't exist.
+         * @return string Image URL, or a fixed unknown image.
          */
         public function get_image(){
-            global $dir;
-            global $path;
-            if (file_exists($dir . "img/unit/" . str_pad($this->id, 8, '0', STR_PAD_LEFT) . ".png")){
-                return $path["img"]["unit"] . str_pad($this->id, 8, '0', STR_PAD_LEFT) . ".png";
+            if (file_exists(PATH::BASE . "img/unit/" . str_pad($this->id, 8, '0', STR_PAD_LEFT) . ".png")){
+                return URL::IMG["UNIT"] . str_pad($this->id, 8, '0', STR_PAD_LEFT) . ".png";
             }
             else{
-                return $path["img"]["root"] . "unknown.png";
+                return URL::IMG["UNKNOWN"];
             }
         }
 

+ 48 - 37
application/entity/Run.php

@@ -1,115 +1,132 @@
 <?php
+    /**
+     * Saved run entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "Unit.php");
-    require_once($path["entity"] . "K_Unit.php");
-    require_once($path["entity"] . "Rune.php");
-    require_once($path["entity"] . "Inventory.php");
-    require_once($path["entity"] . "K_Area.php");
-    require_once($path["entity"] . "K_Rune_Set.php");
+     // TODO: Replace in_array for property_exists
+
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
+    require_once(PATH::ENTITY . "Unit.php");
+    require_once(PATH::ENTITY . "K_Unit.php");
+    require_once(PATH::ENTITY . "Rune.php");
+    require_once(PATH::ENTITY . "Inventory.php");
+    require_once(PATH::ENTITY . "K_Area.php");
+    require_once(PATH::ENTITY . "K_Rune_Set.php");
 
 
     /**
      * A run.
      *
      * Represents an object from the table 'run'.
+     *
+     * @category Entity
      */
     class Run extends Entity{
 
         /**
-         * Player identifier.
+         * @var int Player identifier.
          */
         public $uid;
 
         /**
-         * Run identifier.
+         * @var int Run identifier.
          */
         public $id;
 
         /**
-         * Run start datestame.
+         * @var DateTime Run start datestamp.
          */
         public $dtime;
 
         /**
-         * Area.
+         * @var K_Area Area.
          */
         public $area;
 
         /**
-         * Stage.
+         * @var int Stage.
          */
         public $stage;
 
         /**
-         * Difficulty (only scenario and dimension hole)
+         * @var int Difficulty (only scenario and dimension hole)
          */
         public $difficulty;
 
         /**
-         * Win or lost run.
+         * @var bool Win or lost run.
          */
         public $win;
 
         /**
-         * Clear time.
+         * @var int Clear time, milliseconds.
          */
         public $time;
 
         /**
-         * Reward mana.
+         * @var int Reward mana.
          */
         public $mana;
 
         /**
-         * Reward energy.
+         * @var int Reward energy.
          */
         public $energy;
 
         /**
-         * Reward crystal.
+         * @var int Reward crystal.
          */
         public $crystal;
 
         /**
-         * Indicates if a frind/mentor helped.
+         * @var bool Indicates if a frind/mentor helped.
          */
         public $helper;
 
         /**
-         * Array of {@see Unit}s or {@see K_Unit}.
+         * @var \Unit[]|\K_Unit[] Uits used.
          * If the unit is still owned, it will be a instance of Unit.
          * If not, it will be a instance of K_Unit.
          */
         public $party = [];
 
         /**
-         * List of {@see Inventory}, of dropped items.
+         * @var \Inventory[] Dropped items.
          */
         public $item = [];
 
         /**
-         * List of {@see K_Unit}s dropped.
+         * @var \K_Unit[] Units dropped.
          */
         public $unit = [];
 
         /**
-         * List of {@see K_Unit}s whose secret dungeons were found on the run.
+         * @var int K_Unit[] Units whose secret dungeons were found on the run.
          */
         public $sd= [];
 
         /**
-         * List of [{@see K_Unit}, amount] of dropped summon pieces.
+         * @var mixed[] List of dropped summon pieces.
+         *
+         * Formated as:
+         *  [@{see K_Unit}, amount]
          */
         public $unit_piece = [];
 
         /**
-         * Number of shapeshifting stones dropped;
+         * @var int Number of shapeshifting stones dropped;
          */
         public $shapeshifting = 0;
 
         /**
-         * List of {@see Rune}s dropped.
+         * @var \Rune[] List of Runes dropped.
          */
         public $rune= [];
 
@@ -119,16 +136,10 @@
          * Searches the database and retrieves the information about the
          * run, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Run identifier.
          */
         public function __construct($db, $id){
-            global $path;
-            global $AREA_TYPE;
-            global $SCENARIO;
-            global $DUNGEON;
-            global $RAID_RIFT_DUNGEON;
-            global $ELEMENTAL_RIFT_DUNGEON;
             parent::__construct($db);
             $s = "
                 SELECT
@@ -154,16 +165,16 @@
             $this->dtime = $r["dtime"];
             $type = 0;
             if (in_array($r["area"], $RAID_RIFT_DUNGEON) && $r["stage"] < 1){
-                $type = $AREA_TYPE["RIFT_RAID_DUNGEON"];
+                $type = AREA_TYPE::RIFT_RAID_DUNGEON;
             }
             elseif (in_array($r["area"], $SCENARIO)){
-                $type = $AREA_TYPE["SCENARIO"];
+                $type = AREA_TYPE::SCENARIO;
             }
             elseif (in_array($r["area"], $ELEMENTAL_RIFT_DUNGEON) && $r["stage"] < 1){
-                $type = $AREA_TYPE["ELEMENTAL_RIFT_DUNGEON"];
+                $type = AREA_TYPE::ELEMENTAL_RIFT_DUNGEON;
             }
             elseif (in_array($r["area"], $DUNGEON)){
-                $type = $AREA_TYPE["CAIROS_DUNGEON"];
+                $type = AREA_TYPE::CAIROS_DUNGEON;
             }
             $this->area = new K_Area($this->db, $r["area"], $type);
             $this->stage = $r["stage"];

+ 89 - 65
application/entity/Rune.php

@@ -1,203 +1,230 @@
 <?php
+    /**
+     * Rune entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "K_Rune_Set.php");
-
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
+    require_once(PATH::ENTITY . "K_Rune_Set.php");
 
     /**
      * Owned rune.
      *
      * Represents an object from the table 'rune'.
+     *
+     * @category Entity
      */
     class Rune extends Entity{
 
         /**
-         * Owner identifier.
+         * @var int Owner identifier.
          */
         public $uid;
 
         /**
-         * Rune identifier.
+         * @var int Rune identifier.
          */
         public $id;
 
         /**
-         * ID of the monster the rune is assigned to.
+         * @var int ID of the monster the rune is assigned to.
          */
         public $assigned_to;
 
         /**
-         * {@see K_Rune_Set}.
+         * @var K_Rune_Set Rune set.
          */
         public $type;
 
         /**
-         * Position of the rune type (1-6).
+         * @var int Position of the rune type (1-6).
          */
         public $slot;
 
         /**
-         * Rune stars.
+         * @var int Rune stars.
          */
         public $stars;
 
         /**
-         * Indicates if the rune is ancient.
+         * @var bool Indicates if the rune is ancient.
          */
         public $ancient;
 
         /**
-         * Level of the rune.
+         * @var int Level of the rune.
          */
         public $level;
 
         /**
-         * Rune quality.
+         * @var int Rune quality.
+         *
+         * @see QUALITY
          */
         public $quality;
 
         /**
-         * Rune original quality.
+         * @var int Rune original quality.
+         *
+         * @see QUALITY
          */
         public $original_quality;
 
         /**
-         * Rune quality name (uppercase).
+         * @var string Rune quality name (uppercase).
          */
         public $quality_name;
 
         /**
-         * Rune original quality name (uppercase).
+         * @var string Rune original quality name (uppercase).
          */
         public $original_quality_name;
 
         /**
-         * Price of the rune.
+         * @var int Price of the rune.
          */
         public $value;
 
         /**
-         * Current efficiency of the rune.
+         * @var float Current efficiency of the rune.
          */
         public $efficiency;
 
         /**
-         * Maximum potential efficiency of the rune.
+         * @var float Maximum potential efficiency of the rune.
          */
         public $max_efficiency;
 
         /**
-         * Main stat of the rune.
+         * @var int Main stat of the rune.
+         *
+         * @see RUNE_STAT
          */
         public $main_stat;
 
         /**
-         * Main stat name (uppercase).
+         * @var string Main stat name (uppercase).
          */
         public $main_stat_name;
 
         /**
-         * Main stat value of the rune.
+         * @var int Main stat value of the rune.
          */
         public $main_stat_value;
 
         /**
-         * Extra stat of the rune.
+         * @var int Extra stat of the rune.
+         *
+         * @see RUNE_STAT
          */
         public $innate_stat;
 
         /**
-         * Extra stat name (uppercase).
+         * @var string Extra stat name (uppercase).
          */
         public $innate_stat_name;
 
         /**
-         * Extra stat value of the rune.
+         * @var string Extra stat value of the rune.
          */
         public $innate_stat_value;
 
         /**
-         * Number of substats.
+         * @var int Number of substats.
          */
         public $substats;
 
         /**
-         * Substat 1 of the rune.
+         * @var int Substat 1 of the rune.
+         *
+         * @see RUNE_STAT
          */
         public $substat_1;
 
         /**
-         * Substat 1 name (uppercase).
+         * @var string Substat 1 name (uppercase).
          */
         public $substat_1_name;
 
         /**
-         * Substat 1 value of the rune.
+         * @var int Substat 1 value of the rune.
          */
         public $substat_1_value;
 
         /**
-         * Ammount gained by the substat 1 enchant.
+         * @var int Ammount gained by the substat 1 enchant.
          */
         public $substat_1_craft;
 
         /**
-         * Substat 2 of the rune.
+         * @var int Substat 2 of the rune.
+         *
+         * @see RUNE_STAT
          */
         public $substat_2;
 
         /**
-         * Substat 2 name (uppercase).
+         * @var string Substat 2 name (uppercase).
          */
         public $substat_2_name;
 
         /**
-         * Substat 2 value of the rune.
+         * @var int Substat 2 value of the rune.
          */
         public $substat_2_value;
 
         /**
-         * Ammount gained by the substat 2 enchant.
+         * @var int Ammount gained by the substat 2 enchant.
          */
         public $substat_2_craft;
 
         /**
-         * Substat 3 of the rune.
+         * @var int Substat 3 of the rune.
+         *
+         * @see RUNE_STAT
          */
         public $substat_3;
 
         /**
-         * Substat 3 name (uppercase).
+         * @var string Substat 3 name (uppercase).
          */
         public $substat_3_name;
 
         /**
-         * Substat 3 value of the rune.
+         * @var int Substat 3 value of the rune.
          */
         public $substat_3_value;
 
         /**
-         * Ammount gained by the substat 3 enchant.
+         * @var int Ammount gained by the substat 3 enchant.
          */
         public $substat_3_craft;
 
         /**
-         * Substat 4 of the rune.
+         * @var int Substat 4 of the rune.
+         *
+         * @see RUNE_STAT
          */
         public $substat_4;
 
         /**
-         * Substat 4 name (uppercase).
+         * @var string Substat 4 name (uppercase).
          */
         public $substat_4_name;
 
         /**
-         * Substat 4 value of the rune.
+         * @var int Substat 4 value of the rune.
          */
         public $substat_4_value;
 
         /**
-         * Ammount gained by the substat 4 enchant.
+         * @var int Ammount gained by the substat 4 enchant.
          */
         public $substat_4_craft;
 
@@ -207,11 +234,10 @@
          * Searches the database and retrieves the information about the
          * rune, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Rune id.
          */
         public function __construct($db, $id){
-            global $path;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -289,9 +315,9 @@
         }
 
         /**
-         * Decodes some properties and assigns name variables.
+         * Calculates name variables.
          */
-        public function refresh_names(){
+        private function refresh_names(){
             $this->main_stat_name = $this->stat_name($this->main_stat);
             $this->innate_stat_name = $this->stat_name($this->innate_stat);
             $this->substat_1_name = $this->stat_name($this->substat_1);
@@ -303,35 +329,34 @@
         }
 
         /**
-         * Gets a stat name frm the maps.
+         * Gets a stat name from the mappings.
          *
          * @param int $stat Stat id.
          * @return string Stat name (Uppercase)
          */
         private function stat_name($stat){
-            global $RUNE_STAT;
             switch ($stat){
-                case $RUNE_STAT["HP"]:
+                case RUNE_STAT_ID::HP:
                     return "HP";
-                case $RUNE_STAT["HP%"]:
+                case RUNE_STAT_ID::HP_P:
                     return "HP%";
-                case $RUNE_STAT["ATK"]:
+                case RUNE_STAT_ID::ATK:
                     return "ATK";
-                case $RUNE_STAT["ATK%"]:
+                case RUNE_STAT_ID::ATK_P:
                     return "ATK%";
-                case $RUNE_STAT["DEF"]:
+                case RUNE_STAT_ID::DEF:
                     return "DEF";
-                case $RUNE_STAT["DEF%"]:
+                case RUNE_STAT_ID::DEF_P:
                     return "DEF%";
-                case $RUNE_STAT["SPD"]:
+                case RUNE_STAT_ID::SPD:
                     return "SPD";
-                case $RUNE_STAT["CRR"]:
+                case RUNE_STAT_ID::CRR:
                     return "CRR";
-                case $RUNE_STAT["CRD"]:
+                case RUNE_STAT_ID::CRD:
                     return "CRD";
-                case $RUNE_STAT["RES"]:
+                case RUNE_STAT_ID::RES:
                     return "RES";
-                case $RUNE_STAT["ACC"]:
+                case RUNE_STAT_ID::ACC:
                     return "ACC";
                 default:
                     return "";
@@ -339,23 +364,22 @@
         }
 
         /**
-         * Gets a stat name frm the maps.
+         * Gets a stat name frm the mappings.
          *
          * @param int $q Quality id.
          * @return string Quality (Uppercase)
          */
         private function quality_name($q){
-            global $QUALITY;
             switch ($q){
-                case $QUALITY["NORMAL"]:
+                case QUALITY_ID::NORMAL:
                     return "NORMAL";
-                case $QUALITY["MAGIC"]:
+                case QUALITY_ID::MAGIC:
                     return "MAGIC";
-                case $QUALITY["RARE"]:
+                case QUALITY_ID::RARE:
                     return "RARE";
-                case $QUALITY["HERO"]:
+                case QUALITY_ID::HERO:
                     return "HERO";
-                case $QUALITY["LEGEND"]:
+                case QUALITY_ID::LEGEND:
                     return "LEGEND";
                 default:
                     return "";

+ 49 - 36
application/entity/Rune_Craft.php

@@ -1,82 +1,98 @@
 <?php
+    /**
+     * Rune craft items entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "K_Rune_Set.php");
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
+    require_once(PATH::ENTITY . "K_Rune_Set.php");
 
     /**
      * Owned rune craft item.
      *
      * Represents an object from the table 'rune_craft'.
+     *
+     * @category Entity
      */
     class Rune_Craft extends Entity{
 
         /**
-         * Owner identifier.
+         * @var int Owner identifier.
          */
         public $uid;
 
         /**
-         * Item identifier.
+         * @var int Item identifier.
          */
         public $id;
 
         /**
-         * Item quality.
+         * @var int Item quality.
+         *
+         * @see QUALITY
          */
         public $quality;
 
         /**
-         * Item quality name.
+         * @var string Item quality name.
          */
         public $quality_name;
 
         /**
-         * {@see K_Rune_Set} the item modifies.
+         * @var K_Rune_Set Rune set the item can be used on.
          */
         public $rune;
 
         /**
-         * Stat the item modifies.
+         * @var int Stat the item modifies.
+         *
+         * @see RUNE_STAT
          */
         public $stat;
 
         /**
-         * Stat name.
+         * @var string Stat name.
          */
         public $stat_name;
 
         /**
-         * Indicates if the Item is a gem.
+         * @var bool Indicates if the Item is a gem.
          */
         public $gem;
 
         /**
-         * Indicates if the Item is ancient.
+         * @var bool Indicates if the Item is ancient.
          */
         public $ancient;
 
         /**
-         * Indicates if the Item is inmemorial.
+         * @var bool Indicates if the Item is inmemorial.
          */
         public $inmemorial;
 
         /**
-         * Item name.
+         * @var string Item name.
          */
         public $name;
 
         /**
-         * Minimum value of the stat.
+         * @var int Minimum value of the stat.
          */
         public $min;
 
         /**
-         * Maximum value of the stat.
+         * @var int Maximum value of the stat.
          */
         public $max;
 
         /**
-         * Sell value.
+         * @var int Sell value.
          */
         public $value;
 
@@ -86,11 +102,10 @@
          * Searches the database and retrieves the information about the
          * rune, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Rune id.
          */
         public function __construct($db, $id){
-            global $path;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -148,29 +163,28 @@
          * @return string Stat name (Uppercase)
          */
         private function stat_name($stat){
-            global $RUNE_STAT;
             switch ($stat){
-                case $RUNE_STAT["HP"]:
+                case RUNE_STAT_ID::HP:
                     return "HP";
-                case $RUNE_STAT["HP%"]:
+                case RUNE_STAT_ID::HP_P:
                     return "HP%";
-                case $RUNE_STAT["ATK"]:
+                case RUNE_STAT_ID::ATK:
                     return "ATK";
-                case $RUNE_STAT["ATK%"]:
+                case RUNE_STAT_ID::ATK_P:
                     return "ATK%";
-                case $RUNE_STAT["DEF"]:
+                case RUNE_STAT_ID::DEF:
                     return "DEF";
-                case $RUNE_STAT["DEF%"]:
+                case RUNE_STAT_ID::DEF_P:
                     return "DEF%";
-                case $RUNE_STAT["SPD"]:
+                case RUNE_STAT_ID::SPD:
                     return "SPD";
-                case $RUNE_STAT["CRR"]:
+                case RUNE_STAT_ID::CRR:
                     return "CRR";
-                case $RUNE_STAT["CRD"]:
+                case RUNE_STAT_ID::CRD:
                     return "CRD";
-                case $RUNE_STAT["RES"]:
+                case RUNE_STAT_ID::RES:
                     return "RES";
-                case $RUNE_STAT["ACC"]:
+                case RUNE_STAT_ID::ACC:
                     return "ACC";
                 default:
                     return "";
@@ -184,17 +198,16 @@
          * @return string Quality (Uppercase)
          */
         private function quality_name($q){
-            global $QUALITY;
             switch ($q){
-                case $QUALITY["NORMAL"]:
+                case QUALITY_ID::NORMAL:
                     return "NORMAL";
-                case $QUALITY["MAGIC"]:
+                case QUALITY_ID::MAGIC:
                     return "MAGIC";
-                case $QUALITY["RARE"]:
+                case QUALITY_ID::RARE:
                     return "RARE";
-                case $QUALITY["HERO"]:
+                case QUALITY_ID::HERO:
                     return "HERO";
-                case $QUALITY["LEGEND"]:
+                case QUALITY_ID::LEGEND:
                     return "LEGEND";
                 default:
                     return "";

+ 32 - 15
application/entity/Team.php

@@ -1,63 +1,80 @@
 <?php
+    /**
+     * Team entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "K_Area.php");
-    require_once($path["entity"] . "Unit.php");
-
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "K_Area.php");
+    require_once(PATH::ENTITY . "Unit.php");
 
     /**
      * A Team.
      *
      * Represents an object from the table 'unit'.
+     *
+     * @category Entity
      */
     class Team extends Entity{
 
         /**
-         * Owner identifier.
+         * @var int Owner identifier.
          */
         public $uid;
 
         /**
-         * Team identifier.
+         * @var int Team identifier.
          */
         public $id;
 
         /**
-         * Team name.
+         * @var string Team name.
          */
         public $name;
 
         /**
-         * Team description.
+         * @var string Team description.
          */
         public $description;
 
         /**
-         * List of {@see Unit}s in the team.
+         * @var \Unit[] Units in the team.
          */
         public $unit = [];
 
         /**
-         * Area the team is designed for.
+         * @var Area Area the team is designed for.
          */
         public $area;
 
         /**
-         * Stage the team is designed for. It can be null.
+         * @var int Stage the team is designed for. It can be null.
          */
         public $stage;
 
+        /**
+         * @var int difficulty the team is designed for. It can be null.
+         *
+         * @see DIFFICULTY
+         */
+        public $difficulty;
+
         /**
          * Constructor.
          *
          * Searches the database and retrieves the information about the
          * monster, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Monster identifier.
-         * @param complete If false, it won't load the units.
+         * @param bool $complete If false, it won't load the units.
          */
         public function __construct($db, $id, $complete = true){
-            global $path;
             parent::__construct($db);
             $s = "
               SELECT
@@ -76,8 +93,8 @@
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->uid = $r["uid"];
             $this->id = $r["id"];
-            $this->name = e($r["name"]);
-            $this->description = e($r["description"]);
+            $this->name = HTML::e($r["name"]);
+            $this->description = HTML::e($r["description"]);
             $this->area = new K_Area($this->db, $r["area"], $r["area_type"]);
             $this->stage = $r["stage"];
             if ($complete){

+ 86 - 68
application/entity/Unit.php

@@ -1,215 +1,226 @@
 <?php
+    /**
+     * Unit entity file.
+     *
+     * Creates the entity and makes it available.
+     *
+     * @category Entity
+     */
 
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "K_Unit.php");
-    require_once($path["entity"] . "Team.php");
-    require_once($path["entity"] . "Rune.php");
-
+    /**
+     * Require dependent entities if not present.
+     */
+    require_once(PATH::ENTITY . "Entity.php");
+    require_once(PATH::ENTITY . "K_Unit.php");
+    require_once(PATH::ENTITY . "Team.php");
+    require_once(PATH::ENTITY . "Rune.php");
 
     /**
      * A Unit.
      *
      * Represents an object from the table 'unit'.
+     *
+     * @category Entity
      */
     class Unit extends Entity{
 
         /**
-         * Owner identifier.
+         * @var int User ID.
          */
         public $uid;
 
         /**
-         * Monster identifier.
+         * @var int Unit ID.
          */
         public $id;
 
         /**
-         * {@see Building} the unit is in.
+         * @var Building Building the unit is on.
          */
         public $building;
 
         /**
-         * Base {@see K_Unit}.
+         * @var K_Unit Base unit.
          */
         public $unit;
 
         /**
-         * Unit stars.
+         * @var int Unit stars.
          */
         public $stars;
 
         /**
-         * Unit level.
+         * @var int Unit level.
          */
         public $level;
 
         /**
-         * Monster base HP stat.
+         * @var int Unit base HP stat.
          */
         public $hp;
 
         /**
-         * Monster base ATK stat.
+         * @var int Unit base ATK stat.
          */
         public $attack;
 
         /**
-         * Monster base DEF stat.
+         * @var int Unit base DEF stat.
          */
         public $defense;
 
         /**
-         * Monster base SPD stat.
+         * @var int Unit base SPD stat.
          */
         public $speed;
 
         /**
-         * Monster base CRR stat.
+         * @var int Unit base CRR stat.
          */
         public $crit_rate;
 
         /**
-         * Monster base CRD stat.
+         * @var int Unit base CRD stat.
          */
         public $crit_damage;
 
         /**
-         * Monster base RES stat.
+         * @var int Unit base RES stat.
          */
         public $resistance;
 
         /**
-         * Monster base ACC stat.
+         * @var int Unit base ACC stat.
          */
         public $accuracy;
 
         /**
-         * Total gained experience.
+         * @var int Total gained experience.
          */
         public $experience;
 
         /**
-         * Total gained experience in its current level.
+         * @var int Total gained experience in its current level.
          */
         public $exp_gained;
 
         /**
-         * Experience / hour in the current building.
+         * @var int Experience / hour in the current building.
          */
         public $exp_gain_rate;
 
         /**
-         * Equipped transmogification.
+         * @var int Equipped transmogification.
          */
         public $costume;
 
         /**
-         * Unit attribute
+         * @var int Unit attribute
          */
         public $attribute;
 
         /**
-         * {@see K_Source} the unit was aquired from.
+         * @var K_Source Source the unit was aquired from.
          */
         public $source;
 
         /**
-         * Datetime the unit was obtained.
+         * @var Datetime  Time the unit was obtained.
          */
         public $create_time;
 
         /**
-         * Indicates if the unit is a Homunculus
+         * @var bool Indicates if the unit is a Homunculus
          */
         public $homunculus;
 
         /**
-         * Indicates the Homunculus name
+         * @var string Indicates the Homunculus name
          */
         public $homunculus_name;
 
         /**
-         * Indicates if the monster is locked.
+         * @var bool Indicates if the monster is locked.
          */
         public $lock;
 
         /**
-         * Unit rune HP stat.
+         * @var int Unit rune HP stat.
          */
         public $rune_hp = 0;
 
         /**
-         * Unit rune ATK stat.
+         * @var int Unit rune ATK stat.
          */
         public $rune_attack = 0;
 
         /**
-         * Unit rune DEF stat.
+         * @var int Unit rune DEF stat.
          */
         public $rune_defense = 0;
 
         /**
-         * Unit rune SPD stat.
+         * @var int Unit rune SPD stat.
          */
         public $rune_speed = 0;
 
         /**
-         * Unit rune CRR stat.
+         * @var int Unit rune CRR stat.
          */
         public $rune_crit_rate = 0;
 
         /**
-         * Unit rune CRD stat.
+         * @var int Unit rune CRD stat.
          */
         public $rune_crit_damage = 0;
 
         /**
-         * Unit rune RES stat.
+         * @var int Unit rune RES stat.
          */
         public $rune_resistance = 0;
 
         /**
-         * Unit rune ACC stat.
+         * @var int Unit rune ACC stat.
          */
         public $rune_accuracy = 0;
 
         /**
-         * Average rune efficiency.
+         * @var float Average rune efficiency.
          */
-        public $avg_rune_efficiency;
+        public $avg_rune_efficiency = 0.0;
 
         /**
-         * Equiped {@see Rune}s
+         * @var \Rune[] Equiped Runes.
          */
         public $rune = [];
 
         /**
-         * The {@see Teams}s the unit is on.
+         * @var \Team[] The Teamss the unit is on.
          */
         public $teams = [];
 
         /**
-         * Array with the levels of the skills.
+         * @var int[] Array with the levels of the skills, in orer.
          */
         public $skill_levels = [];
 
         /**
-         * Total experience required for the current level.
+         * @var int Total experience required for the current level.
          */
         public $experience_level = 0;
 
         /**
-         * Experience required to level up.
+         * @var int Experience required to level up.
          */
         public $experience_level_up = 0;
 
         /**
-         * Indcates if the unit is in storage.
+         * @var int Indcates if the unit is in storage.
          */
         public $in_storage = false;
 
         /**
-         * Unit title.
+         * @var string Unit title.
          * If Homunculus,it will be it's name.
          * If awakened, it will be the awakened from name.
          * If unawakened, it will be <element> <name>.
@@ -223,12 +234,13 @@
          * Searches the database and retrieves the information about the
          * monster, populating it and it's items.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          * @param int $id Monster identifier.
-         * @param complete If false, query only monster and k_monster.
+         * @param bool $complete If false, query only monster and k_monster.
+         * @global int Player ID.
          */
         public function __construct($db, $id, $complete = true){
-            global $path;
+            global $UID;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -257,7 +269,9 @@
               "  homunculus_name, " .
               "  lock " .
               "FROM unit " .
-              "WHERE id = '$id'; ";
+              "WHERE " .
+              "  uid = '$UID' AND " .
+              "  id = '$id'; ";
             $q = $this->db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->uid = $r["uid"];
@@ -331,11 +345,12 @@
         }
 
         /**
-         * Checks if the monster is in storage and sets $in_storage to true
-         * or false.
+         * Checks if the monster is in storage and sets {@see $in_storage} to
+         * true or false.
+         *
+         * @global int Player ID.
          */
         public function check_storage(){
-            global $BUILDING;
             global $UID;
             $s = "
               SELECT 1
@@ -347,7 +362,7 @@
                 unit.uid = '$UID' AND
                 building.uid = '$UID' AND
                 unit.building = building.id AND
-                building.building = '" . $BUILDING["MONSTER_STORAGE"] . "';
+                building.building = '" . BUILDING_ID::MONSTER_STORAGE . "';
             ";
             $q = $this->db->query($s);
             if ($q->fetchArray(SQLITE3_ASSOC) == false){
@@ -359,7 +374,9 @@
         }
 
         /**
-         * Loads the teams array, with the @{Team}s the unit is on.
+         * Loads the {@see teams} array, with the teams the unit is on.
+         *
+         * @global int Player ID.
          */
         public function load_teams(){
             global $UID;
@@ -416,46 +433,47 @@
          * @param int $value Stat increase value.
          */
         private function sum_rune_stat($stat, $value){
-            global $RUNE_STAT;
             switch ($stat){
-                case $RUNE_STAT["ATK"]:
+                case RUNE_STAT_ID::ATK:
                     $this->rune_attack += $value;
                     break;
-                case $RUNE_STAT["DEF"]:
+                case RUNE_STAT_ID::DEF:
                     $this->rune_defense += $value;
                     break;
-                case $RUNE_STAT["HP"]:
+                case RUNE_STAT_ID::HP:
                     $this->rune_hp += $value;
                     break;
-                case $RUNE_STAT["SPD"]:
+                case RUNE_STAT_ID::SPD:
                     $this->rune_speed += $value;
                     break;
-                case $RUNE_STAT["CRR"]:
+                case RUNE_STAT_ID::CRR:
                     $this->rune_crit_rate += $value;
                     break;
-                case $RUNE_STAT["CRD"]:
+                case RUNE_STAT_ID::CRD:
                     $this->rune_crit_damage += $value;
                     break;
-                case $RUNE_STAT["ACC"]:
+                case RUNE_STAT_ID::ACC:
                     $this->rune_accuracy += $value;
                     break;
-                case $RUNE_STAT["RES"]:
+                case RUNE_STAT_ID::RES:
                     $this->rune_resistance += $value;
                     break;
-                case $RUNE_STAT["ATK%"]:
+                case RUNE_STAT_ID::ATK_P:
                     $this->rune_attack += ($this->attack * $value / 100);
                     break;
-                case $RUNE_STAT["DEF%"]:
+                case RUNE_STAT_ID::DEF_P:
                     $this->rune_defense += ($this->defense * $value / 100);
                     break;
-                case $RUNE_STAT["HP%"]:
+                case RUNE_STAT_ID::HP_P:
                     $this->rune_hp += ($this->hp * $value / 100);
                     break;
             }
         }
 
         /**
-         *
+         * Checks if the unit skills are completly maxed.
+         * 
+         * @return bool True if all skills maxed, false otherwise.
          */
         public function are_skills_maxed(){
             $maxed = true;

+ 45 - 0
application/helper/DB_Helper.php

@@ -0,0 +1,45 @@
+<?php
+    /**
+     * DB helper file.
+     *
+     * Provides a helper to perform database operations.
+     *
+     * @category Helper.
+     */
+
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::HELPER . "Helper.php");
+
+    /**
+     * Database helper.
+     *
+     * Contains database utilities to connect.
+     *
+     * @category Helper.
+     */
+    final class DB extends Helper{
+
+        /**
+         * Creates a database connection using the data in the config files.
+         * 
+         * @return resource Connection to the database.
+         */
+        public static function start(){
+            /*class SQLite extends SQLite3 {
+                function __construct($file) {
+                    $this->open($file);
+                }
+            }*/
+            $db = new SQLite3(PATH::DB_KEY);
+            if(!$db) {
+                error_log($db->lastErrorMsg());
+            }
+            else {
+                $db->query("attach '" . PATH::DB_DATA . "' as data");
+                return $db;
+            }
+        }
+    }
+?>

+ 469 - 0
application/helper/HTML_Helper.php

@@ -0,0 +1,469 @@
+<?php
+    /**
+     * HTML helper file.
+     *
+     * Provides a helper to perform HTML operations.
+     *
+     * @category Helper.
+     */
+
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::HELPER . "Helper.php");
+    require_once(PATH::ENTITY . "Unit.php");
+    require_once(PATH::ENTITY . "K_Unit.php");
+    require_once(PATH::ENTITY . "Building.php");
+    require_once(PATH::ENTITY . "K_Building.php");
+    require_once(PATH::ENTITY . "Decoration.php");
+    require_once(PATH::ENTITY . "K_Decoration.php");
+    require_once(PATH::ENTITY . "Rune.php");
+    require_once(PATH::ENTITY . "Rune_Craft.php");
+    require_once(PATH::ENTITY . "Inventory.php");
+
+    /**
+     * HTML helper.
+     *
+     * Contains utilities to parse and format HTML and to build elements.
+     *
+     * @category Helper.
+     */
+    final class HTML extends Helper{
+
+        /**
+         * Escapes HTML characters
+         * 
+         * Alias for htmlspecialchars([input], ENT_QUOTES)
+         *
+         * @param string $input Text to escape.
+         * @return string Escaped text.
+         */
+        public static function e($input){
+           return htmlspecialchars($input, ENT_QUOTES);
+        }
+
+        /**
+         * Generates a unit panel.
+         * 
+         * @param Unit|K_Unit Entity to get the info from.
+         * @return string HTML content for a monster panel. Empty on error.
+         */
+        public static function unit_panel($unit) {
+            if ($unit instanceof Unit){
+                $k = $unit->unit;
+                $stars = $unit->stars;
+                $level = true;
+                $teams = (sizeof($unit->teams) > 0);
+                $lock = $unit->lock;
+                $storage = $unit->in_storage;
+                $maxed = ($unit->level == 40 && $unit->are_skills_maxed());
+            }
+            elseif ($unit instanceof K_Unit){
+                $k = $unit;
+                $stars = $unit->base_stars;
+                $level = false;
+                $teams = 0;
+                $lock = false;
+                $storage = false;
+                $maxed = false;
+            }
+            else{
+                return "";
+            }
+            $html = "";
+            if ($k->awakens_from == "" && $k->awakens_to == ""){
+                // No to, no from, silver monster.
+                $star_class ="star_silver";
+            }
+            elseif ($k->awakens_from != ""){
+                // Already awakened
+                if ($k->base_stars - $k->natural_stars == 1){
+                    // Normal awaken.
+                    $star_class ="star_purple";
+                }
+                else{
+                    // Second awaken.
+                    $star_class ="star_red";
+                }
+            }
+            elseif ($k->awakens_to != ""){
+                // Awakeable.
+                $star_class ="star_gold";
+            }
+            $html .= "<span class='stars'>\n";
+            for ($i = 0; $i < $stars; $i ++){
+                $html .= "<img class='star $star_class' src='" . URL::IMG["ICON"] . "star.png'/>\n";
+            }
+            $html .= "</span>\n";
+            $html .= "<img title='" . $unit->title . "' class='monster border_" . $k->element_name . "' src='" . $k->get_image() . "'/>\n";
+            if ($level){
+                $html .= "<span class='level'>\n";
+                $html .= $unit->level . "\n";
+                $html .= "</span>\n";
+            }
+            $html .= "<span class='badges'>\n";
+            if ($maxed){
+                $html .= "<img title='Maxed unit' src='" . URL::IMG["ICON"] . "maxed.png'>";
+            }
+            if ($teams > 0){
+                $title = $teams . " teams";
+                if ($teams == 1){
+                    $title = "1 team: " . $unit->teams[0]->name;
+                }
+                $html .= "<img title='$title' src='" . URL::IMG["ICON"] . "team.png'>";
+            }
+            if ($lock == 1){
+                $html .= "<img title='Locked' src='" . URL::IMG["ICON"] . "lock.png'>";
+            }
+            if ($storage){
+                $html .= "<img title='In storage' src='" . URL::IMG["ICON"] . "storage.png'>";
+            }
+
+            $html .= "</span>\n";
+            return $html;
+        }
+
+        /**
+         * Generates a transformed monster panel.
+         * 
+         * @param Unit|K_Unit Entity to get the info from.
+         * @return string HTML content for a monster panel. Empty on error.
+         */
+        public static function unit_transformation_panel($unit) {
+            $html = "";
+            if ($unit instanceof Unit){
+                $k = $unit->unit;
+            }
+            elseif ($unit instanceof K_Unit){
+                $k = $unit;
+            }
+            else{
+                return "";
+            }
+            if ($k->transformation == null){
+                return "";
+            }
+            $html .= "<div class='monster_transformation_panel'>\n";
+            $html .= "<img title='" . $unit->title . " (transformed)' class='monster_transformation border_" . $k->element_name . "' src='" . $k->transformation->get_image() . "'/>\n";
+            $html .= "</div>\n";
+            return $html;
+        }
+
+        /**
+         * Generates a rune panel.
+         * 
+         * @param Rune rune Entity to get the info from.
+         * @param Unit unit Optional. The unit the rune is assigned to.
+         * @return string HTML content for a rune panel. Empty on error.
+         */
+        public static function rune_panel($rune, $unit = null) {
+            if (!($rune instanceof Rune)){
+                return "";
+            }
+            $html = "";
+            $html .= "<div class='rune_panel rune_slot_" . $rune->slot . " rune_level_" . $rune->level . " rune_quality_" . strtolower($rune->quality_name) . " rune_original_quality_" . strtolower($rune->original_quality_name) . " rune_ancient_" . $rune->ancient . "'>\n";
+            $html .= "<img class='rune_base' src='" . URL::IMG["RUNE"] . "base.png'/>\n";
+            $html .= "<img class='rune_icon' src='" . $rune->type->get_image() . "'/>\n";
+            $html .= "<span class='rune_stars'>\n";
+            for ($i = 0; $i < $rune->stars; $i ++){
+                $html .= "<img class='star' src='" . URL::IMG["ICON"] . "star.png'/>\n";
+            }
+            $html .= "</span>\n";
+            $html .= "<span class='rune_level'>\n";
+            $html .= $rune->level . "\n";
+            $html .= "</span>\n";
+            $html .= "</div>\n";
+            if ($unit instanceof Unit){
+                $html .= "<div class='assigned'>\n";
+                $html .= "<a target='blank' href='/monsters/" . $unit->id . "'>\n";
+                $html .= "<img title='" . $unit->title . "' class='monster_image border_" . $unit->unit->element_name . "' src='" . $unit->unit->get_image() . "'/>\n";
+                $html .= "</a>\n";
+                $html .= "</div>\n";
+            }
+            return $html;
+        }
+
+        /**
+         * Generates a rune table.
+         * 
+         * @param Rune rune Entity to get the info from.
+         * @param Unit unit Optional. The unit the rune is assigned to.
+         * @return string HTML content for a rune table. Empty on error.
+         */
+        public static function rune_table($rune, $unit = null) {
+            if (!($rune instanceof Rune)){
+                return "";
+            }
+            $html = "";
+            $html .= "<table class='rune'>\n";
+            $html .= "<tr>\n";
+            $html .= "<td class='icon'>\n";
+            $html .= html_rune_panel($rune, $unit) . "\n";
+            $html .= "</td>\n";
+            $html .= "<td class='stats'>\n";
+            $html .= "<table>\n";
+            // Main stat
+            $html .= "<tr class='main_stat'>\n";
+            $html .= "<td class='stat'>\n";
+            if (in_array($rune->main_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                $stat_name = str_replace("%", "", $rune->main_stat_name);
+                $stat_value = "+ " . $rune->main_stat_value . "%";
+            }
+            else{
+                $stat_name = $rune->main_stat_name;
+                $stat_value = "+ " . $rune->main_stat_value;
+            }
+            $html .= $stat_name . "\n";
+            $html .= "</td>\n";
+            $html .= "<td class='value'>\n";
+            $html .= $stat_value . "\n";
+            $html .= "<td>\n";
+            $html .= "</tr>\n";
+            // Innate stat
+            $html .= "<tr class='innate_stat'>\n";
+            $html .= "<td class='stat'>\n";
+            if (strlen($rune->innate_stat) == 0){
+                $stat_name = "&nbsp;";
+                $stat_value = "";
+            }
+            elseif (in_array($rune->innate_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                $stat_name = str_replace("%", "", $rune->innate_stat_name);
+                $stat_value = "+ " . $rune->innate_stat_value . "%";
+            }
+            else{
+                $stat_name = $rune->innate_stat_name;
+                $stat_value = "+ " . $rune->innate_stat_value;
+            }
+            $html .= $stat_name . "\n";
+            $html .= "</td>\n";
+            $html .= "<td class='value'>\n";
+            $html .= $stat_value . "\n";
+            $html .= "<td>\n";
+            $html .= "</tr>\n";
+            $substats = array($rune->substat_1, $rune->substat_2, $rune->substat_3, $rune->substat_4);
+            $substats_name = array($rune->substat_1_name, $rune->substat_2_name, $rune->substat_3_name, $rune->substat_4_name);
+            $substats_value = array($rune->substat_1_value, $rune->substat_2_value, $rune->substat_3_value, $rune->substat_4_value);
+            $substats_grind = array($rune->substat_1_grind, $rune->substat_2_grind, $rune->substat_3_grind, $rune->substat_4_grind);
+            $substats_enchant = array($rune->substat_1_enchant, $rune->substat_2_enchant, $rune->substat_3_enchant, $rune->substat_4_enchant);
+            for ($i = 0; $i < 4; $i ++){
+                if (strlen($substats_name[$i]) == 0){
+                    $stat_name = "&nbsp;";
+                    $stat_value = "";
+                }
+                elseif (in_array($substats_name[$i], array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                    $stat_name = str_replace("%", "", $substats_name[$i]);
+                    $stat_value = "+ " . $substats_value[$i] . "%";
+                }
+                else{
+                    $stat_name = $substats_name[$i];
+                    $stat_value = "+ " . $substats_value[$i];
+                }
+                $grind = "";
+                if ($substats_grind[$i] > 0){
+                    $grind = "+" . $substats_grind[$i];
+                    if (in_array($substats_name[$i], array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                        $grind = $grind . "%";
+                    }
+                }
+                $html .= "<tr class=substat>\n";
+                $html .= "<td class='stat'>\n";
+                $html .= $stat_name . "\n";
+                $html .= "</td>\n";
+                $html .= "<td class='value'>\n";
+                $html .= $stat_value . "\n";
+                $html .= "<span class='grind grind_$grind'>\n";
+                $html .= $grind . "\n";
+                $html .= "</span>\n";
+                if ($substats_enchant[$i] == 1){
+                    $html .= "<img title='Enchanted' src='" . URL::IMG["RUNE"] . "enchanted.png'/>\n";
+                }
+                $html .= "</td>\n";
+                $html .= "</tr>\n";
+            }
+            $html .= "</table>\n";
+            $html .= "</td>\n";
+            // Details
+            $html .= "<td class='details'>\n";
+            $html .= "<table class='table_details'>\n";
+            $html .= "<tr>\n";
+            $html .= "<td class='title'>\n";
+            $html .= "Quality:\n";
+            $html .= "</td>\n";
+            $html .= "<td class='value'>\n";
+            $html .= "<span class='quality quality_" . strtolower($rune->quality_name) . "'>\n";
+            $html .= $rune->quality_name . "\n";
+            $html .= "</span>\n";
+            $html .= "</td>\n";
+            $html .= "</tr>\n";
+            $html .= "<tr>\n";
+            $html .= "<td class='title'>\n";
+            $html .= "Origina q.:\n";
+            $html .= "</td>\n";
+            $html .= "<td class='value'>\n";
+            $html .= "<span class='quality quality_" . strtolower($rune->original_quality_name) . "'>\n";
+            $html .= $rune->original_quality_name . "\n";
+            $html .= "</span>\n";
+            $html .= "</td>\n";
+            $html .= "</tr>\n";
+            $html .= "<tr>\n";
+            $html .= "<td class='title'>\n";
+            $html .= "Value:\n";
+            $html .= "</td>\n";
+            $html .= "<td class='value'>\n";
+            $html .= number_format($rune->value, 0, ".", ",") . "\n";
+            $html .= "</td>\n";
+            $html .= "</tr>\n";
+            $html .= "<tr>\n";
+            $html .= "<td class='title'>\n";
+            $html .= "Efficiency:\n";
+            $html .= "</td>\n";
+            $html .= "<td class='value'>\n";
+            $html .= number_format($rune->efficiency, 2, ".", ",") . "%\n";
+            $html .= "</td>\n";
+            $html .= "</tr>\n";
+            $html .= "<tr>\n";
+            $html .= "<td class='title'>\n";
+            $html .= "Max. eff.:\n";
+            $html .= "</td>\n";
+            $html .= "<td class='value'>\n";
+            $html .= number_format($rune->max_efficiency, 2, ".", ",") . "%\n";
+            $html .= "</td>\n";
+            $html .= "</tr>\n";
+            $html .= "<tr>\n";
+            $html .= "<td class='title'>\n";
+            $html .= "Reached. eff.:\n";
+            $html .= "</td>\n";
+            $html .= "<td class='value'>\n";
+            $html .= number_format($rune->efficiency * 100 / $rune->max_efficiency, 2, ".", ",") . "%\n";
+            $html .= "</td>\n";
+            $html .= "</tr>\n";
+            $html .= "</table>\n";
+            $html .= "</td>\n";
+            $html .= "</tr>\n";
+            $html .= "</table>\n";
+            return $html;
+        }
+
+        /**
+         * Generates a grindstone or gem panel.
+         * 
+         * @param Rune_Craft craft Entity to get the info from.
+         * @return string HTML content for a rune panel. Empty on error.
+         */
+        public static function craft_panel($craft) {
+            if (!($craft instanceof Rune_Craft)){
+                return "";
+            }
+            $html = "";
+            if ($craft->gem == 1){
+                if ($craft->inmemorial == 1){
+                    $base = URL::IMG["GRIND"] . "gem_inmemorial.png";
+                }
+                else{
+                    $base = URL::IMG["GRIND"] . "gem.png";
+                }
+            }
+            else{
+                if ($craft->inmemorial == 1){
+                    $base = URL::IMG["GRIND"] . "grind_inmemorial.png";
+                }
+                else{
+                    $base = URL::IMG["GRIND"] . "grind.png";
+                }
+            }
+            if ($craft->inmemorial == 0 && isset($craft->rune)){
+                $icon = "<img class='craft_icon' src='" . $craft->rune->get_image() . "'/>\n";
+            }
+            else{
+                $icon = "";
+            }
+            if (in_array($craft->stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                $stat_name = str_replace("%", "", $craft->stat_name);
+                $stat_value = "+ " . $craft->min . "~" . $craft->max . "%";
+            }
+            else{
+                $stat_name = $craft->stat_name;
+                $stat_value = "+ " . $craft->min . "~" . $craft->max;
+            }
+            $html .= "<div class='craft_panel craft_quality_" . strtolower($craft->quality_name) . " rune_ancient_" . $craft->ancient . "'>\n";
+            $html .= "<img class='craft_base' src='" . $base . "'/>\n";
+            $html .= $icon;
+            $html .= "<span class='craft_stat'>\n";
+            $html .= "<span class='craft_stat_name'>" . $stat_name . "</span>\n";
+            $html .= "<span class='craft_stat_value'>" . $stat_value . "</span>\n";
+            $html .= "</span>\n";
+            $html .= "</div>\n";
+            return $html;
+        }
+
+        /**
+         * Generates a building panel.
+         *
+         * @param Building|Decoration|K_Building|K_Decoration $building Entity to get the info from.
+         * @return string HTML content for a building panel. Empty on error.
+         */
+        public static function building_panel($building) {
+            if ($building instanceof Building){
+                $level = false;
+                $title = $building->building->name;
+                $description = $building->building->description;
+                $img = $building->building->get_image();
+            }
+            elseif ($building instanceof K_Building){
+                $level = false;
+                $title = $building->name;
+                $description = $building->building->description;
+                $img = $building->get_image();
+            }
+            elseif ($building instanceof Decoration){
+                $level = $building->level;
+                $title = $building->decoration->name;
+                $description = $building->decoration->description;
+                $img = $building->decoration->get_image();
+            }
+            elseif ($building instanceof K_Decoration){
+                $level = false;
+                $title = $building->name;
+                $description = $building->building->description;
+                $img = $building->get_image();
+            }
+            else{
+                return "";
+            }
+            if (strlen($description) > 0){
+                $title .= ": " . $description;
+            }
+            $html = "";
+            $html = "<div class='building_panel'>\n";
+            $html .= "<img title='" . $title . "' class='building' src='" . $img . "'/>\n";
+            if ($level){
+                $html .= "<span class='level'>\n";
+                $html .= $level . "\n";
+                $html .= "</span>\n";
+            }
+            $html .= "</div>\n";
+            return $html;
+        }
+
+        /**
+         * Generates a item panel.
+         *
+         * @param Inventory $item Entity to get the info from.
+         * @return string HTML content for a building panel. Empty on error.
+         */
+        public static function item_panel($item) {
+            if (!($item instanceof Inventory)){
+                return "";
+            }
+            $html = "";
+            $html = "<div class='item_panel'>\n";
+            $html .= "<img title='" . $item->name . "' class='item' src='" . $item->get_image() . "'/>\n";
+            $html .= "<span class='amount'>\n";
+            $html .= $item->amount . "\n";
+            $html .= "</span>\n";
+            $html .= "</div>\n";
+            return $html;
+        }
+    }
+
+?>

+ 19 - 0
application/helper/Helper.php

@@ -0,0 +1,19 @@
+<?php
+    /**
+     * Base helper file.
+     *
+     * Provides an empty helper.
+     *
+     * @category Helper
+     */
+
+    /**
+     * Helper superclass.
+     *
+     * Every other entity must inherit from this one. 
+     * 
+     * @abstract
+     * @category Helper
+     */
+    abstract class Helper{}
+?>

+ 61 - 0
application/helper/NET_Helper.php

@@ -0,0 +1,61 @@
+<?php
+    /**
+     * Netowrk helper file.
+     *
+     * Provides a helper to perform network operations.
+     *
+     * @category Helper.
+     */
+
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::HELPER . "Helper.php");
+
+    /**
+     * Netowrk helper.
+     *
+     * Contains netowrk related utilities.
+     *
+     * @category Helper.
+     */
+    final class NET extends Helper{
+
+        /**
+         * Finds out the protocol the user is connecting to the site with.
+         *
+         * @return string "http://" or "https://".
+         */
+        public static function get_protocol(){
+            if (isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on" || $_SERVER["HTTPS"] == 1) || isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && $_SERVER["HTTP_X_FORWARDED_PROTO"] == "https") {
+                $protocol = "https://";
+            }
+            else {
+                $protocol = "http://";
+            }
+            return $protocol;
+        }
+
+        /**
+         * Finds out the IP address of the client.
+         * 
+         * @return string Client IP address.
+         */
+        public static function get_ip(){
+            $client  = @$_SERVER["HTTP_CLIENT_IP"];
+            $forward = @$_SERVER["HTTP_X_FORWARDED_FOR"];
+            $remote  = $_SERVER["REMOTE_ADDR"];
+            if(filter_var($client, FILTER_VALIDATE_IP)){
+                $ip = $client;
+            }
+            elseif(filter_var($forward, FILTER_VALIDATE_IP)){
+                $ip = $forward;
+            }
+            else{
+                $ip = $remote;
+            }
+            return $ip;
+        }
+
+    }
+?>

+ 110 - 0
application/helper/TEXT_Helper.php

@@ -0,0 +1,110 @@
+<?php
+    /**
+     * Text helper file.
+     *
+     * Provides a helper to perform text operations.
+     *
+     * @category Helper.
+     */
+
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::HELPER . "Helper.php");
+
+    /**
+     * Text helper.
+     *
+     * Contains utilities to format and escapee text.
+     *
+     * @category Helper.
+     */
+    final class TEXT extends Helper{
+
+        /**
+         * Turns a date string into a human readable string on the specified
+         * language. Only works for spanish, basque and english.
+         * 
+         * @param string $str_date Date string ('yyyy-mm-dd' or 'yyyy-mm-dd HH:MM:SS')
+         * @param string $time Append the time at the end.
+         * @return string Formatted date string.
+         */
+        public static function format_date($str_date, $time = true){
+            $date = strtotime($str_date);
+            $year = date("o", $date);
+            $month = date("n", $date);
+            $month --;
+            $day = date("j", $date);
+            $wday = date("N", $date);
+            $wday --;
+            $hour = date("H", $date);
+            $minute = date("i", $date);
+            $week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
+            $months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
+            if ($time){
+                $str = "$week[$wday], $months[$month] $day, $year at $hour:$minute";
+            }
+            else{
+                $str = "$week[$wday], $months[$month] $day, $year";
+            }
+            return $str;
+        }
+
+        /**
+         * Closes all the opened HTML tags in a given string.
+         * 
+         * @param string html The string with HTML tags.
+         * @return string HTML with closed tags.
+         */
+        public static function close_tags($html) {
+            $result = [];
+            preg_match_all("#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?(?<![/|/ ])>#iU", $html, $result);
+            $openedtags = $result[1];
+            preg_match_all("#</([a-z]+)>#iU", $html, $result);
+            $closedtags = $result[1];
+            $len_opened = count($openedtags);
+            if (count($closedtags) == $len_opened) {
+                return $html;
+            }
+            $openedtags = array_reverse($openedtags);
+            for ($i=0; $i < $len_opened; $i++) {
+                if (!in_array($openedtags[$i], $closedtags)) {
+                    $html .= "</".$openedtags[$i].">";
+                } else {
+                    unset($closedtags[array_search($openedtags[$i], $closedtags)]);
+                }
+            }
+            return $html;
+        }
+
+        /**
+         * Text shortener.
+         *
+         * Given a string, it trims in the proximity of the
+         * desired string, up to the next white character. If indicated, it will
+         * append a link to the full text.
+         * 
+         * @param string $text The text to shorten.
+         * @param int $length The desired length.
+         * @param string $link_text Text for the link. Optional.
+         * @param string $link URI of the link.
+         * @return string Shortened text.
+         */
+        public static function cut_text($text, $length, $link_text = "", $link = ""){
+            if (strlen($text) < $length){
+                return $text;
+            }
+            $cut = substr($text, 0, strpos($text, " ", $length));
+            $cut = close_tags($cut);
+            if (strlen($cut) == 0){
+                $cut = $text;
+            }
+            if (strlen($text) != strlen($cut) && strlen($link) > 0 && strlen($link_text) > 0){
+                $cut = $cut . "... <a href='$link'>$link_text</a>";
+            }
+            return $cut;
+        }
+    }
+
+?>
+

+ 0 - 27
application/helper/db.php

@@ -1,27 +0,0 @@
-<?php
-
-
-    /**
-     * Creates a database connection using the data in the config files.
-     * 
-     * @return SQLite3Result Connection to the database.
-     */
-    function start_db(){
-        global $path;
-        //return new SQLiteDatabase($path["db"]);
-        class SQLite extends SQLite3 {
-            function __construct($file) {
-                $this->open($file);
-            }
-        }
-        $db = new SQLite3($path["db_key"]);
-        if(!$db) {
-            error_log($db->lastErrorMsg());
-        }
-        else {
-            $db->query("attach '" . $path["db_data"] . "' as data");
-            return $db;
-        }
-    }
-
-?>

+ 0 - 444
application/helper/html.php

@@ -1,444 +0,0 @@
-<?php
-
-    /**
-     * Alias for htmlspecialchars([input], ENT_QUOTES)
-     *
-     * @param input Text to escape.
-     * @return Escaped text.
-     */
-    function e($input){
-       return htmlspecialchars($input, ENT_QUOTES);
-    }
-
-    /**
-     * Generates a monster panel.
-     * 
-     * @param unit Unit/K_Unit Entity to get the info from.
-     * @return string HTML content for a monster panel. Empty on error.
-     */
-    function html_unit_panel($unit) {
-        global $path;
-        if ($unit instanceof Unit){
-            $k = $unit->unit;
-            $stars = $unit->stars;
-            $level = true;
-            $teams = (sizeof($unit->teams) > 0);
-            $lock = $unit->lock;
-            $storage = $unit->in_storage;
-            $maxed = ($unit->level == 40 && $unit->are_skills_maxed());
-        }
-        elseif ($unit instanceof K_Unit){
-            $k = $unit;
-            $stars = $unit->base_stars;
-            $level = false;
-            $teams = 0;
-            $lock = false;
-            $storage = false;
-            $maxed = false;
-        }
-        else{
-            return "";
-        }
-        $html = "";
-        if ($k->awakens_from == "" && $k->awakens_to == ""){
-            // No to, no from, silver monster.
-            $star_class ="star_silver";
-        }
-        elseif ($k->awakens_from != ""){
-            // Already awakened
-            if ($k->base_stars - $k->natural_stars == 1){
-                // Normal awaken.
-                $star_class ="star_purple";
-            }
-            else{
-                // Second awaken.
-                $star_class ="star_red";
-            }
-        }
-        elseif ($k->awakens_to != ""){
-            // Awakeable.
-            $star_class ="star_gold";
-        }
-        $html .= "<span class='stars'>\n";
-        for ($i = 0; $i < $stars; $i ++){
-            $html .= "<img class='star $star_class' src='" . $path["img"]["icon"] . "star.png'/>\n";
-        }
-        $html .= "</span>\n";
-        $html .= "<img title='" . $unit->title . "' class='monster border_" . $k->element_name . "' src='" . $k->get_image() . "'/>\n";
-        if ($level){
-            $html .= "<span class='level'>\n";
-            $html .= $unit->level . "\n";
-            $html .= "</span>\n";
-        }
-        $html .= "<span class='badges'>\n";
-        if ($maxed){
-            $html .= "<img title='Maxed unit' src='" . $path["img"]["icon"] . "maxed.png'>";
-        }
-        if ($teams > 0){
-            $title = $teams . " teams";
-            if ($teams == 1){
-                $title = "1 team: " . $unit->teams[0]->name;
-            }
-            $html .= "<img title='$title' src='" . $path["img"]["icon"] . "team.png'>";
-        }
-        if ($lock == 1){
-            $html .= "<img title='Locked' src='" . $path["img"]["icon"] . "lock.png'>";
-        }
-        if ($storage){
-            $html .= "<img title='In storage' src='" . $path["img"]["icon"] . "storage.png'>";
-        }
-
-        $html .= "</span>\n";
-        return $html;
-    }
-
-    /**
-     * Generates a transformed monster panel.
-     * 
-     * @param unit Unit/K_Unit Entity to get the info from.
-     * @return string HTML content for a monster panel. Empty on error.
-     */
-    function html_unit_transformation_panel($unit) {
-        global $path;
-        $html = "";
-        if ($unit instanceof Unit){
-            $k = $unit->unit;
-        }
-        elseif ($unit instanceof K_Unit){
-            $k = $unit;
-        }
-        else{
-            return "";
-        }
-        if ($k->transformation == null){
-            return "";
-        }
-        $html .= "<div class='monster_transformation_panel'>\n";
-        $html .= "<img title='" . $unit->title . " (transformed)' class='monster_transformation border_" . $k->element_name . "' src='" . $k->transformation->get_image() . "'/>\n";
-        $html .= "</div>\n";
-        return $html;
-    }
-
-    /**
-     * Generates a rune panel.
-     * 
-     * @param Rune rune Entity to get the info from.
-     * @param Unit unit Optional. The unit the rune is assigned to.
-     * @return string HTML content for a rune panel. Empty on error.
-     */
-    function html_rune_panel($rune, $unit = null) {
-        global $path;
-        if (!($rune instanceof Rune)){
-            return "";
-        }
-        $html = "";
-        $html .= "<div class='rune_panel rune_slot_" . $rune->slot . " rune_level_" . $rune->level . " rune_quality_" . strtolower($rune->quality_name) . " rune_original_quality_" . strtolower($rune->original_quality_name) . " rune_ancient_" . $rune->ancient . "'>\n";
-        $html .= "<img class='rune_base' src='" . $path["img"]["rune"] . "base.png'/>\n";
-        $html .= "<img class='rune_icon' src='" . $rune->type->get_image() . "'/>\n";
-        $html .= "<span class='rune_stars'>\n";
-        for ($i = 0; $i < $rune->stars; $i ++){
-            $html .= "<img class='star' src='" . $path["img"]["icon"] . "star.png'/>\n";
-        }
-        $html .= "</span>\n";
-        $html .= "<span class='rune_level'>\n";
-        $html .= $rune->level . "\n";
-        $html .= "</span>\n";
-        $html .= "</div>\n";
-        if ($unit instanceof Unit){
-            $html .= "<div class='assigned'>\n";
-            $html .= "<a target='blank' href='/monsters/" . $unit->id . "'>\n";
-            $html .= "<img title='" . $unit->title . "' class='monster_image border_" . $unit->unit->element_name . "' src='" . $unit->unit->get_image() . "'/>\n";
-            $html .= "</a>\n";
-            $html .= "</div>\n";
-        }
-        return $html;
-    }
-
-    /**
-     * Generates a rune table.
-     * 
-     * @param Rune rune Entity to get the info from.
-     * @param Unit unit Optional. The unit the rune is assigned to.
-     * @return string HTML content for a rune table. Empty on error.
-     */
-    function html_rune_table($rune, $unit = null) {
-        global $path;
-        if (!($rune instanceof Rune)){
-            return "";
-        }
-        $html = "";
-        $html .= "<table class='rune'>\n";
-        $html .= "<tr>\n";
-        $html .= "<td class='icon'>\n";
-        $html .= html_rune_panel($rune, $unit) . "\n";
-        $html .= "</td>\n";
-        $html .= "<td class='stats'>\n";
-        $html .= "<table>\n";
-        // Main stat
-        $html .= "<tr class='main_stat'>\n";
-        $html .= "<td class='stat'>\n";
-        if (in_array($rune->main_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-            $stat_name = str_replace("%", "", $rune->main_stat_name);
-            $stat_value = "+ " . $rune->main_stat_value . "%";
-        }
-        else{
-            $stat_name = $rune->main_stat_name;
-            $stat_value = "+ " . $rune->main_stat_value;
-        }
-        $html .= $stat_name . "\n";
-        $html .= "</td>\n";
-        $html .= "<td class='value'>\n";
-        $html .= $stat_value . "\n";
-        $html .= "<td>\n";
-        $html .= "</tr>\n";
-        // Innate stat
-        $html .= "<tr class='innate_stat'>\n";
-        $html .= "<td class='stat'>\n";
-        if (strlen($rune->innate_stat) == 0){
-            $stat_name = "&nbsp;";
-            $stat_value = "";
-        }
-        elseif (in_array($rune->innate_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-            $stat_name = str_replace("%", "", $rune->innate_stat_name);
-            $stat_value = "+ " . $rune->innate_stat_value . "%";
-        }
-        else{
-            $stat_name = $rune->innate_stat_name;
-            $stat_value = "+ " . $rune->innate_stat_value;
-        }
-        $html .= $stat_name . "\n";
-        $html .= "</td>\n";
-        $html .= "<td class='value'>\n";
-        $html .= $stat_value . "\n";
-        $html .= "<td>\n";
-        $html .= "</tr>\n";
-        $substats = array($rune->substat_1, $rune->substat_2, $rune->substat_3, $rune->substat_4);
-        $substats_name = array($rune->substat_1_name, $rune->substat_2_name, $rune->substat_3_name, $rune->substat_4_name);
-        $substats_value = array($rune->substat_1_value, $rune->substat_2_value, $rune->substat_3_value, $rune->substat_4_value);
-        $substats_grind = array($rune->substat_1_grind, $rune->substat_2_grind, $rune->substat_3_grind, $rune->substat_4_grind);
-        $substats_enchant = array($rune->substat_1_enchant, $rune->substat_2_enchant, $rune->substat_3_enchant, $rune->substat_4_enchant);
-        for ($i = 0; $i < 4; $i ++){
-            if (strlen($substats_name[$i]) == 0){
-                $stat_name = "&nbsp;";
-                $stat_value = "";
-            }
-            elseif (in_array($substats_name[$i], array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                $stat_name = str_replace("%", "", $substats_name[$i]);
-                $stat_value = "+ " . $substats_value[$i] . "%";
-            }
-            else{
-                $stat_name = $substats_name[$i];
-                $stat_value = "+ " . $substats_value[$i];
-            }
-            $grind = "";
-            if ($substats_grind[$i] > 0){
-                $grind = "+" . $substats_grind[$i];
-                if (in_array($substats_name[$i], array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                    $grind = $grind . "%";
-                }
-            }
-            $html .= "<tr class=substat>\n";
-            $html .= "<td class='stat'>\n";
-            $html .= $stat_name . "\n";
-            $html .= "</td>\n";
-            $html .= "<td class='value'>\n";
-            $html .= $stat_value . "\n";
-            $html .= "<span class='grind grind_$grind'>\n";
-            $html .= $grind . "\n";
-            $html .= "</span>\n";
-            if ($substats_enchant[$i] == 1){
-                $html .= "<img title='Enchanted' src='" . $path["img"]["rune"] . "enchanted.png'/>\n";
-            }
-            $html .= "</td>\n";
-            $html .= "</tr>\n";
-        }
-        $html .= "</table>\n";
-        $html .= "</td>\n";
-        // Details
-        $html .= "<td class='details'>\n";
-        $html .= "<table class='table_details'>\n";
-        $html .= "<tr>\n";
-        $html .= "<td class='title'>\n";
-        $html .= "Quality:\n";
-        $html .= "</td>\n";
-        $html .= "<td class='value'>\n";
-        $html .= "<span class='quality quality_" . strtolower($rune->quality_name) . "'>\n";
-        $html .= $rune->quality_name . "\n";
-        $html .= "</span>\n";
-        $html .= "</td>\n";
-        $html .= "</tr>\n";
-        $html .= "<tr>\n";
-        $html .= "<td class='title'>\n";
-        $html .= "Origina q.:\n";
-        $html .= "</td>\n";
-        $html .= "<td class='value'>\n";
-        $html .= "<span class='quality quality_" . strtolower($rune->original_quality_name) . "'>\n";
-        $html .= $rune->original_quality_name . "\n";
-        $html .= "</span>\n";
-        $html .= "</td>\n";
-        $html .= "</tr>\n";
-        $html .= "<tr>\n";
-        $html .= "<td class='title'>\n";
-        $html .= "Value:\n";
-        $html .= "</td>\n";
-        $html .= "<td class='value'>\n";
-        $html .= number_format($rune->value, 0, ".", ",") . "\n";
-        $html .= "</td>\n";
-        $html .= "</tr>\n";
-        $html .= "<tr>\n";
-        $html .= "<td class='title'>\n";
-        $html .= "Efficiency:\n";
-        $html .= "</td>\n";
-        $html .= "<td class='value'>\n";
-        $html .= number_format($rune->efficiency, 2, ".", ",") . "%\n";
-        $html .= "</td>\n";
-        $html .= "</tr>\n";
-        $html .= "<tr>\n";
-        $html .= "<td class='title'>\n";
-        $html .= "Max. eff.:\n";
-        $html .= "</td>\n";
-        $html .= "<td class='value'>\n";
-        $html .= number_format($rune->max_efficiency, 2, ".", ",") . "%\n";
-        $html .= "</td>\n";
-        $html .= "</tr>\n";
-        $html .= "<tr>\n";
-        $html .= "<td class='title'>\n";
-        $html .= "Reached. eff.:\n";
-        $html .= "</td>\n";
-        $html .= "<td class='value'>\n";
-        $html .= number_format($rune->efficiency * 100 / $rune->max_efficiency, 2, ".", ",") . "%\n";
-        $html .= "</td>\n";
-        $html .= "</tr>\n";
-        $html .= "</table>\n";
-        $html .= "</td>\n";
-        $html .= "</tr>\n";
-        $html .= "</table>\n";
-        return $html;
-    }
-
-    /**
-     * Generates a grindstone or gem panel.
-     * 
-     * @param Rune_Craft craft Entity to get the info from.
-     * @return string HTML content for a rune panel. Empty on error.
-     */
-    function html_craft_panel($craft) {
-        global $path;
-        if (!($craft instanceof Rune_Craft)){
-            return "";
-        }
-        $html = "";
-        if ($craft->gem == 1){
-            if ($craft->inmemorial == 1){
-                $base = $path["img"]["grind"] . "gem_inmemorial.png";
-            }
-            else{
-                $base = $path["img"]["grind"] . "gem.png";
-            }
-        }
-        else{
-            if ($craft->inmemorial == 1){
-                $base = $path["img"]["grind"] . "grind_inmemorial.png";
-            }
-            else{
-                $base = $path["img"]["grind"] . "grind.png";
-            }
-        }
-        if ($craft->inmemorial == 0 && isset($craft->rune)){
-            $icon = "<img class='craft_icon' src='" . $craft->rune->get_image() . "'/>\n";
-        }
-        else{
-            $icon = "";
-        }
-        if (in_array($craft->stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-            $stat_name = str_replace("%", "", $craft->stat_name);
-            $stat_value = "+ " . $craft->min . "~" . $craft->max . "%";
-        }
-        else{
-            $stat_name = $craft->stat_name;
-            $stat_value = "+ " . $craft->min . "~" . $craft->max;
-        }
-        $html .= "<div class='craft_panel craft_quality_" . strtolower($craft->quality_name) . " rune_ancient_" . $craft->ancient . "'>\n";
-        $html .= "<img class='craft_base' src='" . $base . "'/>\n";
-        $html .= $icon;
-        $html .= "<span class='craft_stat'>\n";
-        $html .= "<span class='craft_stat_name'>" . $stat_name . "</span>\n";
-        $html .= "<span class='craft_stat_value'>" . $stat_value . "</span>\n";
-        $html .= "</span>\n";
-        $html .= "</div>\n";
-        return $html;
-    }
-
-    /**
-     * Generates a building panel.
-     *
-     * @param unit Building/Decoration/K_Building/K_Decoration Entity to get the info from.
-     * @return string HTML content for a building panel. Empty on error.
-     */
-    function html_building_panel($building) {
-        global $path;
-        if ($building instanceof Building){
-            $level = false;
-            $title = $building->building->name;
-            $description = $building->building->description;
-            $img = $building->building->get_image();
-        }
-        elseif ($building instanceof K_Building){
-            $level = false;
-            $title = $building->name;
-            $description = $building->building->description;
-            $img = $building->get_image();
-        }
-        elseif ($building instanceof Decoration){
-            $level = $building->level;
-            $title = $building->decoration->name;
-            $description = $building->decoration->description;
-            $img = $building->decoration->get_image();
-        }
-        elseif ($building instanceof K_Decoration){
-            $level = false;
-            $title = $building->name;
-            $description = $building->building->description;
-            $img = $building->get_image();
-        }
-        else{
-            return "";
-        }
-        if (strlen($description) > 0){
-            $title .= ": " . $description;
-        }
-        $html = "";
-        $html = "<div class='building_panel'>\n";
-        $html .= "<img title='" . $title . "' class='building' src='" . $img . "'/>\n";
-        if ($level){
-            $html .= "<span class='level'>\n";
-            $html .= $level . "\n";
-            $html .= "</span>\n";
-        }
-        $html .= "</div>\n";
-        return $html;
-    }
-
-    /**
-     * Generates a item panel.
-     *
-     * @param item Inventory Entity to get the info from.
-     * @return string HTML content for a building panel. Empty on error.
-     */
-    function html_item_panel($item) {
-        global $path;
-        global $INVENTORY_TYPE;
-        if (!($item instanceof Inventory)){
-            return "";
-        }
-        $html = "";
-        $html = "<div class='item_panel'>\n";
-        $html .= "<img title='" . $item->name . "' class='item' src='" . $item->get_image() . "'/>\n";
-        $html .= "<span class='amount'>\n";
-        $html .= $item->amount . "\n";
-        $html .= "</span>\n";
-        $html .= "</div>\n";
-        return $html;
-    }
-
-?>

+ 0 - 117
application/helper/net.php

@@ -1,117 +0,0 @@
-<?php
-
-
-    /**
-     * Finds out the protocol the user is connecting to the site with.
-     *
-     * @return string "http://" or "https://".
-     */
-    function get_protocol(){
-        if (isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on" || $_SERVER["HTTPS"] == 1) || isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && $_SERVER["HTTP_X_FORWARDED_PROTO"] == "https") {
-            $protocol = "https://";
-        }
-        else {
-            $protocol = "http://";
-        }
-        return $protocol;
-    }
-
-
-    /**
-     * Finds out the IP address of the client.
-     * 
-     * @return string Client IP address.
-     */
-    function get_ip(){
-        $client  = @$_SERVER["HTTP_CLIENT_IP"];
-        $forward = @$_SERVER["HTTP_X_FORWARDED_FOR"];
-        $remote  = $_SERVER["REMOTE_ADDR"];
-        if(filter_var($client, FILTER_VALIDATE_IP)){
-            $ip = $client;
-        }
-        elseif(filter_var($forward, FILTER_VALIDATE_IP)){
-            $ip = $forward;
-        }
-        else{
-            $ip = $remote;
-        }
-        return $ip;
-    }
-
-
-    /**
-     * Registers the page viewed by the user. If it is first page shown in his
-     * visit, it also registers the visit. 
-     * 
-     * @param MySQL_connection $db Connection to the database.
-     * @param string $section Site section being visited.
-     * @param string $id ID of the entry being visited.
-     */
-    function stats($db, $section, $id){
-
-        // Get client data
-        $ip = get_ip();
-        $browser_data = get_browser(null, true);
-        $os = $browser_data["platform"];
-        $browser = $browser_data["browser"];
-        $uagent = $browser_data["browser_name_pattern"];
-
-        //If bot, do nothing
-        $bot_kw = Array();
-        $bot_kw[0] = "bot";
-        $bot_kw[1] = "spider";
-        $bot_kw[2] = "crawl";
-        $bot_kw[3] = ".com";
-        $bot_kw[4] = ".ru";
-        $bot_kw[5] = "baidu";
-        $bot_kw[6] = "survey";
-        $bot_kw[7] = "scan";
-        $bot_kw[8] = "feed";
-        $bot_kw[9] = "bing";
-        $bot_kw[10] = "yahoo";
-        $bot_kw[11] = "engine";
-        $bot_kw[12] = "preview";
-        $bot_kw[13] = "checker";
-        $bot_kw[14] = "catalog";
-        $bot_kw[15] = "accelerator";
-        $bot_kw[16] = "python";
-        $bot_kw[14] = "qt";
-        $bot_kw[15] = "webdav";
-        $bot_kw[16] = "http";
-        $bot_kw[17] = "url";
-        $bot_kw[18] = "fake";
-        $bot_kw[19] = "library";
-        $bot_kw[20] = "commerce";
-        $bot_kw[21] = "htmlbot";
-        $bot_kw[22] = "fetch";
-        $bot_kw[23] = "googleb";
-        $bot_kw[24] = "facebook";
-        $bot_kw[25] = "whatsapp";
-        $bot_kw[26] = "pinterest";
-        $bot_kw[27] = "scrapy";
-        $bot_kw[28] = "libwww";
-        $bot_kw[29] = "java standard library";
-        $bot_kw[30] = "default browser";
-        $bot_kw[31] = "twingly recon";
-        $bot_kw[32] = "siteexplorer";
-        $bot_kw[33] = "yandex";
-        $bot_kw[34] = "wotbox";
-        $bot_kw[35] = "apache synapse";
-        $bot_kw[36] = "catexplorador";
-        $bot_kw[37] = "internet archive";
-        if (in_array(strtolower($uagent), $bot_kw)){
-            return;
-        }
-
-        //Look for a visit with the same IP in the last 30 mins.
-        $q = mysqli_query($db, "SELECT stat_visit.id AS visitid FROM stat_view, stat_visit WHERE visit = stat_visit.id AND stat_view.dtime > DATE_SUB(now(), INTERVAL 30 MINUTE) AND ip = '$ip' AND uagent = '$uagent';");
-        if (mysqli_num_rows($q) == 0){
-            mysqli_query($db, "INSERT INTO stat_visit (ip, uagent, os, browser) VALUES ('$ip', '$uagent', '$os', '$browser');");
-            $q = mysqli_query($db, "SELECT stat_visit.id AS visitid FROM stat_visit WHERE ip = '$ip' AND uagent = '$uagent' ORDER BY stat_visit.id DESC LIMIT 1;");
-        }
-        $r = mysqli_fetch_array($q);
-        $visit = $r['visitid'];
-        mysqli_query($db, "INSERT INTO stat_view (visit, section, entry) VALUES ($visit, '$section', '$id');");
-    }
-
-?>

+ 0 - 87
application/helper/text.php

@@ -1,87 +0,0 @@
-<?php
-
-
-    /**
-     * Tturns a date string into a human readable string on the specified
-     * language. Only works for spanish, basque and english.
-     * 
-     * @param string $str_date Date string ('yyyy-mm-dd' or 'yyyy-mm-dd HH:MM:SS')
-     * @param string $time Append the time at the end.
-     * @return string Formatted date string.
-     */
-    function format_date($str_date, $lang, $time = true){
-        $date = strtotime($str_date);
-        $year = date("o", $date);
-        $month = date("n", $date);
-        $month --;
-        $day = date("j", $date);
-        $wday = date("N", $date);
-        $wday --;
-        $hour = date("H", $date);
-        $minute = date("i", $date);
-        $week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
-        $months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
-        if ($time){
-            $str = "$week[$wday], $months[$month] $day, $year at $hour:$minute";
-        }
-        else{
-            $str = "$week[$wday], $months[$month] $day, $year";
-        }
-        return $str;
-    }
-
-    /**
-     * This function closes all the opened HTML tags in a given string.
-     * 
-     * @param string html The string with HTML tags.
-     * @return string HTML with closed tags.
-     */
-    function close_tags($html) {
-        $result = [];
-        preg_match_all("#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?(?<![/|/ ])>#iU", $html, $result);
-        $openedtags = $result[1];
-        preg_match_all("#</([a-z]+)>#iU", $html, $result);
-        $closedtags = $result[1];
-        $len_opened = count($openedtags);
-        if (count($closedtags) == $len_opened) {
-            return $html;
-        }
-        $openedtags = array_reverse($openedtags);
-        for ($i=0; $i < $len_opened; $i++) {
-            if (!in_array($openedtags[$i], $closedtags)) {
-                $html .= "</".$openedtags[$i].">";
-            } else {
-                unset($closedtags[array_search($openedtags[$i], $closedtags)]);
-            }
-        }
-        return $html;
-    }
-
-    /**
-     * Text shortener. Given a string, it trims in the proximity of the
-     * desired string, up to the next white character. If indicated, it will
-     * append a link to the full text.
-     * 
-     * @param string $text The text to shorten.
-     * @param int $length The desired length.
-     * @param string $link_text Text for the link. Optional.
-     * @param string $link URI of the link.
-     * @return string Shortened text.
-     */
-     function cut_text($text, $length, $link_text = "", $link = ""){
-        if (strlen($text) < $length){
-            return $text;
-        }
-        $cut = substr($text, 0, strpos($text, " ", $length));
-        $cut = close_tags($cut);
-        if (strlen($cut) == 0){
-            $cut = $text;
-        }
-        if (strlen($text) != strlen($cut) && strlen($link) > 0 && strlen($link_text) > 0){
-            $cut = $cut . "... <a href='$link'>$link_text</a>";
-        }
-        return $cut;
-    }
-
-?>
-

+ 39 - 36
application/page/Catalog_Page.php

@@ -1,45 +1,51 @@
 <?php
+    /**
+     * Catalog page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "K_Unit.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "K_Unit.php");
 
 
     /**
      * Catalog page model.
+     *
+     * @category Page
      */
     class Catalog_Page extends Page{
 
         /**
-         * Array of {@see K_Unit}.
-         */
-        public $monsters = [];
-
-        /**
-         * The filters the page can handle.
+         * @var \K_Unit[] List of units to show.
          */
-        public $filters;
+        public $units = [];
 
         /**
          * Constructor.
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             parent::__construct($db);
-            $this->view = $path["view"] . "catalog.php";
+            $this->view = PATH::VIEW . "catalog.php";
             $this->parse_filters();
             $s_mon = $this->build_query();
             $q_mon = $this->db->query($s_mon);
             while ($r_mon = $q_mon->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->monsters, new K_Unit($db, $r_mon["id"], false));
+                array_push($this->units, new K_Unit($db, $r_mon["id"], false));
             }
+            error_log($s_mon);
             $this->title = "Catalog - SWDB";
             $this->description = "Catalog of all monsters";
-            $this->canonical = $root . "catalog/";
+            $this->canonical = URL::BASE . "catalog/";
         }
 
         /**
@@ -47,20 +53,18 @@
          * and adds them to the $filters array.
          */
         private function parse_filters(){
-            global $ELEMENT;
-            global $FILTER_CATALOG;
-            $this->filters = $FILTER_CATALOG;
-            if (isset($_GET["element"]) && in_array($_GET["element"], $ELEMENT)){
-                $this->filters["element"] = $_GET["element"];
+            $this->filters = FILTER::CATALOG;
+            if (isset($_GET["element"]) && property_exists(ELEMENT_ID, strtoupper($_GET["element"]))){
+                $this->filters["ELEMENT"] = $_GET["element"];
             }
             if (isset($_GET["name"]) && strlen($_GET["name"]) > 0){
-                $this->filters["name"] = SQLite3::escapeString($_GET["name"]);
+                $this->filters["NAME"] = SQLite3::escapeString($_GET["name"]);
             }
             if (isset($_GET["min_stars"]) && intval($_GET["min_stars"]) > 0 && intval($_GET["min_stars"]) <= 5){
-                $this->filters["min_stars"] = $_GET["min_stars"];
+                $this->filters["MIN_STARS"] = $_GET["min_stars"];
             }
             if (isset($_GET["max_stars"]) && intval($_GET["max_stars"]) > 0 && intval($_GET["max_stars"]) <= 5){
-                $this->filters["max_stars"] = $_GET["max_stars"];
+                $this->filters["MAX_STARS"] = $_GET["max_stars"];
             }
             return;
         }
@@ -69,31 +73,30 @@
          * Builds the query to the rune table using the selected or default
          * filters.
          *
-         * @return The query to be executed.
+         * @return string The query to be executed.
          */
         private function build_query(){
-            global $ELEMENT;
             $s = "
                 SELECT id 
                 FROM k_unit 
                 WHERE 
                   obtainable = 1 AND
                   awakens_from IS NULL AND
-                  natural_stars >= " . $this->filters["min_stars"] . " AND 
-                  natural_stars <= " . $this->filters["max_stars"];
-            if (in_array($this->filters["element"], $ELEMENT)){
-                $s = $s . " AND element = " . strtoupper($this->filters["element"]) . " ";
+                  natural_stars >= " . $this->filters["MIN_STARS"] . " AND 
+                  natural_stars <= " . $this->filters["MAX_STARS"];
+            if(property_exists(ELEMENT_ID, $this->filters["ELEMENT"])){
+                $s = $s . " AND element = " . $this->filters["ELEMENT"] . " ";
             }
-            if ($this->filters["name"] != ""){
-                $s = $s . " AND upper(name) LIKE '%" . strtoupper($this->filters["name"]) . "%' ";
+            if ($this->filters["NAME"] != ""){
+                $s = $s . " AND upper(name) LIKE '%" . strtoupper($this->filters["NAME"]) . "%' ";
             }
             $s = $s . "
                 ORDER BY
-                  element = " . $ELEMENT["FIRE"] ." DESC,
-                  element = " . $ELEMENT["WATER"] ." DESC,
-                  element = " . $ELEMENT["WIND"] ." DESC,
-                  element = " . $ELEMENT["LIGHT"] ." DESC,
-                  element = " . $ELEMENT["DARK"] ." DESC,
+                  element = " . ELEMENT_ID::FIRE ." DESC,
+                  element = " . ELEMENT_ID::WATER ." DESC,
+                  element = " . ELEMENT_ID::WIND ." DESC,
+                  element = " . ELEMENT_ID::LIGHT ." DESC,
+                  element = " . ELEMENT_ID::DARK ." DESC,
                   natural_stars;
             ";
             return $s;

+ 22 - 18
application/page/Fusion_Page.php

@@ -1,8 +1,18 @@
 <?php
+    /**
+     * Fusion page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Fusion.php");
-    require_once($path["entity"] . "K_Unit.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "Fusion.php");
+    require_once(PATH::ENTITY . "K_Unit.php");
 
 
     /**
@@ -11,35 +21,28 @@
     class Fusion_Page extends Page{
 
         /**
-         * List of top-level {@see K_Fusion}s to display.
+         * @var \K_Fusion[] List of top-level fusions to display.
          */
         public $fusion = [];
 
         /**
-         * List of top-level fuseable {@see K_Unit}s (for filter).
+         * @var \K_Unit[] List of top-level fuseable units (for filter).
          */
         public $products = [];
 
-        /**
-         * The filters the page can handle.
-         */
-        public $filters = [
-            "product" => 0,
-        ];
 
         /**
          * Constructor.
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
+         * @global int User ID.
          */
         public function __construct($db){
             global $UID;
-            global $path;
-            global $root;
             parent::__construct($db);
-            $this->view = $path["view"] . "fusion.php";
+            $this->view = PATH::VIEW . "fusion.php";
             $this->parse_filters();
             $s =
               "SELECT DISTINCT product " .
@@ -57,7 +60,7 @@
             }
             $this->title = "Fusion - SWDB";
             $this->description = "Fusion chart";
-            $this->canonical = $root . "fusion/";
+            $this->canonical = URL::BASE . "fusion/";
         }
 
         /**
@@ -65,6 +68,7 @@
          * and adds them to the $filters array.
          */
         private function parse_filters(){
+            $this->filters = FILTER::FUSION;
             if (isset($_GET["product"]) && intval($_GET["product"]) > 0){
                 $this->filters["product"] = $_GET["product"];
             }
@@ -75,7 +79,7 @@
          * Builds the query to the rune table using the selected or default
          * filters.
          * 
-         * @return The query to be executed.
+         * @return string The query to be executed.
          */
         private function build_query(){
             $s =
@@ -83,7 +87,7 @@
               "FROM k_fusion " .
               "WHERE stars = 5 ";
             if ($this->filters["product"] > 0){
-                $s = $s . " AND product = " . strtoupper($this->filters["product"]) . " ";
+                $s = $s . " AND product = " . $this->filters["product"] . " ";
             }
             $s = $s . "ORDER BY stars DESC;";
             return $s;

+ 24 - 13
application/page/Guild_Page.php

@@ -1,21 +1,33 @@
- <?php
+<?php
+    /**
+     * Guild page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Guild.php");
-    require_once($path["entity"] . "K_Guild_Skill_Group.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "Guild.php");
+    require_once(PATH::ENTITY . "K_Guild_Skill_Group.php");
 
     /**
-     * Guild page.
+     * Guild page model.
+     *
+     * @category Page
      */
     class Guild_Page extends Page{
 
         /**
-         * @{see Guild}.
+         * @var Guild Player guild.
          */
-        public $guild = [];
+        public $guild;
 
         /**
-         * List of {@see K_Guild_Skill_Group}s.
+         * @var \K_Guild_Skill_Group[] List of Guild skill groups.
          */
         public $skill_groups = [];
 
@@ -24,14 +36,13 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
+         * @global int Player id.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             global $UID;
             parent::__construct($db);
-            $this->view = $path["view"] . "guild.php";
+            $this->view = PATH::VIEW . "guild.php";
             $s = "
               SELECT id
               FROM guild
@@ -59,7 +70,7 @@
                 $this->title = "Guild - SWDB";
                 $this->description = "No guild";
             }
-            $this->canonical = $root . "guild/";
+            $this->canonical = URL::BASE . "guild/";
         }
     }
 ?>

+ 40 - 30
application/page/Home_Page.php

@@ -1,54 +1,66 @@
 <?php
+    /**
+     * Home page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Unit.php");
-    require_once($path["entity"] . "Building.php");
-    require_once($path["entity"] . "Decoration.php");
-    require_once($path["entity"] . "Inventory.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "Unit.php");
+    require_once(PATH::ENTITY . "Building.php");
+    require_once(PATH::ENTITY . "Decoration.php");
+    require_once(PATH::ENTITY . "Inventory.php");
 
 
     /**
      * Home page model.
+     *
+     * @category Page
      */
     class Home_Page extends Page{
 
         /**
-         * Player ID.
+         * @var int Player ID.
          */
         public $uid;
 
         /**
-         * Player level.
+         * @var int Player level.
          */
         public $level;
 
         /**
-         * Player name.
+         * @var string Player name.
          */
         public $name;
 
         /**
-         * Player country (XX).
+         * @var string Player country (XX).
          */
         public $country;
 
         /**
-         * Total experience.
+         * @var int Total experience.
          */
-         public $experience;
+        public $experience;
 
         /**
-         * Representative {@see Unit}.
+         * @var Unit Representative Unit.
          */
         public $rep;
 
         /**
-         * {@see Unit}s in Arena defense.
+         * @var \Unit[] Unitss in Arena defense.
          */
         public $defense = [];
 
         /**
-         * Currency
+         * @var int[] Currency.
          */
         public $currency = [
             "mana" => 0,
@@ -72,32 +84,32 @@
         ];
 
         /**
-         * List of {@see Building}s.
+         * @var \Building[] List of Buildings.
          */
         public $building = [];
 
         /**
-         * List of {@see Decoration}s.
+         * @var \Decoration[] List of Decorations.
          */
         public $decoration = [];
 
         /**
-         * List of Scrolls in {@see Inventory}s.
+         * @var \Inventory[] List of Scrolls in Inventory.
          */
         public $inventory_scroll = [];
 
         /**
-         * List of rune crafting items in {@see Inventory}s.
+         * @var \Inventory[] List of rune crafting items in Inventory.
          */
         public $inventory_craft_rune = [];
 
         /**
-         * List of rune crafting items in {@see Inventory}s.
+         * @var \Inventory[] List of rune crafting items in Inventory.
          */
         public $inventory_craft = [];
 
         /**
-         * List of rune crafting items in {@see Inventory}s.
+         * @var \Inventory[] List of rune crafting items in Inventory.
          */
         public $inventory_essence = [];
 
@@ -106,16 +118,14 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
-         * @param string $lang Lowercase, two-letter language code.
+         * @param resource $db Connection to the database.
+         * @global int Player ID.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             global $INVENTORY_TYPE;
             global $UID;
             parent::__construct($db);
-            $this->view = $path["view"] . "home.php";
+            $this->view = PATH::VIEW . "home.php";
             $s = "
               SELECT
                 uid,
@@ -208,7 +218,7 @@
                 FROM inventory
                 WHERE
                   uid = '$UID' AND
-                  type = " . $INVENTORY_TYPE["SCROLL"] . " AND
+                  type = " . INVENTORY_TYPE_ID::SCROLL . " AND
                   amount > 0
                 ORDER BY inventory.type;
             ";
@@ -225,7 +235,7 @@
                   inventory
                 WHERE
                   inventory.uid = '$UID' AND
-                  inventory.type = " . $INVENTORY_TYPE["RUNE_CRAFT"] . " AND
+                  inventory.type = " . INVENTORY_TYPE_ID::RUNE_CRAFT . " AND
                   amount > 0
                 ORDER BY inventory.id;
             ";
@@ -241,7 +251,7 @@
                   inventory
                 WHERE
                   inventory.uid = '$UID' AND
-                  inventory.type = " . $INVENTORY_TYPE["CRAFT_STUFF"] . " AND
+                  inventory.type = " . INVENTORY_TYPE_ID::CRAFT_STUFF . " AND
                   amount > 0
                 ORDER BY inventory.id;
             ";
@@ -260,7 +270,7 @@
                   inventory.id = k_inventory.id AND
                   inventory.type = k_inventory.type AND
                   inventory.uid = '$UID' AND
-                  inventory.type = " . $INVENTORY_TYPE["ESSENCES"] . " AND
+                  inventory.type = " . INVENTORY_TYPE_ID::ESSENCES . " AND
                   amount > 0
                 ORDER BY
                   upper(name) NOT LIKE '%MAGIC%',
@@ -280,7 +290,7 @@
             }
             $this->title = "SWDB";
             $this->description = "Summoners War DataBase";
-            $this->canonical = $root;
+            $this->canonical = URL::BASE;
         }
     }
 ?>

+ 17 - 7
application/page/Landing_Page.php

@@ -1,9 +1,21 @@
 <?php
+    /**
+     * Landing (login) page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
 
     /**
-     * Landing page model.
+     * Landing (login) page model.
+     *
+     * @category Page
      */
     class Landing_Page extends Page{
 
@@ -12,16 +24,14 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database. Can be null.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             parent::__construct($db);
-            $this->view = $path["view"] . "landing.php";
+            $this->view = PATH::VIEW . "landing.php";
             $this->title = "Login - SWDB";
             $this->description = "Login to SWDB";
-            $this->canonical = $root . "landing/";
+            $this->canonical = URL::BASE . "landing/";
         }
     }
 ?>

+ 22 - 11
application/page/Monster_Info_Page.php

@@ -1,16 +1,29 @@
  <?php
+    /**
+     * Monster details page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "K_Unit.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "K_Unit.php");
 
 
     /**
-     * Monster details page.
+     * Monster details page model.
+     *
+     * @category Page
      */
     class Monster_Info_Page extends Page{
 
         /**
-         * Selected @{see K_Unit} array.
+         * @var \K_Unit[] Selected unit array.
+         *
          * [0]: Unawakened monster (null if default purple).
          * [1]: Awakened monster (null if silver).
          * [2]: Second awakened monster (null if unavailaable).
@@ -18,7 +31,7 @@
         public $monster = [];
 
         /**
-         * IDs to other monsters of the family
+         * @var int[] IDs to other units of the family
          */
         public $family = [];
 
@@ -27,14 +40,12 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
-         * @param string $id Monster id. Can be any of the awakening stages
+         * @param resource $db Connection to the database.
+         * @param int $id Monster id. Can be any of the awakening stages
          */
         public function __construct($db, $id){
-            global $path;
-            global $root;
             parent::__construct($db);
-            $this->view = $path["view"] . "monster_info.php";
+            $this->view = PATH::VIEW . "monster_info.php";
             $title = "";
             $monster = new K_Unit($db, $id);
             if ($monster->can_awaken == 0){
@@ -74,7 +85,7 @@
 
             $this->title = $title ." - SWDB";
             $this->description = $title . " info - SWDB";
-            $this->canonical = $root . "monster_info/" . $id;
+            $this->canonical = URL::BASE . "monster_info/" . $id;
         }
     }
 ?>

+ 30 - 21
application/page/Monster_Page.php

@@ -1,21 +1,32 @@
  <?php
+    /**
+     * Monster view page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Unit.php");
-
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "Unit.php");
 
     /**
-     * Monster view page.
+     * Monster view page model.
+     *
+     * @category Page
      */
     class Monster_Page extends Page{
 
         /**
-         * Selected @{see Unit}.
+         * @var Unit Selected Unit.
          */
         public $unit;
 
         /**
-         * Stats gained by building.
+         * @var mixed[] Stats gained by building.
          */
         public $building_stats = [
             "atk" => 0,
@@ -37,28 +48,26 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
-         * @param string $id Monster id
+         * @param resource $db Connection to the database.
+         * @param string $id Selected unit id
          */
         public function __construct($db, $id){
-            global $path;
-            global $root;
             parent::__construct($db);
-            $this->view = $path["view"] . "monster.php";
+            $this->view = PATH::VIEW . "monster.php";
             $this->calculate_buildings();
             $this->unit = new Unit($db, $id);
             $this->title = $this->unit->unit->name ." - SWDB";
             $this->description = "Owned " . $this->unit->unit->name;
-            $this->canonical = $root . "monster/" . $id;
+            $this->canonical = URL::BASE . "monster/" . $id;
         }
 
         /**
          * Calculates the stats gained from bulding upgrades and populates the
          * $building_stats array.
+         *
+         * @gobal int User ID.
          */
         private function calculate_buildings(){
-            global $STAT;
-            global $EFFECT_AREA;
             global $UID;
             $s = "
               SELECT
@@ -74,25 +83,25 @@
                 k_decoration.id = decoration.decoration AND
                 decoration.decoration = k_decoration_level.decoration AND
                 decoration.level = k_decoration_level.level AND
-                area = " . $EFFECT_AREA["GENERAL"] . " AND
-                affected_stat IN (" . $STAT["ATK"] . ", " . $STAT["DEF"] . ", " . $STAT["HP"] . ", " . $STAT["SPD"] . ", " . $STAT["CRIT_DMG"] . ");
+                area = " . EFFECT_AREA::GENERAL . " AND
+                affected_stat IN (" . STAT::ATK . ", " . STAT::DEF . ", " . STAT::HP . ", " . STAT::SPD . ", " . STAT::CRIT_DMG . ");
             ";
             $q = $this->db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
                 switch($r["affected_stat"]){
-                    case $STAT["DEF"]:
+                    case STAT::DEF:
                         $this->building_stats["def"] += $r["bonus"];
                         break;
-                    case $STAT["HP"]:
+                    case STAT::HP:
                         $this->building_stats["hp"] += $r["bonus"];
                         break;
-                    case $STAT["SPD"]:
+                    case STAT::SPD:
                         $this->building_stats["spd"] += $r["bonus"];
                         break;
-                    case $STAT["CRIT_DMG"]:
+                    case STAT::CRIT_DMG:
                         $this->building_stats["crd"] += $r["bonus"];
                         break;
-                    case $STAT["ATK"]:
+                    case STAT::ATK:
                         if(strlen($r["element"]) > 0){
                             $this->building_stats["elm"][$r["element"]] += $r["bonus"];
                         }

+ 39 - 35
application/page/Monsters_Page.php

@@ -1,25 +1,32 @@
  <?php
+    /**
+     * Monster list page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Unit.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "Unit.php");
 
     /**
-     * Monster list page.
+     * Monster list page model.
+     *
+     * @category Page
      */
     class Monsters_Page extends Page{
 
         /**
-         * Array of @{see Monsters}s.
+         * @var \Unit[] Units to show.
          */
         public $monsters = [];
 
         /**
-         * The filters the page can handle.
-         */
-        public $filters;
-
-        /**
-         * Stats gained by building.
+         * @var mixed[] Stats gained by buildings.
          */
         public $building_stats = [
             "atk" => 0,
@@ -41,13 +48,11 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             parent::__construct($db);
-            $this->view = $path["view"] . "monsters.php";
+            $this->view = PATH::VIEW . "monsters.php";
             $this->parse_filters();
             $this->calculate_buildings();
             $s_mon = $this->build_query();
@@ -57,7 +62,7 @@
             }
             $this->title = "Monsters - SWDB";
             $this->description = "Owned monsters";
-            $this->canonical = $root . "monsters/";
+            $this->canonical = URL::BASE . "monsters/";
         }
 
         /**
@@ -65,9 +70,8 @@
          * and adds them to the $filters array.
          */
         private function parse_filters(){
-            global $FILTER_MONSTER;
-            $this->filters = $FILTER_MONSTER;
-            if (isset($_GET["element"]) && in_array($_GET["element"], $ELEMENT)){
+            $this->filters = FILTER::MONSTER;
+            if (isset($_GET["element"]) && property_exists(ELEMENT_ID, strtoupper($_GET["element"]))){
                 $this->filters["element"] = $_GET["element"];
             }
             if (isset($_GET["name"]) && strlen($_GET["name"]) > 0){
@@ -92,10 +96,10 @@
          * Builds the query to the rune table using the selected or default
          * filters.
          *
-         * @return The query to be executed.
+         * @return string The query to be executed.
+         * @global int Player ID.
          */
         private function build_query(){
-            global $ELEMENT;
             global $UID;
             $s = "
                 SELECT unit.id AS id
@@ -107,14 +111,14 @@
                   unit.unit = k_unit.id AND 
                   stars >= " . $this->filters["min_stars"] . " AND 
                   stars <= " . $this->filters["max_stars"];
-            if (in_array($this->filters["element"], $ELEMENT)){
-                $s = $s . " AND unit IN (SELECT id FROM k_unit WHERE upper(element) = '" . strtoupper($this->filters["element"]) . "') ";
+            if (property_exists(ELEMENT_ID, $this->filters["element"])){
+                $s = $s . " AND unit IN (SELECT id FROM k_unit WHERE element = " . $this->filters["element"] . ") ";
             }
             if ($this->filters["name"] != ""){
                 $s = $s . " AND unit IN (SELECT id FROM k_unit WHERE upper(name) LIKE '%" . strtoupper($this->filters["name"]) . "%') ";
             }
             if ($this->filters["in_storage"]){
-                // TODO $s = $s . " AND in_storage = 0 ";
+                $s = $s . " AND in_storage = 0 ";
             }
             if (!$this->filters["without_runes"]){
                 $s = $s . " AND unit.id IN (SELECT DISTINCT assigned_to FROM rune) ";
@@ -123,11 +127,11 @@
                 ORDER BY 
                   stars DESC,
                   level DESC,
-                  element = " . $ELEMENT["FIRE"] ." DESC,
-                  element = " . $ELEMENT["WATER"] ." DESC,
-                  element = " . $ELEMENT["WIND"] ." DESC,
-                  element = " . $ELEMENT["LIGHT"] ." DESC,
-                  element = " . $ELEMENT["DARK"] ." DESC
+                  element = " . ELEMENT_ID::FIRE ." DESC,
+                  element = " . ELEMENT_ID::WATER ." DESC,
+                  element = " . ELEMENT_ID::WIND ." DESC,
+                  element = " . ELEMENT_ID::LIGHT ." DESC,
+                  element = " . ELEMENT_ID::DARK ." DESC
             ";
             return $s;
         }
@@ -154,25 +158,25 @@
                 k_decoration.id = decoration.decoration AND
                 decoration.decoration = k_decoration_level.decoration AND
                 decoration.level = k_decoration_level.level AND
-                area = " . $EFFECT_AREA["GENERAL"] . " AND
-                affected_stat IN (" . $STAT["ATK"] . ", " . $STAT["DEF"] . ", " . $STAT["HP"] . ", " . $STAT["SPD"] . ", " . $STAT["CRIT_DMG"] . ");
+                area = " . EFFECT_AREA::GENERAL . " AND
+                affected_stat IN (" . STAT::ATK . ", " . STAT::DEF . ", " . STAT::HP . ", " . STAT::SPD . ", " . STAT::CRIT_DMG . ");
             ";
             $q = $this->db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
                 switch($r["affected_stat"]){
-                    case $STAT["DEF"]:
+                    case STAT::DEF:
                         $this->building_stats["def"] += $r["bonus"];
                         break;
-                    case $STAT["HP"]:
+                    case STAT::HP:
                         $this->building_stats["hp"] += $r["bonus"];
                         break;
-                    case $STAT["SPD"]:
+                    case STAT::SPD:
                         $this->building_stats["spd"] += $r["bonus"];
                         break;
-                    case $STAT["CRIT_DMG"]:
+                    case STAT::CRIT_DMG:
                         $this->building_stats["crd"] += $r["bonus"];
                         break;
-                    case $STAT["ATK"]:
+                    case STAT::ATK:
                         if(strlen($r["element"]) > 0){
                             $this->building_stats["elm"][$r["element"]] += $r["bonus"];
                         }

+ 36 - 16
application/page/Page.php

@@ -1,71 +1,91 @@
 <?php
-
+    /**
+     * Page superclass file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
     /**
      * Page superclass.
      *
      * Every visitable page type must inherit from this one.
+     *
+     * @category Page
      */
     abstract class Page{
 
         /**
-         * Database connection.
+         * @var resource Database connection.
          */
         public $db;
 
         /**
-         * View associated with the page.
+         * @var string Path to the view associated with the page.
          */
         public $view;
 
         /**
-         * Title of the page, in the defined language.
+         * @var string Title of the page, in the defined language.
          */
         public $title;
 
         /**
-         * Site name.
+         * @var string Site name.
          */
         public $name;
 
         /**
-         * Page description, in the defined language.
+         * @var string Page description, in the defined language.
          */
         public $description;
 
         /**
-         * Path to the site favicon.
+         * @var string URL to the site favicon.
          */
         public $favicon;
 
         /**
-         * Path to the page icon or main image.
+         * @var string URL to the page icon or main image.
          */
         public $icon;
 
         /**
-         * Canonical URL.
+         * @var string Canonical URL.
          */
         public $canonical;
 
         /**
-         * Autjhor URL.
+         * @var string Autjhor URL.
          */
         public $author;
 
+        /**
+         * @var mixed[] The filters the page can handle.
+         *
+         * @see FILTER::CATALOG
+         */
+        public $filters;
+
         /**
          * Constructor.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             $this->db = $db;
-            $this->favicon = $path["img"]["logo"] . "sw.png";
-            $this->icon = $path["img"]["logo"] . "sw.png";
+            $this->favicon = URL::IMG["LOGO"] . "sw.png";
+            $this->icon = URL::IMG["LOGO"] . "sw.png";
             $this->name = "SWDB";
-            $this->author = $root;
+            $this->author = URL::BASE;
         }
+        /**
+         * Parses the request looking for the selected filters, validates them
+         * and adds them to the $filters array.
+         *
+         * Must be overriden in the page classes.
+         */
+        private function parse_filters(){}
     }
 ?>

+ 29 - 7
application/page/Profile_Page.php

@@ -1,15 +1,38 @@
  <?php
+    /**
+     * User profile page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
 
 
     /**
-     * User profile page.
+     * User profile page model.
+     *
+     * @category Page
      */
     class Profile_Page extends Page{
 
+        /**
+         * @var string Player name.
+         */
         public $name;
+
+        /**
+         * @var string Player email.
+         */
         public $mail;
+
+        /**
+         * @var string Player API key.
+         */
         public $api_key;
 
         /**
@@ -17,14 +40,13 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
+         * @global int Player ID.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             global $UID;
             parent::__construct($db);
-            $this->view = $path["view"] . "profile.php";
+            $this->view = PATH::VIEW . "profile.php";
             $s = "
               SELECT
                 name,
@@ -41,7 +63,7 @@
             }
             $this->title = $this->name ." - SWDB";
             $this->description = $this->name . " user profile";
-            $this->canonical = $root . "profile/";
+            $this->canonical = URL::BASE . "profile/";
         }
 
     }

+ 21 - 9
application/page/Report_Page.php

@@ -1,16 +1,28 @@
  <?php
+    /**
+     * Main reports page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Custom_Filter.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "Custom_Filter.php");
 
 
     /**
-     * Main reports page.
+     * Main reports page model.
+     *
+     * @category Page
      */
     class Report_Page extends Page{
 
         /**
-         * Custom filters for this page.
+         * @var \Filter[] Custom filters for thie rune upgrade form.
          */
         public $custom_filters_runeupgrade = [];
 
@@ -19,14 +31,13 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
+         * @global int Player ID.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             global $UID;
             parent::__construct($db);
-            $this->view = $path["view"] . "report.php";
+            $this->view = PATH::VIEW . "report.php";
 
             // Get custom filters
             $s = "
@@ -43,7 +54,8 @@
 
             $this->title = "Reports - SWDB";
             $this->description = "Usefull reports for summoners";
-            $this->canonical = $root . "report";$this->title = "Reports - SWDB";
+            $this->canonical = URL::BASE . "report";
+            $this->title = "Reports - SWDB";
         }
     }
 ?>

+ 31 - 28
application/page/Report_Runecraft_Page.php

@@ -1,23 +1,31 @@
  <?php
+    /**
+     * Upgradeable runes report page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Unit.php");
-    require_once($path["entity"] . "Rune.php");
-    require_once($path["entity"] . "Rune_Craft.php");
-    //include($path["application"] . "Filter.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "Unit.php");
+    require_once(PATH::ENTITY . "Rune.php");
+    require_once(PATH::ENTITY . "Rune_Craft.php");
 
     /**
-     * Upgradeable runes report page.
+     * Upgradeable runes report page model.
+     *
+     * @category Page
      */
     class Report_Runecraft_Page extends Page{
 
         /**
-         * Filters the report can handle.
-         */
-        public $filters;
-
-        /**
-         * List of available upgrades. Can be described as:
+         * @var mixed[] List of available upgrades.
+         *
+         * Can be described as:
          * $upgrades = [
          *   [
          *     unit (Unit),
@@ -37,13 +45,11 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             parent::__construct($db);
-            $this->view = $path["view"] . "report_runecraft.php";
+            $this->view = PATH::VIEW . "report_runecraft.php";
             $this->parse_filters();
             $s = $this->build_query();
             $q = $this->db->query($s);
@@ -88,7 +94,7 @@
             array_push($this->upgrades, $upgrade);
             $this->title = "Rune craft - SWDB";
             $this->description = "Find runes that can be upgraded via crafting.";
-            $this->canonical = $root . "report/runecraft/";
+            $this->canonical = URL::BASE . "report/runecraft/";
         }
 
         /**
@@ -97,11 +103,7 @@
          * min_stars (1-6) and in_storage (on/off).
          */
         private function parse_filters(){
-            //global $RUNE_STAT;
-            global $FILTER_RUNECRAFT;
-            global $FILTER_SKILLUP;
-            global $QUALITY;
-            $this->filters = $FILTER_RUNECRAFT;
+            $this->filters = FILTER::RUNECRAFT;
             // Monster
             if (isset($_GET["monster_min_stars"]) && intval($_GET["monster_min_stars"]) > 0 && intval($_GET["monster_min_stars"]) < 7){
                 $this->filters["monster_min_stars"] = $_GET["monster_min_stars"];
@@ -131,16 +133,16 @@
             if (isset($_GET["rune_max_level"]) && intval($_GET["rune_max_level"]) >= 0 && intval($_GET["rune_max_level"]) <= 15){
                 $this->filters["rune_max_level"] = $_GET["rune_max_level"];
             }
-            if (isset($_GET["rune_min_quality"]) && intval($_GET["rune_min_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["rune_min_quality"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["rune_min_quality"]) && intval($_GET["rune_min_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["rune_min_quality"]) <= QUALITY_ID::LEGEND){
                 $this->filters["rune_min_quality"] = $_GET["rune_min_quality"];
             }
-            if (isset($_GET["rune_max_quality"]) && intval($_GET["rune_max_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["rune_max_quality"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["rune_max_quality"]) && intval($_GET["rune_max_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["rune_max_quality"]) <= QUALITY_ID::LEGEND){
                 $this->filters["rune_max_quality"] = $_GET["rune_max_quality"];
             }
-            if (isset($_GET["rune_min_original_quality"]) && intval($_GET["rune_min_original_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["rune_min_original_quality"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["rune_min_original_quality"]) && intval($_GET["rune_min_original_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["rune_min_original_quality"]) <= QUALITY_ID::LEGEND){
                 $this->filters["rune_min_original_quality"] = $_GET["rune_min_original_quality"];
             }
-            if (isset($_GET["rune_max_original_quality"]) && intval($_GET["rune_max_original_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["rune_max_original_quality"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["rune_max_original_quality"]) && intval($_GET["rune_max_original_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["rune_max_original_quality"]) <= QUALITY_ID::LEGEND){
                 $this->filters["rune_max_original_quality"] = $_GET["rune_max_original_quality"];
             }
             if (isset($_GET["rune_min_efficiency"]) && intval($_GET["rune_min_efficiency"]) >= 0 && intval($_GET["rune_min_efficiency"]) <= 100){
@@ -164,7 +166,7 @@
                 }
             }
             // Grindstones
-            if (isset($_GET["grind_min_quality"]) && intval($_GET["grind_min_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["grind_min_quality"]) < $QUALITY["LEGEND"]){
+            if (isset($_GET["grind_min_quality"]) && intval($_GET["grind_min_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["grind_min_quality"]) < QUALITY_ID::LEGEND){
                 $this->filters["grind_min_quality"] = $_GET["grind_min_quality"];
             }
             if (isset($_GET["grind_stat"])){
@@ -194,7 +196,8 @@
         /**
          * Builds the query for the page, using the providded or default filters.
          *
-         * @return The query to be executed.
+         * @return string The query to be executed.
+         * @global int Player ID.
          */
         private function build_query(){
             global $UID;

+ 35 - 49
application/page/Report_Runeupgrade_Page.php

@@ -1,50 +1,36 @@
  <?php
+    /**
+     * Upgradeable runes report page model.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Custom_Filter.php");
-    require_once($path["entity"] . "Unit.php");
-    require_once($path["entity"] . "Rune.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "Custom_Filter.php");
+    require_once(PATH::ENTITY . "Unit.php");
+    require_once(PATH::ENTITY . "Rune.php");
 
     /**
-     * Upgradeable runes report page.
+     * Upgradeable runes report page model.
+     *
+     * @category Page
      */
     class Report_Runeupgrade_Page extends Page{
 
         /**
-         * Filtrs the eport can handle.
-         */
-        public $filters = [
-            "monster_min_stars" => 5,
-            "monster_max_stars" => 6,
-            "monster_name" => "",
-            "monster_in_storage" => false,
-            "rune_min_stars" => 5,
-            "rune_max_stars" => 6,
-            "rune_min_level" => 0,
-            "rune_max_level" => 15,
-            "rune_min_quality" => 0,
-            "rune_max_quality" => 5,
-            "rune_min_original_quality" => 0,
-            "rune_max_original_quality" => 5,
-            "rune_min_efficiency" => 0,
-            "rune_max_efficiency" => 100,
-            "rune_min_max_efficiency" => 0,
-            "rune_max_max_efficiency" => 100,
-            "rune_slot" => [],
-            "alternative_min_stars" => 5,
-            "alternative_min_original_quality" => 0,
-            "alternative_min_level" => 0,
-            "alternative_condition" => 3,
-            "alternative_source" => 0,
-        ];
-
-        /**
-         * Custom filters for this page.
+         * @var \Filter[] Custom filters for this page.
          */
         public $custom_filters = [];
 
         /**
-         * List of available upgrades. Can be described as:
+         * @var mixed[] List of available upgrades.
+         *
+         * Can be described as:
          * $upgrades = [
          *   [
          *     unit (Unit),
@@ -64,14 +50,13 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
+         * @global int Player ID.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             global $UID;
             parent::__construct($db);
-            $this->view = $path["view"] . "report_runeupgrade.php";
+            $this->view = PATH::VIEW . "report_runeupgrade.php";
             $this->parse_filters();
             if (!isset($_GET["custom_filter"])){
                 $s = $this->build_query();
@@ -138,7 +123,7 @@
             }
             $this->title = "Replaceable runes - SWDB";
             $this->description = "Find equiped runes that can be substituted for better ones.";
-            $this->canonical = $root . "report/runeupgrade/";
+            $this->canonical = URL::BASE . "report/runeupgrade/";
         }
 
         /**
@@ -147,7 +132,6 @@
          * min_stars (1-6) and in_storage (on/off).
          */
         private function parse_filters(){
-            global $QUALITY;
             // Monster
             if (isset($_GET["monster_min_stars"]) && intval($_GET["monster_min_stars"]) > 0 && intval($_GET["monster_min_stars"]) < 7){
                 $this->filters["monster_min_stars"] = $_GET["monster_min_stars"];
@@ -177,16 +161,16 @@
             if (isset($_GET["rune_max_level"]) && intval($_GET["rune_max_level"]) >= 0 && intval($_GET["rune_max_level"]) <= 15){
                 $this->filters["rune_max_level"] = $_GET["rune_max_level"];
             }
-            if (isset($_GET["rune_min_quality"]) && intval($_GET["rune_min_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["rune_min_quality"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["rune_min_quality"]) && intval($_GET["rune_min_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["rune_min_quality"]) <= QUALITY_ID::LEGEND){
                 $this->filters["rune_min_quality"] = $_GET["rune_min_quality"];
             }
-            if (isset($_GET["rune_max_quality"]) && intval($_GET["rune_max_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["rune_max_quality"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["rune_max_quality"]) && intval($_GET["rune_max_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["rune_max_quality"]) <= QUALITY_ID::LEGEND){
                 $this->filters["rune_max_quality"] = $_GET["rune_max_quality"];
             }
-            if (isset($_GET["rune_min_original_quality"]) && intval($_GET["rune_min_original_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["rune_min_original_quality"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["rune_min_original_quality"]) && intval($_GET["rune_min_original_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["rune_min_original_quality"]) <= QUALITY_ID::LEGEND){
                 $this->filters["rune_min_original_quality"] = $_GET["rune_min_original_quality"];
             }
-            if (isset($_GET["rune_max_original_quality"]) && intval($_GET["rune_max_original_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["rune_max_original_quality"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["rune_max_original_quality"]) && intval($_GET["rune_max_original_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["rune_max_original_quality"]) <= QUALITY_ID::LEGEND){
                 $this->filters["rune_max_original_quality"] = $_GET["rune_max_original_quality"];
             }
             if (isset($_GET["rune_min_efficiency"]) && intval($_GET["rune_min_efficiency"]) >= 0 && intval($_GET["rune_min_efficiency"]) <= 100){
@@ -216,10 +200,10 @@
             if (isset($_GET["alternative_min_level"]) && intval($_GET["alternative_min_level"]) >= 0 && intval($_GET["alternative_min_level"]) <= 15){
                 $this->filters["alternative_min_level"] = $_GET["alternative_min_level"];
             }
-            if (isset($_GET["alternative_min_original_quality"]) && intval($_GET["alternative_min_original_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["alternative_min_original_quality"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["alternative_min_original_quality"]) && intval($_GET["alternative_min_original_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["alternative_min_original_quality"]) <= QUALITY_ID::LEGEND){
                 $this->filters["alternative_min_original_quality"] = $_GET["alternative_min_original_quality"];
             }
-            if (isset($_GET["alternative_condition"]) && intval($_GET["alternative_condition"]) >= 0 && intval($_GET["alternative_condition"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["alternative_condition"]) && intval($_GET["alternative_condition"]) >= 0 && intval($_GET["alternative_condition"]) <= QUALITY_ID::LEGEND){
                 $this->filters["alternative_condition"] = $_GET["alternative_condition"];
             }
             if (isset($_GET["alternative_source"]) && intval($_GET["alternative_source"]) >= 0 && intval($_GET["alternative_source"]) <= 2){
@@ -232,7 +216,8 @@
          * Builds the query to the rune table using the a custom filter.
          * 
          * @param int $filter Custom filter ID.
-         * @return The query to be executed.
+         * @return string The query to be executed.
+         * @global int Player ID.
          */
         private function build_custom_query($filter){
             global $UID;
@@ -285,7 +270,8 @@
         /**
          * Builds the query for the page, using the providded or default filters.
          *
-         * @return The query to be executed.
+         * @return string The query to be executed.
+         * @global int Player ID.
          */
         private function build_query(){
             global $UID;

+ 21 - 26
application/page/Report_Skillup_Page.php

@@ -1,46 +1,40 @@
  <?php
+    /**
+     * Urgent Skillup report page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Unit.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "Unit.php");
 
     /**
-     * Urgent Skillup report page.
+     * Urgent Skillup report page model.
+     *
+     * @category Page
      */
     class Report_Skillup_Page extends Page{
 
         /**
-         * Array of @{see Monsters}s.
+         * @var \Unit[] Sorted list of units.
          */
         public $units = [];
 
-        /**
-         * The filters the page can handle.
-         */
-        public $filters = [
-            "min_stars" => 5,
-            "max_stars" => 6,
-            "min_natural_stars" => 5,
-            "max_natural_stars" => 5,
-            "in_storage" => false,
-            "without_runes" => false,
-            "family" => false,
-            "maxed" => false,
-            "2a" => false,
-            "homunculus" => false
-        ];
-
         /**
          * Constructor.
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             parent::__construct($db);
-            $this->view = $path["view"] . "report_skillup.php";
+            $this->view = PATH::VIEW . "report_skillup.php";
             $this->parse_filters();
             $s_mon = $this->build_query();
             $q_mon = $this->db->query($s_mon);
@@ -49,7 +43,7 @@
             }
             $this->title = "Urgent skill-ups - SWDB";
             $this->description = "Monster in need of skilling up";
-            $this->canonical = $root . "report/skillups";
+            $this->canonical = URL::BASE . "report/skillups";
         }
 
         /**
@@ -95,7 +89,8 @@
          * Builds the query to the rune table using the selected or default
          * filters.
          *
-         * @return The query to be executed.
+         * @return string The query to be executed.
+         * @global int Player ID.
          */
         private function build_query(){
             global $UID;

+ 33 - 44
application/page/Runes_Page.php

@@ -1,64 +1,53 @@
  <?php
+ 
+    /**
+     * Rune list page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Custom_Filter.php");
-    require_once($path["entity"] . "Rune.php");
-    require_once($path["entity"] . "Unit.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "Custom_Filter.php");
+    require_once(PATH::ENTITY . "Rune.php");
+    require_once(PATH::ENTITY . "Unit.php");
 
     /**
-     * Rune list page.
+     * Rune list page model.
+     *
+     * @category Page
      */
     class Runes_Page extends Page{
 
         /**
-         * Array of @{see Rune}s.
+         * @var \Rune[] Runes to show.
+         *
          * NOTE: In this case, the monster member is not the id, but a monster
          * instance.
          */
         public $runes = [];
 
         /**
-         * Custom filters for this page.
+         * @var \Filter[] Custom filters for this page.
          */
         public $custom_filters = [];
 
-        /**
-         * The filters the page can handle.
-         */
-        public $filters = [
-            "type" => [],
-            "main" => [],
-            "sub" => [],
-            "slot" => [],
-            "min_quality" => 0,
-            "max_quality" => 5,
-            "min_original_quality" => 0,
-            "max_original_quality" => 5,
-            "min_stars" => 1,
-            "max_stars" => 6,
-            "min_level" => 0,
-            "max_level" => 15,
-            "min_efficiency" => 0,
-            "max_efficiency" => 100,
-            "min_max_efficiency" => 0,
-            "max_max_efficiency" => 100,
-            "assigned" => 1,
-            "group" => 0 // 0-> SLOT, 1->TYPE
-        ];
-
         /**
          * Constructor.
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
+         * @global int Player ID.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             global $UID;
             parent::__construct($db);
-            $this->view = $path["view"] . "runes.php";
+            $this->view = PATH::VIEW . "runes.php";
             $this->parse_filters();
             if (!isset($_GET["custom_filter"])){
                 $s = $this->build_query();
@@ -88,7 +77,7 @@
             }
             $this->title = "Runes - SWDB";
             $this->description = "Rune inventory";
-            $this->canonical = $root . "runes/";
+            $this->canonical = URL::BASE . "runes/";
         }
 
         /**
@@ -96,7 +85,6 @@
          * and adds them to the $filters array.
          */
         private function parse_filters(){
-            global $QUALITY;
             if (isset($_GET["type"])){
                 $types = $_GET["type"];
                 foreach ($types as $type){
@@ -135,16 +123,16 @@
             if (isset($_GET["max_level"]) && intval($_GET["max_level"]) >= 0 && intval($_GET["max_level"]) <= 15){
                 $this->filters["max_level"] = $_GET["max_level"];
             }
-            if (isset($_GET["min_quality"]) && intval($_GET["min_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["min_quality"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["min_quality"]) && intval($_GET["min_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["min_quality"]) <= QUALITY_ID::LEGEND){
                 $this->filters["min_quality"] = $_GET["min_quality"];
             }
-            if (isset($_GET["max_quality"]) && intval($_GET["max_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["max_quality"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["max_quality"]) && intval($_GET["max_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["max_quality"]) <= QUALITY_ID::LEGEND){
                 $this->filters["max_quality"] = $_GET["max_quality"];
             }
-            if (isset($_GET["min_original_quality"]) && intval($_GET["min_original_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["min_original_quality"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["min_original_quality"]) && intval($_GET["min_original_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["min_original_quality"]) <= QUALITY_ID::LEGEND){
                 $this->filters["min_original_quality"] = $_GET["min_original_quality"];
             }
-            if (isset($_GET["max_original_quality"]) && intval($_GET["max_original_quality"]) >= $QUALITY["NORMAL"] && intval($_GET["max_original_quality"]) <= $QUALITY["LEGEND"]){
+            if (isset($_GET["max_original_quality"]) && intval($_GET["max_original_quality"]) >= QUALITY_ID::NORMAL && intval($_GET["max_original_quality"]) <= QUALITY_ID::LEGEND){
                 $this->filters["max_original_quality"] = $_GET["max_original_quality"];
             }
             if (isset($_GET["min_efficiency"]) && intval($_GET["min_efficiency"]) >= 0 && intval($_GET["min_efficiency"]) <= 100){
@@ -165,14 +153,14 @@
             if (isset($_GET["group"]) && ($_GET["group"] == "1" || $_GET["group"] == "0")){
                 $this->filters["group"] = $_GET["group"];
             }
-            return;
         }
 
         /**
          * Builds the query to the rune table using the a custom filter.
          * 
          * @param int $filter Custom filter ID.
-         * @return The query to be executed.
+         * @return string The query to be executed.
+         * @global int Player ID.
          */
         private function build_custom_query($filter){
             global $UID;
@@ -203,7 +191,8 @@
          * Builds the query to the rune table using the selected or default
          * filters.
          * 
-         * @return The query to be executed.
+         * @return string The query to be executed.
+         * @global int Player ID.
          */
         private function build_query(){
             global $UID;

+ 23 - 19
application/page/Runs_Page.php

@@ -1,35 +1,40 @@
  <?php
+    /**
+     * Run list file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Run.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "Run.php");
 
     /**
-     * Run list page.
+     * Run list page model.
+     *
+     * @category Page
      */
     class Runs_Page extends Page{
 
         /**
-         * Array of @{see Run}s.
+         * @var \Run[] Runs to show.
          */
         public $runs = [];
 
-        /**
-         * Filters the page can handle.
-         */
-        public $filters;
-
         /**
          * Constructor.
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             parent::__construct($db);
-            $this->view = $path["view"] . "runs.php";
+            $this->view = PATH::VIEW . "runs.php";
             $this->parse_filters();
             $s = $this->build_query();
             $q = $this->db->query($s);
@@ -38,7 +43,7 @@
             }
             $this->title = "Runs - SWDB";
             $this->description = "Run logs";
-            $this->canonical = $root . "runs/";
+            $this->canonical = URL::BASE . "runs/";
         }
 
         /**
@@ -46,9 +51,7 @@
          * and adds them to the $filters array.
          */
         private function parse_filters(){
-            global $FILTER_RUN;
-            global $DIFFICULTY;
-            $this->filters = $FILTER_RUN;
+            $this->filters = FILTER::RUN;
             if (isset($_GET["area_type"]) && intval($_GET["area_type"]) > 0){
                 $this->filters["area_type"] = $_GET["area_type"];
             }
@@ -58,7 +61,7 @@
             if (isset($_GET["stage"]) && intval($_GET["stage"]) > 0){
                 $this->filters["stage"] = $_GET["stage"];
             }
-            if (isset($_GET["difficulty"]) && intval($_GET["difficulty"]) >= $DIFFICULTY["NORMAL"] && intval($_GET["difficulty"]) <= $DIFFICULTY["HELL"]){
+            if (isset($_GET["difficulty"]) && intval($_GET["difficulty"]) >= DIFFICULTY_ID::NORMAL && intval($_GET["difficulty"]) <= DIFFICULTY_ID::HELL){
                 $this->filters["difficulty"] = $_GET["difficulty"];
             }
             if (isset($_GET["date_min"]) && strlen($_GET["date_min"]) > 0){
@@ -89,7 +92,8 @@
          * Builds the query to the run table using the selected or default
          * filters.
          * 
-         * @return The query to be executed.
+         * @return string The query to be executed.
+         * @global int Player ID.
          */
         private function build_query(){
             global $UID;

+ 24 - 20
application/page/Teams_Page.php

@@ -1,25 +1,32 @@
  <?php
+    /**
+     * Team list page file.
+     *
+     * Provides a class with all the properties and methods to display the page.
+     *
+     * @category Page
+     */
 
-    require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Team.php");
+    /**
+     * Require dependent files if not present.
+     */
+    require_once(PATH::PAGE . "Page.php");
+    require_once(PATH::ENTITY . "Team.php");
 
     /**
-     * Monster list page.
+     * Team list page model.
+     *
+     * @category Page
      */
     class Teams_Page extends Page{
 
         /**
-         * Array of @{see Team}s.
+         * @var \Team[] Teams to show.
          */
         public $teams = [];
 
         /**
-         * The filters the page can handle.
-         */
-        public $filters;
-
-        /**
-         * List of all units for team creation
+         * @var \Unit[] List of all units for team creation.
          */
         public $units = [];
 
@@ -29,14 +36,13 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param SQLite3 $db Connection to the database.
+         * @param resource $db Connection to the database.
+         * @global int Player ID.
          */
         public function __construct($db){
-            global $path;
-            global $root;
             global $UID;
             parent::__construct($db);
-            $this->view = $path["view"] . "teams.php";
+            $this->view = PATH::VIEW . "teams.php";
             $this->parse_filters();
             $s = $this->build_query();
             $q = $this->db->query($s);
@@ -54,7 +60,7 @@
             }
             $this->title = "Teams - SWDB";
             $this->description = "Teams";
-            $this->canonical = $root . "teams/";
+            $this->canonical = URL::BASE . "teams/";
         }
 
         /**
@@ -62,10 +68,8 @@
          * and adds them to the $filters array.
          */
         private function parse_filters(){
-            global $FILTER_TEAM;
-            global $AREA_TYPE;
-            $this->filters = $FILTER_TEAM;
-            if (isset($_GET["area"]) && in_array($_GET["area"], $AREA_TYPE)){
+            $this->filters = FILTER::TEAM;
+            if (isset($_GET["area"]) && property_exists(AREA_TYPE_ID, $_GET["area"])){
                 $this->filters["area"] = $_GET["area"];
             }
             if (isset($_GET["name"]) && strlen($_GET["name"]) > 0){
@@ -88,7 +92,7 @@
               FROM team
               WHERE uid = '$UID'
             ";
-            if (in_array($this->filters["area"], $ELEMENT)){
+            if (property_exists(AREA_ID, $this->filters["area"])){
                 $s = $s . " AND area  = '" . strtoupper($this->filters["area"]) . "') ";
             }
             if ($this->filters["name"] != ""){

+ 19 - 6
application/view/catalog.php

@@ -1,3 +1,16 @@
+<?php
+    /**
+     * Catalog view.
+     *
+     * Contains the view layout and some code to present the data
+     *
+     * @category View
+     * @property_read Catalog_Page $page The page model
+     * @property_read int $UID Player ID
+     */
+
+    namespace swdb;
+?>
 <!DOCTYPE html>
 <html lang='en'>
     <head>
@@ -6,9 +19,9 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>catalog.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>filters.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>catalog.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>filters.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -52,7 +65,7 @@
 ?>
         <section class='filters'>
             <h2 id='filters_title' onClick='toggleFilters();'>
-                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=$path["img"]["icon"]?>slid.png'/>
+                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
                 Catalog filters
             </h2>
             <article id='filters_content'>
@@ -71,7 +84,7 @@
             <article>
 <?php
                 $element = "";
-                foreach ($page->monsters as $mon){
+                foreach ($page->units as $mon){
                     if ($mon->element != $element){
                         if ($element != ""){
 ?>
@@ -85,7 +98,7 @@
                     <div class='monster'>
                         <a href='/<?=$UID?>/catalog/<?=$mon->id?>'>
                             <div class='monster_panel'>
-                                <?=html_unit_panel($mon)?>
+                                <?=HTML::unit_panel($mon)?>
                             </div>
                         </a>
                     </div>

+ 46 - 33
application/view/fusion.php

@@ -1,3 +1,16 @@
+<?php
+    /**
+     * Fusion view.
+     *
+     * Contains the view layout and some code to present the data.
+     *
+     * @category View
+     * @property_read Fusion_Page $page The page model.
+     * @property_read int $UID Player ID.
+     */
+
+    namespace swdb;
+?>
 <!DOCTYPE html>
 <html lang='en'>
     <head>
@@ -6,9 +19,9 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>fusion.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>filters.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>fusion.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>filters.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -52,7 +65,7 @@
 ?>
         <section class='filters'>
             <h2 id='filters_title' onClick='toggleFilters();'>
-                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=$path["img"]["icon"]?>slid.png'/>
+                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
                 Fusion filters
             </h2>
             <article id='filters_content'>
@@ -77,11 +90,11 @@
                             <a target='_blank' title='<?=$fusion->product->name?>' href='/<?=$UID?>/catalog/<?=$fusion->product->id?>'>
                                 <div class='monster_panel'>
                                     <span class='stars'>
-                                        <img class='star star_gold' src='<?=$path["img"]["icon"]?>star.png'/>
-                                        <img class='star star_gold' src='<?=$path["img"]["icon"]?>star.png'/>
-                                        <img class='star star_gold' src='<?=$path["img"]["icon"]?>star.png'/>
-                                        <img class='star star_gold' src='<?=$path["img"]["icon"]?>star.png'/>
-                                        <img class='star star_gold' src='<?=$path["img"]["icon"]?>star.png'/>
+                                        <img class='star star_gold' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                        <img class='star star_gold' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                        <img class='star star_gold' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                        <img class='star star_gold' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                        <img class='star star_gold' src='<?=URL::IMG["ICON"]?>star.png'/>
                                     </span>
                                     <img title='<?=$fusion->product->name?>' class='monster border_<?=$fusion->product->element_name?>' src='<?=$fusion->product->get_image()?>'/>
                                     <span class='level'>
@@ -125,7 +138,7 @@
 <?php
                                                 for ($i = 0; $i < $owned->stars; $i ++){
 ?>
-                                                    <img class='star <?=$star_class?>' src='<?=$path["img"]["icon"]?>star.png'/>
+                                                    <img class='star <?=$star_class?>' src='<?=URL::IMG["ICON"]?>star.png'/>
 <?php
                                                 }
 ?>
@@ -149,11 +162,11 @@
                                         <a target='_blank' title='<?=$sub_fusion->product_awaken->name?>' href='/<?=$UID?>/catalog/<?=$sub_fusion->product_awaken->id?>'>
                                             <div class='awakened monster_panel'>
                                                 <span class='stars'>
-                                                    <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
-                                                    <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
-                                                    <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
-                                                    <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
-                                                    <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
+                                                    <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                                    <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                                    <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                                    <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                                    <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
                                                 </span>
                                                 <img title='<?=$sub_fusion->product_awaken->name?>' class='monster border_<?=$sub_fusion->product_awaken->element_name?>' src='<?=$sub_fusion->product_awaken->get_image()?>'/>
                                                 <span class='level'>
@@ -167,7 +180,7 @@
 <?php
                                                     for ($i = 0; $i < $sub_fusion->product->base_stars; $i ++){
 ?>
-                                                        <img class='star star_gold' src='<?=$path["img"]["icon"]?>star.png'/>
+                                                        <img class='star star_gold' src='<?=URL::IMG["ICON"]?>star.png'/>
 <?php
                                                     }
 ?>
@@ -183,7 +196,7 @@
                                             foreach ($sub_fusion->product->essences as $essence){
 ?>
                                                 <div class='essence border_<?=$essence["element"]?>'>
-                                                    <img alt='<?=$essence["grade"]?> <?=$essence["element"]?> essence' title='<?=$essence["amount"]?>x <?=$essence["grade"]?> <?=$essence["element"]?> essence' class='essence' src='<?=$path["img"]["essence"]?><?=$essence["element"]?>_<?=$essence["grade"]?>.png'/>
+                                                    <img alt='<?=$essence["grade"]?> <?=$essence["element"]?> essence' title='<?=$essence["amount"]?>x <?=$essence["grade"]?> <?=$essence["element"]?> essence' class='essence' src='<?=URL::IMG["ESSENCE"]?><?=$essence["element"]?>_<?=$essence["grade"]?>.png'/>
                                                     <span>
                                                         <?=$essence["amount"]?>
                                                     </span>
@@ -228,7 +241,7 @@
 <?php
                                                             for ($i = 0; $i < $owned->stars; $i ++){
 ?>
-                                                                <img class='star <?=$star_class?>' src='<?=$path["img"]["icon"]?>star.png'/>
+                                                                <img class='star <?=$star_class?>' src='<?=URL::IMG["ICON"]?>star.png'/>
 <?php
                                                             }
 ?>
@@ -253,10 +266,10 @@
                                                     <a target='_blank' title='<?=$sub_monster->name?>' href='/<?=$UID?>/catalog/<?=$sub_monster->id?>'>
                                                         <div class='awakened monster_panel'>
                                                             <span class='stars'>
-                                                                <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
-                                                                <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
-                                                                <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
-                                                                <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
+                                                                <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                                                <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                                                <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                                                <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
                                                             </span>
                                                             <img title='<?=$sub_monster->name?>' class='monster border_<?=$sub_monster->element_name?>' src='<?=$sub_monster->get_image()?>'/>
                                                             <span class='level'>
@@ -269,7 +282,7 @@
                                                         foreach ($sub_fusion->ingredient_unawaken[$num]->essences as $essence){
 ?>
                                                             <div class='essence border_<?=$essence["element"]?>'>
-                                                                <img alt='<?=$essence["grade"]?> <?=$essence["element"]?> essence' title='<?=$essence["amount"]?>x <?=$essence["grade"]?> <?=$essence["element"]?> essence' class='essence' src='<?=$path["img"]["essence"]?><?=$essence["element"]?>_<?=$essence["grade"]?>.png'/>
+                                                                <img alt='<?=$essence["grade"]?> <?=$essence["element"]?> essence' title='<?=$essence["amount"]?>x <?=$essence["grade"]?> <?=$essence["element"]?> essence' class='essence' src='<?=URL::IMG["ESSENCE"]?><?=$essence["element"]?>_<?=$essence["grade"]?>.png'/>
                                                                 <span>
                                                                     <?=$essence["amount"]?>
                                                                 </span>
@@ -284,7 +297,7 @@
 <?php
                                                                 for ($i = 0; $i < $sub_fusion->ingredient_unawaken[$num]->base_stars; $i ++){
 ?>
-                                                                    <img class='star star_gold' src='<?=$path["img"]["icon"]?>star.png'/>
+                                                                    <img class='star star_gold' src='<?=URL::IMG["ICON"]?>star.png'/>
 <?php
                                                                 }
 ?>
@@ -331,7 +344,7 @@
 <?php
                                                                         for ($i = 0; $i < $owned->stars; $i ++){
 ?>
-                                                                            <img class='star <?=$star_class?>' src='<?=$path["img"]["icon"]?>star.png'/>
+                                                                            <img class='star <?=$star_class?>' src='<?=URL::IMG["ICON"]?>star.png'/>
 <?php
                                                                         }
 ?>
@@ -363,11 +376,11 @@
                                     <a target='_blank' title='<?=$fusion->ingredient[0]->name?>' href='/<?=$UID?>/catalog/<?=$fusion->ingredient[0]->id?>'>
                                         <div class='awakened monster_panel'>
                                             <span class='stars'>
-                                                <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
-                                                <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
-                                                <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
-                                                <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
-                                                <img class='star star_purple' src='<?=$path["img"]["icon"]?>star.png'/>
+                                                <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                                <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                                <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                                <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
+                                                <img class='star star_purple' src='<?=URL::IMG["ICON"]?>star.png'/>
                                             </span>
                                             <img title='<?=$fusion->ingredient[0]->name?>' class='monster border_<?=$fusion->ingredient[0]->element_name?>' src='<?=$fusion->ingredient[0]->get_image()?>'/>
                                             <span class='level'>
@@ -380,7 +393,7 @@
                                         foreach ($fusion->ingredient_unawaken[0]->essences as $essence){
 ?>
                                             <div class='essence border_<?=$essence["element"]?>'>
-                                                <img alt='<?=$essence["grade"]?> <?=$essence["element"]?> essence' title='<?=$essence["amount"]?>x <?=$essence["grade"]?> <?=$essence["element"]?> essence' class='essence' src='<?=$path["img"]["essence"]?><?=$essence["element"]?>_<?=$essence["grade"]?>.png'/>
+                                                <img alt='<?=$essence["grade"]?> <?=$essence["element"]?> essence' title='<?=$essence["amount"]?>x <?=$essence["grade"]?> <?=$essence["element"]?> essence' class='essence' src='<?=URL::IMG["ESSENCE"]?><?=$essence["element"]?>_<?=$essence["grade"]?>.png'/>
                                                 <span>
                                                     <?=$essence["amount"]?>
                                                 </span>
@@ -395,7 +408,7 @@
 <?php
                                                 for ($i = 0; $i < $fusion->ingredient[0]->base_stars; $i ++){
 ?>
-                                                    <img class='star star_gold' src='<?=$path["img"]["icon"]?>star.png'/>
+                                                    <img class='star star_gold' src='<?=URL::IMG["ICON"]?>star.png'/>
 <?php
                                                 }
 ?>
@@ -440,7 +453,7 @@
                                                     }
                                                     for ($i = 0; $i < $owned->stars; $i ++){
 ?>
-                                                    <img class='star <?=$star_class?>' src='<?=$path["img"]["icon"]?>star.png'/>
+                                                    <img class='star <?=$star_class?>' src='<?=URL::IMG["ICON"]?>star.png'/>
 <?php
                                                     }
 ?>

+ 46 - 39
application/view/guild.php

@@ -1,7 +1,14 @@
 <?php
-    global $GUILD_MEMBER_GRADE;
-    global $ARENA_RANKING_POINTS;
-    global $ARENA_RANKING_RANK;
+    /**
+     * Guild view.
+     *
+     * Contains the view layout and some code to present the data.
+     *
+     * @category View
+     * @property_read Guild_Page $page The page model.
+     */
+
+    namespace swdb;
 ?>
 <!DOCTYPE html>
 <html lang='en'>
@@ -11,8 +18,8 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>guild.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>guild.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -132,14 +139,14 @@
                         <tr>
                             <td class='grade <?=$odd?>'>
 <?php
-                                if ($member->grade == $GUILD_MEMBER_GRADE["LEADER"]){
+                                if ($member->grade == GUILD_MEMBER_GRADE::LEADER){
 ?>
-                                    <img alt='yes' src='<?=$path["img"]["icon"] . "leader.png"?>'/>
+                                    <img alt='yes' src='<?=URL::IMG["ICON"] . "leader.png"?>'/>
 <?php
                                 }
-                                elseif ($member->grade == $GUILD_MEMBER_GRADE["VICELEADER"]){
+                                elseif ($member->grade == GUILD_MEMBER_GRADE::VICELEADER){
 ?>
-                                    <img alt='yes' src='<?=$path["img"]["icon"] . "viceleader.png"?>'/>
+                                    <img alt='yes' src='<?=URL::IMG["ICON"] . "viceleader.png"?>'/>
 <?php
                                 }
 ?>
@@ -155,60 +162,60 @@
                             </td>
                             <td class='score_icon <?=$odd?>'>
 <?php
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["BEGINER"] && ($ARENA_RANKING_RANK["BEGINER"] == null || $member->rating <= $ARENA_RANKING_RANK["BEGINER"])){
-                                    $src = $path["img"]["icon"] . "rank_beg.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::BEGINER && (ARENA_RANKING_RANK::BEGINER == null || $member->rating <= ARENA_RANKING_RANK::BEGINER)){
+                                    $src = URL::IMG["ICON"] . "rank_beg.png";
                                     $tit = "Beginer";
                                 }
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["CHALLENGER_1"] && ($ARENA_RANKING_RANK["CHALLENGER_1"] == null || $member->rating <= $ARENA_RANKING_RANK["CHALLENGER_1"])){
-                                    $src = $path["img"]["icon"] . "rank_cha1.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::CHALLENGER_1 && (ARENA_RANKING_RANK::CHALLENGER_1 == null || $member->rating <= ARENA_RANKING_RANK::CHALLENGER_1)){
+                                    $src = URL::IMG["ICON"] . "rank_cha1.png";
                                     $tit = "Challenger 1";
                                 }
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["CHALLENGER_2"] && ($ARENA_RANKING_RANK["CHALLENGER_2"] == null || $member->rating <= $ARENA_RANKING_RANK["CHALLENGER_2"])){
-                                    $src = $path["img"]["icon"] . "rank_cha2.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::CHALLENGER_2 && (ARENA_RANKING_RANK::CHALLENGER_2 == null || $member->rating <= ARENA_RANKING_RANK::CHALLENGER_2)){
+                                    $src = URL::IMG["ICON"] . "rank_cha2.png";
                                     $tit = "Challenger 2";
                                 }
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["CHALLENGER_3"] && ($ARENA_RANKING_RANK["CHALLENGER_3"] == null || $member->rating <= $ARENA_RANKING_RANK["CHALLENGER_3"])){
-                                    $src = $path["img"]["icon"] . "rank_cha3.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::CHALLENGER_3 && (ARENA_RANKING_RANK::CHALLENGER_3 == null || $member->rating <= ARENA_RANKING_RANK::CHALLENGER_3)){
+                                    $src = URL::IMG["ICON"] . "rank_cha3.png";
                                     $tit = "Challenger 3";
                                 }
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["FIGHTER_1"] && ($ARENA_RANKING_RANK["FIGHTER_1"] == null || $member->rating <= $ARENA_RANKING_RANK["FIGHTER_1"])){
-                                    $src = $path["img"]["icon"] . "rank_fig1.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::FIGHTER_1 && (ARENA_RANKING_RANK::FIGHTER_1 == null || $member->rating <= ARENA_RANKING_RANK::FIGHTER_1)){
+                                    $src = URL::IMG["ICON"] . "rank_fig1.png";
                                     $tit = "Fighter 1";
                                 }
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["FIGHTER_2"] && ($ARENA_RANKING_RANK["FIGHTER_2"] == null || $member->rating <= $ARENA_RANKING_RANK["FIGHTER_2"])){
-                                    $src = $path["img"]["icon"] . "rank_fig2.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::FIGHTER_2 && (ARENA_RANKING_RANK::FIGHTER_2 == null || $member->rating <= ARENA_RANKING_RANK::FIGHTER_2)){
+                                    $src = URL::IMG["ICON"] . "rank_fig2.png";
                                     $tit = "Fighter 2";
                                 }
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["FIGHTER_3"] && ($ARENA_RANKING_RANK["FIGHTER_3"] == null || $member->rating <= $ARENA_RANKING_RANK["FIGHTER_3"])){
-                                    $src = $path["img"]["icon"] . "rank_fig3.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::FIGHTER_3 && (ARENA_RANKING_RANK::FIGHTER_3 == null || $member->rating <= ARENA_RANKING_RANK::FIGHTER_3)){
+                                    $src = URL::IMG["ICON"] . "rank_fig3.png";
                                     $tit = "Fighter 3";
                                 }
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["CONQUEROR_1"] && ($ARENA_RANKING_RANK["CONQUEROR_1"] == null || $member->rating <= $ARENA_RANKING_RANK["CONQUEROR_1"])){
-                                    $src = $path["img"]["icon"] . "rank_con1.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::CONQUEROR_1 && (ARENA_RANKING_RANK::CONQUEROR_1 == null || $member->rating <= ARENA_RANKING_RANK::CONQUEROR_1)){
+                                    $src = URL::IMG["ICON"] . "rank_con1.png";
                                     $tit = "Conqueror 1";
                                 }
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["CONQUEROR_2"] && ($ARENA_RANKING_RANK["CONQUEROR_2"] == null || $member->rating <= $ARENA_RANKING_RANK["CONQUEROR_2"])){
-                                    $src = $path["img"]["icon"] . "rank_con2.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::CONQUEROR_2 && (ARENA_RANKING_RANK::CONQUEROR_2 == null || $member->rating <= ARENA_RANKING_RANK::CONQUEROR_2)){
+                                    $src = URL::IMG["ICON"] . "rank_con2.png";
                                     $tit = "Conqueror 2";
                                 }
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["CONQUEROR_3"] && ($ARENA_RANKING_RANK["CONQUEROR_3"] == null || $member->rating <= $ARENA_RANKING_RANK["CONQUEROR_3"])){
-                                    $src = $path["img"]["icon"] . "rank_con3.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::CONQUEROR_3 && (ARENA_RANKING_RANK::CONQUEROR_3 == null || $member->rating <= ARENA_RANKING_RANK::CONQUEROR_3)){
+                                    $src = URL::IMG["ICON"] . "rank_con3.png";
                                     $tit = "Conqueror 3";
                                 }
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["GUARDIAN_1"] && ($ARENA_RANKING_RANK["GUARDIAN_1"] == null || $member->rating <= $ARENA_RANKING_RANK["GUARDIAN_1"])){
-                                    $src = $path["img"]["icon"] . "rank_gua1.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::GUARDIAN_1 && (ARENA_RANKING_RANK::GUARDIAN_1 == null || $member->rating <= ARENA_RANKING_RANK::GUARDIAN_1)){
+                                    $src = URL::IMG["ICON"] . "rank_gua1.png";
                                     $tit = "Guardian 1";
                                 }
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["GUARDIAN_2"] && ($ARENA_RANKING_RANK["GUARDIAN_2"] == null || $member->rating <= $ARENA_RANKING_RANK["GUARDIAN_2"])){
-                                    $src = $path["img"]["icon"] . "rank_gua2.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::GUARDIAN_2 && (ARENA_RANKING_RANK::GUARDIAN_2 == null || $member->rating <= ARENA_RANKING_RANK::GUARDIAN_2)){
+                                    $src = URL::IMG["ICON"] . "rank_gua2.png";
                                     $tit = "Guardian 2";
                                 }
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["GUARDIAN_3"] && ($ARENA_RANKING_RANK["GUARDIAN_3"] == null || $member->rating <= $ARENA_RANKING_RANK["GUARDIAN_3"])){
-                                    $src = $path["img"]["icon"] . "rank_gua3.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::GUARDIAN_3 && (ARENA_RANKING_RANK::GUARDIAN_3 == null || $member->rating <= ARENA_RANKING_RANK::GUARDIAN_3)){
+                                    $src = URL::IMG["ICON"] . "rank_gua3.png";
                                     $tit = "Guardian 3";
                                 }
-                                if ($member->arena_score >= $ARENA_RANKING_POINTS["LEGEND"] && ($ARENA_RANKING_RANK["LEGEND"] == null || $member->rating <= $ARENA_RANKING_RANK["LEGEND"])){
-                                    $src = $path["img"]["icon"] . "rank_leg.png";
+                                if ($member->arena_score >= ARENA_RANKING_POINTS::LEGEND && (ARENA_RANKING_RANK::LEGEND == null || $member->rating <= ARENA_RANKING_RANK::LEGEND)){
+                                    $src = URL::IMG["ICON"] . "rank_leg.png";
                                     $tit = "Legend";
                                 }
 ?>
@@ -218,7 +225,7 @@
 <?php
                                 if ($member->in_war){
 ?>
-                                    <img alt='yes' src='<?=$path["img"]["icon"] . "ok.png"?>'/>
+                                    <img alt='yes' src='<?=URL::IMG["ICON"] . "ok.png"?>'/>
 <?php
                                 }
 ?>
@@ -227,7 +234,7 @@
 <?php
                                 if ($member->has_defense){
 ?>
-                                    <img alt='yes' src='<?=$path["img"]["icon"] . "ok.png"?>'/>
+                                    <img alt='yes' src='<?=URL::IMG["ICON"] . "ok.png"?>'/>
 <?php
                                 }
 ?>

+ 15 - 2
application/view/help.php

@@ -1,3 +1,16 @@
+<?php
+    /**
+     * Help view.
+     *
+     * Contains the view layout and some code to present the data.
+     *
+     * @category View
+     * @property_read Page $page The page model.
+     */
+
+    namespace swdb;
+    // TODO: Implement
+?>
 <!DOCTYPE html>
 <html lang='en'>
     <head>
@@ -6,8 +19,8 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>help.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>help.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>

+ 34 - 25
application/view/home.php

@@ -1,5 +1,14 @@
 <?php
-    global $EFFECT_AREA;
+    /**
+     * Home view.
+     *
+     * Contains the view layout and some code to present the data.
+     *
+     * @category View
+     * @property_read Home_Page $page The page model.
+     */
+
+    namespace swdb;
 ?>
 <!DOCTYPE html>
 <html lang='en'>
@@ -9,8 +18,8 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>home.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>home.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -60,7 +69,7 @@
                             Rep. Monster
                         </h4>
                         <div class='monster_panel'>
-                            <?=html_unit_panel($page->rep)?>
+                            <?=HTML::unit_panel($page->rep)?>
                         </div> <!-- .monster_panel -->
                     </div>
 <?php
@@ -75,7 +84,7 @@
                     foreach ($page->defense as $defense){
 ?>
                         <div class='monster_panel'>
-                            <?=html_unit_panel($defense)?>
+                            <?=HTML::unit_panel($defense)?>
                         </div>
 <?php
                         if ($first && isset($defense->unit->leader_skill) && ($defense->unit->leader_skill->area == $EFFECT_AREA["GENERAL"] || $defense->unit->leader_skill->area == $EFFECT_AREA["ARENA"])){
@@ -103,7 +112,7 @@
 <?php
                         }
 ?>
-                        <?=html_building_panel($building)?>
+                        <?=HTML::building_panel($building)?>
 <?php
                         $i ++;
                     }$i ++;
@@ -123,7 +132,7 @@
 <?php
                         }
 ?>
-                        <?=html_building_panel($decoration)?>
+                        <?=HTML::building_panel($decoration)?>
 <?php
                         $i ++;
                     }
@@ -143,7 +152,7 @@
 <?php
                         }
 ?>
-                        <?=html_item_panel($item)?>
+                        <?=HTML::item_panel($item)?>
 <?php
                         $i ++;
                     }
@@ -162,7 +171,7 @@
 <?php
                         }
 ?>
-                        <?=html_item_panel($item)?>
+                        <?=HTML::item_panel($item)?>
 <?php
                         $prev = $item->id;
                     }
@@ -181,7 +190,7 @@
 <?php
                         }
 ?>
-                        <?=html_item_panel($item)?>
+                        <?=HTML::item_panel($item)?>
 <?php
                         $prev = $item->id;
                     }
@@ -200,7 +209,7 @@
 <?php
                         }
 ?>
-                        <?=html_item_panel($item)?>
+                        <?=HTML::item_panel($item)?>
 <?php
                         $prev = preg_split('/\s+/', $item->name)[2];
                     }
@@ -212,59 +221,59 @@
                     </h4>
                     <ul>
                         <li>
-                            <img title='Energy' src='<?=$path["img"]["currency"]?>energy.png'/>
+                            <img title='Energy' src='<?=URL::IMG["CURRENCY"]?>energy.png'/>
                             <?=$page->currency["energy"]?> / <?=$page->currency["energy_max"]?>
                         </li>
                         <li>
-                            <img title='Arena Invitations' src='<?=$path["img"]["currency"]?>arenaenergy.png'/>
+                            <img title='Arena Invitations' src='<?=URL::IMG["CURRENCY"]?>arenaenergy.png'/>
                             <?=$page->currency["arena_energy"]?> / <?=$page->currency["arena_energy_max"]?>
                         </li>
                         <li>
-                            <img title='Dimensional Energy' src='<?=$path["img"]["currency"]?>dimensionenergy.png'/>
+                            <img title='Dimensional Energy' src='<?=URL::IMG["CURRENCY"]?>dimensionenergy.png'/>
                             <?=$page->currency["dimension_energy"]?> / <?=$page->currency["dimension_energy_max"]?>
                         </li>
                         <li>
-                            <img title='Dimensional Crystal' src='<?=$path["img"]["currency"]?>darkportalenergy.png'/>
+                            <img title='Dimensional Crystal' src='<?=URL::IMG["CURRENCY"]?>darkportalenergy.png'/>
                             <?=$page->currency["darkportal_energy"]?> / <?=$page->currency["darkportal_energy_max"]?>
                         </li>
                         <li>
-                            <img title='Mana' src='<?=$path["img"]["currency"]?>mana.png'/>
+                            <img title='Mana' src='<?=URL::IMG["CURRENCY"]?>mana.png'/>
                             <?=$page->currency["mana"]?>
                         </li>
                         <li>
-                            <img title='Crystal' src='<?=$path["img"]["currency"]?>crystal.png'/>
+                            <img title='Crystal' src='<?=URL::IMG["CURRENCY"]?>crystal.png'/>
                             <?=$page->currency["crystal"]?>
                         </li>
                         <li>
-                            <img title='Social Points' src='<?=$path["img"]["currency"]?>socialpoint.png'/>
+                            <img title='Social Points' src='<?=URL::IMG["CURRENCY"]?>socialpoint.png'/>
                             <?=$page->currency["social_point"]?>
                         </li>
                         <li>
-                            <img title='Honor Points' src='<?=$path["img"]["currency"]?>honor.png'/>
+                            <img title='Honor Points' src='<?=URL::IMG["CURRENCY"]?>honor.png'/>
                             <?=$page->currency["honor_point"]?>
                         </li>
                         <li>
-                            <img title='Guild Points' src='<?=$path["img"]["currency"]?>guildpoint.png'/>
+                            <img title='Guild Points' src='<?=URL::IMG["CURRENCY"]?>guildpoint.png'/>
                             <?=$page->currency["guild_point"]?>
                         </li>
                         <li>
-                            <img title='Honor Medals' src='<?=$path["img"]["currency"]?>badge.png'/>
+                            <img title='Honor Medals' src='<?=URL::IMG["CURRENCY"]?>badge.png'/>
                             <?=$page->currency["honor_medal"]?>
                         </li>
                         <li>
-                            <img src='<?=$path["img"]["currency"]?>mark.png'/>
+                            <img src='<?=URL::IMG["CURRENCY"]?>mark.png'/>
                             <?=$page->currency["honor_mark"]?>
                         </li>
                         <li>
-                            <img title='Ancient Coins' src='<?=$path["img"]["currency"]?>ancientcoin.png'/>
+                            <img title='Ancient Coins' src='<?=URL::IMG["CURRENCY"]?>ancientcoin.png'/>
                             <?=$page->currency["event_coin"]?>
                         </li>
                         <li>
-                            <img title='Ancient Crystal' src='<?=$path["img"]["currency"]?>ancientstone.png'/>
+                            <img title='Ancient Crystal' src='<?=URL::IMG["CURRENCY"]?>ancientstone.png'/>
                             <?=$page->currency["ancient_stone"]?>
                         </li>
                         <li>
-                            <img title='Shapeshifting Stones' src='<?=$path["img"]["currency"]?>costumestone.png'/>
+                            <img title='Shapeshifting Stones' src='<?=URL::IMG["CURRENCY"]?>costumestone.png'/>
                             <?=$page->currency["costume_point"]?>
                         </li>
                     </ul>

+ 20 - 10
application/view/inc/filter_catalog.php

@@ -1,5 +1,15 @@
 <?php
-    global $ELEMENT;
+    /**
+     * Catalog filter view.
+     *
+     * To be included from the catalog view.
+     *
+     * @category View
+     * @property_read mixed[] $filters Selected filters.
+     * @property_read int $page Player ID.
+     */
+
+    namespace swdb;
 ?>
 <form action='/<?=$UID?>/catalog/' method='get' id='filter_catalog' class='filter'>
     <table>
@@ -8,28 +18,28 @@
                 <span>Element:</span>
 <?php
                 $selected = Array("", "", "", "", "");
-                $selected[$filters["element"] - 1] = "selected";
+                $selected[$filters["ELEMENT"] - 1] = "selected";
 ?>
                 <select name='element'>
                     <option value='0'>All</option>
-                    <option value='<?=$ELEMENT["WATER"]?>' <?=$selected[0]?>>Water</option>
-                    <option value='<?=$ELEMENT["FIRE"]?>' <?=$selected[1]?>>Fire</option>
-                    <option value='<?=$ELEMENT["WIND"]?>' <?=$selected[2]?>>Wind</option>
-                    <option value='<?=$ELEMENT["LIGHT"]?>' <?=$selected[3]?>>Light</option>
-                    <option value='<?=$ELEMENT["DARK"]?>' <?=$selected[4]?>>Dark</option>
+                    <option value='<?=ELEMENT_ID::WATER?>' <?=$selected[0]?>>Water</option>
+                    <option value='<?=ELEMENT_ID::FIRE?>' <?=$selected[1]?>>Fire</option>
+                    <option value='<?=ELEMENT_ID::WIND?>' <?=$selected[2]?>>Wind</option>
+                    <option value='<?=ELEMENT_ID::LIGHT?>' <?=$selected[3]?>>Light</option>
+                    <option value='<?=ELEMENT_ID::DARK?>' <?=$selected[4]?>>Dark</option>
                 </select>
             </td>
             <td class='filter' id='filter_stars'>
                 <span>Stars:</span>
-                <input type='number' name='min_stars' id='filter_stars_min' min='1' max='5' value='<?=$filters["min_stars"]?>'/>
+                <input type='number' name='min_stars' id='filter_stars_min' min='1' max='5' value='<?=$filters["MIN_STARS"]?>'/>
                 -
-                <input type='number' name='max_stars' id='filter_stars_max' min='1' max='5' value='<?=$filters["max_stars"]?>'/>
+                <input type='number' name='max_stars' id='filter_stars_max' min='1' max='5' value='<?=$filters["MAX_STARS"]?>'/>
             </td>
         </tr>
         <tr>
             <td class='filter' colspan='2'>
                 <span>Name:</span>
-                <input type='text' name='name' id='filter_name' value='<?=$filters["name"]?>'/>
+                <input type='text' name='name' id='filter_name' value='<?=$filters["NAME"]?>'/>
             </td>
         </tr>
     </table>

+ 16 - 2
application/view/inc/filter_fusion.php

@@ -1,4 +1,18 @@
-<form action='/fusion/' method='get' id='filter_fusion' class='filter'>
+<?php
+    /**
+     * Fusion filter view.
+     *
+     * To be included from the fusion view.
+     *
+     * @category View
+     * @property_read mixed[] $filters Selected filters.
+     * @property_read Fusion_Page $page The page model.
+     * @property_read int $page Player ID.
+     */
+
+    namespace swdb;
+?>
+<form action='/<?=$UID?>/fusion/' method='get' id='filter_fusion' class='filter'>
     <table>
         <tr>
             <td class='filter'>
@@ -7,7 +21,7 @@
                     <option value=''>All</option>
 <?php
                     foreach ($page->products as $product){
-                        if ($product->id == $page->filters["product"]){
+                        if ($product->id == $page->filters["PRODUCT"]){
                             $selected = "selected";
                         }
                         else{

+ 22 - 12
application/view/inc/filter_monsters.php

@@ -1,5 +1,15 @@
 <?php
-    global $ELEMENT;
+    /**
+     * Monsters filter view.
+     *
+     * To be included from the monsters view.
+     *
+     * @category View
+     * @property_read mixed[] $filters Selected filters.
+     * @property_read int $page Player ID.
+     */
+
+    namespace swdb;
 ?>
 <form action='/<?=$UID?>/monsters/' method='get'  id='filter_monsters' class='filter'>
     <table>
@@ -8,35 +18,35 @@
                 <span>Element:</span>
 <?php
                 $selected = Array("", "", "", "", "");
-                $selected[$filters["element"]] = "selected";
+                $selected[$filters["ELEMENT"]] = "selected";
 ?>
                 <select name='element'>
                     <option> </option>
-                    <option value='<?=$ELEMENT["FIRE"]?>' <?=$selected[0]?>>Fire</option>
-                    <option value='<?=$ELEMENT["WATER"]?>' <?=$selected[1]?>>Water</option>
-                    <option value='<?=$ELEMENT["WIND"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$ELEMENT["LIGHT"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$ELEMENT["DARK"]?>' <?=$selected[4]?>>Legend</option>
+                    <option value='<?=ELEMENT_ID::FIRE?>' <?=$selected[0]?>>Fire</option>
+                    <option value='<?=ELEMENT_ID::WATER?>' <?=$selected[1]?>>Water</option>
+                    <option value='<?=ELEMENT_ID::WIND?>' <?=$selected[2]?>>Rare</option>
+                    <option value='<?=ELEMENT_ID::LIGHT?>' <?=$selected[3]?>>Hero</option>
+                    <option value='<?=ELEMENT_ID::DARK?>' <?=$selected[4]?>>Legend</option>
                 </select>
             </td>
             <td class='filter' id='filter_stars'>
                 <span>Stars:</span>
-                <input type='number' name='min_stars' id='filter_stars_min' min='1' max='6' value='<?=filters["min_stars"]?>'/>
+                <input type='number' name='min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["MIN_STARS"]?>'/>
                 -
-                <input type='number' name='max_stars' id='filter_stars_max' min='1' max='6' value='<?=filters["max_stars"]?>'/>
+                <input type='number' name='max_stars' id='filter_stars_max' min='1' max='6' value='<?=$filters["MAX_STARS"]?>'/>
             </td>
         </tr>
         <tr>
             <td class='filter' colspan='2'>
                 <span>Name:</span>
-                <input type='text' name='name' id='filter_name' value='<?=$page->filters["name"]?>'/>
+                <input type='text' name='name' id='filter_name' value='<?=$filters["NAME"]?>'/>
             </td>
         </tr>
         <tr>
             <td class='filter' colspan='2'>
 <?php
                 $checked = "";
-                if ($page->filters["in_storage"]){
+                if ($filters["IN_STORAGE"]){
                     $checked = "checked";
                 }
 ?>
@@ -48,7 +58,7 @@
             <td class='filter' colspan='2'>
 <?php
                 $checked = "";
-                if ($page->filters["without_runes"]){
+                if ($filters["WITHOUT_RUNES"]){
                     $checked = "checked";
                 }
 ?>

+ 68 - 59
application/view/inc/filter_report_runecraft.php

@@ -1,6 +1,15 @@
 <?php
-    global $RUNE_STAT;
-    global $QUALITY;
+    /**
+     * Rune craft report filter view.
+     *
+     * To be included from the rune craft report view.
+     *
+     * @category View
+     * @property_read mixed[] $filters Selected filters.
+     * @property_read int $page Player ID.
+     */
+
+    namespace swdb;
 ?>
 <form action='/<?=$UID?>/report/runecraft/' method='get' id='filter_runecraft' class='filter'>
     <table>
@@ -12,19 +21,19 @@
             </td>
             <td class='filter' colspan='3'>
                 <span>Name:</span>
-                <input type='text' name='monster_name' id='filter_name' value='<?=$filters["monster_name"]?>'/>
+                <input type='text' name='monster_name' id='filter_name' value='<?=$filters["MONSTER_NAME"]?>'/>
             </td>
             <td class='filter'>
                 <span>Stars:</span>
-                <input type='number' name='monster_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["monster_min_stars"]?>'/>
+                <input type='number' name='monster_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["MONSTER_MIN_STARS"]?>'/>
                 -
-                <input type='number' name='monster_max_stars' id='filter_stars_max' min='1' max='6' value='<?=$filters["monster_max_stars"]?>'/>
+                <input type='number' name='monster_max_stars' id='filter_stars_max' min='1' max='6' value='<?=$filters["MONSTER_MAX_STARS"]?>'/>
             </td>
         </tr>
             <td class='filter' colspan='4'>
 <?php
                 $checked = "";
-                if ($filters["monster_in_storage"]){
+                if ($filters["MONSTER_IN_STORAGE"]){
                     $checked = "checked";
                 }
 ?>
@@ -40,15 +49,15 @@
             </td>
             <td class='filter filter_stars filter_separator' colspan='2'>
                 <span>Stars:</span>
-                <input type='number' name='rune_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["rune_min_stars"]?>'/>
+                <input type='number' name='rune_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["RUNE_MIN_STARS"]?>'/>
                 -
-                <input type='number' name='rune_max_stars' id='filter_stars_max' min='1' max='6' value='<?=$filters["rune_max_stars"]?>'/>
+                <input type='number' name='rune_max_stars' id='filter_stars_max' min='1' max='6' value='<?=$filters["RUNE_MAX_STARS"]?>'/>
             </td>
             <td class='filter filter_separator' colspan='2'>
                 <span>Level:</span>
-                <input type='number' name='rune_min_level' id='filter_level_min' min='0' max='15' value='<?=$filters["rune_min_level"]?>'/>
+                <input type='number' name='rune_min_level' id='filter_level_min' min='0' max='15' value='<?=$filters["RUNE_MIN_LEVEL"]?>'/>
                 -
-                <input type='number' name='rune_max_level' id='filter_level_max' min='0' max='15' value='<?=$filters["rune_max_level"]?>'/>
+                <input type='number' name='rune_max_level' id='filter_level_max' min='0' max='15' value='<?=$filters["RUNE_MAX_LEVEL"]?>'/>
             </td>
         </tr>
         <tr>
@@ -57,7 +66,7 @@
                 <select multiple name='rune_slot[]' id='filter_slot'>
 <?php
                     for ($i = 1; $i <= 6; $i ++){
-                        if (in_array($i, $filters["rune_slot"])){
+                        if (in_array($i, $filters["RUNE_SLOT"])){
                             $selected = "selected='selected'";
                         }
                         else{
@@ -75,26 +84,26 @@
 <?php
 
                 $selected = Array("", "", "", "", "");
-                $selected[$filters["rune_min_quality"] - 1] = "selected";
+                $selected[$filters["RUNE_MIN_QUALITY"] - 1] = "selected";
 ?>
                 <select name='rune_min_quality' id='filter_quality_min'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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[$filters["rune_max_quality"] - 1] = "selected";
+                $selected[$filters["RUNE_MAX_QUALITY"] - 1] = "selected";
 ?>
                 <select name='rune_max_quality' id='filter_quality_max'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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>
@@ -103,43 +112,43 @@
                 <span>Original quality:</span>
 <?php
                 $selected = Array("", "", "", "", "");
-                $selected[$filters["rune_min_original_quality"] - 1] = "selected";
+                $selected[$filters["RUNE_MIN_ORIGINAL_QUALITY"] - 1] = "selected";
 ?>
                 <select name='rune_min_original_quality' id='filter_original_quality_min'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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[$filters["rune_max_original_quality"] - 1] = "selected";
+                $selected[$filters["RUNE_MAX_ORIGINAL_QUALITY"] - 1] = "selected";
 ?>
                 <select name='rune_max_original_quality' id='filter_original_quality_max'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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='filter' colspan='3'>
                 <span>Efficiency:</span>
-                <input type='number' name='rune_min_efficiency' id='filter_efficiency_min' min='0' max='100' value='<?=$filters["rune_min_efficiency"]?>'/>%
+                <input type='number' name='rune_min_efficiency' id='filter_efficiency_min' min='0' max='100' value='<?=$filters["RUNE_MIN_EFFICIENCY"]?>'/>%
                 -
-                <input type='number' name='rune_max_efficiency' id='filter_efficiency_max' min='0' max='100' value='<?=$filters["rune_max_efficiency"]?>'/>%
+                <input type='number' name='rune_max_efficiency' id='filter_efficiency_max' min='0' max='100' value='<?=$filters["RUNE_MAX_EFFICIENCY"]?>'/>%
             </td>
         </tr>
         <tr>
             <td class='filter' colspan='3'>
                 <span>Maximum efficiency:</span>
-                <input type='number' name='rune_min_max_efficiency' id='filter_max_efficiency_min' min='0' max='100' value='<?=$filters["rune_min_max_efficiency"]?>'/>%
+                <input type='number' name='rune_min_max_efficiency' id='filter_max_efficiency_min' min='0' max='100' value='<?=$filters["RUNE_MIN_MAX_EFFICIENCY"]?>'/>%
                 -
-                <input type='number' name='rune_max_max_efficiency' id='filter_max_efficiency_max' min='0' max='100' value='<?=$filters["rune_max_max_efficiency"]?>'/>%
+                <input type='number' name='rune_max_max_efficiency' id='filter_max_efficiency_max' min='0' max='100' value='<?=$filters["RUNE_MAX_MAX_EFFICIENCY"]?>'/>%
             </td>
         </tr>
         <tr>
@@ -151,7 +160,7 @@
             <td class='filter filter_stars filter_separator'>
 <?php
                 $checked = "";
-                if ($filters["grind"]){
+                if ($filters["GRIND"]){
                     $checked = "checked";
                 }
 ?>
@@ -162,23 +171,23 @@
                 <span>Min. quality:</span>
 <?php
                 $selected = Array("", "", "", "", "");
-                $selected[$filters["grind_min_quality"] - 1] = "selected";
+                $selected[$filters["GRIND_MIN_QUALITY"] - 1] = "selected";
 ?>
                 <select name='grind_min_quality'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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>
             <td class='filter filter_separator' colspan='2'>
                 <span>Stats:</span>
                 <select multiple name='grind_stat[]' id='filter_grind_stat'>
 <?php
-                    foreach($RUNE_STAT as $k=>$n){
+                    foreach(RUNE_STAT_ID as $k=>$n){
                         $selected = "";
-                        if (in_array($n, $filters["grind_stat"])){
+                        if (in_array($n, $filters["GRIND_STAT"])){
                             $selected = "selected='selected'";
                         }
                         $name = ucwords($k);
@@ -199,7 +208,7 @@
             <td class='filter filter_stars filter_separator'>
 <?php
                 $checked = "";
-                if ($filters["gem"]){
+                if ($filters["GEM"]){
                     $checked = "checked";
                 }
 ?>
@@ -210,23 +219,23 @@
                 <span>Min. quality:</span>
 <?php
                 $selected = Array("", "", "", "", "");
-                $selected[$filters["gem_min_quality"] - 1] = "selected";
+                $selected[$filters["GEM_MIN_QUALITY"] - 1] = "selected";
 ?>
                 <select name='gem_min_quality'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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>
             <td class='filter filter_separator'>
                 <span>Replace...</span>
                 <select multiple name='gem_stat_from[]' id='filter_gem_stat_from'>
 <?php
-                    foreach($RUNE_STAT as $k=>$n){
+                    foreach(RUNE_STAT_ID as $k=>$n){
                         $selected = "";
-                        if (in_array($n, $filters["gem_stat_from"])){
+                        if (in_array($n, $filters["GEM_STAT_FROM"])){
                             $selected = "selected='selected'";
                         }
                         $name = ucwords($k);
@@ -241,9 +250,9 @@
                 <span>...with...</span>
                 <select multiple name='gem_stat_from[]' id='filter_gem_stat_to'>
 <?php
-                    foreach($RUNE_STAT as $k=>$n){
+                    foreach(RUNE_STAT_ID as $k=>$n){
                         $selected = "";
-                        if (in_array($n, $filters["gem_stat_to"])){
+                        if (in_array($n, $filters["GEM_STAT_TO"])){
                             $selected = "selected='selected'";
                         }
                         $name = ucwords($k);

+ 59 - 48
application/view/inc/filter_report_runeupgrade.php

@@ -1,10 +1,21 @@
 <?php
-    global $QUALITY;
+    /**
+     * Rune upgrade report filter view.
+     *
+     * To be included from the rune upgrade report view.
+     *
+     * @category View
+     * @property_read mixed[] $filters Selected filters.
+     * @property_read int $page Player ID.
+     */
+
+    namespace swdb;
 ?>
 <?php
     if (count($custom_filters) > 0){
 ?>
         <script>
+
             /**
              * Changes the filter description.
              *
@@ -62,19 +73,19 @@
             </td>
             <td class='filter' colspan='3'>
                 <span>Name:</span>
-                <input type='text' name='monster_name' id='filter_name' value='<?=$filters["monster_name"]?>'/>
+                <input type='text' name='monster_name' id='filter_name' value='<?=$filters["MONSTER_NAME"]?>'/>
             </td>
             <td class='filter'>
                 <span>Stars:</span>
-                <input type='number' name='monster_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["monster_min_stars"]?>'/>
+                <input type='number' name='monster_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["MONSTER_MIN_STARS"]?>'/>
                 -
-                <input type='number' name='monster_max_stars' id='filter_stars_max' min='1' max='6' value='<?=$filters["monster_max_stars"]?>'/>
+                <input type='number' name='monster_max_stars' id='filter_stars_max' min='1' max='6' value='<?=$filters["MONSTER_MAX_STARS"]?>'/>
             </td>
         </tr>
             <td class='filter' colspan='4'>
 <?php
                 $checked = "";
-                if ($filters["monster_in_storage"]){
+                if ($filters["MONSTER_IN_STORAGE"]){
                     $checked = "checked";
                 }
 ?>
@@ -90,15 +101,15 @@
             </td>
             <td class='filter filter_stars filter_separator' colspan='2'>
                 <span>Stars:</span>
-                <input type='number' name='rune_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["rune_min_stars"]?>'/>
+                <input type='number' name='rune_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["RUNE_MIN_STARS"]?>'/>
                 -
-                <input type='number' name='rune_max_stars' id='filter_stars_max' min='1' max='6' value='<?=$filters["rune_max_stars"]?>'/>
+                <input type='number' name='rune_max_stars' id='filter_stars_max' min='1' max='6' value='<?=$filters["RUNE_MAX_STARS"]?>'/>
             </td>
             <td class='filter filter_separator' colspan='2'>
                 <span>Level:</span>
-                <input type='number' name='rune_min_level' id='filter_level_min' min='0' max='15' value='<?=$filters["rune_min_level"]?>'/>
+                <input type='number' name='rune_min_level' id='filter_level_min' min='0' max='15' value='<?=$filters["RUNE_MIN_LEVEL"]?>'/>
                 -
-                <input type='number' name='rune_max_level' id='filter_level_max' min='0' max='15' value='<?=$filters["rune_max_level"]?>'/>
+                <input type='number' name='rune_max_level' id='filter_level_max' min='0' max='15' value='<?=$filters["RUNE_MAX_LEVEL"]?>'/>
             </td>
         </tr>
         <tr>
@@ -107,7 +118,7 @@
                 <select multiple name='rune_slot[]' id='filter_slot'>
 <?php
                     for ($i = 0; $i < 6; $i ++){
-                        if (in_array($i, $filters["rune_slot"])){
+                        if (in_array($i, $filters["RUNE_SLOT"])){
                             $selected = "selected='selected'";
                         }
                         else{
@@ -125,26 +136,26 @@
 <?php
 
                 $selected = Array("", "", "", "", "");
-                $selected[$filters["rune_min_quality"] - 1] = "selected";
+                $selected[$filters["RUNE_MIN_QUALITY"] - 1] = "selected";
 ?>
                 <select name='rune_min_quality' id='filter_quality_min'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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[$filters["rune_max_quality"] - 1] = "selected";
+                $selected[$filters["RUNE_MAX_QUALITY"] - 1] = "selected";
 ?>
                 <select name='rune_max_quality' id='filter_quality_max'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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>
@@ -153,43 +164,43 @@
                 <span>Original quality:</span>
 <?php
                 $selected = Array("", "", "", "", "");
-                $selected[$filters["rune_min_original_quality"] - 1] = "selected";
+                $selected[$filters["RUNE_MIN_ORIGINAL_QUALITY"] - 1] = "selected";
 ?>
                 <select name='rune_min_original_quality' id='filter_original_quality_min'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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[$filters["rune_max_original_quality"] - 1] = "selected";
+                $selected[$filters["RUNE_MAX_ORIGINAL_QUALITY"] - 1] = "selected";
 ?>
                 <select name='rune_max_original_quality' id='filter_original_quality_max'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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='filter' colspan='3'>
                 <span>Efficiency:</span>
-                <input type='number' name='rune_min_efficiency' id='filter_efficiency_min' min='0' max='100' value='<?=$filters["rune_min_efficiency"]?>'/>%
+                <input type='number' name='rune_min_efficiency' id='filter_efficiency_min' min='0' max='100' value='<?=$filters["RUNE_MIN_EFFICIENCY"]?>'/>%
                 -
-                <input type='number' name='rune_max_efficiency' id='filter_efficiency_max' min='0' max='100' value='<?=$filters["rune_max_efficiency"]?>'/>%
+                <input type='number' name='rune_max_efficiency' id='filter_efficiency_max' min='0' max='100' value='<?=$filters["RUNE_MAX_EFFICIENCY"]?>'/>%
             </td>
         </tr>
         <tr>
             <td class='filter' colspan='3'>
                 <span>Maximum efficiency:</span>
-                <input type='number' name='rune_min_max_efficiency' id='filter_max_efficiency_min' min='0' max='100' value='<?=$filters["rune_min_max_efficiency"]?>'/>%
+                <input type='number' name='rune_min_max_efficiency' id='filter_max_efficiency_min' min='0' max='100' value='<?=$filters["RUNE_MIN_MAX_EFFICIENCY"]?>'/>%
                 -
-                <input type='number' name='rune_max_max_efficiency' id='filter_max_efficiency_max' min='0' max='100' value='<?=$filters["rune_max_max_efficiency"]?>'/>%
+                <input type='number' name='rune_max_max_efficiency' id='filter_max_efficiency_max' min='0' max='100' value='<?=$filters["RUNE_MAX_MAX_EFFICIENCY"]?>'/>%
             </td>
         </tr>
         <tr>
@@ -200,25 +211,25 @@
             </td>
             <td class='filter filter_stars filter_separator'>
                 <span>Min. stars:</span>
-                <input type='number' name='alternative_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["alternative_min_stars"]?>'/>
+                <input type='number' name='alternative_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["ALTERNATIVE_MIN_STARS"]?>'/>
             </td>
             <td class='filter filter_separator' colspan='2'>
                 <span>Min. O. quality:</span>
 <?php
                 $selected = Array("", "", "", "", "");
-                $selected[$filters["alternative_min_original_quality"]] = "selected";
+                $selected[$filters["ALTERNATIVE_MIN_ORIGINAL_QUALITY"]] = "selected";
 ?>
                 <select name='alternative_min_original_quality' id='filter_original_quality_min'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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>
             <td class='filter filter_separator'>
                 <span>Min. Level:</span>
-                <input type='number' name='alternative_min_level' id='filter_level_min' min='0' max='15' value='<?=$filters["alternative_min_level"]?>'/>
+                <input type='number' name='alternative_min_level' id='filter_level_min' min='0' max='15' value='<?=$filters["ALTERNATIVE_MIN_LEVEL"]?>'/>
             </td>
         </tr>
         <tr>
@@ -226,7 +237,7 @@
                 <span>Condition:</span>
 <?php
                 $selected = Array("", "", "", "", "", "");
-                $selected[$filters["alternative_condition"]] = "selected";
+                $selected[$filters["ALTERNATIVE_CONDITION"]] = "selected";
 
 ?>
                 <select name='alternative_condition'>
@@ -244,7 +255,7 @@
                 <span>Source:</span>
 <?php
                 $selected = Array("", "", "", "");
-                $selected[$filters["alternative_source"]] = "selected";
+                $selected[$filters["ALTERNATIVE_SOURCE"]] = "selected";
 ?>
                 <select name='alternative_source'>
                     <option value='0' <?=$selected[0]?>>Inventory only</option>

+ 23 - 10
application/view/inc/filter_report_skillup.php

@@ -1,24 +1,37 @@
+<?php
+    /**
+     * Skillup report filter view.
+     *
+     * To be included from the skillup report view.
+     *
+     * @category View
+     * @property_read mixed[] $filters Selected filters.
+     * @property_read int $page Player ID.
+     */
+
+    namespace swdb;
+?>
 <form action='/<?=$UID?>/report/skillup/' method='get' id='filter_skillup' class='filter'>
     <table>
         <tr>
             <td class='filter' id='filter_stars'>
                 <span>Stars:</span>
-                <input type='number' name='min_stars' min='1' max='6' value='<?=$filters["min_stars"]?>'/>
+                <input type='number' name='min_stars' min='1' max='6' value='<?=$filters["MIN_STARS"]?>'/>
                 -
-                <input type='number' name='max_stars'  min='1' max='6' value='<?=$filters["max_stars"]?>'/>
+                <input type='number' name='max_stars'  min='1' max='6' value='<?=$filters["MAX_STARS"]?>'/>
             </td>
             <td class='filter' id='filter_stars'>
                 <span>Natural stars:</span>
-                <input type='number' name='min_natural_stars' min='1' max='5' value='<?=$filters["min_natural_stars"]?>'/>
+                <input type='number' name='min_natural_stars' min='1' max='5' value='<?=$filters["MIN_NATURAL_STARS"]?>'/>
                 -
-                <input type='number' name='max_natural_stars' min='1' max='5' value='<?=$filters["max_natural_stars"]?>'/>
+                <input type='number' name='max_natural_stars' min='1' max='5' value='<?=$filters["MAX_NATURAL_STARS"]?>'/>
             </td>
         </tr>
         <tr>
             <td class='filter' colspan='2'>
 <?php
                 $checked = "";
-                if ($filters["family"]){
+                if ($filters["FAMILY"]){
                     $checked = "checked";
                 }
 ?>
@@ -30,7 +43,7 @@
             <td class='filter' colspan='2'>
 <?php
                 $checked = "";
-                if ($filters["2a"]){
+                if ($filters["2A"]){
                     $checked = "checked";
                 }
 ?>
@@ -42,7 +55,7 @@
             <td class='filter' colspan='2'>
 <?php
                 $checked = "";
-                if ($filters["homunculus"]){
+                if ($filters["HOMUNCULUS"]){
                     $checked = "checked";
                 }
 ?>
@@ -54,7 +67,7 @@
             <td class='filter' colspan='2'>
 <?php
                 $checked = "";
-                if ($filters["in_storage"]){
+                if ($filters["IN_STORAGE"]){
                     $checked = "checked";
                 }
 ?>
@@ -66,7 +79,7 @@
             <td class='filter' colspan='2'>
 <?php
                 $checked = "";
-                if ($filters["without_runes"]){
+                if ($filters["WITHOUT_RUNES"]){
                     $checked = "checked";
                 }
 ?>
@@ -78,7 +91,7 @@
             <td class='filter' colspan='2'>
 <?php
                 $checked = "";
-                if ($filters["maxed"]){
+                if ($filters["MAXED"]){
                     $checked = "checked";
                 }
 ?>

+ 53 - 46
application/view/inc/filter_runes.php

@@ -1,9 +1,16 @@
 <?php
-    global $RUNE_SET;
-    global $RUNE_STAT;
-    global $QUALITY;
-?>
-<?php
+    /**
+     * Rune filter view.
+     *
+     * To be included from the rune view.
+     *
+     * @category View
+     * @property_read mixed[] $filters Selected filters.
+     * @property_read int $page Player ID.
+     */
+
+    namespace swdb;
+
     if (count($custom_filters) > 0){
 ?>
         <script>
@@ -62,9 +69,9 @@
                 <span>Type:</span>
                 <select multiple name='type[]' id='filter_type'>
 <?php
-                    foreach($RUNE_SET as $k=>$n){
+                    foreach(RUNE_SET_ID as $k=>$n){
                         $selected = "";
-                        if (in_array($n, $filters["type"])){
+                        if (in_array($n, $filters["TYPE"])){
                             $selected = "selected='selected'";
                         }
                         $name = ucwords(strtolower($k));
@@ -80,7 +87,7 @@
                 <select multiple name='slot[]' id='filter_slot'>
 <?php
                     for ($i = 1; $i <= 6; $i ++){
-                        if (in_array($i, $filters["slot"])){
+                        if (in_array($i, $filters["SLOT"])){
                             $selected = "selected='selected'";
                         }
                         else{
@@ -95,17 +102,17 @@
             </td>
             <td class='filter filter_stars' >
                 <span>Stars:</span>
-                <input type='number' name='min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["min_stars"]?>'/>
+                <input type='number' name='min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["MIN_STARS"]?>'/>
                 -
-                <input type='number' name='max_stars' id='filter_stars_max' min='1' max='6' value='<?=$filters["max_stars"]?>'/>
+                <input type='number' name='max_stars' id='filter_stars_max' min='1' max='6' value='<?=$filters["MAX_STARS"]?>'/>
             </td>
         </tr>
         <tr>
             <td class='filter'>
                 <span>Level:</span>
-                <input type='number' name='min_level' id='filter_level_min' min='0' max='15' value='<?=$filters["min_level"]?>'/>
+                <input type='number' name='min_level' id='filter_level_min' min='0' max='15' value='<?=$filters["MIN_LEVEL"]?>'/>
                 -
-                <input type='number' name='max_level' id='filter_level_max' min='0' max='15' value='<?=$filters["max_level"]?>'/>
+                <input type='number' name='max_level' id='filter_level_max' min='0' max='15' value='<?=$filters["MAX_LEVEL"]?>'/>
             </td>
         </tr>
         <tr>
@@ -113,9 +120,9 @@
                 <span>Main stat:</span>
                 <select multiple name='main_stat[]' id='filter_main_stat'>
 <?php
-                    foreach($RUNE_STAT as $k=>$n){
+                    foreach(RUNE_STAT_ID as $k=>$n){
                         $selected = "";
-                        if (in_array($n, $filters["main"])){
+                        if (in_array($n, $filters["MAIN"])){
                             $selected = "selected='selected'";
                         }
                         $name = ucwords($k);
@@ -130,9 +137,9 @@
                 <span>Has sub stat:</span>
                 <select multiple name='sub_stat[]' id='filter_sub_stat'>
 <?php
-                    foreach($RUNE_STAT as $k=>$n){
+                    foreach(RUNE_STAT_ID as $k=>$n){
                         $selected = "";
-                        if (in_array($n, $filters["sub"])){
+                        if (in_array($n, $filters["SUB"])){
                             $selected = "selected='selected'";
                         }
                         $name = ucwords($k);
@@ -151,7 +158,7 @@
                 </span>
 <?php
                 $selected = Array("", "", "", "", "");
-                $selected[$filters["assigned"]] = "selected";
+                $selected[$filters["ASSIGNED"]] = "selected";
 ?>
                 <select name='assigned' id='filter_assigned'>
                     <option value='0' <?=$selected[0]?>>All</option>
@@ -165,26 +172,26 @@
                 <span>Quality:</span>
 <?php
                 $selected = Array("", "", "", "", "");
-                $selected[$filters["min_quality"] - 1] = "selected";
+                $selected[$filters["MIN_QUALITY"] - 1] = "selected";
 ?>
                 <select name='min_quality' id='filter_quality_min'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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[$filters["max_quality"] - 1] = "selected";
+                $selected[$filters["MAX_QUALITY"] - 1] = "selected";
 ?>
                 <select name='max_quality' id='filter_quality_max'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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>
@@ -195,26 +202,26 @@
                 <span>Original quality:</span>
 <?php
                 $selected = Array("", "", "", "", "");
-                $selected[$filters["min_original_quality"] - 1] = "selected";
+                $selected[$filters["MIN_ORIGINAL_QUALITY"] - 1] = "selected";
 ?>
                 <select name='min_original_quality' id='filter_original_quality_min'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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[$filters["max_original_quality"] - 1] = "selected";
+                $selected[$filters["MAX_ORIGINAL_QUALITY"] - 1] = "selected";
 ?>
                 <select name='max_original_quality' id='filter_original_quality_max'>
-                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
-                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
-                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
-                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
-                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
+                    <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>
@@ -223,9 +230,9 @@
             </td>
             <td class='filter' colspan='2'>
                 <span>Efficiency:</span>
-                <input type='number' name='min_efficiency' id='filter_efficiency_min' min='0' max='100' value='<?=$filters["min_efficiency"]?>'/>%
+                <input type='number' name='min_efficiency' id='filter_efficiency_min' min='0' max='100' value='<?=$filters["MIN_EFFICIENCY"]?>'/>%
                 -
-                <input type='number' name='max_efficiency' id='filter_efficiency_max' min='0' max='100' value='<?=$filters["max_efficiency"]?>'/>%
+                <input type='number' name='max_efficiency' id='filter_efficiency_max' min='0' max='100' value='<?=$filters["MAX_EFFICIENCY"]?>'/>%
             </td>
         </tr>
         <tr>
@@ -233,7 +240,7 @@
                 <span>Group by:</span>
 <?php
                 $selected = Array("", "");
-                $selected[$filters["group"]] = "selected";
+                $selected[$filters["GROUP"]] = "selected";
 ?>
                 <select name='group' id='filter_group'>
                     <option value='0' <?=$selected[0]?>>Slot</option>
@@ -242,9 +249,9 @@
             </td>
             <td class='filter' colspan='2'>
                 <span>Maximum efficiency:</span>
-                <input type='number' name='min_max_efficiency' id='filter_max_efficiency_min' min='0' max='100' value='<?=$filters["min_max_efficiency"]?>'/>%
+                <input type='number' name='min_max_efficiency' id='filter_max_efficiency_min' min='0' max='100' value='<?=$filters["MIN_MAX_EFFICIENCY"]?>'/>%
                 -
-                <input type='number' name='max_max_efficiency' id='filter_max_efficiency_max' min='0' max='100' value='<?=$filters["max_max_efficiency"]?>'/>%
+                <input type='number' name='max_max_efficiency' id='filter_max_efficiency_max' min='0' max='100' value='<?=$filters["MAX_MAX_EFFICIENCY"]?>'/>%
             </td>
         </tr>
     </table>

+ 31 - 21
application/view/inc/filter_runs.php

@@ -1,5 +1,15 @@
 <?php
-    global $AREA_TYPE;
+    /**
+     * Run filter view.
+     *
+     * To be included from the run view.
+     *
+     * @category View
+     * @property_read mixed[] $filters Selected filters.
+     * @property_read int $page Player ID.
+     */
+
+    namespace swdb;
 ?>
 <form action='/<?=$UID?>/runs/' method='get' id='filter_runeupgrade' class='filter'>
     <table>
@@ -11,30 +21,30 @@
             </td>
             <td class='filter'>
 <?php
-                $selected = array_fill(0, sizeof($AREA_TYPE) + 1, "");
-                $selected[$filters["area_type"]] = "selected";
+                $selected = array_fill(0, 12 + 1, "");
+                $selected[$filters["AREA_TYPE"]] = "selected";
 ?>
                 <span>Region:</span>
                 <select name='area_type' id='filter_area'>
                     <option value='0'>All</option>
-                    <option value='<?=$AREA_TYPE["SCENARIO"]?>' <?=$selected[$AREA_TYPE["SCENARIO"]]?>>Scenario</option>
-                    <option value='<?=$AREA_TYPE["CAIROS_DUNGEON"]?>' <?=$selected[$AREA_TYPE["CAIROS_DUNGEON"]]?>>Cairos Dungeon</option>
-                    <option value='<?=$AREA_TYPE["RIFT_DUNGEON"]?>' <?=$selected[$AREA_TYPE["RIFT_DUNGEON"]]?>>Rift Beast</option>
-                    <option value='<?=$AREA_TYPE["RIFT_RAID"]?>' <?=$selected[$AREA_TYPE["RIFT_RAID"]]?>>Rift Raid</option>
-                    <option value='<?=$AREA_TYPE["DIMENSIONAL_HOLE"]?>' <?=$selected[$AREA_TYPE["DIMENSIONAL_HOLE"]]?>>Dimensional Hole</option>
-                    <option value='<?=$AREA_TYPE["ARENA"]?>' <?=$selected[$AREA_TYPE["ARENA"]]?>>Arena</option>
-                    <option value='<?=$AREA_TYPE["GUILD_WAR"]?>' <?=$selected[$AREA_TYPE["GUILD_WAR"]]?>>Guild War</option>
-                    <option value='<?=$AREA_TYPE["GUILD_SIEGE"]?>' <?=$selected[$AREA_TYPE["GUILD_SIEGE"]]?>>Guild Siege</option>
-                    <option value='<?=$AREA_TYPE["TARTARUS_LABYRINTH"]?>' <?=$selected[$AREA_TYPE["TARTARUS_LABYRINTH"]]?>>Tartarus Labyrinth</option>
-                    <option value='<?=$AREA_TYPE["TRIAL_OF_ASCENSION"]?>' <?=$selected[$AREA_TYPE["TRIAL_OF_ASCENSION"]]?>>Trial of Ascension</option>
-                    <option value='<?=$AREA_TYPE["WORLD_BOSS"]?>' <?=$selected[$AREA_TYPE["WORLD_BOSS"]]?>>World Boss</option>
-                    <option value='<?=$AREA_TYPE["DIMENSIONAL_RIFT"]?>' <?=$selected[$AREA_TYPE["DIMENSIONAL_RIFT"]]?>>Dimensional Rift</option>
+                    <option value='<?=AREA_TYPE_ID::SCENARIO?>' <?=$selected[AREA_TYPE_ID::SCENARIO]?>>Scenario</option>
+                    <option value='<?=AREA_TYPE_ID::CAIROS_DUNGEON?>' <?=$selected[AREA_TYPE_ID::CAIROS_DUNGEON]?>>Cairos Dungeon</option>
+                    <option value='<?=AREA_TYPE_ID::RIFT_DUNGEON?>' <?=$selected[AREA_TYPE_ID::RIFT_DUNGEON]?>>Rift Beast</option>
+                    <option value='<?=AREA_TYPE_ID::RIFT_RAID?>' <?=$selected[AREA_TYPE_ID::RIFT_RAID]?>>Rift Raid</option>
+                    <option value='<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>' <?=$selected[AREA_TYPE_ID::DIMENSIONAL_HOLE]?>>Dimensional Hole</option>
+                    <option value='<?=AREA_TYPE_ID::ARENA?>' <?=$selected[AREA_TYPE_ID::ARENA]?>>Arena</option>
+                    <option value='<?=AREA_TYPE_ID::GUILD_WAR?>' <?=$selected[AREA_TYPE_ID::GUILD_WAR]?>>Guild War</option>
+                    <option value='<?=AREA_TYPE_ID::GUILD_SIEGE?>' <?=$selected[AREA_TYPE_ID::GUILD_SIEGE]?>>Guild Siege</option>
+                    <option value='<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>' <?=$selected[AREA_TYPE_ID::TARTARUS_LABYRINTH]?>>Tartarus Labyrinth</option>
+                    <option value='<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>' <?=$selected[AREA_TYPE_ID::TRIAL_OF_ASCENSION]?>>Trial of Ascension</option>
+                    <option value='<?=AREA_TYPE_ID::WORLD_BOSS?>' <?=$selected[AREA_TYPE_ID::WORLD_BOSS]?>>World Boss</option>
+                    <option value='<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>' <?=$selected[AREA_TYPE_ID::DIMENSIONAL_RIFT]?>>Dimensional Rift</option>
                 </select>
             </td>
             <td class='filter'>
 <?php
                 $selected = array_fill(0, 9002, "");
-                $selected[$filters["area"]] = "selected";
+                $selected[$filters["AREA"]] = "selected";
 ?>
                 <span>Area:</span>
                 <select name='area_scenario'>
@@ -75,16 +85,16 @@
             </td>
             <td class='filter filter_separator' colspan='2'>
                 <span>Date range:</span>
-                <input type='date' name='date_min' id='date_min' value='<?=$filters["date_min"]?>'/>
+                <input type='date' name='date_min' id='date_min' value='<?=$filters["DATE_MIN"]?>'/>
                 -
-                <input type='date' name='date_max' id='date_max' value='<?=$filters["date_max"]?>'/>
+                <input type='date' name='date_max' id='date_max' value='<?=$filters["DATE_MAX"]?>'/>
             </td>
         </tr>
         <tr>
             <td class='filter' colspan='2'>
 <?php
                 $checked = "";
-                if ($filters["defeat"]){
+                if ($filters["DEFEAT"]){
                     $checked = "checked";
                 }
 ?>
@@ -96,7 +106,7 @@
             <td class='filter' colspan='2'>
 <?php
                 $checked = "";
-                if ($filters["helper"]){
+                if ($filters["HELPER"]){
                     $checked = "checked";
                 }
 ?>
@@ -106,7 +116,7 @@
         </tr>
         <tr>
             <td class='filter' colspan='2'>
-                <input type='number' name='number' id='number' min='1' value='<?=$filters["number"]?>'/> runs per page
+                <input type='number' name='number' id='number' min='1' value='<?=$filters["NUMBER"]?>'/> runs per page
             </td>
         </tr>
     </table>

+ 25 - 14
application/view/inc/filter_teams.php

@@ -1,29 +1,40 @@
 <?php
-    global $AREA_TYPE;
+    /**
+     * Team filter view.
+     *
+     * To be included from the team view.
+     *
+     * @category View
+     * @property_read mixed[] $filters Selected filters.
+     * @property_read Fusion_Page $page The page model.
+     * @property_read int $page Player ID.
+     */
+
+    namespace swdb;
 ?>
 <form action='/<?=$UID?>/teams/' method='get'  id='filter_monsters' class='filter'>
     <table>
         <tr>
             <td class='filter' colspan='2'>
                 <span>Name:</span>
-                <input type='text' name='name' id='filter_name' value='<?=$page->filters["name"]?>'/>
+                <input type='text' name='name' id='filter_name' value='<?=$page->filters["NAME"]?>'/>
             </td>
             <td>
                 <span>Area:</span>
                 <select name='area'>
                     <option value=''> <option>
-                    <option value='<?=$AREA_TYPE["SCENARIO"]?>'>Scenario</option>
-                    <option value='<?=$AREA_TYPE["CAIROS_DUNGEON"]?>'>Cairos Dungeon</option>
-                    <option value='<?=$AREA_TYPE["RIFT_DUNGEON"]?>'>Rift Dungeon</option>
-                    <option value='<?=$AREA_TYPE["RIFT_RAID"]?>'>Rift Raid</option>
-                    <option value='<?=$AREA_TYPE["DIMENSIONAL_HOLE"]?>'>Dimensional Hole></option>
-                    <option value='<?=$AREA_TYPE["AREAN"]?>'>Arena</option>
-                    <option value='<?=$AREA_TYPE["GUILD_WAR"]?>'>Guild War</option>
-                    <option value='<?=$AREA_TYPE["GUILD_SIEGE"]?>'>Guild Siege</option>
-                    <option value='<?=$AREA_TYPE["TARTARUS_LABYRINTH"]?>'>Tartarus Labyrinth</option>
-                    <option value='<?=$AREA_TYPE["TRIAL_OF_ASCENSION"]?>'>Trial of Ascension</option>
-                    <option value='<?=$AREA_TYPE["WORLD_BOSS"]?>'>World Boss</option>
-                    <option value='<?=$AREA_TYPE["DIMENSIONAL_RIFT"]?>'>Dimensinal Rift</option>
+                    <option value='<?=AREA_TYPE_ID::SCENARIO?>'>Scenario</option>
+                    <option value='<?=AREA_TYPE_ID::CAIROS_DUNGEON?>'>Cairos Dungeon</option>
+                    <option value='<?=AREA_TYPE_ID::RIFT_DUNGEON?>'>Rift Dungeon</option>
+                    <option value='<?=AREA_TYPE_ID::RIFT_RAID?>'>Rift Raid</option>
+                    <option value='<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>'>Dimensional Hole></option>
+                    <option value='<?=AREA_TYPE_ID::AREAN?>'>Arena</option>
+                    <option value='<?=AREA_TYPE_ID::GUILD_WAR?>'>Guild War</option>
+                    <option value='<?=AREA_TYPE_ID::GUILD_SIEGE?>'>Guild Siege</option>
+                    <option value='<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>'>Tartarus Labyrinth</option>
+                    <option value='<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>'>Trial of Ascension</option>
+                    <option value='<?=AREA_TYPE_ID::WORLD_BOSS?>'>World Boss</option>
+                    <option value='<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>'>Dimensinal Rift</option>
                 </select>
             </td>
         </tr>

+ 12 - 4
application/view/inc/footer.php

@@ -1,11 +1,19 @@
+<?php
+    /**
+     * Site footer view.
+     *
+     * To be included from all views.
+     *
+     * @category View
+     */
+
+    namespace swdb;
+?>
 <footer>
     <table id='footer_table'>
         <tr>
             <td id='footer_left'>
-<?php
-                global $app_version;
-?>
-                Version <?=$app_version?>. Developed by <a href='https://inigovalentin.com'>I&ntilde;igo Valentin</a>.
+                Version <?=APP::VERSION?>. Developed by <a href='https://inigovalentin.com'>I&ntilde;igo Valentin</a>.
                 <br/>
                 <br/>
                 Source code available on <a href='https://github.com'>Github</a> under the GPLv3.

+ 12 - 1
application/view/inc/header.php

@@ -1,6 +1,17 @@
+<?php
+    /**
+     * Site header view.
+     *
+     * To be included from all views.
+     *
+     * @category View
+     */
+
+    namespace swdb;
+?>
 <header>
     <div id='logo'>
-        <img id='logo_img' src='<?=$path["img"]["logo"]?>sw.png' alt=''/>
+        <img id='logo_img' src='<?=URL::IMG["LOGO"]?>sw.png' alt=''/>
         <h1 id='logo_text'>
             <span class='large'>D</span>
             <span class='small'>ata</span>

+ 14 - 2
application/view/landing.php

@@ -1,3 +1,15 @@
+<?php
+    /**
+     * Login view.
+     *
+     * Contains the view layout and some code to present the data.
+     *
+     * @category View
+     * @property_read Landing_Page $page The page model.
+     */
+
+    namespace swdb;
+?>
 <!DOCTYPE html>
 <html lang='en'>
     <head>
@@ -6,8 +18,8 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>landing.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>landing.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>

+ 17 - 4
application/view/monster.php

@@ -1,3 +1,16 @@
+<?php
+    /**
+     * Monster view.
+     *
+     * Contains the view layout and some code to present the data.
+     *
+     * @category View
+     * @property_read Monster_Page $page The page model.
+     * @property_read int $UID Player ID.
+     */
+
+    namespace swdb;
+?>
 <!DOCTYPE html>
 <html lang='en'>
     <head>
@@ -6,8 +19,8 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>monster.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>monster.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -40,7 +53,7 @@
             <article id='profile'>
                 <div id='monster_info'>
                     <div class='monster_panel'>
-                        <?=html_unit_panel($page->unit)?>
+                        <?=HTML::unit_panel($page->unit)?>
                     </div>
 <?php
                     if ($page->unit->experience_level != 0){
@@ -451,7 +464,7 @@
                 $total_runes ++;
 ?>
                 <article>
-                    <?=html_rune_table($rune)?>
+                    <?=HTML::rune_table($rune)?>
                 </article>
 <?php
             }

+ 15 - 6
application/view/monster_info.php

@@ -1,5 +1,14 @@
 <?php
-    global $ELEMENT;
+    /**
+     * Monster Info Page view.
+     *
+     * Contains the view layout and ome code to present the data.
+     *
+     * @category View
+     * @property_read Monster_Info_Page The page model.
+     */
+
+    namespace swdb;
 ?>
 <!DOCTYPE html>
 <html lang='en'>
@@ -9,8 +18,8 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>monster_info.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>monster_info.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -43,9 +52,9 @@
                     <article class='stage'>
                         <div class='profile'>
                             <div class='monster_panel'>
-                                <?=html_unit_panel($page->monster[$i])?>
+                                <?=HTML::unit_panel($page->monster[$i])?>
                             </div>
-                            <?=html_unit_transformation_panel($page->monster[$i])?>
+                            <?=HTML::unit_transformation_panel($page->monster[$i])?>
                         </div>
                         <table class='stats'>
                             <tr>
@@ -149,7 +158,7 @@
                                     foreach ($page->monster[$i]->essences as $essence){
 ?>
                                        <div class='essence border_<?=$essence["element"]?>'>
-                                            <img alt='<?=$essence["grade"]?> <?=$essence["element"]?> essence' title='<?=$essence["amount"]?>x <?=$essence["grade"]?> <?=$essence["element"]?> essence' class='essence' src='<?=$path["img"]["essence"]?><?=$essence["element"]?>_<?=$essence["grade"]?>.png'/>
+                                            <img alt='<?=$essence["grade"]?> <?=$essence["element"]?> essence' title='<?=$essence["amount"]?>x <?=$essence["grade"]?> <?=$essence["element"]?> essence' class='essence' src='<?=URL::IMG["ESSENCE"]?><?=$essence["element"]?>_<?=$essence["grade"]?>.png'/>
                                             <span>
                                                 <?=$essence["amount"]?>
                                             </span>

+ 16 - 6
application/view/monsters.php

@@ -1,5 +1,15 @@
 <?php
-    global $ELEMENT;
+    /**
+     * Monsters view.
+     *
+     * Contains the view layout and ome code to present the data.
+     *
+     * @category View
+     * @property_read Monsters_Page $page The page model.
+     * @property_read int $UID Player ID.
+     */
+
+    namespace swdb;
 ?>
 <!DOCTYPE html>
 <html lang='en'>
@@ -9,9 +19,9 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>monsters.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>filters.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>monsters.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>filters.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -55,7 +65,7 @@
 ?>
         <section class='filters'>
             <h2 id='filters_title' onClick='toggleFilters();'>
-                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=$path["img"]["icon"]?>slid.png'/>
+                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
                 Monster filters
             </h2>
             <article id='filters_content'>
@@ -78,7 +88,7 @@
                     <div class='monster'>
                         <a href='/<?=$UID?>/monsters/<?=$mon->id?>'>
                             <div class='monster_panel'>
-                                <?=html_unit_panel($mon)?>
+                                <?=HTML::unit_panel($mon)?>
                             </div>
                         </a>
                         <div class='monster_tooltip'>

+ 15 - 2
application/view/profile.php

@@ -1,3 +1,16 @@
+<?php
+    /**
+     * User profile view.
+     *
+     * Contains the view layout and ome code to present the data.
+     *
+     * @category View
+     * @property_read Profile_Page $page The page model.
+     * @property_read int $UID Player ID.
+     */
+
+    namespace swdb;
+?>
 <!DOCTYPE html>
 <html lang='en'>
     <head>
@@ -6,8 +19,8 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>profile.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>profile.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>

+ 19 - 12
application/view/report.php

@@ -1,7 +1,14 @@
 <?php
-    global $FILTER_RUNECRAFT;
-    global $FILTER_RUNEUPGRADE;
-    global $FILTER_SKILLUP;
+    /**
+     * Main report view.
+     *
+     * Contains the view layout and ome code to present the data.
+     *
+     * @category View
+     * @property_read Report_Page $page The page model.
+     */
+
+    namespace swdb;
 ?>
 <!DOCTYPE html>
 <html lang='en'>
@@ -11,9 +18,9 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>report.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>filters.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>report.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>filters.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -42,13 +49,13 @@
                 Pending skill-ups
             </h2>
             <article>
-                <img alt=' ' src='<?=$path["img"]["unit"]?>00015105.png'> <!-- Devilmon image -->
+                <img alt=' ' src='<?=URL::IMG["UNIT"]?>00015105.png'> <!-- Devilmon image -->
                 <p>
                     Shows a list of the monstes in need of skilling-up
                     It sorts monster not by the absolute ammount of remaining power-ups, but by a ponderated list tht takes into account to which skills the previous power ups have gone, placing more value in the more advanced skills. 
                 </p>
 <?php
-                $filters = $FILTER_SKILLUP;
+                $filters = FILTER::SKILLUP;
                 include __DIR__ . "/inc/filter_report_skillup.php";
 ?>
             </article>
@@ -58,13 +65,13 @@
                 Runes to replace
             </h2>
             <article class='report'>
-                <img alt=' ' src='<?=$path["img"]["rune"]?>base.png'>
+                <img alt=' ' src='<?=URL::IMG["RUNE"]?>base.png'>
                 <p>
                     Shows monsters with runes that can be upgraded.
                     It list the runes that can be replaced by other runes in your inventory that have either more stars or a higher base quality.
                 </p>
 <?php
-                $filters = $FILTER_RUNEUPGRADE;
+                $filters = FILTER::RUNEUPGRADE;
                 $custom_filters = $page->custom_filters_runeupgrade;
                 include __DIR__ . "/inc/filter_report_runeupgrade.php";
 ?>
@@ -75,13 +82,13 @@
                 Runes to upgrade
             </h2>
             <article class='report'>
-                <img alt=' ' src='<?=$path["img"]["grind"]?>gem_inmemorial.png'> 
+                <img alt=' ' src='<?=URL::IMG["GRIND"]?>gem_inmemorial.png'> 
                 <p>
                     Shows monsters with runes that can be crafted.
                     It list the grindstones and gems that are available for each rune.
                 </p>
 <?php
-                $filters = $FILTER_RUNECRAFT;
+                $filters = FILTER::RUNECRAFT;
                 include __DIR__ . "/inc/filter_report_runecraft.php";
 ?>
             </article>

+ 17 - 8
application/view/report_runecraft.php

@@ -1,5 +1,14 @@
 <?php
-    global $RUNE_STAT;
+    /**
+     * Rune craft report view.
+     *
+     * Contains the view layout and ome code to present the data.
+     *
+     * @category View
+     * @property_read Report_Runecraft_Page $page The page model.
+     */
+
+    namespace swdb;
 ?>
 <!DOCTYPE html>
 <html lang='en'>
@@ -9,9 +18,9 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>report_runecraft.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>filters.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>report_runecraft.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>filters.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -55,7 +64,7 @@
 ?>
         <section class='filters'>
             <h2 id='filters_title' onClick='toggleFilters();'>
-                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=$path["img"]["icon"]?>slid.png'/>
+                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
                 Upgrade filters
             </h2>
             <article id='filters_content'>
@@ -80,7 +89,7 @@
                     <div class='monster'>
                         <div class='profile'>
                             <div class='monster_panel'>
-                                <?=html_unit_panel($upgrade["unit"])?>
+                                <?=HTML::unit_panel($upgrade["unit"])?>
                             </div>
                         </div> <!-- .profile -->
                     </div>
@@ -88,12 +97,12 @@
 <?php
                         foreach ($upgrade["upgrade"] as $rupgrade){
 ?>
-                            <?=html_rune_table($rupgrade["rune"])?>
+                            <?=HTML::rune_table($rupgrade["rune"])?>
                             <div class='craft'>
 <?php
                                 foreach ($rupgrade["craft"] as $craft){
 ?>
-                                    <?=html_craft_panel($craft)?>
+                                    <?=HTML::craft_panel($craft)?>
 <?php
                                 }
 ?>

+ 17 - 9
application/view/report_runeupgrade.php

@@ -1,6 +1,14 @@
 <?php
-    global $RUNE_STAT;
-    global $QUALITY;
+    /**
+     * Rune upgrade report view.
+     *
+     * Contains the view layout and ome code to present the data.
+     *
+     * @category View
+     * @property_read Report_Runecupgrade_Page $page The page model.
+     */
+
+    namespace swdb;
 ?>
 <!DOCTYPE html>
 <html lang='en'>
@@ -10,9 +18,9 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>report_runeupgrade.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>filters.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>report_runeupgrade.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>filters.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -56,7 +64,7 @@
 ?>
         <section class='filters'>
             <h2 id='filters_title' onClick='toggleFilters();'>
-                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=$path["img"]["icon"]?>slid.png'/>
+                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
                 Upgrade filters
             </h2>
             <article id='filters_content'>
@@ -81,7 +89,7 @@
                     <div class='monster'>
                         <div class='profile'>
                             <div class='monster_panel'>
-                                <?=html_unit_panel($upgrade["unit"])?>
+                                <?=HTML::unit_panel($upgrade["unit"])?>
                             </div>
                         </div> <!-- .profile -->
                     </div>
@@ -89,12 +97,12 @@
 <?php
                         foreach ($upgrade["upgrade"] as $rupgrade){
 ?>
-                            <?=html_rune_table($rupgrade["rune"])?>
+                            <?=HTML::rune_table($rupgrade["rune"])?>
                             <div class='alternatives'>
 <?php
                                 foreach ($rupgrade["alternative"] as $alternative){
 ?>
-                                    <?=html_rune_table($alternative, $alternative->assigned_to)?>
+                                    <?=HTML::rune_table($alternative, $alternative->assigned_to)?>
 <?php
                                 }
 ?>

+ 17 - 5
application/view/report_skillup.php

@@ -1,3 +1,15 @@
+<?php
+    /**
+     * Skillup report view.
+     *
+     * Contains the view layout and ome code to present the data.
+     *
+     * @category View
+     * @property_read Report_Skillup_Page $page The page model.
+     */
+
+    namespace swdb;
+?>
 <!DOCTYPE html>
 <html lang='en'>
     <head>
@@ -6,9 +18,9 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>report_skillup.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>filters.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>report_skillup.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>filters.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -52,7 +64,7 @@
 ?>
         <section class='filters'>
             <h2 id='filters_title' onClick='toggleFilters();'>
-                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=$path["img"]["icon"]?>slid.png'/>
+                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
                 Monster filters
             </h2>
             <article id='filters_content'>
@@ -125,7 +137,7 @@
 <?php
                                     for ($i = 0; $i < $unit->stars; $i ++){
 ?>
-                                        <img class='star <?=$star_class?>' src='<?=$path["img"]["icon"] . "star.png"?>'/>
+                                        <img class='star <?=$star_class?>' src='<?=URL::IMG["ICON"] . "star.png"?>'/>
 <?php
                                     }
 ?>

+ 19 - 7
application/view/runes.php

@@ -1,3 +1,15 @@
+<?php
+    /**
+     * Runes view.
+     *
+     * Contains the view layout and ome code to present the data.
+     *
+     * @category View
+     * @property_read Runes_Page $page The page model.
+     */
+
+    namespace swdb;
+?>
 <!DOCTYPE html>
 <html lang='en'>
     <head>
@@ -6,9 +18,9 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>runes.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>filters.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>runes.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>filters.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -52,7 +64,7 @@
 ?>
         <section class='filters'>
             <h2 id='filters_title' onClick='toggleFilters();'>
-                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=$path["img"]["icon"]?>slid.png'/>
+                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
                 Rune filters
             </h2>
             <article id='filters_content'>
@@ -74,12 +86,12 @@
                     case 1: // "TYPE":
                         $group = $rune->type->name;
                         $group_title = $rune->type->name;
-                        $group_image = $path["img"]["rune"] . str_pad($rune->type->id, 2, '0', STR_PAD_LEFT) . ".png";
+                        $group_image = URL::IMG["RUNE"] . str_pad($rune->type->id, 2, '0', STR_PAD_LEFT) . ".png";
                         break;
                     default:
                         $group = $rune->slot;
                         $group_title = "Slot " . $rune->slot;
-                        $group_image = $path["img"]["rune"] . "base.png";
+                        $group_image = URL::IMG["RUNE"] . "base.png";
                 }
                 if ($prev_group != $group){
                     if ($prev_group == ""){
@@ -106,7 +118,7 @@
 <?php
                 }
 ?>
-                <?=html_rune_table($rune, $rune->assigned_to)?>
+                <?=HTML::rune_table($rune, $rune->assigned_to)?>
 <?php
             }
 ?>

+ 40 - 20
application/view/runs.php

@@ -1,7 +1,15 @@
 <?php
-    global $AREA_TYPE;
-    global $SCENARIO;
-    global $UID;
+    /**
+     * Runs view.
+     *
+     * Contains the view layout and ome code to present the data.
+     *
+     * @category View
+     * @property_read Runs_Page $page The page model.
+     * @property_read int $UID Player ID.
+     */
+
+    namespace swdb;
 ?>
 <!DOCTYPE html>
 <html lang='en'>
@@ -11,9 +19,9 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>runs.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>filters.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>runs.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>filters.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -33,6 +41,13 @@
         <meta name='twitter:url' content='<?=$page->canonical?>'/>
         <meta name='robots' content='index follow'/>
         <script>
+        
+            /**
+             * Shows or hiddes the save team form.
+             *
+             * @param id Run ID.
+             * @param show TRue to show, false to hide.
+             */
             function saveForm(id, show){
                 if (show === true){
                     document.getElementById('save_team').style.display = 'block';
@@ -43,6 +58,11 @@
                 }
             }
 
+            /**
+             * Makes a request to save the team.
+             *
+             * Hides the team save form on success.
+             */
             function saveTeam(){
                 var id = document.getElementById('save_id').value;
                 var name = document.getElementById('save_team_name').value;
@@ -85,7 +105,7 @@
 ?>
         <section class='filters'>
             <h2 id='filters_title' onClick='toggleFilters();'>
-                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=$path["img"]["icon"]?>slid.png'/>
+                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
                 Run filters
             </h2>
             <article id='filters_content'>
@@ -135,13 +155,13 @@
 <?php
                                     }
                                     // TODO: Labyrinth difficulty
-                                    if (in_array($run->area->id, $SCENARIO)){
+                                    if(property_exists(SCENARIO_ID, $run->area->id)){
 ?>
                                         <span class='difficulty'>
 <?php
                                             for ($i = 0; $i < $run->difficulty; $i ++){
 ?>
-                                                <img class='difficulty' src='<?=$path["img"]["icon"]?>star.png'/>
+                                                <img class='difficulty' src='<?=URL::IMG["ICON"]?>star.png'/>
 <?php
                                             }
 ?>
@@ -163,7 +183,7 @@
                                     $enable_save = false;
 ?>
                                     <div class='monster_panel helper'>
-                                        <img class='monster' title='Friend/Menstor' src='<?=$path["img"]["currency"]?>socialpoint.png'/>
+                                        <img class='monster' title='Friend/Menstor' src='<?=URL::IMG["CURRENCY"]?>socialpoint.png'/>
                                     </div>
 <?php
                                 }
@@ -182,7 +202,7 @@
                                     }
 ?>
                                     <div class='monster_panel <?=$disabled?>'>
-                                        <?=html_unit_panel($party)?>
+                                        <?=HTML::unit_panel($party)?>
                                     </div>
 <?php
                                     if ($disabled == ""){
@@ -218,7 +238,7 @@
                                 if ($run->energy > 0){
 ?>
                                     <div class='item'>
-                                        <img class='item' title='Energy' src='<?=$path["img"]["currency"]?>energy.png'/>
+                                        <img class='item' title='Energy' src='<?=URL::IMG["CURRENCY"]?>energy.png'/>
                                         <span class='item'><?=$run->energy?></span>
                                     </div>
 <?php
@@ -226,7 +246,7 @@
                                 if ($run->mana > 0){
 ?>
                                     <div class='item'>
-                                        <img class='item' title='Mana' src='<?=$path["img"]["currency"]?>mana.png'/>
+                                        <img class='item' title='Mana' src='<?=URL::IMG["CURRENCY"]?>mana.png'/>
                                         <span class='item'><?=$run->mana?></span>
                                     </div>
 <?php
@@ -234,7 +254,7 @@
                                 if ($run->crystal > 0){
 ?>
                                     <div class='item'>
-                                        <img class='item' title='Crystal' src='<?=$path["img"]["currency"]?>crystal.png'/>
+                                        <img class='item' title='Crystal' src='<?=URL::IMG["CURRENCY"]?>crystal.png'/>
                                         <span class='item'><?=$run->crystal?></span>
                                     </div>
 <?php
@@ -258,7 +278,7 @@
 ?>
                                     <div class='item'>
                                         <img class='item' title='<?=$sd->unit->title?>' src='<?=$sd->unit->get_image()?>'/>
-                                        <img class='item' title=' ' src='<?=$path["img"]["misc"]?>mask-sd.png'/>
+                                        <img class='item' title=' ' src='<?=URL::IMG["MISC"]?>mask-sd.png'/>
                                     </div>
 <?php
                                 }
@@ -266,7 +286,7 @@
 ?>
                                     <div class='item'>
                                         <img class='item' title='<?=$piece->unit->title?>' src='<?=$piece->unit->get_image()?>'/>
-                                        <img class='item' title=' ' src='<?=$path["img"]["misc"]?>mask-piece.png'/>
+                                        <img class='item' title=' ' src='<?=URL::IMG["MISC"]?>mask-piece.png'/>
                                         <span class='item'><?=$piece->quantity?></span>
                                     </div>
 <?php
@@ -274,7 +294,7 @@
                                 if ($run->shapeshifting > 0){
 ?>
                                     <div class='item'>
-                                        <img class='item' title='Shapeshifting Stones' src='<?=$path["img"]["currency"]?>costumestone.png'/>
+                                        <img class='item' title='Shapeshifting Stones' src='<?=URL::IMG["CURRENCY"]?>costumestone.png'/>
                                         <span class='item'><?=$run->shapeshifting?></span>
                                     </div>
 <?php
@@ -282,8 +302,8 @@
                                 foreach ($run->rune as $rune){
 ?>
                                     <div class='item item_rune'>
-                                        <img class='item' title='Rune' src='<?=$path["img"]["rune"]?>base.png'/>
-                                        <?=html_rune_table($rune)?>
+                                        <img class='item' title='Rune' src='<?=URL::IMG["RUNE"]?>base.png'/>
+                                        <?=HTML::rune_table($rune)?>
                                     </div>
 <?php
                                 }
@@ -293,7 +313,7 @@
 <?php
                                 if ($enable_save){
 ?>
-                                    <img alt='Save Team' class='save_team' onclick='saveForm(<?=$run->id?>, true);' src='<?=$path["img"]["icon"]?>save.png'/>
+                                    <img alt='Save Team' class='save_team' onclick='saveForm(<?=$run->id?>, true);' src='<?=URL::IMG["ICON"]?>save.png'/>
 <?php
                                 }
 ?>

+ 111 - 107
application/view/teams.php

@@ -1,11 +1,15 @@
 <?php
-    global $AREA_TYPE;
-    global $SCENARIO;
-    global $DUNGEON;
-    global $LABYRINTH_STAGES;
-    global $DIFFICULTY;
-    global $ELEMENTAL_RIFT_DUNGEON;
-    global $UID;
+    /**
+     * Teamss view.
+     *
+     * Contains the view layout and ome code to present the data.
+     *
+     * @category View
+     * @property_read Teams_Page $page The page model.
+     * @property_read int $page Player ID.
+     */
+
+    namespace swdb;
 ?>
 <!DOCTYPE html>
 <html lang='en'>
@@ -15,9 +19,9 @@
         <title><?=$page->title?></title>
         <link rel='shortcut icon' href='<?=$page->favicon?>'/>
         <!-- CSS files -->
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>teams.css'/>
-        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>filters.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>teams.css'/>
+        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>filters.css'/>
         <!-- Meta tags -->
         <link rel='canonical' href='<?=$page->canonical?>'/>
         <link rel='author' href='<?=$page->author?>'/>
@@ -85,40 +89,40 @@
                 var difficulty = null;
                 var stage = null;
                 switch (area_type){
-                    case '<?=$AREA_TYPE["SCENARIO"]?>':
+                    case '<?=AREA_TYPE_ID::SCENARIO?>':
                         area = document.getElementById('new_area_scenario').options[document.getElementById('new_area_scenario').selectedIndex].value;
                         difficulty = document.getElementById('new_area_difficulty').options[document.getElementById('new_area_difficulty').selectedIndex].value;
                         stage = document.getElementById('new_area_stage').options[document.getElementById('new_area_stage').selectedIndex].value;
                         break;
-                    case '<?=$AREA_TYPE["CAIROS_DUNGEON"]?>':
+                    case '<?=AREA_TYPE_ID::CAIROS_DUNGEON?>':
                         area = document.getElementById('new_area_cairos_dungeon').options[document.getElementById('new_area_cairos_dungeon').selectedIndex].value;
                         stage = document.getElementById('new_area_stage').options[document.getElementById('new_area_stage').selectedIndex].value;
                         break;
-                    case '<?=$AREA_TYPE["RIFT_DUNGEON"]?>':
+                    case '<?=AREA_TYPE_ID::RIFT_DUNGEON?>':
                         area = document.getElementById('new_area_rift_dungeon').options[document.getElementById('new_area_rift_dungeon').selectedIndex].value;
                         break;
-                    case '<?=$AREA_TYPE["RIFT_RAID"]?>':
+                    case '<?=AREA_TYPE_ID::RIFT_RAID?>':
                         area = document.getElementById('new_area_rift_raid').options[document.getElementById('new_area_rift_raid').selectedIndex].value;
                         stage = document.getElementById('new_area_stage').options[document.getElementById('new_area_stage').selectedIndex].value;
                         break;
-                    case '<?=$AREA_TYPE["ARENA"]?>':
+                    case '<?=AREA_TYPE_ID::ARENA?>':
                         break;
-                    case '<?=$AREA_TYPE["GUILD_WAR"]?>':
+                    case '<?=AREA_TYPE_ID::GUILD_WAR?>':
                         break;
-                    case '<?=$AREA_TYPE["GUILD_SIEGE"]?>':
+                    case '<?=AREA_TYPE_ID::GUILD_SIEGE?>':
                         break;
-                    case '<?=$AREA_TYPE["TARTARUS_LABYRINTH"]?>':
+                    case '<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>':
                         difficulty = document.getElementById('new_area_difficulty').options[document.getElementById('new_area_difficulty').selectedIndex].value;
                         stage = document.getElementById('new_area_stage').options[document.getElementById('new_area_stage').selectedIndex].value;
                         break;
-                    case '<?=$AREA_TYPE["TRIAL_OF_ASCENSION"]?>':
+                    case '<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>':
                         difficulty = document.getElementById('new_area_difficulty').options[document.getElementById('new_area_difficulty').selectedIndex].value;
                         break;
-                    case '<?=$AREA_TYPE["DIMENSIONAL_HOLE"]?>':
+                    case '<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>':
                         area = document.getElementById('new_area_dimensional_hole').options[document.getElementById('new_area_dimensional_hole').selectedIndex].value;
                         stage = document.getElementById('new_area_stage').options[document.getElementById('new_area_stage').selectedIndex].value;
                         break;
-                    case '<?=$AREA_TYPE["DIMENSIONAL_RIFT"]?>':
+                    case '<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>':
                         difficulty = document.getElementById('new_area_difficulty').options[document.getElementById('new_area_difficulty').selectedIndex].value;
                         break;
                     default:
@@ -212,7 +216,7 @@
                         var star = document.createElement('img');
                         // TODO: Handle star color.
                         star.setAttribute('class', 'star star_purple');
-                        star.setAttribute('src', '<?=$path["img"]["icon"]?>star.png');
+                        star.setAttribute('src', '<?=URL::IMG["ICON"]?>star.png');
                         monsterStars.appendChild(star);
                     }
                     var monsterImage = document.createElement('img');
@@ -324,7 +328,7 @@
                     opt = document.createElement('option');
                     tex = document.createTextNode('Easy difficulty');
                     att = document.createAttribute('value');
-                    att.value = '<?=$DIFFICULTY["EASY"]?>';
+                    att.value = '<?=DIFFICULTY_ID::EASY?>';
                     opt.setAttributeNode(att);
                     opt.appendChild(tex);
                     sel.appendChild(opt);
@@ -333,7 +337,7 @@
                 opt = document.createElement('option');
                 tex = document.createTextNode('Normal difficulty');
                 att = document.createAttribute('value');
-                att.value = '<?=$DIFFICULTY["NORMAL"]?>';
+                att.value = '<?=DIFFICULTY_ID::NORMAL?>';
                 opt.setAttributeNode(att);
                 opt.appendChild(tex);
                 sel.appendChild(opt);
@@ -341,7 +345,7 @@
                 opt = document.createElement('option');
                 tex = document.createTextNode('Hard difficulty');
                 att = document.createAttribute('value');
-                att.value = '<?=$DIFFICULTY["HARD"]?>';
+                att.value = '<?=DIFFICULTY_ID::HARD?>';
                 opt.setAttributeNode(att);
                 opt.appendChild(tex);
                 sel.appendChild(opt);
@@ -350,7 +354,7 @@
                     opt = document.createElement('option');
                     tex = document.createTextNode('Hell difficulty');
                     att = document.createAttribute('value');
-                    att.value = '<?=$DIFFICULTY["HELL"]?>';
+                    att.value = '<?=DIFFICULTY_ID::HELL?>';
                     opt.setAttributeNode(att);
                     opt.appendChild(tex);
                     sel.appendChild(opt);
@@ -378,51 +382,51 @@
                 document.getElementById('new_area_stage').style.display = 'none';
                 document.getElementById('new_area_stage').selectedIndex = 0;
                 switch (type){
-                    case '<?=$AREA_TYPE["SCENARIO"]?>':
+                    case '<?=AREA_TYPE_ID::SCENARIO?>':
                         document.getElementById('new_area_scenario').style.display = 'inline';
                         max_units = 4;
                         break;
-                    case '<?=$AREA_TYPE["CAIROS_DUNGEON"]?>':
+                    case '<?=AREA_TYPE_ID::CAIROS_DUNGEON?>':
                         document.getElementById('new_area_cairos_dungeon').style.display = 'inline';
                         max_units = 5;
                         break;
-                    case '<?=$AREA_TYPE["RIFT_DUNGEON"]?>':
+                    case '<?=AREA_TYPE_ID::RIFT_DUNGEON?>':
                         document.getElementById('new_area_rift_dungeon').style.display = 'inline';
                         max_units = 6;
                         break;
-                    case '<?=$AREA_TYPE["RIFT_RAID"]?>':
+                    case '<?=AREA_TYPE_ID::RIFT_RAID?>':
                         document.getElementById('new_area_rift_raid').style.display = 'inline';
                         max_units = 6
                         break;
-                    case '<?=$AREA_TYPE["ARENA"]?>':
+                    case '<?=AREA_TYPE_ID::ARENA?>':
                         max_units = 4;
                         //document.getElementById('new_area_arena').style.display = 'inline';
                         break;
-                    case '<?=$AREA_TYPE["GUILD_WAR"]?>':
+                    case '<?=AREA_TYPE_ID::GUILD_WAR?>':
                         max_units = 3;
                         document.getElementById('new_area_guild_war').style.display = 'inline';
                         break;
-                    case '<?=$AREA_TYPE["GUILD_SIEGE"]?>':
+                    case '<?=AREA_TYPE_ID::GUILD_SIEGE?>':
                         max_units = 3;
                         document.getElementById('new_area_guild_siege').style.display = 'inline';
                         break;
-                    case '<?=$AREA_TYPE["TARTARUS_LABYRINTH"]?>':
+                    case '<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>':
                         max_units = 5;
                         document.getElementById('new_area_tartarus_labyrinth').style.display = 'inline';
                         break;
-                    case '<?=$AREA_TYPE["TRIAL_OF_ASCENSION"]?>':
+                    case '<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>':
                         max_units = 5;
                         //document.getElementById('new_area_trial_of_ascension').style.display = 'inline';
                         break;
-                    case '<?=$AREA_TYPE["WORLD_BOSS"]?>':
+                    case '<?=AREA_TYPE_ID::WORLD_BOSS?>':
                         //max_units = 5;
                         //document.getElementById('new_area_world_boss').style.display = 'inline';
                         break;
-                    case '<?=$AREA_TYPE["DIMENSIONAL_HOLE"]?>':
+                    case '<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>':
                         max_units = 4;
                         document.getElementById('new_area_dimensional_hole').style.display = 'inline';
                         break;
-                    case '<?=$AREA_TYPE["DIMENSIONAL_RIFT"]?>':
+                    case '<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>':
                         max_units = 5;
                         //document.getElementById('new_area_dimensional_rift').style.display = 'inline';
                         break;
@@ -446,44 +450,44 @@
                 document.getElementById('new_area_stage').style.display = 'none';
                 document.getElementById('new_area_difficulty').style.display = 'none';
                 switch (type){
-                    case '<?=$AREA_TYPE["SCENARIO"]?>':
+                    case '<?=AREA_TYPE_ID::SCENARIO?>':
                         document.getElementById('new_area_stage').style.display = 'inline';
                         document.getElementById('new_area_difficulty').style.display = 'inline';
                         populateStage(7);
                         populateDifficulty();
                         break;
-                    case '<?=$AREA_TYPE["CAIROS_DUNGEON"]?>':
+                    case '<?=AREA_TYPE_ID::CAIROS_DUNGEON?>':
                         document.getElementById('new_area_stage').style.display = 'inline';
                         populateStage(10);
                         populateDifficulty();
                         break;
-                    case '<?=$AREA_TYPE["RIFT_DUNGEON"]?>':
+                    case '<?=AREA_TYPE_ID::RIFT_DUNGEON?>':
                         break;
-                    case '<?=$AREA_TYPE["RIFT_RAID"]?>':
+                    case '<?=AREA_TYPE_ID::RIFT_RAID?>':
                         document.getElementById('new_area_stage').style.display = 'inline';
                         populateStage(5);
                         break;
-                    case '<?=$AREA_TYPE["ARENA"]?>':
+                    case '<?=AREA_TYPE_ID::ARENA?>':
                         break;
-                    case '<?=$AREA_TYPE["GUILD_WAR"]?>':
+                    case '<?=AREA_TYPE_ID::GUILD_WAR?>':
                         break;
-                    case '<?=$AREA_TYPE["GUILD_SIEGE"]?>':
+                    case '<?=AREA_TYPE_ID::GUILD_SIEGE?>':
                         break;
-                    case '<?=$AREA_TYPE["TARTARUS_LABYRINTH"]?>':
+                    case '<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>':
                         document.getElementById('new_area_difficulty').style.display = 'inline';
                         populateDifficulty(true, false);
                         break;
-                    case '<?=$AREA_TYPE["TRIAL_OF_ASCENSION"]?>':
+                    case '<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>':
                         document.getElementById('new_area_difficulty').style.display = 'inline';
                         populateDifficulty(false, true);
                         break;
-                    case '<?=$AREA_TYPE["WORLD_BOSS"]?>':
+                    case '<?=AREA_TYPE_ID::WORLD_BOSS?>':
                         break;
-                    case '<?=$AREA_TYPE["DIMENSIONAL_HOLE"]?>':
+                    case '<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>':
                         document.getElementById('new_area_stage').style.display = 'inline';
                         populateStage(5);
                         break;
-                    case '<?=$AREA_TYPE["DIMENSIONAL_RIFT"]?>':
+                    case '<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>':
                         break;
                 }
             }
@@ -512,7 +516,7 @@
 ?>
         <section class='filters'>
             <h2 id='filters_title' onClick='toggleFilters();'>
-                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=$path["img"]["icon"]?>slid.png'/>
+                <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
                 Team filters
             </h2>
             <article id='filters_content'>
@@ -569,7 +573,7 @@
 ?>
                                     <a href='/<?=$UID?>/monsters/<?=$unit->id?>'>
                                         <div class='monster_panel'>
-                                            <?=html_unit_panel($unit)?>
+                                            <?=HTML::unit_panel($unit)?>
                                         </div>
                                     </a>
 <?php
@@ -607,77 +611,77 @@
                         <td class='new_values'>
                             <select id='new_area_type' name='new_area_type' onChange='selectNewAreaType();'>
                                 <option value=''> </option>
-                                <option value='<?=$AREA_TYPE["SCENARIO"]?>'>Scenario</option>
-                                <option value='<?=$AREA_TYPE["CAIROS_DUNGEON"]?>'>Cairos Dungeon</option>
-                                <option value='<?=$AREA_TYPE["RIFT_DUNGEON"]?>'>Rift Dungeon</option>
-                                <option value='<?=$AREA_TYPE["RIFT_RAID"]?>'>Rift Raid</option>
-                                <option value='<?=$AREA_TYPE["DIMENSIONAL_HOLE"]?>'>Dimensional Hole</option>
-                                <option value='<?=$AREA_TYPE["ARENA"]?>'>Arena</option>
-                                <option value='<?=$AREA_TYPE["GUILD_WAR"]?>'>Guild War</option>
-                                <option value='<?=$AREA_TYPE["GUILD_SIEGE"]?>'>Guild Siege</option>
-                                <option value='<?=$AREA_TYPE["TARTARUS_LABYRINTH"]?>'>Tartarus Labyrinth</option>
-                                <option value='<?=$AREA_TYPE["TRIAL_OF_ASCENSION"]?>'>Trial of Ascension</option>
-                                <!--<option value='<?=$AREA_TYPE["WORLD_BOSS"]?>'>World Boss</option>-->
-                                <option value='<?=$AREA_TYPE["DIMENSIONAL_RIFT"]?>'>Dimensinal Rift</option>
+                                <option value='<?=AREA_TYPE_ID::SCENARIO?>'>Scenario</option>
+                                <option value='<?=AREA_TYPE_ID::CAIROS_DUNGEON?>'>Cairos Dungeon</option>
+                                <option value='<?=AREA_TYPE_ID::RIFT_DUNGEON?>'>Rift Dungeon</option>
+                                <option value='<?=AREA_TYPE_ID::RIFT_RAID?>'>Rift Raid</option>
+                                <option value='<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>'>Dimensional Hole</option>
+                                <option value='<?=AREA_TYPE_ID::ARENA?>'>Arena</option>
+                                <option value='<?=AREA_TYPE_ID::GUILD_WAR?>'>Guild War</option>
+                                <option value='<?=AREA_TYPE_ID::GUILD_SIEGE?>'>Guild Siege</option>
+                                <option value='<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>'>Tartarus Labyrinth</option>
+                                <option value='<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>'>Trial of Ascension</option>
+                                <!--<option value='<?=AREA_TYPE_ID::WORLD_BOSS?>'>World Boss</option>-->
+                                <option value='<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>'>Dimensinal Rift</option>
                             </select>
                             <select id='new_area_scenario' class='new_area' onChange='selectNewArea();'>
                                 <option value=''> </option>
-                                <option value='<?=$SCENARIO['GAREN_FOREST']?>'>Garen Forest</option>
-                                <option value='<?=$SCENARIO['MT_SIZ']?>'>Mt. Siz</option>
-                                <option value='<?=$SCENARIO['KABIR_RUINS']?>'>Kabir Ruins</option>
-                                <option value='<?=$SCENARIO['MT_WHITE_RAGON']?>'>Mt. White Ragon</option>
-                                <option value='<?=$SCENARIO['TELAIN_FOREST']?>'>Telain Forest</option>
-                                <option value='<?=$SCENARIO['HYDENI_RUINS']?>'>Hydeni Ruins</option>
-                                <option value='<?=$SCENARIO['TAMOR_DESERT']?>'>Tamor Desert</option>
-                                <option value='<?=$SCENARIO['VROFAGUS_RUINS']?>'>Vrofagus Ruins</option>
-                                <option value='<?=$SCENARIO['FAIMON_VOLCANO']?>'>Faimon Volcano</option>
-                                <option value='<?=$SCENARIO['AIDEN_FOREST']?>'>Aiden Forest</option>
-                                <option value='<?=$SCENARIO['FERUN_CASTLE']?>'>Ferun Castle</option>
-                                <option value='<?=$SCENARIO['MT_RUNAR']?>'>Mt. Runar</option>
-                                <option value='<?=$SCENARIO['CHIRUKA_REMAINS']?>'>Charuca Remains</option>
+                                <option value='<?=SCENARIO_ID::GAREN_FOREST?>'>Garen Forest</option>
+                                <option value='<?=SCENARIO_ID::MT_SIZ?>'>Mt. Siz</option>
+                                <option value='<?=SCENARIO_ID::KABIR_RUINS?>'>Kabir Ruins</option>
+                                <option value='<?=SCENARIO_ID::MT_WHITE_RAGON?>'>Mt. White Ragon</option>
+                                <option value='<?=SCENARIO_ID::TELAIN_FOREST?>'>Telain Forest</option>
+                                <option value='<?=SCENARIO_ID::HYDENI_RUINS?>'>Hydeni Ruins</option>
+                                <option value='<?=SCENARIO_ID::TAMOR_DESERT?>'>Tamor Desert</option>
+                                <option value='<?=SCENARIO_ID::VROFAGUS_RUINS?>'>Vrofagus Ruins</option>
+                                <option value='<?=SCENARIO_ID::FAIMON_VOLCANO?>'>Faimon Volcano</option>
+                                <option value='<?=SCENARIO_ID::AIDEN_FOREST?>'>Aiden Forest</option>
+                                <option value='<?=SCENARIO_ID::FERUN_CASTLE?>'>Ferun Castle</option>
+                                <option value='<?=SCENARIO_ID::MT_RUNAR?>'>Mt. Runar</option>
+                                <option value='<?=SCENARIO_ID::CHIRUKA_REMAINS?>'>Charuca Remains</option>
                             </select>
                             <select id='new_area_cairos_dungeon' class='new_area' onChange='selectNewArea();'>
                                 <option value=''> </option>
-                                <option value='<?=$DUNGEON['GIANTS_KEEP']?>'>Giant&#39;s Keep</option>
-                                <option value='<?=$DUNGEON['DRAGONS_LAIR']?>'>Dragon&#39;s Lair</option>
-                                <option value='<?=$DUNGEON['NECROPOLIS']?>'>Necropolis</option>
-                                <option value='<?=$DUNGEON['HALL_OF_MAGIC']?>'>Hall of Magic</option>
-                                <option value='<?=$DUNGEON['HALL_OF_FIRE']?>'>Hall of Fire</option>
-                                <option value='<?=$DUNGEON['HALL_OF_WATER']?>'>Hall of Water</option>
-                                <option value='<?=$DUNGEON['HALL_OF_WIND']?>'>Hall of Wind</option>
-                                <option value='<?=$DUNGEON['HALL_OF_LIGHT']?>'>Hall of Light</option>
-                                <option value='<?=$DUNGEON['HALL_OF_DARK']?>'>Hall of Dark</option>
+                                <option value='<?=DUNGEON_ID::GIANTS_KEEP?>'>Giant&#39;s Keep</option>
+                                <option value='<?=DUNGEON_ID::DRAGONS_LAIR?>'>Dragon&#39;s Lair</option>
+                                <option value='<?=DUNGEON_ID::NECROPOLIS?>'>Necropolis</option>
+                                <option value='<?=DUNGEON_ID::HALL_OF_MAGIC?>'>Hall of Magic</option>
+                                <option value='<?=DUNGEON_ID::HALL_OF_FIRE?>'>Hall of Fire</option>
+                                <option value='<?=DUNGEON_ID::HALL_OF_WATER?>'>Hall of Water</option>
+                                <option value='<?=DUNGEON_ID::HALL_OF_WIND?>'>Hall of Wind</option>
+                                <option value='<?=DUNGEON_ID::HALL_OF_LIGHT?>'>Hall of Light</option>
+                                <option value='<?=DUNGEON_ID::HALL_OF_DARK?>'>Hall of Dark</option>
                             </select>
                             <select id='new_area_rift_dungeon' class='new_area' onChange='selectNewArea();'>
                                 <option value=''> </option>
-                                <option value='<?=$ELEMENTAL_RIFT_DUNGEON['FIRE_BEAST']?>'>Fire Beast</option>
-                                <option value='<?=$ELEMENTAL_RIFT_DUNGEON['ICE_BEAST']?>'>Ice Beast</option>
-                                <option value='<?=$ELEMENTAL_RIFT_DUNGEON['WIND_BEAST']?>'>Wind Beast</option>
-                                <option value='<?=$ELEMENTAL_RIFT_DUNGEON['LIGHT_BEAST']?>'>Light Beast</option>
-                                <option value='<?=$ELEMENTAL_RIFT_DUNGEON['DARK_BEAST']?>'>Dark Beast</option>
+                                <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::FIRE_BEAST?>'>Fire Beast</option>
+                                <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::ICE_BEAST?>'>Ice Beast</option>
+                                <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::WIND_BEAST?>'>Wind Beast</option>
+                                <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::LIGHT_BEAST?>'>Light Beast</option>
+                                <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::DARK_BEAST?>'>Dark Beast</option>
                             </select>
                             <select id='new_area_dimensional_hole' class='new_area' onChange='selectNewArea();'>
                                 <option value=''> </option>
-                                <option value='<?=$DUNGEON['FOREST_OF_ROARING_BEASTS']?>'>Forest or Roaring Beasts</option>
-                                <option value='<?=$DUNGEON['KARZHAN_REMAINS_WARBEAR']?>'>Karzhan Remains (Warbear)</option>
-                                <option value='<?=$DUNGEON['KARZHAN_REMAINS_WARBEAR']?>'>Karzhan Remains (Inugami)</option>
-                                <option value='<?=$DUNGEON['SANCTUARY_OF_DREAMING_FAIRIES']?>'>Sanctuary of Dreaming Fairies</option>
-                                <option value='<?=$DUNGEON['ELLUNIA_REMAINS_FAIRY']?>'>Ellunia Remains (Fairy)</option>
-                                <option value='<?=$DUNGEON['ELLUNIA_REMAINS_PIXIE']?>'>Ellunia Remains (Pixie)</option>
+                                <option value='<?=DUNGEON_ID::FOREST_OF_ROARING_BEASTS?>'>Forest or Roaring Beasts</option>
+                                <option value='<?=DUNGEON_ID::KARZHAN_REMAINS_WARBEAR?>'>Karzhan Remains (Warbear)</option>
+                                <option value='<?=DUNGEON_ID::KARZHAN_REMAINS_WARBEAR?>'>Karzhan Remains (Inugami)</option>
+                                <option value='<?=DUNGEON_ID::SANCTUARY_OF_DREAMING_FAIRIES?>'>Sanctuary of Dreaming Fairies</option>
+                                <option value='<?=DUNGEON_ID::ELLUNIA_REMAINS_FAIRY?>'>Ellunia Remains (Fairy)</option>
+                                <option value='<?=DUNGEON_ID::ELLUNIA_REMAINS_PIXIE?>'>Ellunia Remains (Pixie)</option>
                                 <!-- TODO: Lumel -->
                             </select>
                             <select id='new_area_tartarus_labyrinth' class='new_area' onChange='selectNewArea();'>
                                 <option value=''> </option>
-                                <option value='<?=$LABYRINTH_STAGES['TARTARUS']?>'>Tartarus</option>
-                                <option value='<?=$LABYRINTH_STAGES['KOTTOS']?>'>Kottos</option>
-                                <option value='<?=$LABYRINTH_STAGES['LEOS']?>'>Leos</option>
-                                <option value='<?=$LABYRINTH_STAGES['AQUILES']?>'>Aquiles</option>
-                                <option value='<?=$LABYRINTH_STAGES['NORMAL']?>'>Normal Stage</option>
-                                <option value='<?=$LABYRINTH_STAGES['RESCUE']?>'>Rescue Stage</option>
-                                <option value='<?=$LABYRINTH_STAGES['EXPLODE']?>'>Explode Stage</option>
-                                <option value='<?=$LABYRINTH_STAGES['COOL_TIME']?>'>Cool Time Stage</option>
-                                <option value='<?=$LABYRINTH_STAGES['SPEED_LIMIT']?>'>Speed Limit Stage</option>
-                                <option value='<?=$LABYRINTH_STAGES['TIME_LIMIT']?>'>Time Limit Stage</option>
+                                <option value='<?=LABYRINTH_STAGES_ID::TARTARUS?>'>Tartarus</option>
+                                <option value='<?=LABYRINTH_STAGES_ID::KOTTOS?>'>Kottos</option>
+                                <option value='<?=LABYRINTH_STAGES_ID::LEOS?>'>Leos</option>
+                                <option value='<?=LABYRINTH_STAGES_ID::AQUILES?>'>Aquiles</option>
+                                <option value='<?=LABYRINTH_STAGES_ID::NORMAL?>'>Normal Stage</option>
+                                <option value='<?=LABYRINTH_STAGES_ID::RESCUE?>'>Rescue Stage</option>
+                                <option value='<?=LABYRINTH_STAGES_ID::EXPLODE?>'>Explode Stage</option>
+                                <option value='<?=LABYRINTH_STAGES_ID::COOL_TIME?>'>Cool Time Stage</option>
+                                <option value='<?=LABYRINTH_STAGES_ID::SPEED_LIMIT?>'>Speed Limit Stage</option>
+                                <option value='<?=LABYRINTH_STAGES_ID::TIME_LIMIT?>'>Time Limit Stage</option>
                                 <!-- TODO: Lumel -->
                             </select>
                             <select id='new_area_difficulty'>

+ 5 - 0
doc/.htaccess

@@ -0,0 +1,5 @@
+# Fixes a vulnerability in CentOS: http://stackoverflow.com/questions/20533279/prevent-php-from-parsing-non-php-files-such-as-somefile-php-txt
+<FilesMatch \.php\.txt$>
+    RemoveHandler .php
+    ForceType text/plain
+</FilesMatch>

Різницю між файлами не показано, бо вона завелика
+ 108 - 0
doc/classes/APP.html


Різницю між файлами не показано, бо вона завелика
+ 108 - 0
doc/classes/ARCHETYPE_ID.html


Різницю між файлами не показано, бо вона завелика
+ 108 - 0
doc/classes/AREA_TYPE_ID.html


Різницю між файлами не показано, бо вона завелика
+ 108 - 0
doc/classes/ARENA_RANKING_POINTS.html


Різницю між файлами не показано, бо вона завелика
+ 108 - 0
doc/classes/ARENA_RANKING_RANK.html


Різницю між файлами не показано, бо вона завелика
+ 108 - 0
doc/classes/BUILDING_ID.html


Різницю між файлами не показано, бо вона завелика
+ 108 - 0
doc/classes/Building.html


Різницю між файлами не показано, бо вона завелика
+ 108 - 0
doc/classes/CRAFT_ID.html


Різницю між файлами не показано, бо вона завелика
+ 108 - 0
doc/classes/Catalog_Page.html


Деякі файли не було показано, через те що забагато файлів було змінено