From: Bartek Przybylski Date: Sat, 2 Jun 2012 22:29:10 +0000 (+0200) Subject: navigate on galleries X-Git-Tag: v4.5.0beta1~74^2~423^2~28 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=76e7e361aef51badd048727db7ffc104e19e231a;p=nextcloud-server.git navigate on galleries --- diff --git a/apps/gallery/lib/managers.php b/apps/gallery/lib/managers.php index 96669da2727..6cb9b420ac6 100644 --- a/apps/gallery/lib/managers.php +++ b/apps/gallery/lib/managers.php @@ -29,9 +29,11 @@ class DatabaseManager { if (!$image->loadFromFile($path)) { return false; } + \OCP\DB::beginTransaction(); $stmt = \OCP\DB::prepare('INSERT INTO *PREFIX*pictures_images_cache (uid_owner, path, width, height) VALUES (?, ?, ?, ?)'); $stmt->execute(array(\OCP\USER::getUser(), $path, $image->width(), $image->height())); unset($image); + \OCP\DB::commit(); return $this->getFileData($path); } @@ -64,7 +66,7 @@ class ThumbnailsManager { $image->fixOrientation(); - $ret = $image->preciseResize(floor((200*$image->width())/$image->height()), 200); + $ret = $image->preciseResize(floor((150*$image->width())/$image->height()), 150); if (!$ret) { \OC_Log::write(self::TAG, 'Couldn\'t resize image', \OC_Log::ERROR); diff --git a/apps/gallery/lib/tiles.php b/apps/gallery/lib/tiles.php index d7f5208ff83..26ff3cbb9f8 100644 --- a/apps/gallery/lib/tiles.php +++ b/apps/gallery/lib/tiles.php @@ -9,11 +9,12 @@ const TILE_PROPORTION_HORIZONTAL = 0; const TILE_PROPORTION_VERTICAL = 0; const GET_THUMBNAIL_PATH = '?app=gallery&getfile=ajax/thumbnail.php&filepath='; const TAG = 'Pictures'; +const IMAGE_WIDTH = 150; class TileBase { public function getWidth() { return false; } - public function getHeight() { return 200; } + public function getHeight() { return 150; } public function getOnHoverAction() { return false; } @@ -64,8 +65,8 @@ class TilesLine { for ($i = 0; $i < count($this->tiles_array); $i++) { $img_w = $this->tiles_array[$i]->getWidth(); $extra = ''; - if ($img_w != 200) $extra = ' style="width:'.$img_w.'px"'; - $r .= ''; + if ($img_w != 150) $extra = ' style="width:'.$img_w.'px"'; + $r .= ''; } $r .= ''; @@ -93,18 +94,6 @@ class TileSingle extends TileBase { $a = ThumbnailsManager::getInstance()->getThumbnailInfo($this->file_path); return $a['width']; } - - public function forceSize($width_must_fit=false) { - $current_height = $this->image->height(); - $current_width = $this->image->width(); - - // we need height of 250px but not for tiles stack - if ($current_width > $current_height && !$width_must_fit) { - $this->image->resize(floor((250*$current_width)/$current_height)); - } else { - $this->image->resize(200); - } - } public function get($extra = '') { return ''; @@ -117,6 +106,10 @@ class TileSingle extends TileBase { public function getPath() { return $this->file_path; } + + public function getOnClickAction() { + return 'javascript:openFile(\''.$this->file_path.'\');'; + } private $file_path; private $image; @@ -145,7 +138,7 @@ class TileStack extends TileBase { for ($i = 0; $i < count($this->tiles_array); $i++) { $max = max($max, $this->tiles_array[$i]->getWidth()); } - return min(200, $max); + return min(IMAGE_WIDTH, $max); } public function get() { @@ -155,11 +148,10 @@ class TileStack extends TileBase { $left = rand(-5, 5); $img_w = $this->tiles_array[$i]->getWidth(); $extra = ''; - if ($img_w < 200) { + if ($img_w < IMAGE_WIDTH) { $extra = 'width:'.$img_w.'px;'; } $r .= ''; -// $r .= $this->tiles_array[$i]->get(' style="margin-top:'.$top.'px; margin-left:'.$left.'px; "'); } return $r; } @@ -175,6 +167,10 @@ class TileStack extends TileBase { public function getCount() { return count($this->tiles_array); } + + public function getOnClickAction() { + return 'javascript:openNewGal(\''.$this->stack_name.'\');'; + } private $tiles_array; private $stack_name; diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index 55710038c0a..d3b281a2c38 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -1,17 +1,25 @@