search.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. /**
  3. * Building view.
  4. *
  5. * Contains the view layout and some code to present the data
  6. *
  7. * @author Iñigo Valentin <i@inigovalentin.com>
  8. * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
  9. * @package SWDB
  10. * @category View
  11. * @property Search_Page $page The page model,.
  12. * @var Search_Page $page The page model,.
  13. */
  14. ?>
  15. <!DOCTYPE html>
  16. <html lang='en'>
  17. <head>
  18. <?=$page->generate_head()?>
  19. <script>
  20. function setFormAction(){
  21. console.log("ON SUBMIT");
  22. var query = document.getElementById('query').value;
  23. console.log(query);
  24. document.getElementById('searchForm').action = '/search/' + query;
  25. }
  26. </script>
  27. </head>
  28. <body>
  29. <header>
  30. <?php
  31. include __DIR__ . "/inc/header_app.php";
  32. ?>
  33. </header>
  34. <aside id='filters' class='content filters'>
  35. <h2 id='filters_title'>
  36. Search filters
  37. </h2>
  38. <form id='searchForm' action='/search/' onsubmit='setFormAction();'>
  39. <input id='query' type='text' placeholder='Search...'/>
  40. <span id='formError'></span>
  41. <hr/>
  42. <span id='include'>
  43. Include...
  44. </span>
  45. <table>
  46. <tr>
  47. <td>
  48. <?php
  49. $checked = "";
  50. if ($page->get_filter("MONSTER")){
  51. $checked = "checked";
  52. }
  53. ?>
  54. <input type='checkbox' name='monster' id='filter_monster' <?=$checked?>/>
  55. <label for='filter_monster'>Monsters</label>
  56. </td>
  57. <td>
  58. <?php
  59. $checked = "";
  60. if ($page->get_filter("DUNGEON")){
  61. $checked = "checked";
  62. }
  63. ?>
  64. <input type='checkbox' name='dungeon' id='filter_dungeon' <?=$checked?>/>
  65. <label for='filter_dungeon'>Dungeons</label>
  66. </td>
  67. </tr>
  68. <tr>
  69. <td>
  70. <?php
  71. $checked = "";
  72. if ($page->get_filter("BUILDING")){
  73. $checked = "checked";
  74. }
  75. ?>
  76. <input type='checkbox' name='building' id='filter_building' <?=$checked?>/>
  77. <label for='filter_building'>Buildings</label>
  78. </td>
  79. <td>
  80. <?php
  81. $checked = "";
  82. if ($page->get_filter("REPORT")){
  83. $checked = "checked";
  84. }
  85. ?>
  86. <input type='checkbox' name='report' id='filter_report' <?=$checked?>/>
  87. <label for='filter_report'>Reports</label>
  88. </td>
  89. </tr>
  90. <tr>
  91. <td>
  92. <?php
  93. $checked = "";
  94. if ($page->get_filter("PLAYER")){
  95. $checked = "checked";
  96. }
  97. ?>
  98. <input type='checkbox' name='monster' id='filter_player' <?=$checked?>/>
  99. <label for='filter_monster'>Players</label>
  100. </td>
  101. <td>
  102. <?php
  103. if (get_context()->get_user() != null){
  104. $checked = "";
  105. if ($page->get_filter("UNIT")){
  106. $checked = "checked";
  107. }
  108. ?>
  109. <input type='checkbox' name='unit' id='filter_unit' <?=$checked?>/>
  110. <label for='filter_unit'>My units</label>
  111. <?php
  112. }
  113. ?>
  114. </td>
  115. </tr>
  116. <tr>
  117. <td>
  118. <?php
  119. if (get_context()->get_user() != null){
  120. $checked = "";
  121. if ($page->get_filter("TEAM")){
  122. $checked = "checked";
  123. }
  124. ?>
  125. <input type='checkbox' name='team' id='filter_team' <?=$checked?>/>
  126. <label for='filter_team'>My teams</label>
  127. <?php
  128. }
  129. ?>
  130. </td>
  131. <td>
  132. </td>
  133. </tr>
  134. </table>
  135. <input type='submit' value='Search'/>
  136. </form>
  137. </aside>
  138. <main>
  139. <section class='content'>
  140. <h2>
  141. Results
  142. </h2>
  143. <article>
  144. <?php
  145. if (sizeof($page->get_results("monster")) > 0){
  146. ?>
  147. <h3>
  148. Monsters
  149. </h3>
  150. <div class='result_row'>
  151. <?php
  152. foreach($page->get_results("monster") as $monster){
  153. ?>
  154. <div class='monster'>
  155. <a href='/monsters/<?=$monster->get_id()?>'>
  156. <div class='monster_panel'>
  157. <?=HTML::unit_panel($monster)?>
  158. </div>
  159. </a>
  160. </div>
  161. <?php
  162. }
  163. ?>
  164. </div>
  165. <?php
  166. }
  167. if (sizeof($page->get_results("monster")) > 0){
  168. ?>
  169. <h3>
  170. Buildings
  171. </h3>
  172. <div class='result_row'>
  173. <?php
  174. foreach($page->get_results("building") as $building){
  175. ?>
  176. <div class='building'>
  177. <a href='/building/<?=$building->get_id()?>'>
  178. <?=HTML::building_panel($building)?>
  179. </a>
  180. </div>
  181. <?php
  182. }
  183. ?>
  184. </div>
  185. <?php
  186. }
  187. ?>
  188. </article>
  189. </section>
  190. </main>
  191. <?php
  192. include __DIR__ . "/inc/footer.php";
  193. ?>
  194. </body>
  195. </html>