Merge branch 'stable4' of git://gitorious.org/owncloud/owncloud into stable4
This commit is contained in:
commit
cdac0eae46
18 changed files with 608 additions and 374 deletions
2
apps/external/ajax/setsites.php
vendored
2
apps/external/ajax/setsites.php
vendored
|
@ -12,7 +12,7 @@ OCP\User::checkAdminUser();
|
|||
$sites = array();
|
||||
for ($i = 0; $i < sizeof($_POST['site_name']); $i++) {
|
||||
if (!empty($_POST['site_name'][$i]) && !empty($_POST['site_url'][$i])) {
|
||||
array_push($sites, array($_POST['site_name'][$i], $_POST['site_url'][$i]));
|
||||
array_push($sites, array(strip_tags($_POST['site_name'][$i]), strip_tags($_POST['site_url'][$i])));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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'];
|
||||
|
||||
$image = OC_Gallery_Photo::getThumbnail($img);
|
||||
$img = $_GET['filepath'];
|
||||
|
||||
$image = \OC\Pictures\ThumbnailsManager::getInstance()->getThumbnail($img);
|
||||
if ($image) {
|
||||
OCP\Response::enableCaching(3600 * 24); // 24 hour
|
||||
$image->show();
|
||||
|
|
|
@ -26,6 +26,8 @@ OC::$CLASSPATH['OC_Gallery_Photo'] = 'apps/gallery/lib/photo.php';
|
|||
OC::$CLASSPATH['OC_Gallery_Scanner'] = 'apps/gallery/lib/scanner.php';
|
||||
OC::$CLASSPATH['OC_Gallery_Sharing'] = 'apps/gallery/lib/sharing.php';
|
||||
OC::$CLASSPATH['OC_Gallery_Hooks_Handlers'] = 'apps/gallery/lib/hooks_handlers.php';
|
||||
OC::$CLASSPATH['Pictures_Managers'] = 'apps/gallery/lib/managers.php';
|
||||
OC::$CLASSPATH['Pictures_Tiles'] = 'apps/gallery/lib/tiles.php';
|
||||
|
||||
$l = OC_L10N::get('gallery');
|
||||
|
||||
|
@ -53,6 +55,6 @@ class OC_GallerySearchProvider extends OC_Search_Provider{
|
|||
}
|
||||
}
|
||||
|
||||
OC_Search::registerProvider('OC_GallerySearchProvider');
|
||||
//OC_Search::registerProvider('OC_GallerySearchProvider');
|
||||
|
||||
require_once('apps/gallery/lib/hooks_handlers.php');
|
||||
|
|
|
@ -5,16 +5,8 @@
|
|||
<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>
|
||||
|
@ -22,48 +14,22 @@
|
|||
<length>64</length>
|
||||
</field>
|
||||
<field>
|
||||
<name>album_name</name>
|
||||
<type>text</type>
|
||||
<notnull>true</notnull>
|
||||
<length>100</length>
|
||||
</field>
|
||||
<field>
|
||||
<name>album_path</name>
|
||||
<name>path</name>
|
||||
<type>text</type>
|
||||
<notnull>true</notnull>
|
||||
<length>256</length>
|
||||
</field>
|
||||
<field>
|
||||
<name>parent_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>
|
||||
<type>integer</type>
|
||||
<default>0</default>
|
||||
<notnull>true</notnull>
|
||||
<length>4</length>
|
||||
</field>
|
||||
<field>
|
||||
<name>file_path</name>
|
||||
<type>text</type>
|
||||
<name>height</name>
|
||||
<type>integer</type>
|
||||
<notnull>true</notnull>
|
||||
<length>256</length>
|
||||
<length>4</length>
|
||||
</field>
|
||||
</declaration>
|
||||
</table>
|
||||
|
|
9
apps/gallery/appinfo/update.php
Normal file
9
apps/gallery/appinfo/update.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
$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('./database.xml');
|
||||
|
|
@ -1 +1 @@
|
|||
0.4.3
|
||||
0.5.0
|
||||
|
|
|
@ -1,20 +1,6 @@
|
|||
div#gallery_list { margin: 4.5em 2em 0 2em; }
|
||||
div#gallery_list.leftcontent { padding-top: 15pt; margin: 0; position: absolute; bottom:0px; text-align: center; overflow: auto; }
|
||||
div.gallery_box { width: 200px; position:relative; text-align: center; border: 0; display: inline-block; margin: 5pt; vertical-align: top; padding: 5px 5px 5px 5px; position: relative; -webkit-transition: color 0.5s ease-in-out; -o-transition: color 0.5s ease-in-out; -moz-transition: color 0.5s ease-in-out;color: #BBB;}
|
||||
div.album {border: 1px solid #e0e0e0; border-radius: 7px;}
|
||||
div.gallery_box h1 { font-size: 9pt; font-family: Verdana; }
|
||||
div.gallery_album_decoration { width: 200px; position: absolute; border: 0; height: 20px; top: 5px; text-align:right; vertical-align:middle; background-color: #eee; opacity: 0; -webkit-transition: opacity 0.5s ease-in-out; -moz-transition: opacity 0.5s ease-in-out; -o-transition: opacity 0.5s ease-in-out; }
|
||||
div.gallery_box:hover { color: black; }
|
||||
div.gallery_box:hover div.gallery_album_decoration { opacity: 0.7;}
|
||||
div.gallery_album_decoration a {padding: 0 4pt; cursor: pointer;}
|
||||
div.gallery_album_cover { width: 200px; height: 200px; border: 0; padding: 0; position:relative;}
|
||||
div.gallery_box:hover div.gallery_control_overlay { opacity:0.5 }
|
||||
div.gallery_control_overlay a { color:white; }
|
||||
#gallery_images.rightcontent { padding:10px 5px; bottom: 0px; overflow: auto; right:0px}
|
||||
#scan { position:absolute; right:13.5em; top:0em; }
|
||||
#scan #scanprogressbar { position:relative; display:inline-block; width:10em; height:1.5em; top:.4em; }
|
||||
#gallerycontent { margin-top: 2.8em; overflow: visible; }
|
||||
#g-settings {position: absolute; left 13.5em; top: 0;}
|
||||
input[type=button] { -webkit-transition: opacity 0.5s ease-in-out; -moz-transition: opacity 0.5s ease-in-out; -o-transition: opacity 0.5s ease-in-out; opacity: 1}
|
||||
div#controls input[type=button] { -webkit-transition: opacity 0.5s ease-in-out; -moz-transition: opacity 0.5s ease-in-out; -o-transition: opacity 0.5s ease-in-out; opacity: 1; position:absolute; right:13.5em; top:0em; }
|
||||
input[type=button]:disabled { opacity: 0.5 }
|
||||
.ui-dialog tr {background-color: #eee;}
|
||||
.ui-dialog input {width: 90%;}
|
||||
|
|
|
@ -27,30 +27,10 @@ OCP\User::checkLoggedIn();
|
|||
OCP\App::checkAppEnabled('gallery');
|
||||
OCP\App::setActiveNavigationEntry( 'gallery_index' );
|
||||
|
||||
if (!file_exists(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery')) {
|
||||
mkdir(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery');
|
||||
}
|
||||
OCP\Util::addStyle('files', 'files');
|
||||
OCP\Util::addStyle('gallery', 'styles');
|
||||
OCP\Util::addScript('gallery', 'pictures');
|
||||
|
||||
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();
|
||||
?>
|
||||
|
|
|
@ -1,138 +0,0 @@
|
|||
var actual_cover;
|
||||
var paths = [];
|
||||
var crumbCount = 0;
|
||||
$(document).ready(returnToElement(0));
|
||||
|
||||
function returnToElement(num) {
|
||||
while (crumbCount != num) {
|
||||
$('#g-album-navigation .last').remove();
|
||||
$('#g-album-navigation .crumb :last').parent().addClass('last');
|
||||
crumbCount--;
|
||||
paths.pop();
|
||||
}
|
||||
var p='';
|
||||
for (var i in paths) p += paths[i]+'/';
|
||||
$('#g-album-loading').show();
|
||||
$.getJSON(OC.filePath('gallery','ajax','galleryOp.php'), {operation: 'get_gallery', path: p }, albumClickHandler);
|
||||
}
|
||||
|
||||
function albumClick(title) {
|
||||
paths.push(title);
|
||||
crumbCount++;
|
||||
var p = '';
|
||||
for (var i in paths) p += paths[i]+'/';
|
||||
$('#g-album-loading').show();
|
||||
$.getJSON(OC.filePath('gallery','ajax','galleryOp.php'), {operation: 'get_gallery', path: p }, function(r) {
|
||||
albumClickHandler(r);
|
||||
if ($('#g-album-navigation :last-child'))
|
||||
$('#g-album-navigation :last-child').removeClass('last');
|
||||
$('#g-album-navigation').append('<div class="crumb last real" style="background-image:url(\''+OC.imagePath('core','breadcrumb')+'\')"><a href=\"javascript:returnToElement('+crumbCount+');\">'+decodeURIComponent(escape(title))+'</a></div>');
|
||||
});
|
||||
}
|
||||
|
||||
function constructSharingPath() {
|
||||
return document.location.protocol + '//' + document.location.host + OC.linkTo('', 'public.php') + '?service=gallery&token=' + Albums.token;
|
||||
}
|
||||
|
||||
function shareGallery() {
|
||||
var existing_token = '';
|
||||
if (Albums.token)
|
||||
existing_token = constructSharingPath();
|
||||
var form_fields = [{text: 'Share', name: 'share', type: 'checkbox', value: Albums.shared},
|
||||
{text: 'Share recursive', name: 'recursive', type: 'checkbox', value: Albums.recursive},
|
||||
{text: 'Shared gallery address', name: 'address', type: 'text', value: existing_token}];
|
||||
OC.dialogs.form(form_fields, t('gallery', 'Share gallery'), function(values){
|
||||
var p = '';
|
||||
for (var i in paths) p += paths[i]+'/';
|
||||
if (p == '') p = '/';
|
||||
alert(p);
|
||||
$.getJSON(OC.filePath('gallery', 'ajax', 'galleryOp.php'), {operation: 'share', path: p, share: values[0].value, recursive: values[1].value}, function(r) {
|
||||
if (r.status == 'success') {
|
||||
Albums.shared = r.sharing;
|
||||
if (Albums.shared) {
|
||||
Albums.token = r.token;
|
||||
Albums.recursive = r.recursive;
|
||||
} else {
|
||||
Albums.token = '';
|
||||
Albums.recursive = false;
|
||||
}
|
||||
var actual_addr = '';
|
||||
if (Albums.token)
|
||||
actual_addr = constructSharingPath();
|
||||
$('input[name="address"]').val(actual_addr);
|
||||
} else {
|
||||
OC.dialogs.alert(t('gallery', 'Error: ') + r.cause, t('gallery', 'Internal error'));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function albumClickHandler(r) {
|
||||
Albums.photos = [];
|
||||
Albums.albums = [];
|
||||
if (r.status == 'success') {
|
||||
for (var i in r.albums) {
|
||||
var a = r.albums[i];
|
||||
Albums.add(a.name, a.numOfItems, a.path, a.shared, a.recursive, a.token);
|
||||
}
|
||||
for (var i in r.photos) {
|
||||
Albums.photos.push(r.photos[i]);
|
||||
}
|
||||
Albums.shared = r.shared;
|
||||
if (Albums.shared) {
|
||||
Albums.recursive = r.recursive;
|
||||
Albums.token = r.token;
|
||||
} else {
|
||||
Albums.recursive = false;
|
||||
Albums.token = '';
|
||||
}
|
||||
$(document).ready(function(){
|
||||
var targetDiv = $('#gallery_list');
|
||||
targetDiv.html('');
|
||||
Albums.display(targetDiv);
|
||||
//$('#gallery_list').sortable({revert:true});
|
||||
$('.album').each(function(i, el) {
|
||||
$(el).click(albumClick.bind(null,$(el).attr('title')));
|
||||
//$(el).draggable({connectToSortable: '#gallery_list', handle: '.dummy'});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
OC.dialogs.alert(t('gallery', 'Error: ') + r.cause, t('gallery', 'Internal error'));
|
||||
}
|
||||
$('#g-album-loading').hide();
|
||||
}
|
||||
|
||||
var albumCounter = 0;
|
||||
var totalAlbums = 0;
|
||||
|
||||
function scanForAlbums(cleanup) {
|
||||
Scanner.scanAlbums();
|
||||
return;
|
||||
}
|
||||
|
||||
function settings() {
|
||||
OC.dialogs.form([{text: t('gallery', 'Scanning root'), name: 'root', type:'text', value:gallery_scanning_root},
|
||||
{text: t('gallery', 'Default order'), name: 'order', type:'select', value:gallery_default_order, options:[
|
||||
{text:t('gallery', 'Ascending'), value:'ASC'}, {text: t('gallery', 'Descending'), value:'DESC'} ]}],
|
||||
t('gallery', 'Settings'),
|
||||
function(values) {
|
||||
var scanning_root = values[0].value;
|
||||
var disp_order = values[1].value;
|
||||
if (scanning_root == '') {
|
||||
OC.dialogs.alert(t('gallery', 'Scanning root cannot be empty'), t('gallery', 'Error'));
|
||||
return;
|
||||
}
|
||||
$.getJSON(OC.filePath('gallery','ajax','galleryOp.php'), {operation: 'store_settings', root: scanning_root, order: disp_order}, function(r) {
|
||||
if (r.status == 'success') {
|
||||
if (r.rescan == 'yes') {
|
||||
Albums.clear(document.getElementById('gallery_list'));
|
||||
scanForAlbums(true);
|
||||
}
|
||||
gallery_scanning_root = scanning_root;
|
||||
} else {
|
||||
OC.dialogs.alert(t('gallery', 'Error: ') + r.cause, t('gallery', 'Error'));
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
37
apps/gallery/js/pictures.js
Normal file
37
apps/gallery/js/pictures.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
function constructSharingPath() {
|
||||
return document.location.protocol + '//' + document.location.host + OC.linkTo('', 'public.php') + '?service=gallery&token=' + Albums.token;
|
||||
}
|
||||
|
||||
function shareGallery() {
|
||||
var existing_token = '';
|
||||
//if (Albums.token)
|
||||
// existing_token = constructSharingPath();
|
||||
var form_fields = [{text: 'Share', name: 'share', type: 'checkbox', value: false},
|
||||
{text: 'Share recursive', name: 'recursive', type: 'checkbox', value: false},
|
||||
{text: 'Shared gallery address', name: 'address', type: 'text', value: ''}];
|
||||
OC.dialogs.form(form_fields, t('gallery', 'Share gallery'), function(values){
|
||||
var p = '';
|
||||
for (var i in paths) p += paths[i]+'/';
|
||||
if (p == '') p = '/';
|
||||
alert(p);
|
||||
$.getJSON(OC.filePath('gallery', 'ajax', 'galleryOp.php'), {operation: 'share', path: p, share: values[0].value, recursive: values[1].value}, function(r) {
|
||||
if (r.status == 'success') {
|
||||
Albums.shared = r.sharing;
|
||||
if (Albums.shared) {
|
||||
Albums.token = r.token;
|
||||
Albums.recursive = r.recursive;
|
||||
} else {
|
||||
Albums.token = '';
|
||||
Albums.recursive = false;
|
||||
}
|
||||
var actual_addr = '';
|
||||
if (Albums.token)
|
||||
actual_addr = constructSharingPath();
|
||||
$('input[name="address"]').val(actual_addr);
|
||||
} else {
|
||||
OC.dialogs.alert(t('gallery', 'Error: ') + r.cause, t('gallery', 'Internal error'));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
|
@ -13,136 +13,30 @@
|
|||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, "OC_Gallery_Hooks_Handlers", "addPhotoFromPath");
|
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_delete, "OC_Gallery_Hooks_Handlers", "removePhoto");
|
||||
//OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_rename, "OC_Gallery_Hooks_Handlers", "renamePhoto");
|
||||
|
||||
require_once(OC::$CLASSPATH['OC_Gallery_Album']);
|
||||
require_once(OC::$CLASSPATH['OC_Gallery_Photo']);
|
||||
require_once(OC::$CLASSPATH['Pictures_Managers']);
|
||||
|
||||
class OC_Gallery_Hooks_Handlers {
|
||||
private static $APP_TAG = "Gallery";
|
||||
|
||||
private static function isPhoto($filename) {
|
||||
$ext = strtolower(substr($filename, strrpos($filename, '.')+1));
|
||||
return $ext=='png' || $ext=='jpeg' || $ext=='jpg' || $ext=='gif';
|
||||
}
|
||||
public static function removePhoto($params) {
|
||||
\OC\Pictures\ThumbnailsManager::getInstance()->delete($params[OC_Filesystem::signal_param_path]);
|
||||
}
|
||||
|
||||
private static function directoryContainsPhotos($dirpath) {
|
||||
$dirhandle = OC_Filesystem::opendir($dirpath.'/');
|
||||
if ($dirhandle != FALSE) {
|
||||
while (($filename = readdir($dirhandle)) != FALSE) {
|
||||
if ($filename[0] == '.') continue;
|
||||
if (self::isPhoto($dirpath.'/'.$filename)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function createAlbum($path) {
|
||||
$new_album_name = trim(str_replace('/', '.', $path), '.');
|
||||
if ($new_album_name == '')
|
||||
$new_album_name = 'main';
|
||||
|
||||
OCP\Util::writeLog(self::$APP_TAG, 'Creating new album '.$new_album_name, OCP\Util::DEBUG);
|
||||
OC_Gallery_Album::create(OCP\USER::getUser(), $new_album_name, $path);
|
||||
|
||||
return OC_Gallery_Album::find(OCP\USER::getUser(), null, $path);
|
||||
}
|
||||
|
||||
public static function pathInRoot($path) {
|
||||
$root = OCP\Config::getUserValue(OCP\USER::getUser(), 'gallery', 'root', '/');
|
||||
return substr($path, 0, strlen($path)>strlen($root)?strlen($root):strlen($path)) == $root;
|
||||
}
|
||||
|
||||
public static function addPhotoFromPath($params) {
|
||||
$fullpath = $params[OC_Filesystem::signal_param_path];
|
||||
$fullpath = rtrim(dirname($fullpath),'/').'/'.basename($fullpath);
|
||||
|
||||
if (!self::isPhoto($fullpath)) return;
|
||||
|
||||
$a = OC_Gallery_Album::find(OCP\USER::getUser(), null, dirname($fullpath));
|
||||
if (!($r = $a->fetchRow())) {
|
||||
OC_Gallery_Album::create(OCP\USER::getUser(), basename(dirname($fullpath)), dirname($fullpath));
|
||||
$a = OC_Gallery_Album::find(OCP\USER::getUser(), null, dirname($fullpath));
|
||||
$r = $a->fetchRow();
|
||||
}
|
||||
$albumId = $r['album_id'];
|
||||
$p = OC_Gallery_Album::find($albumId, $fullpath);
|
||||
if (!($p->fetchRow()))
|
||||
OC_Gallery_Photo::create($albumId, $fullpath);
|
||||
}
|
||||
|
||||
public static function removePhoto($params) {
|
||||
$fullpath = $params[OC_Filesystem::signal_param_path];
|
||||
$fullpath = rtrim(dirname($fullpath),'/').'/'.basename($fullpath);
|
||||
|
||||
if (OC_Filesystem::is_dir($fullpath)) {
|
||||
OC_Gallery_Album::remove(OCP\USER::getUser(), null, $fullpath);
|
||||
} elseif (self::isPhoto($fullpath)) {
|
||||
$a = OC_Gallery_Album::find(OCP\USER::getUser(), null, rtrim(dirname($fullpath),'/'));
|
||||
if (($r = $a->fetchRow())) {
|
||||
OC_Gallery_Photo::removeByPath($fullpath, $r['album_id']);
|
||||
$p = OC_Gallery_Photo::findForAlbum(OCP\USER::getUser(), $r['album_name']);
|
||||
if (!($p->fetchRow())) {
|
||||
OC_Gallery_Album::remove(OCP\USER::getUser(), null, dirname($fullpath));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function renamePhoto($params) {
|
||||
$oldpath = $params[OC_Filesystem::signal_param_oldpath];
|
||||
$newpath = $params[OC_Filesystem::signal_param_newpath];
|
||||
if (OC_Filesystem::is_dir($newpath.'/') && self::directoryContainsPhotos($newpath)) {
|
||||
OC_Gallery_Album::changePath($oldpath, $newpath, OCP\USER::getUser());
|
||||
} elseif (self::isPhoto($newpath)) {
|
||||
$olddir = dirname($oldpath);
|
||||
$newdir = dirname($newpath);
|
||||
if ($olddir == '') $olddir = '/';
|
||||
if ($newdir == '') $newdir = '/';
|
||||
if (!self::isPhoto($newpath)) return;
|
||||
OCP\Util::writeLog(self::$APP_TAG, 'Moving photo from '.$oldpath.' to '.$newpath, OCP\Util::DEBUG);
|
||||
$album;
|
||||
$newAlbumId;
|
||||
$oldAlbumId;
|
||||
if ($olddir == $newdir) {
|
||||
// album changing is not needed
|
||||
$albums = OC_Gallery_Album::find(OCP\USER::getUser(), null, $olddir);
|
||||
$album = $albums->fetchRow();
|
||||
if (!$album) {
|
||||
$albums = self::createAlbum($newdir);
|
||||
$album = $albums->fetchRow();
|
||||
}
|
||||
$newAlbumId = $oldAlbumId = $album['album_id'];
|
||||
} else {
|
||||
$newalbum = OC_Gallery_Album::find(OCP\USER::getUser(), null, $newdir);
|
||||
$oldalbum = OC_Gallery_Album::find(OCP\USER::getUser(), null, $olddir);
|
||||
|
||||
if (!($newalbum = $newalbum->fetchRow())) {
|
||||
$newalbum = self::createAlbum($newdir);
|
||||
$newalbum = $newalbum->fetchRow();
|
||||
}
|
||||
$oldalbum = $oldalbum->fetchRow();
|
||||
if (!$oldalbum) {
|
||||
OC_Gallery_Photo::create($newalbum['album_id'], $newpath);
|
||||
return;
|
||||
}
|
||||
$newAlbumId = $newalbum['album_id'];
|
||||
$oldAlbumId = $oldalbum['album_id'];
|
||||
|
||||
}
|
||||
OC_Gallery_Photo::changePath($oldAlbumId, $newAlbumId, $oldpath, $newpath);
|
||||
}
|
||||
}
|
||||
public static function renamePhoto($params) {
|
||||
$oldpath = $params[OC_Filesystem::signal_param_oldpath];
|
||||
$newpath = $params[OC_Filesystem::signal_param_newpath];
|
||||
//TODO: implement this
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
97
apps/gallery/lib/managers.php
Normal file
97
apps/gallery/lib/managers.php
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
namespace OC\Pictures;
|
||||
|
||||
require_once('lib/base.php');
|
||||
|
||||
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;
|
||||
}
|
||||
$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()));
|
||||
$ret = array('path' => $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);
|
||||
if (!$arr) {
|
||||
$thubnail = $this->getThumbnail($path);
|
||||
unset($thubnail);
|
||||
$arr = DatabaseManager::getInstance()->getFileData($path);
|
||||
}
|
||||
$ret = array('filepath' => $arr['path'],
|
||||
'width' => $arr['width'],
|
||||
'height' => $arr['height']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function delete($path) {
|
||||
unlink(\OCP\Config::getSystemValue('datadirectory').'/'.\OC_User::getUser()."/gallery".$path);
|
||||
}
|
||||
|
||||
private function __construct() {}
|
||||
|
||||
}
|
||||
?>
|
178
apps/gallery/lib/tiles.php
Normal file
178
apps/gallery/lib/tiles.php
Normal file
|
@ -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="'.htmlentities(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:explode(this);return false;';
|
||||
}
|
||||
|
||||
public function getOnOutAction() {
|
||||
return 'javascript:deplode(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;
|
||||
}
|
||||
|
||||
?>
|
87
apps/gallery/lib/tiles_test.php
Normal file
87
apps/gallery/lib/tiles_test.php
Normal file
|
@ -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();
|
||||
|
||||
?>
|
|
@ -1,31 +1,122 @@
|
|||
<?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');
|
||||
$root = !empty($_GET['root']) ? $_GET['root'] : '/';
|
||||
?>
|
||||
<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>
|
||||
<style>
|
||||
div.gallery_div {position:relative; display: inline-block; height: 152px; width: 150px; margin: 5px;}
|
||||
div.miniature_border {position:absolute; height: 150px; -moz-transition-duration: 0.2s; -o-transition-duration:0.2s; -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; -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.visible { opacity: 0.8;}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
|
||||
var root = "<?php echo $root; ?>";
|
||||
|
||||
function explode(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 deplode(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>
|
||||
|
||||
<div id="controls"><?php
|
||||
$sr = trim($root, '/');
|
||||
if (!empty($sr)) {
|
||||
$paths = explode('/', $sr);
|
||||
$path = '/';
|
||||
for ($i = 0; $i < count($paths); $i++) {
|
||||
$path .= urlencode($paths[$i]).'/';
|
||||
$classess = 'crumb'.($i == count($paths)-1?' last':'');
|
||||
echo '<div class="'.$classess.'" style="background-image:url(\''.\OCP\image_path('core','breadcrumb.png').'\')"><a href="'.\OCP\Util::linkTo('gallery', 'index.php').'&root='.$path.'">'.$paths[$i].'</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
?> <!--<a href="javascript:shareGallery();"><input type="button" value="<?php echo $l->t('Share');?>" /></a>--><br/>
|
||||
</div>
|
||||
<div id="gallery_list">
|
||||
<div id="gallerycontent">
|
||||
<?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();
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
|
|
@ -341,6 +341,20 @@ class OC_Filesystem{
|
|||
return self::$defaultInstance->getLocalFile($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* return path to file which reflects one visible in browser
|
||||
* @param string path
|
||||
* @return string
|
||||
*/
|
||||
static public function getLocalPath($path) {
|
||||
$datadir = \OCP\Config::getSystemValue('datadirectory').'/'.\OC_User::getUser().'/files';
|
||||
$newpath = $path;
|
||||
if (strncmp($newpath, $datadir, strlen($datadir)) == 0) {
|
||||
$newpath = substr($path, strlen($datadir));
|
||||
}
|
||||
return $newpath;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the requested path is valid
|
||||
* @param string path
|
||||
|
|
|
@ -136,6 +136,8 @@ class OC_Image {
|
|||
*/
|
||||
private function _output($filepath=null) {
|
||||
if($filepath) {
|
||||
if (!file_exists(dirname($filepath)))
|
||||
mkdir(dirname($filepath), 0777, true);
|
||||
if(!is_writable(dirname($filepath))) {
|
||||
OC_Log::write('core',__METHOD__.'(): Directory \''.dirname($filepath).'\' is not writable.', OC_Log::ERROR);
|
||||
return false;
|
||||
|
@ -398,7 +400,9 @@ class OC_Image {
|
|||
break;
|
||||
*/
|
||||
default:
|
||||
$this->resource = imagecreatefromstring(file_get_contents($imagepath));
|
||||
|
||||
// this is mostly file created from encrypted file
|
||||
$this->resource = imagecreatefromstring(\OC_Filesystem::file_get_contents(\OC_Filesystem::getLocalPath($imagepath)));
|
||||
$itype = IMAGETYPE_PNG;
|
||||
OC_Log::write('core','OC_Image->loadFromFile, Default', OC_Log::DEBUG);
|
||||
break;
|
||||
|
@ -419,7 +423,7 @@ class OC_Image {
|
|||
if(is_resource($str)) {
|
||||
return false;
|
||||
}
|
||||
$this->resource = imagecreatefromstring($str);
|
||||
$this->resource = @imagecreatefromstring($str);
|
||||
if(!$this->resource) {
|
||||
OC_Log::write('core','OC_Image->loadFromData, couldn\'t load', OC_Log::DEBUG);
|
||||
return false;
|
||||
|
@ -438,7 +442,7 @@ class OC_Image {
|
|||
}
|
||||
$data = base64_decode($str);
|
||||
if($data) { // try to load from string data
|
||||
$this->resource = imagecreatefromstring($data);
|
||||
$this->resource = @imagecreatefromstring($data);
|
||||
if(!$this->resource) {
|
||||
OC_Log::write('core','OC_Image->loadFromBase64, couldn\'t load', OC_Log::DEBUG);
|
||||
return false;
|
||||
|
@ -489,6 +493,32 @@ class OC_Image {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function preciseResize($width, $height) {
|
||||
if (!$this->valid()) {
|
||||
OC_Log::write('core',__METHOD__.'(): No image loaded', OC_Log::ERROR);
|
||||
return false;
|
||||
}
|
||||
$width_orig=imageSX($this->resource);
|
||||
$height_orig=imageSY($this->resource);
|
||||
$process = imagecreatetruecolor($width, $height);
|
||||
|
||||
if ($process == false) {
|
||||
OC_Log::write('core',__METHOD__.'(): Error creating true color image',OC_Log::ERROR);
|
||||
imagedestroy($process);
|
||||
return false;
|
||||
}
|
||||
|
||||
imagecopyresampled($process, $this->resource, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
|
||||
if ($process == false) {
|
||||
OC_Log::write('core',__METHOD__.'(): Error resampling process image '.$width.'x'.$height,OC_Log::ERROR);
|
||||
imagedestroy($process);
|
||||
return false;
|
||||
}
|
||||
imagedestroy($this->resource);
|
||||
$this->resource = $process;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Crops the image to the middle square. If the image is already square it just returns.
|
||||
* @param int maximum size for the result (optional)
|
||||
|
|
|
@ -83,7 +83,7 @@ class OC_Util {
|
|||
* @return array
|
||||
*/
|
||||
public static function getVersion(){
|
||||
return array(4,00,1);
|
||||
return array(4,00,2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,7 +91,7 @@ class OC_Util {
|
|||
* @return string
|
||||
*/
|
||||
public static function getVersionString(){
|
||||
return '4.0.1';
|
||||
return '4.0.2';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue