diff options
author | Bartek Przybylski <bart.p.pl@gmail.com> | 2011-09-26 20:05:36 +0200 |
---|---|---|
committer | Bartek Przybylski <bart.p.pl@gmail.com> | 2011-09-26 20:05:36 +0200 |
commit | e4dc33b368ffcfb7b0223dfaf57cfec1b93a5a73 (patch) | |
tree | 592d71668eef9dfa02eca12172acd6f68aa31cf6 /apps/gallery | |
parent | bcf92badd1dae888fec85c1b3615a924a2e6a859 (diff) | |
download | nextcloud-server-e4dc33b368ffcfb7b0223dfaf57cfec1b93a5a73.tar.gz nextcloud-server-e4dc33b368ffcfb7b0223dfaf57cfec1b93a5a73.zip |
Reverting: initial commit for gallery app
Diffstat (limited to 'apps/gallery')
-rw-r--r-- | apps/gallery/ajax/cover.php | 62 | ||||
-rw-r--r-- | apps/gallery/ajax/createAlbum.php | 14 | ||||
-rw-r--r-- | apps/gallery/ajax/getCovers.php | 16 | ||||
-rw-r--r-- | apps/gallery/ajax/scanForAlbums.php | 14 | ||||
-rw-r--r-- | apps/gallery/ajax/thumbnail.php | 59 | ||||
-rw-r--r-- | apps/gallery/appinfo/app.php | 13 | ||||
-rw-r--r-- | apps/gallery/appinfo/database.xml | 58 | ||||
-rw-r--r-- | apps/gallery/appinfo/info.xml | 10 | ||||
-rw-r--r-- | apps/gallery/css/styles.css | 22 | ||||
-rw-r--r-- | apps/gallery/index.php | 33 | ||||
-rw-r--r-- | apps/gallery/js/album_cover.js | 48 | ||||
-rw-r--r-- | apps/gallery/lib_scanner.php | 59 | ||||
-rw-r--r-- | apps/gallery/templates/index.php | 22 | ||||
-rw-r--r-- | apps/gallery/templates/view_album.php | 20 |
14 files changed, 0 insertions, 450 deletions
diff --git a/apps/gallery/ajax/cover.php b/apps/gallery/ajax/cover.php deleted file mode 100644 index 33d913c60ac..00000000000 --- a/apps/gallery/ajax/cover.php +++ /dev/null @@ -1,62 +0,0 @@ -<? -require_once('../../../lib/base.php'); - -function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSrc is a FILE - Returns an image resource. - //getting the image dimensions - list($width_orig, $height_orig) = getimagesize($imgSrc); - switch (strtolower(substr($imgSrc, strrpos($imgSrc, '.')+1))) { - case "jpeg": - case "jpg": - $myImage = imagecreatefromjpeg($imgSrc); - break; - default: - exit(); - } - $ratio_orig = $width_orig/$height_orig; - - if ($thumbnail_width/$thumbnail_height > $ratio_orig) { - $new_height = $thumbnail_width/$ratio_orig; - $new_width = $thumbnail_width; - } else { - $new_width = $thumbnail_height*$ratio_orig; - $new_height = $thumbnail_height; - } - - $x_mid = $new_width/2; //horizontal middle - $y_mid = $new_height/2; //vertical middle - - $process = imagecreatetruecolor(round($new_width), round($new_height)); - - imagecopyresampled($process, $myImage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig); - $thumb = imagecreatetruecolor($thumbnail_width, $thumbnail_height); - imagecopyresampled($thumb, $process, 0, 0, ($x_mid-($thumbnail_width/2)), ($y_mid-($thumbnail_height/2)), $thumbnail_width, $thumbnail_height, $thumbnail_width, $thumbnail_height); - - imagedestroy($process); - imagedestroy($myImage); - return $thumb; -} - -// Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.'))); - exit(); -} -$box_size = 200; -$album_name = $_GET['album']; -$x = $_GET['x']; - -$stmt = OC_DB::prepare('SELECT file_path FROM *PREFIX*gallery_photos,*PREFIX*gallery_albums WHERE *PREFIX*gallery_albums.uid_owner = ? AND album_name = ? AND *PREFIX*gallery_photos.album_id == *PREFIX*gallery_albums.album_id'); -$result = $stmt->execute(array(OC_User::getUser(), $album_name)); -$x = min((int)($x/($box_size/$result->numRows())), $result->numRows()-1); // get image to display -$result->seek($x); // never throws -$path = $result->fetchRow(); -$path = $path['file_path']; -$tmp = OC::$CONFIG_DATADIRECTORY . $path; -$imagesize = getimagesize($tmp); - -header('Content-Type: image/png'); -$image = CroppedThumbnail($tmp, $box_size, $box_size); - -imagepng($image); -imagedestroy($image); -?> diff --git a/apps/gallery/ajax/createAlbum.php b/apps/gallery/ajax/createAlbum.php deleted file mode 100644 index 93e3312d324..00000000000 --- a/apps/gallery/ajax/createAlbum.php +++ /dev/null @@ -1,14 +0,0 @@ -<? -require_once('../../../lib/base.php'); - -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.'))); - exit(); -} - -$stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums ("uid_owner", "album_name") VALUES ("'.OC_User::getUser().'", "'.$_GET['album_name'].'")'); -$stmt->execute(array()); - -echo json_encode(array( 'status' => 'success', 'name' => $_GET['album_name'])); - -?> diff --git a/apps/gallery/ajax/getCovers.php b/apps/gallery/ajax/getCovers.php deleted file mode 100644 index 69c03d3a446..00000000000 --- a/apps/gallery/ajax/getCovers.php +++ /dev/null @@ -1,16 +0,0 @@ -<? - -require_once('../../../lib/base.php'); - -$album_name = $_GET['album']; - -$stmt = OC_DB::prepare('SELECT file_path FROM *PREFIX*gallery_photos,*PREFIX*gallery_albums WHERE *PREFIX*gallery_albums.uid_owner = ? AND album_name = ? AND *PREFIX*gallery_photos.album_id == *PREFIX*gallery_albums.album_id'); -$result = $stmt->execute(array(OC_User::getUser(), $album_name)); -$images = array(); -while ($i = $result->fetchRow()) { - $images[] = $i['file_path']; -} - -echo json_encode(array('status' => 'success', 'imageCount' => $result->numRows(), 'images' => $images)); - -?> diff --git a/apps/gallery/ajax/scanForAlbums.php b/apps/gallery/ajax/scanForAlbums.php deleted file mode 100644 index 64832a113b6..00000000000 --- a/apps/gallery/ajax/scanForAlbums.php +++ /dev/null @@ -1,14 +0,0 @@ -<? - -require_once('../../../lib/base.php'); -require_once('../lib_scanner.php'); - -if (!OC_User::IsLoggedIn()) { - echo json_encode(array('status' => 'error', 'message' => 'You need to log in')); - exit(); -} - -echo json_encode(array( 'status' => 'success', 'albums' => OC_GALLERY_SCANNER::scan(''))); -//echo json_encode(array('status' => 'success', 'albums' => array(array('name' => 'test', 'imagesCount' => 1, 'images' => array('dupa'))))); - -?> diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php deleted file mode 100644 index c8b9ee3ef3e..00000000000 --- a/apps/gallery/ajax/thumbnail.php +++ /dev/null @@ -1,59 +0,0 @@ -<? -require_once('../../../lib/base.php'); - -function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSrc is a FILE - Returns an image resource. - //getting the image dimensions - list($width_orig, $height_orig) = getimagesize($imgSrc); - switch (strtolower(substr($imgSrc, strrpos($imgSrc, '.')+1))) { - case "jpeg": - case "jpg": - case "tiff": - $myImage = imagecreatefromjpeg($imgSrc); - break; - case "png": - $myImage = imagecreatefrompng($imgSrc); - break; - default: - exit(); - } - $ratio_orig = $width_orig/$height_orig; - - if ($thumbnail_width/$thumbnail_height > $ratio_orig) { - $new_height = $thumbnail_width/$ratio_orig; - $new_width = $thumbnail_width; - } else { - $new_width = $thumbnail_height*$ratio_orig; - $new_height = $thumbnail_height; - } - - $x_mid = $new_width/2; //horizontal middle - $y_mid = $new_height/2; //vertical middle - - $process = imagecreatetruecolor(round($new_width), round($new_height)); - - imagecopyresampled($process, $myImage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig); - $thumb = imagecreatetruecolor($thumbnail_width, $thumbnail_height); - imagecopyresampled($thumb, $process, 0, 0, ($x_mid-($thumbnail_width/2)), ($y_mid-($thumbnail_height/2)), $thumbnail_width, $thumbnail_height, $thumbnail_width, $thumbnail_height); - - imagedestroy($process); - imagedestroy($myImage); - return $thumb; -} - -// Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.'))); - exit(); -} -$box_size = 200; -$img = $_GET['img']; - -$tmp = OC::$CONFIG_DATADIRECTORY . $img; -$imagesize = getimagesize($tmp); - -header('Content-Type: image/png'); -$image = CroppedThumbnail($tmp, $box_size, $box_size); - -imagepng($image); -imagedestroy($image); -?> diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php deleted file mode 100644 index 2c72c29218e..00000000000 --- a/apps/gallery/appinfo/app.php +++ /dev/null @@ -1,13 +0,0 @@ -<? -OC_App::register(array( - 'order' => 20, - 'id' => 'gallery', - 'name' => 'Gallery')); - -OC_App::addNavigationEntry( array( - 'id' => 'gallery_index', - 'order' => 20, - 'href' => OC_Helper::linkTo('gallery', 'index.php'), - 'icon' => '', - 'name' => 'Gallery')); -?> diff --git a/apps/gallery/appinfo/database.xml b/apps/gallery/appinfo/database.xml deleted file mode 100644 index fd55b3a6fb4..00000000000 --- a/apps/gallery/appinfo/database.xml +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<database> - <name>*dbname*</name> - <create>true</create> - <overwrite>false</overwrite> - <charset>latin1</charset> - <table> - <name>*dbprefix*gallery_albums</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> - </declaration> - </table> - <table> - <name>*dbprefix*gallery_photos</name> - <declaration> - <field> - <name>photo_id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <length>4</length> - </field> - <field> - <name>album_id</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>100</length> - </field> - </declaration> - </table> -</database> diff --git a/apps/gallery/appinfo/info.xml b/apps/gallery/appinfo/info.xml deleted file mode 100644 index 8353ca4f35d..00000000000 --- a/apps/gallery/appinfo/info.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0"?> -<info> - <id>gallery</id> - <name>Gallery</name> - <version>0.1</version> - <licence>AGPL</licence> - <author>Bartosz Przybylski</author> - <require>2</require> - <description></description> -</info> diff --git a/apps/gallery/css/styles.css b/apps/gallery/css/styles.css deleted file mode 100644 index 8ce31c9e4a3..00000000000 --- a/apps/gallery/css/styles.css +++ /dev/null @@ -1,22 +0,0 @@ -div#gallery_list { - margin: 90pt 20pt; -} - -div.gallery_album_box { - width: 200px; - text-align: center; - border: 0; - float: left; - margin: 5pt; -} - -div.gallery_album_box h1 { - font-size: 12pt; - font-family: Arial; -} - -img.gallery_album_cover { - width: 200px; - height: 200px; - border: solid 1px black; -} diff --git a/apps/gallery/index.php b/apps/gallery/index.php deleted file mode 100644 index 29ec30b5b6e..00000000000 --- a/apps/gallery/index.php +++ /dev/null @@ -1,33 +0,0 @@ -<? -require_once('../../lib/base.php'); - -OC_Util::checkLoggedIn(); -OC_App::setActiveNavigationEntry( 'gallery_index' ); - - -if (!isset($_GET['view'])) { - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ?'); - $result = $stmt->execute(array(OC_User::getUser())); - - $r = array(); - while ($row = $result->fetchRow()) - $r[] = $row; - - $tmpl = new OC_Template( 'gallery', 'index', 'user' ); - $tmpl->assign('r', $r); - $tmpl->printPage(); -} else { - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos, *PREFIX*gallery_albums WHERE uid_owner = ? AND album_name = ? AND *PREFIX*gallery_albums.album_id = *PREFIX*gallery_photos.album_id'); - - $result = $stmt->execute(array(OC_User::getUser(), $_GET['view'])); - - $photos = array(); - while ($p = $result->fetchRow()) - $photos[] = $p['file_path']; - - $tmpl = new OC_Template( 'gallery', 'view_album', 'user' ); - $tmpl->assign('photos', $photos); - $tmpl->assign('albumName', $_GET['view']); - $tmpl->printPage(); -} -?> diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js deleted file mode 100644 index d4fb1f0475e..00000000000 --- a/apps/gallery/js/album_cover.js +++ /dev/null @@ -1,48 +0,0 @@ -var actual_cover; -$('body').ready(function() { - $('div[class=gallery_album_box]').each(function(i, e) { - $.getJSON('ajax/getCovers.php', { album: $(e).children('h1:last').text() }, function(a) { - if (a.status == "success") { - e.ic = a.imageCount; - e.images = a.images; - if (e.ic > 0) { - $(e).find('img[class=gallery_album_cover]').attr('src', 'ajax/thumbnail.php?img=' + e.images[0]); - actual_cover = 0; - } - } - }); - }); - $('img[class=gallery_album_cover]').each(function(i, e) { - $(e).mousemove(function(a) { - if (e.parentNode.parentNode.ic!=0) { - var x = Math.min(Math.floor((a.clientX - this.offsetLeft)/(200/e.parentNode.parentNode.ic)), e.parentNode.parentNode.ic-1); - if (actual_cover != x) { - $(e).attr('src', 'ajax/thumbnail.php?img=' + e.parentNode.parentNode.images[x]); - actual_cover = x; - } - } - }); - }); -}); - -function createNewAlbum() { - var name = prompt("album name", ""); - if (name != null && name != "") { - $.getJSON("ajax/createAlbum.php", {album_name: name}, function(r) { - if (r.status == "success") { - var v = '<div class="gallery_album_box"><a href="?view='+r.name+'"><img class="gallery_album_cover"/></a><h1>'+r.name+'</h1></div>'; - $('div#gallery_list').append(v); - } - }); - } -} - -function scanForAlbums() { - $.getJSON('ajax/scanForAlbums.php', function(r) { - if (r.status == 'success') { - window.location.reload(true); - } else { - alert('Error occured: ' + r.message); - } - }); -} diff --git a/apps/gallery/lib_scanner.php b/apps/gallery/lib_scanner.php deleted file mode 100644 index 8f7c49b671a..00000000000 --- a/apps/gallery/lib_scanner.php +++ /dev/null @@ -1,59 +0,0 @@ -<? - -require_once('base.php'); // base lib - -class OC_GALLERY_SCANNER { - - public static function scan($root) { - $albums = array(); - self::scanDir($root, $albums); - return $albums; - } - - public static function scanDir($path, &$albums) { - $current_album = array('name'=> $path, 'imagesCount' => 0, 'images' => array()); - $current_album['name'] = str_replace('/', '.', str_replace(OC::$CONFIG_DATADIRECTORY, '', $current_album['name'])); - $current_album['name'] = ($current_album['name']==='')?'main':$current_album['name']; - - if ($dh = OC_Filesystem::opendir($path)) { - while (($filename = readdir($dh)) !== false) { - $filepath = $path.'/'.$filename; - if (substr($filename, 0, 1) == '.') continue; - if (OC_Filesystem::is_dir($filepath)) { - self::scanDir($filepath, $albums); - } elseif (self::isPhoto($path.'/'.$filename)) { - $current_album['images'][] = $filepath; - } - } - } - $current_album['imagesCount'] = count($current_album['images']); - $albums[] = $current_album; - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE "uid_owner" = ? AND "album_name" = ?'); - $result = $stmt->execute(array(OC_User::getUser(), $current_album['name'])); - if ($result->numRows() == 0) { - $stmt = OC_DB::prepare('INSERT OR REPLACE INTO *PREFIX*gallery_albums ("uid_owner", "album_name") VALUES (?, ?)'); - $stmt->execute(array(OC_User::getUser(), $current_album['name'])); - } - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE "uid_owner" = ? AND "album_name" = ?'); - $result = $stmt->execute(array(OC_User::getUser(), $current_album['name'])); - $albumId = $result->fetchRow(); - $albumId = $albumId['album_id']; - foreach ($current_album['images'] as $img) { - error_log($img); - error_log($albumId); - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE "album_id" = ? AND "file_path" = ?'); - $result = $stmt->execute(array($albumId, $img)); - if ($result->numRows() == 0) { - $stmt = OC_DB::prepare('INSERT OR REPLACE INTO *PREFIX*gallery_photos ("album_id", "file_path") VALUES (?, ?)'); - $stmt->execute(array($albumId, $img)); - } - } - } - - public static function isPhoto($filename) { - if (substr(OC_Filesystem::getMimeType($filename), 0, 6) == "image/") - return 1; - return 0; - } -} -?> diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php deleted file mode 100644 index 45f70daa2e0..00000000000 --- a/apps/gallery/templates/index.php +++ /dev/null @@ -1,22 +0,0 @@ -<? -OC_Util::addStyle('gallery', 'styles'); -OC_Util::addScript('gallery', 'album_cover'); -?> - -<div id="controls"> - <input type="button" value="New album" onclick="javascript:createNewAlbum();" /> - <input type="button" value="Rescan" onclick="javascript:scanForAlbums();" /><br/> -</div> -<div id="gallery_list"> -<? -require_once('base.php'); -foreach ($_['r'] as $r) { -?> - <div class="gallery_album_box"> - <a href="?view=<? echo $r['album_name']; ?>"><img class="gallery_album_cover"></a> - <h1><? echo $r['album_name']; ?></h1> - </div> -<? -} -?> -</div> diff --git a/apps/gallery/templates/view_album.php b/apps/gallery/templates/view_album.php deleted file mode 100644 index c1298a22c22..00000000000 --- a/apps/gallery/templates/view_album.php +++ /dev/null @@ -1,20 +0,0 @@ -<? -OC_Util::addStyle('gallery', 'styles'); -OC_Util::addScript('gallery', 'album_cover'); -OC_Util::addScript( 'files_imageviewer', 'lightbox' ); -OC_Util::addStyle( 'files_imageviewer', 'lightbox' ); -?> - -<div id="controls"> - <a href="?"><input type="button" value="Back" /></a><br/> -</div> -<div id="gallery_list"> -<? -foreach ($_['photos'] as $a) { -?> -<a onclick="javascript:viewImage('/','<? echo $a; ?>');"><img src="ajax/thumbnail.php?img=<? echo $a ?>"></a> -<? - } -?> - -</div> |