setting.global.navigation.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. global $myUser,$conf;
  3. if(!$myUser->connected()) throw new Exception("Vous devez être connecté pour accéder à cette fonctionnalité",401);
  4. require_once(__DIR__.SLASH.'MenuItem.class.php');
  5. if($conf->get("navigation_allow_custom_menu")==0 && !$myUser->can('navigation','configure')) throw new Exception("Vous n'avez pas la permission d'afficher cette page", 403);
  6. ?>
  7. <div class="row">
  8. <div class="col-md-12">
  9. <br>
  10. <div onclick="navigation_setting_save();" class="btn btn-success right"><i class="fas fa-check"></i> Enregistrer</div>
  11. <h3>Réglages Navigation</h3>
  12. <hr>
  13. </div>
  14. <div class="col-md-12 navigation-tree">
  15. <br>
  16. <h3>Arborescence du menu
  17. <select class="navigation-menu-selector text-primary" id="navigation-menu" onchange="navigation_tree_search()">
  18. <?php
  19. $filters = array('menu'=>'0');
  20. if($myUser->can('navigation','configure')){
  21. //l'admin menu voit ses menu et les menu non attaché a un user
  22. $filters['user:IN'] = ','.$myUser->login;
  23. }else{
  24. //les non admins menu ne voient que leurs menus
  25. $filters['user'] = $myUser->login;
  26. }
  27. $menus = MenuItem::loadAll($filters,array('label'));
  28. //Récuperation du menu raccourcis du user
  29. $shortcutMenu = MenuItem::load(array('user'=>$myUser->login,'slug'=>'shortcut-menu'));
  30. //On créé un menu raccourcis pour l'utilisateur courant si celui ci n'existe pas
  31. if(!$shortcutMenu){
  32. $shortcutMenu = new MenuItem();
  33. $shortcutMenu->label = 'Menu raccourcis';
  34. $shortcutMenu->slug = 'shortcut-menu';
  35. $shortcutMenu->user = $myUser->login;
  36. $shortcutMenu->menu = '0';
  37. $shortcutMenu->save();
  38. $menus[] = $shortcutMenu;
  39. }
  40. foreach($menus as $menu): ?>
  41. <option <?php echo (isset($_['menu']) && $_['menu']=="mine" && $shortcutMenu->id == $menu->id ? 'selected="selected"': ''); ?> value="<?php echo $menu->id ?>"><?php echo $menu->label ?></option>
  42. <?php endforeach; ?>
  43. </select>
  44. </h3>
  45. <hr>
  46. <div onclick="navigation_tree_new();" class="btn btn-info"><i class="fas fa-plus"></i> Nouvel élément</div>
  47. <div class="btn btn-light" data-toggle="modal" data-target="#navigation-page-modal"><i class="fas fa-plus"></i> Ajouter une page existante</div>
  48. <ul class="navigation-tree-list">
  49. <li class="navigation-line {{class}} hidden" data-id="{{id}}" >
  50. <div class="navigation-item">
  51. <div class="navigation-item-header">
  52. <span class="navigation-item-icon"><i class="{{icon}}"></i></span>
  53. <h1 class="navigation-item-label">{{label}}</h1>
  54. <small class="navigation-item-url">{{#url}}- {{url}}{{/url}}</small>
  55. <h3 class="navigation-item-type"><span>{{target.label}}</span> <i onclick="navigation_tree_toggle(this)" title="Afficher/Cacher" class="navigation-item-toggle fas fa-angle-right"></i></h3>
  56. </div>
  57. <div class="navigation-item-form hidden">
  58. <h4>Titre</h4>
  59. <div class="input-group mb-3">
  60. <input type="text" class="item-icon" data-type="icon" value="{{icon}}">
  61. <input type="text" class="form-control item-label" value="{{label}}" placeholder="Libellé du lien">
  62. </div>
  63. <h4>Adresse <small class="text-muted">- Optionnel</small></h4>
  64. <div class="input-group mb-3">
  65. <input type="text" class="form-control item-url" value="{{url}}" placeholder="Adresse du lien">
  66. </div>
  67. <h4>Type d'ouverture <small class="text-muted">- Optionnel</small></h4>
  68. <!-- la balise form est obligatoire pour contrer le bug de jquery ui sortable, ne pas enlever -->
  69. <form>
  70. <?php foreach (MenuItem::target() as $slug => $target): ?>
  71. <label><input type="radio" name="item-target" value="<?php echo $slug; ?>" data-value="{{target.slug}}"> <i class="<?php echo $target['icon']; ?>"></i> <?php echo $target['label']; ?></label>
  72. <?php endforeach; ?>
  73. </form>
  74. <h4>Visibilité <small class="text-muted">- Laisser vide pour rendre public</small></h4>
  75. <input type="text" class="item-visibility form-control" data-type="user-tpl" data-types="rank,user" data-multiple="true" value="{{visibility}}">
  76. <i title="Supprimer" class="navigation-item-delete far fa-trash-alt" onclick="navigation_tree_remove(this)"></i>
  77. </div>
  78. </div>
  79. <ul></ul>
  80. </li>
  81. </ul>
  82. </div>
  83. <?php if($myUser->can('navigation','configure')): ?>
  84. <div class="col-md-12 mt-3">
  85. <h3>Options générales</h3>
  86. <?php echo Configuration::html('navigation'); ?>
  87. </div>
  88. <?php endif; ?>
  89. </div>
  90. <!-- Modale page interne -->
  91. <div class="modal fade" id="navigation-page-modal" tabindex="-1" role="dialog" aria-hidden="true">
  92. <div class="modal-dialog" role="document">
  93. <div class="modal-content">
  94. <div class="modal-header">
  95. <h5 class="modal-title" id="exampleModalLabel">Ajouter une page</h5>
  96. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  97. <span aria-hidden="true">&times;</span>
  98. </button>
  99. </div>
  100. <div class="modal-body">
  101. <ul class="list-group">
  102. <?php
  103. $pages = array();
  104. Plugin::callHook("menu_main", array(&$pages));
  105. uasort ($pages , function($a,$b){return $a['sort']>$b['sort']?1:-1;});
  106. foreach($pages as $page):
  107. $icon = isset($page['icon'])? $page['icon'] : 'far fa-bookmark';
  108. ?>
  109. <li class="list-group-item d-flex justify-content-between align-items-center" data-label="<?php echo $page['label']; ?>" data-icon="<?php echo $page['icon']; ?>" data-url="<?php echo $page['url']; ?>">
  110. <div>
  111. <i class="<?php echo $icon; ?>"></i> <?php echo $page['label']; ?> <a class="text-muted" href="<?php echo $page['url']; ?>"> -<?php echo $page['url']; ?></a>
  112. </div>
  113. <span class="badge badge-success pointer" title="Ajouter au menu" onclick="navigation_tree_new(this);"><i class="fas fa-plus"></i></span>
  114. </li>
  115. <?php endforeach; ?>
  116. </ul>
  117. </div>
  118. <div class="modal-footer">
  119. <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
  120. </div>
  121. </div>
  122. </div>
  123. </div>