Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorBartek Przybylski <bart.p.pl@gmail.com>2012-06-03 02:29:10 +0400
committerBartek Przybylski <bart.p.pl@gmail.com>2012-06-10 15:15:39 +0400
commit7aff5eae6c17ea8f7e95ebd200b3362f88e05773 (patch)
tree82e9b3a609a03ba362768a3368f1e89fdfd4bce0 /apps
parent2b80102909a1be391717f5ce375bc1d0afd5fe81 (diff)
navigate on galleries
Diffstat (limited to 'apps')
-rw-r--r--apps/gallery/lib/managers.php4
-rw-r--r--apps/gallery/lib/tiles.php32
-rw-r--r--apps/gallery/templates/index.php34
3 files changed, 45 insertions, 25 deletions
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 .= '<div class="gallery_div" '.$extra.' onmouseover="'.$this->tiles_array[$i]->getOnHoverAction().'" onmouseout="'.$this->tiles_array[$i]->getOnOutAction().'">'.$this->tiles_array[$i]->get().'</div>';
+ if ($img_w != 150) $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>';
@@ -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 '<img src="'.GET_THUMBNAIL_PATH.urlencode($this->getPath()).'" '.$extra.'>';
@@ -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 .= '<div class="miniature_border gallery_div" style="background-image:url(\''.$this->tiles_array[$i]->getMiniatureSrc().'\');margin-top:'.$top.'px; margin-left:'.$left.'px;'.$extra.'"></div>';
-// $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 @@
<?php
+OCP\Util::addStyle('files', 'files');
+OCP\Util::addscript('files_imageviewer', 'jquery.mousewheel-3.0.4.pack');
+OCP\Util::addscript('files_imageviewer', 'jquery.fancybox-1.3.4.pack');
+OCP\Util::addStyle( 'files_imageviewer', 'jquery.fancybox-1.3.4' );
+
$l = OC_L10N::get('gallery');
?>
<style>
-div.gallery_div {position:relative; display: inline-block; height: 202px; width: 200px; margin: 5px;}
-div.miniature_border {position:absolute; height: 200px; -webkit-transition-duration: .2s; background-position: 50%;}
-div.line {display:inline-block; border: 0; width: auto; height: 210px}
-div.gallery_div img{position:absolute; top: 1; left: 0; -webkit-transition-duration: 0.3s; height:200px; width: auto;}
+div.gallery_div {position:relative; display: inline-block; height: 152px; width: 150px; margin: 5px;}
+div.miniature_border {position:absolute; height: 150px; -webkit-transition-duration: .2s; background-position: 50%;}
+div.line {display:inline-block; border: 0; width: auto; height: 160px}
+div.gallery_div img{position:absolute; top: 1; left: 0; -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:10px; height:auto; padding: 5px; width: 170px; 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; 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.visible { opacity: 0.8;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
+
+var root = "<?php echo !empty($_GET['root']) ? $_GET['root'] : '/'; ?>";
+
function t(element) {
$('div', element).each(function(index, elem) {
if ($(elem).hasClass('title')) {
@@ -36,6 +44,20 @@ function o(element) {
});
}
+function openNewGal(album_name) {
+ root = root + album_name + "/";
+ var url = window.location.toString().replace(window.location.search, '');
+ url = url + "?app=gallery&root="+root;
+
+ window.location = url;
+}
+
+function openFile(file_path) {
+ var url = window.location.toString().replace(window.location.search, '');
+ url = url + "?app=files&getfile=download.php?file="+file_path;
+ window.location = url;
+}
+
</script>
<?php
@@ -43,7 +65,7 @@ function o(element) {
include('apps/gallery/lib/tiles.php');
$root = empty($_GET['root'])?'/':$_GET['root'];
-$images = \OC_FileCache::searchByMime('image', null, '/'.\OCP\USER\getUser().'/files'.$root);
+$images = \OC_FileCache::searchByMime('image', null, '/'.\OCP\USER::getUser().'/files'.$root);
sort($images);
$arr = array();