PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/vues/video.php

https://github.com/cyprieng/MediaStreamer
PHP | 80 lines | 58 code | 7 blank | 15 comment | 6 complexity | 765ee7d021965d0c8971c4ab288fd7bd MD5 | raw file
  1. <div class="container-fluid">
  2. <div class="row-fluid">
  3. <div class="span4" id="mediaList">
  4. <?php
  5. /*
  6. Affiche l'arboresence
  7. @params arborescence Array d'arborescence
  8. @return Affiche une mise en forme l'arborescence
  9. @see modele/home.php
  10. */
  11. function showArborescence($arborescence){
  12. //On affiche le nom du dossier
  13. if(!isset($arborescence[0])) return;
  14. echo '<ul><span class="addToLibrary"><i class="icon-folder-close"></i><a href="#">'.substr(strrchr($arborescence[0],'/'),1).'</a></span><br/>';
  15. unset($arborescence[0]);
  16. foreach($arborescence as $arbo){
  17. if(is_array($arbo)){ //C'est un dossier => on le parcours
  18. showArborescence($arbo);
  19. }
  20. else{ //Fichier => on l'affiche
  21. $info = pathinfo($arbo);
  22. $file_name = basename($arbo,'.'.$info['extension']);
  23. echo '<li><i class="icon-file"></i><a href="'.MODELE_PATH.'media.php?file='.urlencode($arbo).'&u='.$_SESSION['name'].'&p='.$_SESSION['pass'].'" onclick="$(\'#videoPlayer embed\').attr(\'target\', \''.MODELE_PATH.'media.php?file='.urlencode($arbo).'&u='.$_SESSION['name'].'&p='.$_SESSION['pass'].'\');ht=$(\'#videoPlayer\').html();$(\'#videoPlayer\').html(ht);return false;">'.$file_name.'</a></li>';
  24. }
  25. }
  26. echo '</ul>';
  27. }
  28. foreach($arborescence as $arbo){
  29. showArborescence($arbo); //On affiche l'arborescence
  30. }
  31. ?>
  32. </div>
  33. <div class="span8">
  34. <div class="separator"></div>
  35. <div id="videoPlayer">
  36. <embed type="application/x-vlc-plugin" name="video1" autoplay="yes" loop="no" width="100%" height="80%" target="" />
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <script type="text/javascript">
  42. window.onload=function(){
  43. //On affiche uniquement la racine
  44. $('#mediaList ul').css('display', 'none');
  45. $('#mediaList li').css('display', 'none');
  46. $('#mediaList > ul').css('display', '');
  47. /*
  48. Cache ou affiche le contenu d'un dossier
  49. @params element Dossier cliqué
  50. */
  51. function toggleChild(element){
  52. if(element.children('ul').css('display') == 'none' || element.children('li').css('display') == 'none'){
  53. //On affiche le contenu
  54. element.children('.addToLibrary').children('.icon-folder-close').attr('class', 'icon-folder-open');
  55. element.children('ul').css('display', '');
  56. element.children('li').css('display', '');
  57. }
  58. else{
  59. //On cache le contenu
  60. element.children('.addToLibrary').children('.icon-folder-open').attr('class', 'icon-folder-close');
  61. element.children('ul').css('display', 'none');
  62. element.children('li').css('display', 'none');
  63. }
  64. }
  65. //On attache les évènement aux dossier
  66. $('#mediaList .addToLibrary').each(function(){
  67. $(this).click(function(){
  68. toggleChild($(this).parent('ul'));
  69. return false;
  70. });
  71. });
  72. };
  73. </script>