setting.global.customiser.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. global $myUser,$conf;
  3. if(!$myUser->can('customiser','configure')) throw new Exception("Vous n'avez pas la permission pour executer cette fonctionnalité",403);
  4. $themes = array(
  5. "default" => array(
  6. "label" => "Défaut",
  7. "folder" => "",
  8. "css-relative-url" => "",
  9. "path" => "",
  10. "checked" => $conf->get('core_theme') == "",
  11. "last-update" => 0
  12. )
  13. );
  14. foreach(glob(__DIR__.SLASH.'theme'.SLASH.'*'.SLASH.'app.json') as $themeFile){
  15. $path = dirname($themeFile);
  16. $theme = json_decode(file_get_contents($themeFile),true);
  17. $theme['folder'] = $path;
  18. $theme['css-relative-url'] = '/plugin/customiser/theme/'.basename($path).'/main.css';
  19. $theme['checked'] = $conf->get('core_theme') == $theme['css-relative-url'];
  20. $theme['last-update'] = filemtime($themeFile);
  21. $themes[] = $theme;
  22. }
  23. ?>
  24. <div class="row customiser">
  25. <div class="col-md-12">
  26. <br>
  27. <?php if($myUser->can('customiser', 'edit')) : ?>
  28. <div onclick="customiser_theme_save();" class="btn btn-success float-right"><i class="fas fa-check"></i> Enregistrer</div>
  29. <?php endif; ?>
  30. <h3>Choix du Thème</h3>
  31. <hr>
  32. <div class="row">
  33. <ul class="theme-cards">
  34. <?php foreach($themes as $theme):
  35. $cover = ROOT_URL.'/plugin/customiser/';
  36. if(isset($theme['cover'])){
  37. $cover .= 'theme/'.basename($theme['folder']).'/'. $theme['cover'];
  38. }else{
  39. $cover .= 'img/default-cover.jpg';
  40. }
  41. ?>
  42. <li >
  43. <div class="theme-card" data-css="<?php echo ROOT_URL.$theme['css-relative-url']; ?>" onclick="customiser_preview(this);">
  44. <label>
  45. <img src="<?php echo $cover; ?>">
  46. <h5 class="mb-2 mt-2"><input type="radio" data-type="radio" <?php echo $theme['checked']?"checked='checked'":""; ?> value="<?php echo $theme['css-relative-url']; ?>" name="selected-theme"> <?php echo $theme['label']; ?></h5>
  47. <span class="text-muted"><i class="far fa-meh-blank"></i> <?php echo isset($theme['author']) ? $theme['author']['name'] : 'Auteur inconnu'; ?> - <i class="far fa-calendar-alt"></i> <?php echo relative_time($theme['last-update']); ?></span>
  48. </label>
  49. </div>
  50. </li>
  51. <?php endforeach; ?>
  52. </ul>
  53. </div>
  54. </div>
  55. </div>