videos.all.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. $videos = fichier::getAll();
  3. ?>
  4. <nav aria-label="breadcrumb" class="ariane">
  5. <ol class="breadcrumb" style="border-radius: 0 0 5px 5px; padding:5px 10px;">
  6. <li class="breadcrumb-item">Toutes les vidéos</li>
  7. </ol>
  8. </nav>
  9. <div class="container" style="margin-top:0;">
  10. <div class="row mb-10">
  11. <div class="col-md-6">
  12. <input type="text" id="searchTitle" class="form-control" placeholder="Rechercher par titre...">
  13. </div>
  14. <div class="col-md-2">
  15. <select id="searchMonth" class="form-control">
  16. <option value="">Mois</option>
  17. <option value="01">01 - Janvier</option>
  18. <option value="02">02 - Février</option>
  19. <option value="03">03 - Mars</option>
  20. <option value="04">04 - Avril</option>
  21. <option value="05">05 - Mai</option>
  22. <option value="06">06 - Juin</option>
  23. <option value="07">07 - Juillet</option>
  24. <option value="08">08 - Août</option>
  25. <option value="09">09 - Septembre</option>
  26. <option value="10">10 - Octobre</option>
  27. <option value="11">11 - Novembre</option>
  28. <option value="12">12 - Décembre</option>
  29. </select>
  30. </div>
  31. <div class="col-md-2">
  32. <input type="number" id="searchYear" class="form-control" placeholder="Année" min="1900" max="2100">
  33. </div>
  34. <div class="col-md-2 text-end">
  35. <button id="resetButton" class="btn btn-secondary">Réinitialiser</button>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="container" style="margin-top:-30px;">
  40. <?php
  41. foreach ($videos as $video) {
  42. fichier::generatePreview($video["md5"]);
  43. echo '<div class="video-container big_topic" id="topic-big-' . $video["id"] . '">
  44. <div class="video-content">
  45. <img src="https://' . DOMAIN_MEDIAS . "/preview/" . $video["hash"] . '" alt="Preview" class="video-preview" style="width:350; height:auto;">
  46. <div class="video-details">
  47. <div class="actions">
  48. <div class="btn-group">
  49. <button type="button" class="btn btn-outline-primary" onclick="window.open(\'/edit/' . $video["hash"] . '\', \'_self\')">
  50. <i class="bi bi-pencil-square"></i>
  51. </button>
  52. </div>
  53. </div>
  54. <div style="margin-top:-35px">
  55. <div class="video-title">' . $video["title"] . '</div>
  56. <div class="input-group mb-3">
  57. <div class="input-group-prepend">
  58. <span class="input-group-text">Lien</span>
  59. </div>
  60. <input type="text" class="form-control" value="https://' . DOMAIN_MEDIAS . "/video/" . $video["hash"] . '" style="background-color: #fff !important;" readonly>
  61. </div>
  62. <div class="video-info" style="text-align: right;">
  63. Date : ' . $video["dateEvent"] . ' | Durée : ' . core::formatDuration($video["duration"]) . ' | Statut : ' . ($video["active"] == 1 ? "<span style='color:green'>Vidéo en ligne</span>" : "<span style='color:red'>Vidéo suspendue</span>") . '
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. ';
  70. echo '<div class="video-container little_topic" id="topic-little-' . $video["id"] . '" onclick="showTopic(' . $video["id"] . ')">
  71. <div class="video-content">
  72. <div class="video-details">
  73. <div>
  74. <div class="video-title title-little">' . $video["title"] . '</div>
  75. <div class="video-info">
  76. Date : ' . $video["dateEvent"] . ' | Durée : ' . core::formatDuration($video["duration"]) . ' | Statut : ' . ($video["active"] == 1 ? "<span style='color:green'>Vidéo en ligne</span>" : "<span style='color:red'>Vidéo suspendue</span>") . '
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. ';
  83. }
  84. ?>
  85. </div>
  86. <script>
  87. document.getElementById('searchTitle').addEventListener('input', filterVideos);
  88. document.getElementById('searchYear').addEventListener('input', filterVideos);
  89. document.getElementById('searchMonth').addEventListener('change', filterVideos);
  90. document.getElementById('resetButton').addEventListener('click', resetFilters);
  91. function filterVideos() {
  92. var searchTitle = document.getElementById('searchTitle').value.toLowerCase();
  93. var searchYear = document.getElementById('searchYear').value;
  94. var searchMonth = document.getElementById('searchMonth').value;
  95. var videos = document.querySelectorAll('.video-container');
  96. videos.forEach(function(video) {
  97. var title = video.querySelector('.video-title').textContent.toLowerCase();
  98. var dateText = video.querySelector('.video-info').textContent.toLowerCase();
  99. // Extraire la date (format attendu : 'Date : YYYY-MM-DD')
  100. var videoDateMatch = dateText.match(/date\s*:\s*(\d{4})-(\d{2})/i); // Extrait YYYY-MM
  101. var videoYear = videoDateMatch ? videoDateMatch[1] : '';
  102. var videoMonth = videoDateMatch ? videoDateMatch[2] : '';
  103. // Vérifier si le titre, l'année et le mois correspondent à la recherche
  104. var titleMatch = title.includes(searchTitle) || searchTitle === '';
  105. var yearMatch = videoYear === searchYear || searchYear === '';
  106. var monthMatch = videoMonth === searchMonth || searchMonth === '';
  107. if (titleMatch && yearMatch && monthMatch) {
  108. video.style.display = ''; // Afficher la vidéo si elle correspond aux critères
  109. } else {
  110. video.style.display = 'none'; // Masquer sinon
  111. }
  112. });
  113. }
  114. function resetFilters() {
  115. document.getElementById('searchTitle').value = '';
  116. document.getElementById('searchYear').value = '';
  117. document.getElementById('searchMonth').value = '';
  118. filterVideos(); // Réinitialiser le filtre
  119. }
  120. function showTopic(id){
  121. $(".little_topic").show();
  122. $(".big_topic").hide();
  123. filterVideos();
  124. $("#topic-little-" + id).hide();
  125. $("#topic-big-" + id).show();
  126. }
  127. </script>