Merge branch 'master' into calendar_repeat

This commit is contained in:
Georg Ehrke 2012-06-09 12:30:39 +02:00
commit c83f418a02
28 changed files with 157 additions and 340 deletions

View File

@ -59,7 +59,7 @@ if ($fn) {
bailOut(OC_Contacts_App::$l10n->t('Couldn\'t save temporary image: ').$tmpkey); bailOut(OC_Contacts_App::$l10n->t('Couldn\'t save temporary image: ').$tmpkey);
} }
} else { } else {
bailOut(OC_Contacts_App::$l10n->t('Couldn\'t load temporary image: ').$tmpkey.$data); bailOut(OC_Contacts_App::$l10n->t('Couldn\'t load temporary image: ').$tmpkey);
} }
} }

View File

@ -18,7 +18,7 @@ class OC_Filestorage_Archive extends OC_Filestorage_Common{
private static $rootView; private static $rootView;
private function stripPath($path){//files should never start with / private function stripPath($path){//files should never start with /
if(substr($path,0,1)=='/'){ if(!$path || $path[0]=='/'){
$path=substr($path,1); $path=substr($path,1);
} }
return $path; return $path;

View File

@ -21,7 +21,7 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
$this->password=$params['password']; $this->password=$params['password'];
$this->secure=isset($params['secure'])?(bool)$params['secure']:false; $this->secure=isset($params['secure'])?(bool)$params['secure']:false;
$this->root=isset($params['root'])?$params['root']:'/'; $this->root=isset($params['root'])?$params['root']:'/';
if(substr($this->root,0,1)!='/'){ if(!$this->root || $this->root[0]!='/'){
$this->root='/'.$this->root; $this->root='/'.$this->root;
} }

View File

@ -23,13 +23,13 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
$this->password=$params['password']; $this->password=$params['password'];
$this->share=$params['share']; $this->share=$params['share'];
$this->root=isset($params['root'])?$params['root']:'/'; $this->root=isset($params['root'])?$params['root']:'/';
if(!$this->root || $this->root[0]!='/'){
$this->root='/'.$this->root;
}
if(substr($this->root,-1,1)!='/'){ if(substr($this->root,-1,1)!='/'){
$this->root.='/'; $this->root.='/';
} }
if(substr($this->root,0,1)!='/'){ if(!$this->share || $this->share[0]!='/'){
$this->root='/'.$this->root;
}
if(substr($this->share,0,1)!='/'){
$this->share='/'.$this->share; $this->share='/'.$this->share;
} }
if(substr($this->share,-1,1)=='/'){ if(substr($this->share,-1,1)=='/'){

View File

@ -269,7 +269,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
$this->user=$params['user']; $this->user=$params['user'];
$this->root=isset($params['root'])?$params['root']:'/'; $this->root=isset($params['root'])?$params['root']:'/';
$this->secure=isset($params['secure'])?(bool)$params['secure']:true; $this->secure=isset($params['secure'])?(bool)$params['secure']:true;
if(substr($this->root,0,1)!='/'){ if(!$this->root || $this->root[0]!='/'){
$this->root='/'.$this->root; $this->root='/'.$this->root;
} }
$this->auth = new CF_Authentication($this->user, $this->token, null, $this->host); $this->auth = new CF_Authentication($this->user, $this->token, null, $this->host);

View File

@ -25,7 +25,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$this->password=$params['password']; $this->password=$params['password'];
$this->secure=isset($params['secure'])?(bool)$params['secure']:false; $this->secure=isset($params['secure'])?(bool)$params['secure']:false;
$this->root=isset($params['root'])?$params['root']:'/'; $this->root=isset($params['root'])?$params['root']:'/';
if(substr($this->root,0,1)!='/'){ if(!$this->root || $this->root[0]!='/'){
$this->root='/'.$this->root; $this->root='/'.$this->root;
} }
if(substr($this->root,-1,1)!='/'){ if(substr($this->root,-1,1)!='/'){
@ -273,7 +273,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
} }
private function cleanPath($path){ private function cleanPath($path){
if(substr($path,0,1)=='/'){ if(!$path || $path[0]=='/'){
return substr($path,1); return substr($path,1);
}else{ }else{
return $path; return $path;

View File

@ -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_Scanner'] = 'apps/gallery/lib/scanner.php';
OC::$CLASSPATH['OC_Gallery_Sharing'] = 'apps/gallery/lib/sharing.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['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'); $l = OC_L10N::get('gallery');

View File

@ -1,20 +1,6 @@
div#gallery_list { margin: 4.5em 2em 0 2em; } #gallerycontent { margin-top: 2.8em; overflow: visible; }
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; }
#g-settings {position: absolute; left 13.5em; top: 0;} #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 } input[type=button]:disabled { opacity: 0.5 }
.ui-dialog tr {background-color: #eee;} .ui-dialog tr {background-color: #eee;}
.ui-dialog input {width: 90%;} .ui-dialog input {width: 90%;}

View File

@ -27,6 +27,10 @@ OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('gallery'); OCP\App::checkAppEnabled('gallery');
OCP\App::setActiveNavigationEntry( 'gallery_index' ); OCP\App::setActiveNavigationEntry( 'gallery_index' );
OCP\Util::addStyle('files', 'files');
OCP\Util::addStyle('gallery', 'styles');
OCP\Util::addScript('gallery', 'pictures');
$tmpl = new OCP\Template( 'gallery', 'index', 'user' ); $tmpl = new OCP\Template( 'gallery', 'index', 'user' );
$tmpl->printPage(); $tmpl->printPage();
?> ?>

View File

@ -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;
}
});
});
}

View 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'));
}
});
});
}

View File

@ -21,127 +21,21 @@
* *
*/ */
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_delete, "OC_Gallery_Hooks_Handlers", "removePhoto");
//OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_rename, "OC_Gallery_Hooks_Handlers", "renamePhoto"); //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['Pictures_Managers']);
require_once(OC::$CLASSPATH['OC_Gallery_Photo']);
class OC_Gallery_Hooks_Handlers { 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';
}
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) { public static function removePhoto($params) {
$fullpath = $params[OC_Filesystem::signal_param_path]; \OC\Pictures\ThumbnailsManager::getInstance()->delete($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) { public static function renamePhoto($params) {
$oldpath = $params[OC_Filesystem::signal_param_oldpath]; $oldpath = $params[OC_Filesystem::signal_param_oldpath];
$newpath = $params[OC_Filesystem::signal_param_newpath]; $newpath = $params[OC_Filesystem::signal_param_newpath];
if (OC_Filesystem::is_dir($newpath.'/') && self::directoryContainsPhotos($newpath)) { //TODO: implement this
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);
}
} }
} }

View File

@ -33,7 +33,7 @@ class DatabaseManager {
$stmt = \OCP\DB::prepare('INSERT INTO *PREFIX*pictures_images_cache (uid_owner, path, width, height) VALUES (?, ?, ?, ?)'); $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())); $stmt->execute(array(\OCP\USER::getUser(), $path, $image->width(), $image->height()));
\OCP\DB::commit(); \OCP\DB::commit();
$ret = array('filepath' => $path, 'width' => $image->width(), 'height' => $image->height()); $ret = array('path' => $path, 'width' => $image->width(), 'height' => $image->height());
unset($image); unset($image);
return $ret; return $ret;
} }
@ -88,7 +88,7 @@ class ThumbnailsManager {
} }
public function delete($path) { public function delete($path) {
unlink(\OC::$CONFIG_DATADIRECTORY_ROOT.'/'.\OC_User::getUser()."/gallery".$path); unlink(\OCP\Config::getSystemValue('datadirectory').'/'.\OC_User::getUser()."/gallery".$path);
} }
private function __construct() {} private function __construct() {}

View File

@ -156,11 +156,11 @@ class TileStack extends TileBase {
} }
public function getOnHoverAction() { public function getOnHoverAction() {
return 'javascript:t(this);return false;'; return 'javascript:explode(this);return false;';
} }
public function getOnOutAction() { public function getOnOutAction() {
return 'javascript:o(this);return false;'; return 'javascript:deplode(this);return false;';
} }
public function getCount() { public function getCount() {

View File

@ -1,21 +1,22 @@
<?php <?php
$l = OC_L10N::get('gallery'); $l = OC_L10N::get('gallery');
$root = !empty($_GET['root']) ? $_GET['root'] : '/';
?> ?>
<style> <style>
div.gallery_div {position:relative; display: inline-block; height: 152px; width: 150px; margin: 5px;} 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.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.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{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.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.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;} div.visible { opacity: 0.8;}
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
var root = "<?php echo !empty($_GET['root']) ? $_GET['root'] : '/'; ?>"; var root = "<?php echo $root; ?>";
function t(element) { function explode(element) {
$('div', element).each(function(index, elem) { $('div', element).each(function(index, elem) {
if ($(elem).hasClass('title')) { if ($(elem).hasClass('title')) {
$(elem).addClass('visible'); $(elem).addClass('visible');
@ -27,7 +28,7 @@ function t(element) {
}); });
} }
function o(element) { function deplode(element) {
$('div', element).each(function(index, elem) { $('div', element).each(function(index, elem) {
if ($(elem).hasClass('title')) { if ($(elem).hasClass('title')) {
$(elem).removeClass('visible'); $(elem).removeClass('visible');
@ -55,6 +56,21 @@ $(document).ready(function() {
</script> </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="gallerycontent">
<?php <?php
include('apps/gallery/lib/tiles.php'); include('apps/gallery/lib/tiles.php');
@ -103,3 +119,4 @@ if ($ts->getCount() != 0) {
echo $tl->get(); echo $tl->get();
?> ?>
</div>

View File

@ -576,7 +576,7 @@ class OC_LDAP {
static private function combineFilter($filters, $operator) { static private function combineFilter($filters, $operator) {
$combinedFilter = '('.$operator; $combinedFilter = '('.$operator;
foreach($filters as $filter) { foreach($filters as $filter) {
if(substr($filter,0,1) != '(') { if($filter[0] != '(') {
$filter = '('.$filter.')'; $filter = '('.$filter.')';
} }
$combinedFilter.=$filter; $combinedFilter.=$filter;

View File

@ -469,7 +469,7 @@ class OC_App{
$apps=array(); $apps=array();
$dh=opendir(OC::$APPSROOT.'/apps'); $dh=opendir(OC::$APPSROOT.'/apps');
while($file=readdir($dh)){ while($file=readdir($dh)){
if(substr($file,0,1)!='.' and is_file(OC::$APPSROOT.'/apps/'.$file.'/appinfo/app.php')){ if($file[0]!='.' and is_file(OC::$APPSROOT.'/apps/'.$file.'/appinfo/app.php')){
$apps[]=$file; $apps[]=$file;
} }
} }

View File

@ -150,7 +150,7 @@ class OC_Archive_TAR extends OC_Archive{
$folderContent=array(); $folderContent=array();
$pathLength=strlen($path); $pathLength=strlen($path);
foreach($files as $file){ foreach($files as $file){
if(substr($file,0,1)=='/'){ if($file[0]=='/'){
$file=substr($file,1); $file=substr($file,1);
} }
if(substr($file,0,$pathLength)==$path and $file!=$path){ if(substr($file,0,$pathLength)==$path and $file!=$path){
@ -241,7 +241,7 @@ class OC_Archive_TAR extends OC_Archive{
} }
} }
} }
if(substr($path,0,1)!='/'){//not all programs agree on the use of a leading / if($path[0]!='/'){//not all programs agree on the use of a leading /
return $this->fileExists('/'.$path); return $this->fileExists('/'.$path);
}else{ }else{
return false; return false;

View File

@ -191,7 +191,7 @@ class OC_Archive_ZIP extends OC_Archive{
} }
private function stripPath($path){ private function stripPath($path){
if(substr($path,0,1)=='/'){ if(!$path || $path[0]=='/'){
return substr($path,1); return substr($path,1);
}else{ }else{
return $path; return $path;

View File

@ -427,7 +427,7 @@ class OC{
register_shutdown_function(array('OC_Helper','cleanTmp')); register_shutdown_function(array('OC_Helper','cleanTmp'));
//parse the given parameters //parse the given parameters
self::$REQUESTEDAPP = (isset($_GET['app'])?str_replace(array('\0', '/', '\\', '..'), '', strip_tags($_GET['app'])):OC_Config::getValue('defaultapp', 'files')); self::$REQUESTEDAPP = (isset($_GET['app']) && trim($_GET['app']) != '' && !is_null($_GET['app'])?str_replace(array('\0', '/', '\\', '..'), '', strip_tags($_GET['app'])):OC_Config::getValue('defaultapp', 'files'));
if(substr_count(self::$REQUESTEDAPP, '?') != 0){ if(substr_count(self::$REQUESTEDAPP, '?') != 0){
$app = substr(self::$REQUESTEDAPP, 0, strpos(self::$REQUESTEDAPP, '?')); $app = substr(self::$REQUESTEDAPP, 0, strpos(self::$REQUESTEDAPP, '?'));
$param = substr(self::$REQUESTEDAPP, strpos(self::$REQUESTEDAPP, '?') + 1); $param = substr(self::$REQUESTEDAPP, strpos(self::$REQUESTEDAPP, '?') + 1);

View File

@ -63,8 +63,8 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
* @return int * @return int
*/ */
public function getSize() { public function getSize() {
$this->stat();
return OC_Filesystem::filesize($this->path); return $this->stat_cache['size'];
} }

View File

@ -29,6 +29,11 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* @var string * @var string
*/ */
protected $path; protected $path;
/**
* file stat cache
* @var array
*/
protected $stat_cache;
/** /**
* Sets up the node, expects a full path name * Sets up the node, expects a full path name
@ -77,7 +82,14 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
} }
/**
* Set the stat cache
*/
protected function stat() {
if (!isset($this->stat_cache)) {
$this->stat_cache = OC_Filesystem::stat($this->path);
}
}
/** /**
* Returns the last modification time, as a unix timestamp * Returns the last modification time, as a unix timestamp
@ -85,8 +97,8 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* @return int * @return int
*/ */
public function getLastModified() { public function getLastModified() {
$this->stat();
return OC_Filesystem::filemtime($this->path); return $this->stat_cache['mtime'];
} }
@ -137,7 +149,9 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
/** /**
* Returns a list of properties for this nodes.; * Returns a list of properties for this nodes.;
* *
* The properties list is a list of propertynames the client requested, encoded as xmlnamespace#tagName, for example: http://www.example.org/namespace#author * The properties list is a list of propertynames the client requested,
* encoded as xmlnamespace#tagName, for example:
* http://www.example.org/namespace#author
* If the array is empty, all properties should be returned * If the array is empty, all properties should be returned
* *
* @param array $properties * @param array $properties
@ -153,11 +167,11 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
$existing[$row['propertyname']] = $row['propertyvalue']; $existing[$row['propertyname']] = $row['propertyvalue'];
} }
// if the array was empty, we need to return everything
if(count($properties) == 0){ if(count($properties) == 0){
return $existing; return $existing;
} }
// if the array was empty, we need to return everything
$props = array(); $props = array();
foreach($properties as $property) { foreach($properties as $property) {
if (isset($existing[$property])) $props[$property] = $existing[$property]; if (isset($existing[$property])) $props[$property] = $existing[$property];

View File

@ -27,14 +27,17 @@
* Manipulation happens by using 2 kind of proxy operations, pre and post proxies * Manipulation happens by using 2 kind of proxy operations, pre and post proxies
* that manipulate the filesystem call and the result of the call respectively * that manipulate the filesystem call and the result of the call respectively
* *
* A pre-proxy recieves the filepath as arugments (or 2 filespaths in case of operations like copy or move) and return a boolean * A pre-proxy recieves the filepath as arugments (or 2 filespaths in case of
* If a pre-proxy returnes false the file operation will be canceled * operations like copy or move) and return a boolean
* If a pre-proxy returns false the file operation will be canceled
* All filesystem operations have a pre-proxy * All filesystem operations have a pre-proxy
* *
* A post-proxy recieves 2 arguments, the filepath and the result of the operation. * A post-proxy recieves 2 arguments, the filepath and the result of the operation.
* The return calue of the post-proxy will be used as the new result of the operation * The return value of the post-proxy will be used as the new result of the operation
* The operations that have a post-proxy are * The operations that have a post-proxy are:
* file_get_contents, is_file, is_dir, file_exists, stat, is_readable, is_writable, fileatime, filemtime, filectime, file_get_contents, getMimeType, hash, fopen, free_space and search * file_get_contents, is_file, is_dir, file_exists, stat, is_readable,
* is_writable, fileatime, filemtime, filectime, file_get_contents,
* getMimeType, hash, fopen, free_space and search
*/ */
class OC_FileProxy{ class OC_FileProxy{
@ -42,16 +45,7 @@ class OC_FileProxy{
public static $enabled=true; public static $enabled=true;
/** /**
* check if this proxy implments a specific proxy operation * fallback function when a proxy operation is not implemented
* @param string #proxy name of the proxy operation
* @return bool
*/
public function provides($operation){
return method_exists($this,$operation);
}
/**
* fallback function when a proxy operation is not implement
* @param string $function the name of the proxy operation * @param string $function the name of the proxy operation
* @param mixed * @param mixed
* *
@ -73,11 +67,10 @@ class OC_FileProxy{
self::$proxies[]=$proxy; self::$proxies[]=$proxy;
} }
public static function getProxies($operation,$post){ public static function getProxies($operation){
$operation=(($post)?'post':'pre').$operation;
$proxies=array(); $proxies=array();
foreach(self::$proxies as $proxy){ foreach(self::$proxies as $proxy){
if($proxy->provides($operation)){ if(method_exists($proxy,$operation)){
$proxies[]=$proxy; $proxies[]=$proxy;
} }
} }
@ -88,8 +81,8 @@ class OC_FileProxy{
if(!self::$enabled){ if(!self::$enabled){
return true; return true;
} }
$proxies=self::getProxies($operation,false);
$operation='pre'.$operation; $operation='pre'.$operation;
$proxies=self::getProxies($operation);
foreach($proxies as $proxy){ foreach($proxies as $proxy){
if(!is_null($filepath2)){ if(!is_null($filepath2)){
if($proxy->$operation($filepath,$filepath2)===false){ if($proxy->$operation($filepath,$filepath2)===false){
@ -108,8 +101,8 @@ class OC_FileProxy{
if(!self::$enabled){ if(!self::$enabled){
return $result; return $result;
} }
$proxies=self::getProxies($operation,true);
$operation='post'.$operation; $operation='post'.$operation;
$proxies=self::getProxies($operation);
foreach($proxies as $proxy){ foreach($proxies as $proxy){
$result=$proxy->$operation($path,$result); $result=$proxy->$operation($path,$result);
} }

View File

@ -150,7 +150,7 @@ class OC_Filesystem{
if(!$path){ if(!$path){
$path='/'; $path='/';
} }
if(substr($path,0,1)!=='/'){ if($path[0]!=='/'){
$path='/'.$path; $path='/'.$path;
} }
$foundMountPoint=''; $foundMountPoint='';
@ -281,7 +281,7 @@ class OC_Filesystem{
} }
/** /**
* change the root to a fake toor * change the root to a fake root
* @param string fakeRoot * @param string fakeRoot
* @return bool * @return bool
*/ */
@ -313,12 +313,12 @@ class OC_Filesystem{
* @param string mountpoint * @param string mountpoint
*/ */
static public function mount($class,$arguments,$mountpoint){ static public function mount($class,$arguments,$mountpoint){
if($mountpoint[0]!='/'){
$mountpoint='/'.$mountpoint;
}
if(substr($mountpoint,-1)!=='/'){ if(substr($mountpoint,-1)!=='/'){
$mountpoint=$mountpoint.'/'; $mountpoint=$mountpoint.'/';
} }
if(substr($mountpoint,0,1)!=='/'){
$mountpoint='/'.$mountpoint;
}
self::$mounts[$mountpoint]=array('class'=>$class,'arguments'=>$arguments); self::$mounts[$mountpoint]=array('class'=>$class,'arguments'=>$arguments);
} }
@ -349,7 +349,7 @@ class OC_Filesystem{
* @return bool * @return bool
*/ */
static public function isValidPath($path){ static public function isValidPath($path){
if(substr($path,0,1)!=='/'){ if(!$path || $path[0]!=='/'){
$path='/'.$path; $path='/'.$path;
} }
if(strstr($path,'/../') || strrchr($path, '/') === '/..' ){ if(strstr($path,'/../') || strrchr($path, '/') === '/..' ){

View File

@ -40,6 +40,8 @@
class OC_FilesystemView { class OC_FilesystemView {
private $fakeRoot=''; private $fakeRoot='';
private $internal_path_cache=array();
private $storage_cache=array();
public function __construct($root){ public function __construct($root){
$this->fakeRoot=$root; $this->fakeRoot=$root;
@ -49,7 +51,7 @@ class OC_FilesystemView {
if(!$path){ if(!$path){
$path='/'; $path='/';
} }
if(substr($path,0,1)!=='/'){ if($path[0]!=='/'){
$path='/'.$path; $path='/'.$path;
} }
return $this->fakeRoot.$path; return $this->fakeRoot.$path;
@ -84,7 +86,10 @@ class OC_FilesystemView {
* @return bool * @return bool
*/ */
public function getInternalPath($path){ public function getInternalPath($path){
return OC_Filesystem::getInternalPath($this->getAbsolutePath($path)); if (!isset($this->internal_path_cache[$path])) {
$this->internal_path_cache[$path] = OC_Filesystem::getInternalPath($this->getAbsolutePath($path));
}
return $this->internal_path_cache[$path];
} }
/** /**
* get the storage object for a path * get the storage object for a path
@ -92,7 +97,10 @@ class OC_FilesystemView {
* @return OC_Filestorage * @return OC_Filestorage
*/ */
public function getStorage($path){ public function getStorage($path){
return OC_Filesystem::getStorage($this->getAbsolutePath($path)); if (!isset($this->storage_cache[$path])) {
$this->storage_cache[$path] = OC_Filesystem::getStorage($this->getAbsolutePath($path));
}
return $this->storage_cache[$path];
} }
/** /**

View File

@ -110,7 +110,7 @@ class OC_Installer{
//try to find it in a subdir //try to find it in a subdir
$dh=opendir($extractDir); $dh=opendir($extractDir);
while($folder=readdir($dh)){ while($folder=readdir($dh)){
if(substr($folder,0,1)!='.' and is_dir($extractDir.'/'.$folder)){ if($folder[0]!='.' and is_dir($extractDir.'/'.$folder)){
if(is_file($extractDir.'/'.$folder.'/appinfo/info.xml')){ if(is_file($extractDir.'/'.$folder.'/appinfo/info.xml')){
$extractDir.='/'.$folder; $extractDir.='/'.$folder;
} }

View File

@ -129,7 +129,7 @@ class OC_User_Database extends OC_User_Backend {
$row=$result->fetchRow(); $row=$result->fetchRow();
if($row){ if($row){
$storedHash=$row['password']; $storedHash=$row['password'];
if (substr($storedHash,0,1)=='$'){//the new phpass based hashing if ($storedHash[0]=='$'){//the new phpass based hashing
$hasher=$this->getHasher(); $hasher=$this->getHasher();
if($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash)){ if($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash)){
return $row['uid']; return $row['uid'];

View File

@ -47,7 +47,7 @@ function loadTests($dir=''){
} }
if($dh=opendir($dir)){ if($dh=opendir($dir)){
while($name=readdir($dh)){ while($name=readdir($dh)){
if(substr($name,0,1)!='.'){//no hidden files, '.' or '..' if($name[0]!='.'){//no hidden files, '.' or '..'
$file=$dir.'/'.$name; $file=$dir.'/'.$name;
if(is_dir($file)){ if(is_dir($file)){
loadTests($file); loadTests($file);