tiles_test.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. $l = OC_L10N::get('gallery');
  3. ?>
  4. <style>
  5. div.gallery_div {position:relative; display: inline-block; height: 202px; width: 200px; margin: 5px;}
  6. div.miniature_border {position:absolute; height: 200px; -webkit-transition-duration: .2s; background-position: 50%;}
  7. div.line {display:inline-block; border: 0; width: auto; height: 210px}
  8. div.gallery_div img{position:absolute; top: 1; left: 0; -webkit-transition-duration: 0.3s; height:200px; 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:10px; height:auto; padding: 5px; width: 170px; 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 src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
  14. <script type="text/javascript">
  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. </script>
  38. <?php
  39. include('apps/gallery/lib/tiles.php');
  40. $root = empty($_GET['root'])?'/':$_GET['root'];
  41. $images = \OC_FileCache::searchByMime('image', null, '/bartek/files'.$root);
  42. sort($images);
  43. $arr = array();
  44. $tl = new \OC\Pictures\TilesLine();
  45. $ts = new \OC\Pictures\TileStack(array(), '');
  46. $previous_element = $images[0];
  47. for($i = 0; $i < count($images); $i++) {
  48. error_log($images[$i]);
  49. $prev_dir_arr = explode('/', $previous_element);
  50. $dir_arr = explode('/', $images[$i]);
  51. if (count($dir_arr)==1) {
  52. $tl->addTile(new \OC\Pictures\TileSingle($images[$i]));
  53. continue;
  54. }
  55. if (strcmp($prev_dir_arr[0], $dir_arr[0])!=0) {
  56. $tl->addTile(new \OC\Pictures\TileStack($arr, $prev_dir_arr[0]));
  57. $arr = array();
  58. }
  59. $arr[] = $root.$images[$i];
  60. $previous_element = $images[$i];
  61. }
  62. $dir_arr = explode('/', $previous_element);
  63. if (count($dir_arr)==0) {
  64. $tl->addTile(new \OC\Pictures\TileSingle($previous_element));
  65. } else if (count($dir_arr) && $ts->getCount() == 0){
  66. $ts = new \OC\Pictures\TileStack(array($previous_element), $dir_arr[0]);
  67. } else {
  68. $arr[] = $previous_element;
  69. $ts->addTile($arr);
  70. }
  71. if ($ts->getCount() != 0) {
  72. $tl->addTile($ts);
  73. }
  74. echo $tl->get();
  75. ?>