diff options
Diffstat (limited to 'apps/gallery')
-rw-r--r-- | apps/gallery/ajax/galleryOp.php | 2 | ||||
-rw-r--r-- | apps/gallery/ajax/sharing.php | 4 | ||||
-rw-r--r-- | apps/gallery/ajax/thumbnail.php | 7 | ||||
-rw-r--r-- | apps/gallery/appinfo/database.xml | 42 | ||||
-rw-r--r-- | apps/gallery/appinfo/update.php | 11 | ||||
-rw-r--r-- | apps/gallery/appinfo/version | 2 | ||||
-rw-r--r-- | apps/gallery/index.php | 24 | ||||
-rw-r--r-- | apps/gallery/lib/album.php | 2 | ||||
-rw-r--r-- | apps/gallery/lib/managers.php | 97 | ||||
-rw-r--r-- | apps/gallery/lib/photo.php | 2 | ||||
-rw-r--r-- | apps/gallery/lib/scanner.php | 2 | ||||
-rw-r--r-- | apps/gallery/lib/tiles.php | 178 | ||||
-rw-r--r-- | apps/gallery/lib/tiles_test.php | 87 | ||||
-rw-r--r-- | apps/gallery/templates/index.php | 130 |
14 files changed, 492 insertions, 98 deletions
diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php index b49e52f0bd2..7cbe3e46e21 100644 --- a/apps/gallery/ajax/galleryOp.php +++ b/apps/gallery/ajax/galleryOp.php @@ -42,7 +42,7 @@ function handleRemove($name) { function handleGetThumbnails($albumname) { OCP\Response::enableCaching(3600 * 24); // 24 hour - $view = OCP\App::getStorage('gallery'); + $view = OCP\Files::getStorage('gallery'); $thumbnail = $view->fopen(urldecode($albumname).'.png', 'r'); header('Content-Type: '.OC_Image::getMimeTypeForFile($thumbnail)); OCP\Response::sendFile($thumbnail); diff --git a/apps/gallery/ajax/sharing.php b/apps/gallery/ajax/sharing.php index 304757b9e91..7134d19e78a 100644 --- a/apps/gallery/ajax/sharing.php +++ b/apps/gallery/ajax/sharing.php @@ -80,7 +80,7 @@ function handleGetThumbnail($token, $imgpath) { function handleGetAlbumThumbnail($token, $albumname) { $owner = OC_Gallery_Sharing::getTokenOwner($token); - $view = OCP\App::getStorage('gallery'); + $view = OCP\Files::getStorage('gallery'); $file = $view->fopen($albumname.'.png', 'r'); $image = new OC_Image($file); if ($image->valid()) { @@ -94,7 +94,7 @@ function handleGetAlbumThumbnail($token, $albumname) function handleGetPhoto($token, $photo) { $owner = OC_Gallery_Sharing::getTokenOwner($token); - $view = OCP\App::getStorage('files'); + $view = OCP\Files::getStorage('files'); $file = $view->fopen(urldecode($photo), 'r'); header('Content-Type: '.OC_Image::getMimeTypeForFile($file)); OCP\Response::sendFile($file); diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php index ff0cb44022c..4fc9eba992d 100644 --- a/apps/gallery/ajax/thumbnail.php +++ b/apps/gallery/ajax/thumbnail.php @@ -20,14 +20,15 @@ * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ - OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('gallery'); +require_once('apps/gallery/lib/managers.php'); + -$img = $_GET['img']; +$img = $_GET['filepath']; -$image = OC_Gallery_Photo::getThumbnail($img); +$image = \OC\Pictures\ThumbnailsManager::getInstance()->getThumbnail($img); if ($image) { OCP\Response::enableCaching(3600 * 24); // 24 hour $image->show(); diff --git a/apps/gallery/appinfo/database.xml b/apps/gallery/appinfo/database.xml index f370e1521e4..d1ccd6b5a24 100644 --- a/apps/gallery/appinfo/database.xml +++ b/apps/gallery/appinfo/database.xml @@ -5,66 +5,32 @@ <overwrite>false</overwrite> <charset>latin1</charset> <table> - <name>*dbprefix*gallery_albums</name> + <name>*dbprefix*pictures_images_cache</name> <declaration> <field> - <name>album_id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <length>4</length> - </field> - <field> <name>uid_owner</name> <type>text</type> <notnull>true</notnull> <length>64</length> </field> <field> - <name>album_name</name> - <type>text</type> - <notnull>true</notnull> - <length>100</length> - </field> - <field> - <name>album_path</name> - <type>text</type> - <notnull>true</notnull> - <length>256</length> - </field> - <field> - <name>parent_path</name> + <name>path</name> <type>text</type> <notnull>true</notnull> <length>256</length> </field> - </declaration> - </table> - <table> - <name>*dbprefix*gallery_photos</name> - <declaration> <field> - <name>photo_id</name> + <name>width</name> <type>integer</type> - <default>0</default> <notnull>true</notnull> - <autoincrement>1</autoincrement> <length>4</length> </field> <field> - <name>album_id</name> + <name>height</name> <type>integer</type> - <default>0</default> <notnull>true</notnull> <length>4</length> </field> - <field> - <name>file_path</name> - <type>text</type> - <notnull>true</notnull> - <length>256</length> - </field> </declaration> </table> <table> diff --git a/apps/gallery/appinfo/update.php b/apps/gallery/appinfo/update.php new file mode 100644 index 00000000000..a0997ab5e86 --- /dev/null +++ b/apps/gallery/appinfo/update.php @@ -0,0 +1,11 @@ +<?php + +$currentVersion=OC_Appconfig::getValue('gallery', 'installed_version'); +if (version_compare($currentVersion, '0.5.0', '<')) { + $stmt = OCP\DB::prepare('DROP TABLE IF EXISTS *PREFIX*gallery_photos'); + $stmt->execute(); + $stmt = OCP\DB::prepare('DROP TABLE IF EXISTS *PREFIX*gallery_albums'); + $stmt->execute(); + + \OC_DB::createDbFromStructure(OC::$APPSROOT.'/apps/'.$appid.'/appinfo/database.xml'); +} diff --git a/apps/gallery/appinfo/version b/apps/gallery/appinfo/version index 17b2ccd9bf9..8f0916f768f 100644 --- a/apps/gallery/appinfo/version +++ b/apps/gallery/appinfo/version @@ -1 +1 @@ -0.4.3 +0.5.0 diff --git a/apps/gallery/index.php b/apps/gallery/index.php index a9fe200c4e4..9d4654a7cc5 100644 --- a/apps/gallery/index.php +++ b/apps/gallery/index.php @@ -27,26 +27,6 @@ OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('gallery'); OCP\App::setActiveNavigationEntry( 'gallery_index' ); -if (!isset($_GET['view'])) { - $result = OC_Gallery_Album::find(OCP\USER::getUser()); - - $r = array(); - while ($row = $result->fetchRow()) - $r[] = $row; - - $tmpl = new OCP\Template( 'gallery', 'index', 'user' ); - $tmpl->assign('r', $r); - $tmpl->printPage(); -} else { - $result = OC_Gallery_Photo::findForAlbum(OCP\USER::getUser(), $_GET['view']); - - $photos = array(); - while ($p = $result->fetchRow()) - $photos[] = $p['file_path']; - - $tmpl = new OCP\Template( 'gallery', 'view_album', 'user' ); - $tmpl->assign('photos', $photos); - $tmpl->assign('albumName', $_GET['view']); - $tmpl->printPage(); -} +$tmpl = new OCP\Template( 'gallery', 'index', 'user' ); +$tmpl->printPage(); ?> diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php index 8ac27b1a70d..39d6d3aded1 100644 --- a/apps/gallery/lib/album.php +++ b/apps/gallery/lib/album.php @@ -90,7 +90,7 @@ class OC_Gallery_Album { } public static function changeThumbnailPath($oldname, $newname) { - $view = OCP\App::getStorage('gallery'); + $view = OCP\Files::getStorage('gallery'); $view->rename($oldname.'.png', $newname.'.png'); } diff --git a/apps/gallery/lib/managers.php b/apps/gallery/lib/managers.php new file mode 100644 index 00000000000..2444659d0a4 --- /dev/null +++ b/apps/gallery/lib/managers.php @@ -0,0 +1,97 @@ +<?php + +namespace OC\Pictures; + +require_once('lib/base.php'); + +\OCP\JSON::checkLoggedIn(); +\OCP\JSON::checkAppEnabled('gallery'); + +class DatabaseManager { + private static $instance = null; + const TAG = 'DatabaseManager'; + + public static function getInstance() { + if (self::$instance === null) + self::$instance = new DatabaseManager(); + return self::$instance; + } + + public function getFileData($path) { + $gallery_path = \OCP\Config::getSystemValue( 'datadirectory' ).'/'.\OC_User::getUser().'/gallery'; + $path = $gallery_path.$path; + $stmt = \OCP\DB::prepare('SELECT * FROM *PREFIX*pictures_images_cache WHERE uid_owner LIKE ? AND path = ?'); + $result = $stmt->execute(array(\OCP\USER::getUser(), $path)); + if (($row = $result->fetchRow()) != false) { + return $row; + } + $image = new \OC_Image(); + 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())); + \OCP\DB::commit(); + $ret = array('filepath' => $path, 'width' => $image->width(), 'height' => $image->height()); + unset($image); + return $ret; + } + + private function __construct() {} +} + +class ThumbnailsManager { + + private static $instance = null; + const TAG = 'ThumbnailManager'; + + public static function getInstance() { + if (self::$instance === null) + self::$instance = new ThumbnailsManager(); + return self::$instance; + } + + public function getThumbnail($path) { + $gallery_path = \OCP\Config::getSystemValue( 'datadirectory' ).'/'.\OC_User::getUser().'/gallery'; + if (file_exists($gallery_path.$path)) { + return new \OC_Image($gallery_path.$path); + } + if (!\OC_Filesystem::file_exists($path)) { + \OC_Log::write(self::TAG, 'File '.$path.' don\'t exists', \OC_Log::WARN); + return false; + } + $image = new \OC_Image(); + $image->loadFromFile(\OC_Filesystem::getLocalFile($path)); + if (!$image->valid()) return false; + + $image->fixOrientation(); + + $ret = $image->preciseResize(floor((150*$image->width())/$image->height()), 150); + + if (!$ret) { + \OC_Log::write(self::TAG, 'Couldn\'t resize image', \OC_Log::ERROR); + unset($image); + return false; + } + + $image->save($gallery_path.'/'.$path); + return $image; + } + + public function getThumbnailInfo($path) { + $arr = DatabaseManager::getInstance()->getFileData($path); + $ret = array('filepath' => $arr['path'], + 'width' => $arr['width'], + 'height' => $arr['height']); + return $ret; + } + + public function delete($path) { + unlink(\OC::$CONFIG_DATADIRECTORY_ROOT.'/'.\OC_User::getUser()."/gallery".$path); + } + + private function __construct() {} + +} +?> diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php index b4b37236b0e..f9527cb5fdb 100644 --- a/apps/gallery/lib/photo.php +++ b/apps/gallery/lib/photo.php @@ -68,7 +68,7 @@ class OC_Gallery_Photo { public static function getThumbnail($image_name, $owner = null) { if (!$owner) $owner = OCP\USER::getUser(); - $view = OCP\App::getStorage('gallery'); + $view = OCP\Files::getStorage('gallery'); $save_dir = dirname($image_name); if (!$view->is_dir($save_dir)) { $view->mkdir($save_dir); diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index e11ba1da454..233fa20bca7 100644 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -81,7 +81,7 @@ class OC_Gallery_Scanner { $image->destroy(); } } - $view = OCP\App::getStorage('gallery'); + $view = OCP\Files::getStorage('gallery'); imagepng($thumbnail, $view->getLocalFile($albumName.'.png')); imagedestroy($thumbnail); } diff --git a/apps/gallery/lib/tiles.php b/apps/gallery/lib/tiles.php new file mode 100644 index 00000000000..ff9519142ac --- /dev/null +++ b/apps/gallery/lib/tiles.php @@ -0,0 +1,178 @@ +<?php + +namespace OC\Pictures; + +require_once('lib/base.php'); +require_once('managers.php'); + +const TAG = 'Pictures'; +const IMAGE_WIDTH = 150; + +class TileBase { + public function getWidth() { return false; } + + public function getHeight() { return IMAGE_WIDTH; } + + public function getOnHoverAction() { return false; } + + public function getOnOutAction() { return false; } + + public function getOnClickAction() { return false; } + + public function getDisplayedLayer() { return false; } + + public function getTileProportion() { return false; } + + public function get() { return false; } +} + +class TilesLine { + + public function __construct() { + $this->tiles_array = array(); + } + + public function setAvailableSpace($space) { + $available_space = $space; + } + + public function getTilesCount() { + return count($this->tiles_array); + } + + public function addTile($tile) { + array_push($this->tiles_array, $tile); + } + + public function getLeftSpace() { + $occupied_space = 0; + for ($i = 0; $i < count($this->tiles_array); $i++) { + $occupied_space += $this->tiles_array[$i]->getWidth(); + } + return $this->available_space - $occupied_space; + } + + public function tileWillFit($tile) { + return $this->getLeftSpace() > $tile->getWidth(); + } + + public function get() { + $r = '<div class="line gallery_div">'; + + for ($i = 0; $i < count($this->tiles_array); $i++) { + $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>'; + return $r; + } + + private $tiles_array; + private $available_space; +} + +class TileSingle extends TileBase { + + public function __construct($path) { + \OC_Log::write(TAG, 'Loading file from path '.$path, \OC_Log::DEBUG); + $this->file_path = $path; +/* $this->image = new \OC_Image(); + if (!$this->image->loadFromFile($this->file_path)) { + \OC_Log::write(TAG, 'Loading file filed', \OC_Log::ERROR); + return; + } + $this->image->fixOrientation();*/ + } + + public function getWidth() { + $a = ThumbnailsManager::getInstance()->getThumbnailInfo($this->file_path); + return $a['width']; + } + + public function get($extra = '') { + // !HACK! file path needs to be encoded twice because files app decode twice url, so any special chars like + or & in filename + // !HACK! will result in failing of opening them + return '<a rel="images" title="'.basename($this->getPath()).'" href="'.\OCP\Util::linkTo('files', 'download.php').'?file='.urlencode(urlencode($this->getPath())).'"><img rel="images" src="'.\OCP\Util::linkTo('gallery', 'ajax/thumbnail.php').'&filepath='.urlencode($this->getPath()).'" '.$extra.'></a>'; + } + + public function getMiniatureSrc() { + return \OCP\Util::linkTo('gallery', 'ajax/thumbnail.php').'&filepath='.urlencode($this->getPath()); + } + + public function getPath() { + return $this->file_path; + } + + public function getOnClickAction() { + return '';//'javascript:openFile(\''.$this->file_path.'\');'; + } + + private $file_path; + private $image; +} + +class TileStack extends TileBase { + + const STACK_REPRESENTATIVES = 3; + + public function __construct($path_array, $stack_name) { + $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]); + array_push($this->tiles_array, $tile); + } + } + + public function forceSize($width_must_fit=false) { + for ($i = 0; $i < count($this->tiles_array); $i++) + $this->tiles_array[$i]->forceSize(true); + } + + public function getWidth() { + $max = 0; + for ($i = 0; $i < count($this->tiles_array); $i++) { + $max = max($max, $this->tiles_array[$i]->getWidth()); + } + return min(IMAGE_WIDTH, $max); + } + + public function get() { + $r = '<div class="title gallery_div">'.$this->stack_name.'</div>'; + for ($i = 0; $i < count($this->tiles_array); $i++) { + $top = rand(-5, 5); + $left = rand(-5, 5); + $img_w = $this->tiles_array[$i]->getWidth(); + $extra = ''; + 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>'; + } + return $r; + } + + public function getOnHoverAction() { + return 'javascript:t(this);return false;'; + } + + public function getOnOutAction() { + return 'javascript:o(this);return false;'; + } + + 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/lib/tiles_test.php b/apps/gallery/lib/tiles_test.php new file mode 100644 index 00000000000..022a88f75cc --- /dev/null +++ b/apps/gallery/lib/tiles_test.php @@ -0,0 +1,87 @@ +<?php +$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 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.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"> +function t(element) { + $('div', element).each(function(index, elem) { + if ($(elem).hasClass('title')) { + $(elem).addClass('visible'); + } else { + $(elem).css('margin-top', Math.floor(30-(Math.random()*60)) + 'px') + .css('margin-left', Math.floor(30-(Math.random()*60))+ 'px') + .css('z-index', '999'); + } + }); +} + +function o(element) { + $('div', element).each(function(index, elem) { + if ($(elem).hasClass('title')) { + $(elem).removeClass('visible'); + } else { + $(elem).css('margin-top', Math.floor(5-(Math.random()*10)) + 'px') + .css('margin-left', Math.floor(5-(Math.random()*10))+ 'px') + .css('z-index', '3'); + } + }); +} + +</script> + +<?php + +include('apps/gallery/lib/tiles.php'); +$root = empty($_GET['root'])?'/':$_GET['root']; + +$images = \OC_FileCache::searchByMime('image', null, '/bartek/files'.$root); +sort($images); + +$arr = array(); +$tl = new \OC\Pictures\TilesLine(); +$ts = new \OC\Pictures\TileStack(array(), ''); +$previous_element = $images[0]; +for($i = 0; $i < count($images); $i++) { + error_log($images[$i]); + $prev_dir_arr = explode('/', $previous_element); + $dir_arr = explode('/', $images[$i]); + + if (count($dir_arr)==1) { + $tl->addTile(new \OC\Pictures\TileSingle($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(); + } + $arr[] = $root.$images[$i]; + $previous_element = $images[$i]; +} + +$dir_arr = explode('/', $previous_element); + +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($previous_element), $dir_arr[0]); +} else { + $arr[] = $previous_element; + $ts->addTile($arr); +} + +if ($ts->getCount() != 0) { + $tl->addTile($ts); +} + +echo $tl->get(); + +?> diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index 99af3bda0a3..39e3bbf47b3 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -1,31 +1,105 @@ <?php -OCP\Util::addStyle('gallery', 'styles'); -OCP\Util::addscript('gallery', 'albums'); -OCP\Util::addscript('gallery', 'scanner'); -OCP\Util::addscript('gallery', 'album_cover'); -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'); ?> -<script type="text/javascript">var gallery_scanning_root='<?php echo OCP\Config::getUserValue(OCP\USER::getUser(), 'gallery', 'root', '/'); ?>'; var gallery_default_order = '<?php echo OCP\Config::getUserValue(OCP\USER::getUser(), 'gallery', 'order', 'ASC'); ?>';</script> -<div id="controls"> - <div id="scan"> - <div id="scanprogressbar"></div> - <input type="button" class="start" value="<?php echo $l->t('Rescan');?>" onclick="javascript:scanForAlbums();" /> - <input type="button" class="stop" style="display:none" value="<?php echo $l->t('Stop');?>" onclick="javascript:Scanner.stop();" /> - <input type="button" id="g-share-button" value="<?php echo $l->t('Share'); ?>" onclick="javascript:shareGallery();" /> - <input type="button" id="g-settings-button" value="<?php echo $l->t('Settings');?>" onclick="javascript:settings();"/> - </div> - <div id="g-album-navigation"> - <div class="crumb last" style="background-image:url('<?php echo OC::$WEBROOT;?>/core/img/breadcrumb.png')"> - <a href="javascript:returnToElement(0);">main</a> - </div> - </div> - <div id="g-album-loading" class="crumb" style="display:none"> - <img src="<?php echo OCP\Util::linkTo('gallery', 'img/loading.gif'); ?>"> - </div> -</div> -<div id="gallery_list"> -</div> +<style> +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: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"> + +var root = "<?php echo !empty($_GET['root']) ? $_GET['root'] : '/'; ?>"; + +function t(element) { + $('div', element).each(function(index, elem) { + if ($(elem).hasClass('title')) { + $(elem).addClass('visible'); + } else { + $(elem).css('margin-top', Math.floor(30-(Math.random()*60)) + 'px') + .css('margin-left', Math.floor(30-(Math.random()*60))+ 'px') + .css('z-index', '999'); + } + }); +} + +function o(element) { + $('div', element).each(function(index, elem) { + if ($(elem).hasClass('title')) { + $(elem).removeClass('visible'); + } else { + $(elem).css('margin-top', Math.floor(5-(Math.random()*10)) + 'px') + .css('margin-left', Math.floor(5-(Math.random()*10))+ 'px') + .css('z-index', '3'); + } + }); +} + +function openNewGal(album_name) { + root = root + album_name + "/"; + var url = window.location.toString().replace(window.location.search, ''); + url = url + "?app=gallery&root="+encodeURIComponent(root); + + window.location = url; +} + +$(document).ready(function() { + $("a[rel=images]").fancybox({ + 'titlePosition': 'inside' + }); +}); + +</script> + +<?php + +include('apps/gallery/lib/tiles.php'); +$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]; +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(); + } + $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 ($ts->getCount() != 0) { + $tl->addTile($ts); +} + +echo $tl->get(); + +?> |