header_app.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Site header view.
  4. *
  5. * To be included from all views.
  6. *
  7. * @category View
  8. */
  9. if ($_SESSION['session'] == true && get_context()->get_user() != null){
  10. $logged_in = true;
  11. //$user_id = get_context()->get_user()->get_id();
  12. }
  13. else{
  14. $logged_in = false;
  15. //$user_id = null;
  16. }
  17. ?>
  18. <script>
  19. function setSearchAction(){
  20. var query = document.getElementById('app_search_query').value;
  21. document.getElementById('app_search_form').action = '/search/' + query;
  22. }
  23. </script>
  24. <nav class='menu' id='menu_app'>
  25. <table>
  26. <tr>
  27. <td>
  28. <h1 id='logo_text'>
  29. SWDB
  30. </h1>
  31. </td>
  32. <td class='item'>
  33. <a href='/monsters/'>
  34. Monsters
  35. </a>
  36. </td>
  37. <td class='item'>
  38. <a href='/dungeons/'>
  39. Dungeons
  40. </a>
  41. </td>
  42. <td class='item'>
  43. <a href='/buildings/'>
  44. Buildings
  45. </a>
  46. </td>
  47. <td class='item'>
  48. <a href='/fusion/'>
  49. Fusion
  50. </a>
  51. </td>
  52. <?php
  53. if (! $logged_in){
  54. ?>
  55. <td class='item'>
  56. <a href='/login/'>
  57. Login
  58. </a>
  59. </td>
  60. <td class='item'>
  61. <a href='/register/'>
  62. Register
  63. </a>
  64. </td>
  65. <?php
  66. }
  67. else{
  68. ?>
  69. <td class='item'>
  70. <a href='/'>
  71. Account
  72. </a>
  73. </td>
  74. <td class='item'>
  75. <a href='/action/logout/'>
  76. Log Out
  77. </a>
  78. </td>
  79. <?php
  80. }
  81. ?>
  82. <td class='item' id='search'>
  83. <form id='app_search_form' onsubmit='setSearchAction();'>
  84. <input id='app_search_query' type='text' placeholder='Search...'/>
  85. <input type='submit' value='Search'/>
  86. </form>
  87. </td>
  88. </tr>
  89. </table>
  90. </nav>