header.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php require_once __DIR__.DIRECTORY_SEPARATOR.'common.php';
  2. $scheme = define_url_scheme();
  3. $mediaRoot = define_media_root();
  4. if(!empty($myUser->preference('passwordTime')) && !$myUser->superadmin){
  5. $basepage = explode('?',$page);
  6. $basepage = $basepage[0];
  7. if(is_numeric($conf->get('password_delay')) && $basepage!="account.php" && ((time() - ($conf->get('password_delay') * 86400) > $myUser->preference('passwordTime'))))
  8. header('location: account.php?error=Votre mot de passe est trop vieux, veuillez le renouveller ci dessous.');
  9. }
  10. //Redirige la home si définie dans les settings
  11. if((strpos($page, 'index.php')!==false || $page==basename(ROOT_URL) || $page=='') && !isset($_['module']) && !empty($conf->get('home_page')) && (!isset($_['admin_login']) || empty($_['admin_login'])))
  12. header('location:'.$conf->get('home_page'));
  13. $cssModule = array();
  14. foreach(array('module','page','section') as $term){
  15. if(isset($_[$term])) $cssModule[] = preg_replace('/([^a-z])/i', '-',$term.'-'.$_[$term]);
  16. }
  17. if(empty($cssModule) && ($page=='index.php' || $page==basename(ROOT_URL) || $page=='' || preg_match("/index\.php\?admin_login=[0|1]/i", $page))) $cssModule[] = 'module-index';
  18. if(isset($_['embedded'])) $cssModule[]='embedded';
  19. if(!isset($_['admin_login']) && file_exists(File::dir().SLASH.'enabled.maintenance') && !$myUser->connected()){
  20. isset($_['error']) && !empty($_['error']) ? header('location: maintenance.php?error='.$_['error']) : header('Location: maintenance.php');
  21. exit();
  22. } else {
  23. $mainMenu = array();
  24. Plugin::callHook("menu_main", array(&$mainMenu));
  25. uasort($mainMenu , function($a,$b){return $a['sort']-$b['sort'];});
  26. $userMenu = array();
  27. if($myUser->connected()){
  28. Plugin::callHook("menu_user", array(&$userMenu));
  29. uasort($userMenu , function($a,$b){return $a['sort']-$b['sort'];});
  30. } ?>
  31. <!DOCTYPE html>
  32. <html class="html <?php echo implode(' ',$cssModule); ?>" lang="fr">
  33. <head>
  34. <meta charset="utf-8">
  35. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  36. <meta name="description" content="">
  37. <meta name="author" content="">
  38. <!-- Blocage du référencement -->
  39. <?php if(empty($conf->get('core_public_seo'))): ?>
  40. <meta name="robots" content="noindex">
  41. <?php endif; ?>
  42. <!-- Favicon -->
  43. <link rel="shortcut icon" type="image/png" href="media/core/public/favicon.png" />
  44. <?php $title = $myUser->connected() ? 'Accueil':'Connexion';
  45. foreach($mainMenu as $item)
  46. $title = (!empty($item['url']) && strpos($page, $item['url']) !== false) ? $item['label'] : $title;
  47. foreach($userMenu as $item)
  48. $title = (isset($item['url']) && strpos($page, $item['url']) !== false) ? $item['label'] : $title;
  49. ?>
  50. <title><?php echo PROGRAM_NAME.' - '.$title ?></title>
  51. <!-- Bootstrap core CSS -->
  52. <link href="<?php echo $mediaRoot ?>/css/bootstrap.min.css" rel="stylesheet">
  53. <!-- jQuery UI -->
  54. <link rel="stylesheet" href="<?php echo $mediaRoot ?>/css/jquery-ui.min.css">
  55. <link rel="stylesheet" href="<?php echo $mediaRoot ?>/css/jquery.timepicker.min.css">
  56. <!-- Font awesome -->
  57. <link rel="stylesheet" href="<?php echo $mediaRoot ?>/css/fontawesome-all.min.css">
  58. <!-- Trumbowyg -->
  59. <link href="<?php echo $mediaRoot ?>/css/trumbowyg.min.css" rel="stylesheet">
  60. <link href="<?php echo $mediaRoot ?>/css/trumbowyg.table.css" rel="stylesheet">
  61. <link href="<?php echo $mediaRoot ?>/css/trumbowyg.colors.css" rel="stylesheet">
  62. <link href="<?php echo $mediaRoot ?>/css/leaflet.css" rel="stylesheet">
  63. <link href="<?php echo $mediaRoot ?>/css/MarkerCluster.css" rel="stylesheet">
  64. <link href="<?php echo $mediaRoot ?>/css/MarkerCluster.Default.css" rel="stylesheet">
  65. <?php if(!$conf->get('offline_mode')): ?>
  66. <!-- Lato font-->
  67. <link href="https://fonts.googleapis.com/css?family=Lato:300,400" rel="stylesheet">
  68. <?php endif; ?>
  69. <!-- Custom styles for this template -->
  70. <link href="<?php echo $mediaRoot ?>/css/component.css?v=<?php echo $cacheVersion; ?>" rel="stylesheet">
  71. <link href="<?php echo $mediaRoot ?>/css/main.css?v=<?php echo $cacheVersion; ?>" rel="stylesheet">
  72. <!-- Plugin css files -->
  73. <?php echo Plugin::callCss($mediaRoot,$cacheVersion); ?>
  74. </head>
  75. <body>
  76. <!-- Fixed navbar -->
  77. <nav id="mainMenu" class="navbar navbar-expand-md navbar-dark fixed-top noPrint">
  78. <?php if ($myUser->connected()): ?>
  79. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
  80. <div class="menu">
  81. <div class="menu-icon">
  82. <div class="menu-line menu-line-1"></div>
  83. <div class="menu-line menu-line-2"></div>
  84. <div class="menu-line menu-line-3"></div>
  85. <div class="menu-line menu-line-4"></div>
  86. <div class="menu-line menu-line-5"></div>
  87. </div>
  88. </div>
  89. </button>
  90. <?php endif;
  91. $logo = 'media/core/public/logo.png';
  92. if($myFirm->id!=0 ){
  93. $firmLogo = $myFirm->logo('publicPath');
  94. if(!empty($firmLogo)) $logo = $firmLogo;
  95. }
  96. ?>
  97. <a class="navbar-brand" style="background-image: url(<?php echo $logo; ?>)" <?php echo $conf->get('logo_website_header') ? 'target="_blank" href="'.$conf->get('logo_website_header').'"' : 'href="index.php"'; ?>><?php echo $conf->get('show_application_name') ? PROGRAM_NAME : ''; ?></a>
  98. <div class="collapse navbar-collapse" id="navbarCollapse">
  99. <ul class="navbar-nav navbar-main">
  100. <?php foreach($mainMenu as $item): ?>
  101. <?php if (isset($item['label']) && $item['label'] == 'Réglages') $page = basename($_SERVER['PHP_SELF']);
  102. $classes = isset($item['classes'])? $item['classes']: '';
  103. if(isset($item['url'])
  104. && ((!empty($item['url'])
  105. && strpos($page, $item['url']) !== false
  106. && $item['url'] != 'index.php') || $page == $item['url'])
  107. || (isset($item['active']) && $item['active'] ==true)
  108. ){
  109. $classes .= ' active';
  110. }
  111. ?>
  112. <li data-id="<?php echo isset($item['id'])?$item['id']:''; ?>" class="nav-item <?php echo $classes; ?> ">
  113. <a class="nav-link"
  114. title="<?php echo isset($item['title'])?$item['title']:''; ?>"
  115. target="<?php echo isset($item['target'])?$item['target']:''; ?>"
  116. onclick="<?php echo isset($item['onclick'])?$item['onclick']:''; ?>"
  117. <?php echo isset($item['url'])? 'href="'.$item['url'].'"':''; ?>>
  118. <?php echo (isset($item['icon'])?'<i class="'.$item['icon'].'"></i> ':'').'<span>'.(isset($item['label'])?$item['label']:'').'</span>'; ?>
  119. <?php echo isset($item['html'])? $item['html']:''; ?>
  120. </a>
  121. </li>
  122. <?php endforeach; ?>
  123. </ul>
  124. <?php Plugin::callHook("header", array()); ?>
  125. <div id="loginHeader" class="ml-auto d-flex text-right" data-firm="<?php echo $myFirm->id; ?>" data-connected="<?php echo $myUser->login; ?>">
  126. <?php Plugin::callHook("login_header", array());
  127. if(empty($conf->get('hide_header_login')) || $myUser->connected() || (!empty($conf->get('hide_header_login')) && ($page!='index.php' || ($page!='' && $page!='index.php')))): ?>
  128. <!-- User connecté -->
  129. <?php if($myUser->connected()): ?>
  130. <div class="dropdown user-dropdown-menu ml-1">
  131. <button class="btn btn-dark dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  132. <img src="<?php echo $myUser->getAvatar(); ?>" class="avatar-mini avatar-rounded avatar-login" title="<?php echo htmlentities($myUser->fullName()); ?>">
  133. </button>
  134. <div class="dropdown-menu dropdown-menu-right pb-1" aria-labelledby="dropdownMenuButton">
  135. <div class="font-weight-bold text-primary p-2 text-center user-fullname"><?php echo $myUser->fullName(); ?></div>
  136. <?php foreach($userMenu as $item): ?>
  137. <?php if(isset($item['custom'])):
  138. echo $item['custom'];
  139. else: ?>
  140. <a class="dropdown-item user-menu-item px-3" href="<?php echo $item['url']; ?>">
  141. <?php echo (isset($item['icon'])?'<i class="fa-fw '.$item['icon'].'"></i> ':'').$item['label']; ?>
  142. </a>
  143. <?php endif; ?>
  144. <?php endforeach; ?>
  145. </div>
  146. </div>
  147. <!-- User non connecté -->
  148. <?php else: ?>
  149. <div class="dropdown user-dropdown-menu ml-1" id="login-dropdown">
  150. <button class="btn btn-dark dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Connexion</button>
  151. <div class="dropdown-menu dropdown-menu-right pb-1" aria-labelledby="dropdownMenuButton">
  152. <div class="dropdown-item login-item">
  153. <?php require_once(__DIR__.SLASH.'login.php'); ?>
  154. </div>
  155. </div>
  156. </div>
  157. <?php endif; ?>
  158. <?php endif; ?>
  159. </div>
  160. </div>
  161. </nav>
  162. <!-- Begin page content -->
  163. <div class="container-fluid">
  164. <?php }