setting.global.navigation.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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>
  15. <div class="row">
  16. <div class="col-md-12" id="notification_preference">
  17. <div class="tab-container mb-0 noPrint">
  18. <ul class="nav nav-tabs" role="tablist">
  19. <li class="nav-item"><a data-toggle="tab" class="nav-link active" href="#tab-menus" aria-controls="tab-menus" aria-selected="false">Menus</a></li>
  20. <?php if($myUser->can('navigation','configure')): ?>
  21. <li class="nav-item"><a data-toggle="tab" class="nav-link" href="#tab-settings" aria-controls="tab-settings" aria-selected="false">Paramètres</a></li>
  22. <?php endif; ?>
  23. </ul>
  24. </div>
  25. <div class="tab-content">
  26. <!-- Onglet Menus -->
  27. <div class="tab-pane show active in" id="tab-menus" role="tabpanel" aria-labelledby="tab-menus"><br>
  28. <div class="col-md-12 navigation-tree p-2">
  29. <h3 class="pt-1 d-inline-block m-0">Arborescence du menu
  30. <select class="navigation-menu-selector text-primary" id="navigation-menu" onchange="navigation_tree_search()">
  31. <?php
  32. $filters = array('menu'=>'0');
  33. if($myUser->can('navigation','configure')){
  34. //l'admin menu voit ses menu et les menu non attaché a un user
  35. $filters['user:IN'] = ','.$myUser->login;
  36. }else{
  37. //les non admins menu ne voient que leurs menus
  38. $filters['user'] = $myUser->login;
  39. }
  40. $menus = MenuItem::loadAll($filters,array('label'));
  41. //Récuperation du menu raccourcis du user
  42. $shortcutMenu = MenuItem::load(array('user'=>$myUser->login,'slug'=>MenuItem::MENU_SHORTCUT));
  43. //On créé un menu raccourcis pour l'utilisateur courant si celui ci n'existe pas
  44. if(!$shortcutMenu){
  45. $shortcutMenu = new MenuItem();
  46. $shortcutMenu->label = 'Menu raccourcis';
  47. $shortcutMenu->slug = MenuItem::MENU_SHORTCUT;
  48. $shortcutMenu->user = $myUser->login;
  49. $shortcutMenu->menu = '0';
  50. $shortcutMenu->save();
  51. $menus[] = $shortcutMenu;
  52. }
  53. foreach($menus as $menu): ?>
  54. <option <?php echo (isset($_['menu']) && $_['menu']=="mine" && $shortcutMenu->id == $menu->id ? 'selected="selected"': ''); ?> value="<?php echo $menu->id; ?>" data-slug="<?php echo $menu->slug; ?>"><?php echo $menu->label ?></option>
  55. <?php endforeach; ?>
  56. </select>
  57. </h3>
  58. <div class="d-inline-block float-right">
  59. <div onclick="navigation_tree_new();" class="btn btn-info"><i class="fas fa-plus"></i> Nouvel élément</div>
  60. <div class="btn btn-light" data-toggle="modal" data-target="#navigation-page-modal"><i class="fas fa-plus"></i> Ajouter une page existante</div>
  61. </div>
  62. <hr>
  63. <ul class="navigation-tree-list">
  64. <li class="navigation-line {{class}} hidden" data-id="{{id}}" >
  65. <div class="navigation-item">
  66. <div class="navigation-item-header">
  67. <span class="navigation-item-icon"><i class="{{icon}} fa-fw"></i></span>
  68. <h1 class="navigation-item-label">{{label}}</h1>
  69. <h3 class="navigation-item-type">
  70. <span>{{target.label}}</span>
  71. <i onclick="navigation_tree_toggle(this)" title="Afficher/Cacher" class="navigation-item-toggle fas fa-angle-right"></i>
  72. </h3>
  73. <small class="navigation-item-url">{{#url}}- {{url}}{{/url}}</small>
  74. </div>
  75. <div class="navigation-item-form row hidden">
  76. <div class="col-md-3">
  77. <h4>Titre :</h4>
  78. <div class="input-group mb-1">
  79. <input type="text" class="item-icon" data-type="icon" value="{{icon}}">
  80. <input type="text" class="form-control item-label" value="{{label}}" placeholder="Libellé du lien">
  81. </div>
  82. </div>
  83. <div class="col-md-9">
  84. <h4>Adresse :<small class="text-muted"> - Optionnel</small></h4>
  85. <div class="input-group mb-1">
  86. <input type="text" class="form-control item-url" value="{{url}}" placeholder="Adresse du lien">
  87. </div>
  88. </div>
  89. {{^shortcut}}
  90. <div class="col-md-3">
  91. <h4>Visibilité :<small class="text-muted"> - Laisser vide pour rendre public</small></h4>
  92. <input type="text" class="item-visibility form-control" data-type="user-tpl" data-types="rank,user" data-multiple="true" value="{{visibility}}">
  93. </div>
  94. {{/shortcut}}
  95. <div class="{{#shortcut}}col-md-12{{/shortcut}}{{^shortcut}}col-md-7{{/shortcut}}">
  96. <h4>Type d'ouverture :<small class="text-muted"> - Optionnel</small></h4>
  97. <!-- la balise form est obligatoire pour contrer le bug de jquery ui sortable, ne pas enlever -->
  98. <form>
  99. <?php foreach (MenuItem::target() as $slug => $target): ?>
  100. <label class="m-0"><input data-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>
  101. <?php endforeach; ?>
  102. </form>
  103. </div>
  104. <div class="col-md-12">
  105. <div class="navigation-item-delete text-danger btn btn-light float-right p-1" onclick="navigation_tree_remove(this)" title="Supprimer l'élément de menu"><i class="far fa-trash-alt"></i> Supprimer</div>
  106. <div class="clear"></div>
  107. </div>
  108. </div>
  109. </div>
  110. </li>
  111. </ul>
  112. </div>
  113. </div>
  114. <?php if($myUser->can('navigation','configure')): ?>
  115. <div class="tab-pane" id="tab-settings" role="tabpanel" aria-labelledby="tab-settings"><br>
  116. <div class="">
  117. <?php echo Configuration::html('navigation'); ?>
  118. </div>
  119. </div>
  120. <?php endif; ?>
  121. </div>
  122. </div>
  123. </div>
  124. <!-- Modal page interne -->
  125. <div class="modal fade" id="navigation-page-modal" tabindex="-1" role="dialog" aria-hidden="true">
  126. <div class="modal-dialog" role="document">
  127. <div class="modal-content">
  128. <div class="modal-header">
  129. <h5 class="modal-title" id="exampleModalLabel">Pages existantes :</h5>
  130. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  131. <span aria-hidden="true">&times;</span>
  132. </button>
  133. </div>
  134. <div class="modal-body">
  135. <ul class="list-group">
  136. <?php
  137. $pages = array();
  138. Plugin::callHook("menu_main", array(&$pages));
  139. uasort ($pages , function($a,$b){return $a['sort']>$b['sort']?1:-1;});
  140. foreach($pages as $page):
  141. $icon = isset($page['icon'])? $page['icon'] : 'far fa-bookmark';
  142. ?>
  143. <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']; ?>">
  144. <div>
  145. <i class="<?php echo $icon; ?>"></i> <?php echo $page['label']; ?> <a class="text-muted" href="<?php echo $page['url']; ?>"> -<?php echo $page['url']; ?></a>
  146. </div>
  147. <span class="btn btn-squarred btn-mini btn-success" title="Ajouter la page <?php echo $page['label']; ?> au menu" onclick="navigation_tree_new(this);"><i class="fas fa-plus"></i></span>
  148. </li>
  149. <?php endforeach; ?>
  150. </ul>
  151. </div>
  152. <div class="modal-footer">
  153. <button type="button" class="btn btn-light" data-dismiss="modal">Fermer</button>
  154. </div>
  155. </div>
  156. </div>
  157. </div>