summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2012-06-15 09:51:04 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2012-06-15 09:51:04 +0200
commit4b7bdd5ace5a7274306ab135d74a52ba9b19c847 (patch)
tree694698759d0e36fed51e41f28afba85738133939 /apps
parenteffb6f1309a2ce3800c0758257a7f7825a8fa5d1 (diff)
parent4eb0c270aa902bd5d84edb2500f866fed4e6e9ab (diff)
downloadnextcloud-server-4b7bdd5ace5a7274306ab135d74a52ba9b19c847.tar.gz
nextcloud-server-4b7bdd5ace5a7274306ab135d74a52ba9b19c847.zip
Merge commit 'refs/merge-requests/128' of git://gitorious.org/owncloud/owncloud into merge-requests/128
Conflicts: apps/gallery/templates/index.php
Diffstat (limited to 'apps')
-rw-r--r--apps/gallery/lib/tiles.php4
-rw-r--r--apps/gallery/templates/index.php65
2 files changed, 45 insertions, 24 deletions
diff --git a/apps/gallery/lib/tiles.php b/apps/gallery/lib/tiles.php
index e43c99bb76a..2ff4fa5647b 100644
--- a/apps/gallery/lib/tiles.php
+++ b/apps/gallery/lib/tiles.php
@@ -63,7 +63,7 @@ class TilesLine {
$img_w = $this->tiles_array[$i]->getWidth();
$extra = '';
if ($img_w != IMAGE_WIDTH) $extra = ' style="width:'.$img_w.'px"';
- $r .= '<div class="gallery_div" '.$extra.' onmouseover="'.$this->tiles_array[$i]->getOnHoverAction().'" onmouseout="'.$this->tiles_array[$i]->getOnOutAction().'" onclick="'.$this->tiles_array[$i]->getOnClickAction().'">'.$this->tiles_array[$i]->get().'</div>';
+ $r .= '<div class="gallery_div" '.$extra.' onmouseover="'.$this->tiles_array[$i]->getOnHoverAction().'" onmouseout="'.$this->tiles_array[$i]->getOnOutAction().'" onclick="'.$this->tiles_array[$i]->getOnClickAction().'" style="background-color:#ddd">'.$this->tiles_array[$i]->get().'</div>';
}
$r .= '</div>';
@@ -122,7 +122,7 @@ class TileStack extends TileBase {
$this->tiles_array = array();
$this->stack_name = $stack_name;
for ($i = 0; $i < count($path_array) && $i < self::STACK_REPRESENTATIVES; $i++) {
- $tile = new TileSingle($path_array[$i]);
+ $tile = new TileSingle($path_array[$i]);
array_push($this->tiles_array, $tile);
}
}
diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php
index 749f8891f81..bf4f117c7de 100644
--- a/apps/gallery/templates/index.php
+++ b/apps/gallery/templates/index.php
@@ -9,7 +9,7 @@ div.miniature_border {position:absolute; height: 150px; -moz-transition-duration
div.line {display:inline-block; border: 0; width: auto; height: 160px}
div.gallery_div img{position:absolute; top: 1; left: 0; -moz-transition-duration: 0.3s; -o-transition-duration:0.3s; -webkit-transition-duration: 0.3s; height:150px; width: auto;}
div.gallery_div img.shrinker {width:80px !important;}
-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}
+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; right:-5px; height:auto; padding: 5px; width: 140px; background-color: black; color: white; -webkit-transition: opacity 0.5s; z-index:1000; border-radius: 7px}
div.visible { opacity: 0.8;}
</style>
<script type="text/javascript">
@@ -43,7 +43,7 @@ function deplode(element) {
function openNewGal(album_name) {
root = root + album_name + "/";
var url = window.location.toString().replace(window.location.search, '');
- url = url + "?app=gallery&root="+encodeURIComponent(root);
+ url = url + "?app=gallery&root="+encodeURIComponent(root);
window.location = url;
}
@@ -79,39 +79,60 @@ $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();
+
+$fallback_images = array(); // if the folder only cotains subfolders with images -> these are taken for the stack preview
+
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(strcmp($prev_dir_arr[0], $dir_arr[0]) != 0) { // if we entered a new directory
+ if(count($second_level_images) == 0) { // if we don't have images in this directory
+ if(count($fallback_images) != 0) { // but have fallback_images
+ $tl->addTile(new \OC\Pictures\TileStack($fallback_images, $prev_dir_arr[0]));
+ $fallback_images = array();
+ }
+ } else { // if we collected images for this directory
+ $tl->addTile(new \OC\Pictures\TileStack($second_level_images, $prev_dir_arr[0]));
+ $fallback_images = array();
+ $second_level_images = array();
+ }
+ }
+ if (count($dir_arr) == 2) { // These are the pics in our current subdir
+ $second_level_images[] = $root.$images[$i];
+ $fallback_images = array();
+ } else { // These are images from the deeper directories
+ if(count($second_level_images) == 0) {
+ $fallback_images[] = $root.$images[$i];
+ }
+ }
+ // 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 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 (count($images)>1 && count($dir_arr) > 1) {
- 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 with no second_level_images we also don't want to miss it ...
+if(count($fallback_images)>0) {
+ $tl->addTile(new \OC\Pictures\TileStack($fallback_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();