menu.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * Bibliotheca
  4. *
  5. * Copyright 2018-2024 Johannes Keßler
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
  19. */
  20. ## optional context action
  21. # the key has to match the column contextaction of the menuentry
  22. # $_collection comes from the $Viewscript
  23. $_contextActions = array();
  24. if(!empty($_collection)) {
  25. $_contextActions['collection'] = $_collection;
  26. }
  27. $_menuShow = $Gorenest->get('show');
  28. $_menuManage = $Gorenest->get('manage', false, $_contextActions);
  29. ?>
  30. <menu role="tablist">
  31. <?php foreach($_menuShow as $entry) { ?>
  32. <li role="tab" <?php if($_requestMode == $entry['action']) echo 'aria-selected="true"'; ?>>
  33. <a href="index.php?p=<?php echo $entry['action']; ?>"><?php echo $I18n->t($entry['text']); ?></a>
  34. </li>
  35. <?php } ?>
  36. <li role="tab">
  37. <a href="index.php?p=auth">
  38. <?php if($Doomguy->isSignedIn() === true) { echo "Logout"; } else { echo "Login"; } ?>
  39. </a>
  40. </li>
  41. <li role="tab">
  42. <a id="showNavSearch" href="#" onclick="showNavSearch();"><?php echo $I18n->t('menu.search'); ?></a>
  43. </li>
  44. <li role="tab" <?php if($_requestMode == 'advancedsearch') echo 'aria-selected="true"'; ?>>
  45. <a href="index.php?p=advancedsearch"><?php echo $I18n->t('menu.search.advanced'); ?></a>
  46. </li>
  47. <?php if(!empty($_menuManage)) { ?>
  48. <li role="tab"><a href=""><?php echo $I18n->t('menu.manage'); ?>:</a></li>
  49. <?php foreach($_menuManage as $entry) { ?>
  50. <li role="tab" <?php if(!empty($_requestMode) && str_starts_with($entry['action'], $_requestMode)) echo 'aria-selected="true"'; ?>>
  51. <a href="index.php?p=<?php echo $entry['action']; ?>"><?php echo $I18n->t($entry['text']); ?></a>
  52. </li>
  53. <?php } ?>
  54. <?php } ?>
  55. </menu>
  56. <dialog id="navSearchDialog" class="window">
  57. <div class="title-bar">
  58. <div class="title-bar-text"><?php echo $I18n->t('menu.search'); ?></div>
  59. <div class="title-bar-controls">
  60. <button aria-label="Close" id="closeNavSearchDialog"></button>
  61. </div>
  62. </div>
  63. <div class="window-body">
  64. <form method="get" action="index.php">
  65. <?php
  66. if(isset($TemplateData['navSearchAction'])) {
  67. foreach($TemplateData['navSearchAction'] as $param=>$pValue) {
  68. echo '<input type="hidden" name="'.$param.'" value="'.$pValue.'" />';
  69. }
  70. }
  71. ?>
  72. <input type="search" placeholder="<?php echo $I18n->t('menu.search'); ?>" name="navSearch" autofocus>
  73. <input type="submit" value="<?php echo $I18n->t('menu.search'); ?>" />
  74. <p><a href="index.php?p=advancedsearch"><?php echo $I18n->t('menu.search.advanced'); ?></a></p>
  75. </form>
  76. </div>
  77. <div class="status-bar">
  78. <p class="status-bar-field"><?php echo $I18n->t('menu.search.enter'); ?></p>
  79. <p class="status-bar-field"><?php echo $I18n->t('menu.search.within'); ?></p>
  80. </div>
  81. </dialog>
  82. <script>
  83. const navSearchDialog = document.getElementById('navSearchDialog');
  84. const closeNavSearchDialog = document.getElementById('closeNavSearchDialog');
  85. function showNavSearch() {
  86. navSearchDialog.showModal();
  87. }
  88. closeNavSearchDialog.addEventListener('click', () => {
  89. navSearchDialog.close();
  90. });
  91. </script>