index.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. $l = OC_L10N::get('gallery');
  3. ?>
  4. <style>
  5. div.gallery_div {position:relative; display: inline-block; height: 152px; width: 150px; margin: 5px;}
  6. div.miniature_border {position:absolute; height: 150px; -webkit-transition-duration: .2s; background-position: 50%;}
  7. div.line {display:inline-block; border: 0; width: auto; height: 160px}
  8. div.gallery_div img{position:absolute; top: 1; left: 0; -webkit-transition-duration: 0.3s; height:150px; width: auto;}
  9. div.gallery_div img.shrinker {width:80px !important;}
  10. div.title { opacity: 0; text-align: center; vertical-align: middle; font-family: Arial; font-size: 12px; border: 0; position: absolute; text-overflow: ellipsis; bottom: 20px; left:5px; height:auto; padding: 5px; width: 140px; background-color: black; color: white; -webkit-transition: opacity 0.5s; z-index:1000; border-radius: 7px}
  11. div.visible { opacity: 0.8;}
  12. </style>
  13. <script type="text/javascript">
  14. var root = "<?php echo !empty($_GET['root']) ? $_GET['root'] : '/'; ?>";
  15. function t(element) {
  16. $('div', element).each(function(index, elem) {
  17. if ($(elem).hasClass('title')) {
  18. $(elem).addClass('visible');
  19. } else {
  20. $(elem).css('margin-top', Math.floor(30-(Math.random()*60)) + 'px')
  21. .css('margin-left', Math.floor(30-(Math.random()*60))+ 'px')
  22. .css('z-index', '999');
  23. }
  24. });
  25. }
  26. function o(element) {
  27. $('div', element).each(function(index, elem) {
  28. if ($(elem).hasClass('title')) {
  29. $(elem).removeClass('visible');
  30. } else {
  31. $(elem).css('margin-top', Math.floor(5-(Math.random()*10)) + 'px')
  32. .css('margin-left', Math.floor(5-(Math.random()*10))+ 'px')
  33. .css('z-index', '3');
  34. }
  35. });
  36. }
  37. function openNewGal(album_name) {
  38. root = root + album_name + "/";
  39. var url = window.location.toString().replace(window.location.search, '');
  40. url = url + "?app=gallery&root="+encodeURIComponent(root);
  41. window.location = url;
  42. }
  43. $(document).ready(function() {
  44. $("a[rel=images]").fancybox({
  45. 'titlePosition': 'inside'
  46. });
  47. });
  48. </script>
  49. <?php
  50. include('apps/gallery/lib/tiles.php');
  51. $root = empty($_GET['root'])?'/':$_GET['root'];
  52. $images = \OC_FileCache::searchByMime('image', null, '/'.\OCP\USER::getUser().'/files'.$root);
  53. sort($images);
  54. $arr = array();
  55. $tl = new \OC\Pictures\TilesLine();
  56. $ts = new \OC\Pictures\TileStack(array(), '');
  57. $previous_element = $images[0];
  58. for($i = 0; $i < count($images); $i++) {
  59. $prev_dir_arr = explode('/', $previous_element);
  60. $dir_arr = explode('/', $images[$i]);
  61. if (count($dir_arr)==1) {
  62. $tl->addTile(new \OC\Pictures\TileSingle($root.$images[$i]));
  63. continue;
  64. }
  65. if (strcmp($prev_dir_arr[0], $dir_arr[0])!=0) {
  66. $tl->addTile(new \OC\Pictures\TileStack($arr, $prev_dir_arr[0]));
  67. $arr = array();
  68. }
  69. $arr[] = $root.$images[$i];
  70. $previous_element = $images[$i];
  71. }
  72. $dir_arr = explode('/', $previous_element);
  73. if (count($images)>1) {
  74. if (count($dir_arr)==0) {
  75. $tl->addTile(new \OC\Pictures\TileSingle($previous_element));
  76. } else if (count($dir_arr) && $ts->getCount() == 0){
  77. $ts = new \OC\Pictures\TileStack(array($root.$previous_element), $dir_arr[0]);
  78. } else {
  79. $arr[] = $previous_element;
  80. $ts->addTile($arr);
  81. }
  82. }
  83. if ($ts->getCount() != 0) {
  84. $tl->addTile($ts);
  85. }
  86. echo $tl->get();
  87. ?>