diff options
author | Stephan Bergemann <st.bergemann@htw-berlin.de> | 2012-06-12 03:23:22 +0200 |
---|---|---|
committer | Stephan Bergemann <st.bergemann@htw-berlin.de> | 2012-06-14 01:27:01 +0200 |
commit | e4278574a8806b4748d132adb5f29fb61e6c6058 (patch) | |
tree | 2f7459d32b7cdb027547f12b175605d3839b9734 /apps/gallery/templates | |
parent | e15480683820426870be62a26dc7b91cbdc9a157 (diff) | |
download | nextcloud-server-e4278574a8806b4748d132adb5f29fb61e6c6058.tar.gz nextcloud-server-e4278574a8806b4748d132adb5f29fb61e6c6058.zip |
fixed sorting errors and missbehaviours - now sorting like file browser
Diffstat (limited to 'apps/gallery/templates')
-rw-r--r-- | apps/gallery/templates/index.php | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index f9926045498..930f80238be 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -16,6 +16,14 @@ div.visible { opacity: 0.8;} var root = "<?php echo htmlentities($root); ?>"; +function explode_empty(element) { + $('div', element).each(function(index, elem) { + if ($(elem).hasClass('title')) { + $(elem).addClass('visible'); + } + }); +} + function explode(element) { $('div', element).each(function(index, elem) { if ($(elem).hasClass('title')) { @@ -28,6 +36,14 @@ function explode(element) { }); } +function deplode_empty(element) { + $('div', element).each(function(index, elem) { + if ($(elem).hasClass('title')) { + $(elem).removeClass('visible'); + } + }); +} + function deplode(element) { $('div', element).each(function(index, elem) { if ($(elem).hasClass('title')) { @@ -79,41 +95,40 @@ $root = empty($_GET['root'])?'/':$_GET['root']; $images = \OC_FileCache::searchByMime('image', null, '/'.\OCP\USER::getUser().'/files'.$root); sort($images); -$arr = array(); $tl = new \OC\Pictures\TilesLine(); $ts = new \OC\Pictures\TileStack(array(), ''); $previous_element = @$images[0]; + +$root_images = array(); +$second_level_images = array(); + for($i = 0; $i < count($images); $i++) { $prev_dir_arr = explode('/', $previous_element); $dir_arr = explode('/', $images[$i]); - if (count($dir_arr)==1) { - $tl->addTile(new \OC\Pictures\TileSingle($root.$images[$i])); - continue; - } - if (strcmp($prev_dir_arr[0], $dir_arr[0])!=0) { - $tl->addTile(new \OC\Pictures\TileStack($arr, $prev_dir_arr[0])); - $arr = array(); + if(count($dir_arr) == 1) { // getting the images in this directory + $root_images[] = $root.$images[$i]; + } else { + if (count($dir_arr) == 2) { // These are the pics in that subdir + $second_level_images[] = $root.$images[$i]; + } + if(strcmp($prev_dir_arr[0], $dir_arr[0]) != 0) { + $tl->addTile(new \OC\Pictures\TileStack($second_level_images, $prev_dir_arr[0])); + $second_level_images = array(); + } + // have us a little something to compare against + $previous_element = $images[$i]; } - $arr[] = $root.$images[$i]; - $previous_element = $images[$i]; } -$dir_arr = explode('/', $previous_element); - -if (count($images)>1) { - if (count($dir_arr)==0) { - $tl->addTile(new \OC\Pictures\TileSingle($previous_element)); - } else if (count($dir_arr) && $ts->getCount() == 0){ - $ts = new \OC\Pictures\TileStack(array($root.$previous_element), $dir_arr[0]); - } else { - $arr[] = $previous_element; - $ts->addTile($arr); - } +// if last element in the directory was a directory we don't want to miss it :) +if(count($second_level_images)>0) { + $tl->addTile(new \OC\Pictures\TileStack($second_level_images, $prev_dir_arr[0])); } -if ($ts->getCount() != 0) { - $tl->addTile($ts); +// and finally our images actually stored in the root folder +for($i = 0; $i<count($root_images); $i++) { + $tl->addTile(new \OC\Pictures\TileSingle($root_images[$i])); } echo $tl->get(); |