setting.update.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. global $myUser;
  3. if($myUser->login=='') throw new Exception("Permissions insuffisantes", 403);
  4. ?>
  5. <div class="row">
  6. <div class="col-md-12">
  7. <?php
  8. //À voir pour le rendre dynamique au
  9. //lieu d'avoir les 30 dernières modifs
  10. $stream = shell_exec('git log -30 --pretty=~~~%ct---%B~~~');
  11. $commits = explode('~~~',$stream);
  12. ?>
  13. <h3>30 Dernières modifications :</h3>
  14. <hr/>
  15. <div class="row">
  16. <div class="col-md-12">
  17. <ul class="update-timeline">
  18. <?php
  19. $i=0;
  20. foreach($commits as $commit):
  21. $infos = explode('---',$commit);
  22. if(count($infos)<2) continue;
  23. $i++;
  24. list($time,$message) = $infos;
  25. $icons = array();
  26. $colors = array();
  27. $tags = array();
  28. if(preg_match('/Merge branch/i', $message)){
  29. $icons[]= 'fas fa-code-branch';
  30. $colors[]= 'info';
  31. $message = str_replace(array('Merge branch',' of ','Conflicts'),array('Fusion de branche',' de ','Conflits'),$message);
  32. $tags['merge'] = 1;
  33. }
  34. $message = preg_replace('/(^|\n)-[\s\t]*([^:-]*)[\s\t]*:/iU', '$1<span class="update-commit-module mt-2"><i class="far fa-bookmark"></i> $2</span>', $message);
  35. $message = preg_replace_callback('/#([^\s]*)(\s|$)/iU', function($matches) use(&$tags){
  36. $tag = trim(strtolower($matches[1]));
  37. if($tag=='') return;
  38. if(!isset($tags[$tag])) $tags[$tag] = 0;
  39. $tags[$tag]++;
  40. return $matches[2];
  41. }, $message);
  42. if(isset($tags['feature'])){
  43. $icons[] = 'fas fa-plus-circle';
  44. $colors[] = 'success';
  45. }
  46. if(isset($tags['bug'])){
  47. $icons[] = 'fas fa-bug';
  48. $colors[] = 'danger';
  49. }
  50. if(preg_match('/refactor|rework/i', $message)){
  51. $icons[] = 'fas fa-sync';
  52. $colors[] = 'warning';
  53. }
  54. if(count($icons)==0) $icons[] ='fas fa-pencil-alt';
  55. ?>
  56. <li <?php echo $i%2==0?'class="update-timeline-inverted"':'' ?>>
  57. <div class="update-timeline-badge <?php echo count($colors)==1?$colors[0]:''; ?>" style="font-size: <?php echo 1.4/count($icons); ?>rem;<?php echo count($colors)>1?'background-color:#e83e8c;':''; ?>">
  58. <?php foreach($icons as $icon): ?>
  59. <i class="<?php echo $icon; ?>" style="font-size: <?php echo 1.4/count($icons); ?>rem"></i>
  60. <?php endforeach; ?>
  61. </div>
  62. <div class="update-timeline-panel">
  63. <div class="update-timeline-heading">
  64. <p><small class="text-muted"><i class="far fa-clock"></i> <?php echo relative_time($time); ?></small></p>
  65. </div>
  66. <div class="update-timeline-body">
  67. <p><?php echo nl2br($message); ?></p>
  68. <?php foreach($tags as $tag=>$count): ?>
  69. <span class="update-commit-tag"><i class="fas fa-tag"></i> <?php echo $tag ?><?php echo $count > 1 ? ' ('.$count.')':'' ?></span>
  70. <?php endforeach; ?>
  71. </div>
  72. </div>
  73. </li>
  74. <?php endforeach; ?>
  75. </ul>
  76. </div>
  77. </div>
  78. <br>
  79. </div>
  80. </div>