header.php 8.6 KB

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