From 6d211155ab505c99dd7a723a011a755c2c038bc8 Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Sat, 2 Jun 2012 15:25:50 +0200 Subject: git status --- apps/gallery/ajax/thumbnail.php | 7 +- apps/gallery/lib/managers.php | 94 ++++++++++++++++++++ apps/gallery/lib/testimg.jpg | Bin 0 -> 839297 bytes apps/gallery/lib/tiles.php | 183 +++++++++++++++++++++++++++++++++++++++ apps/gallery/lib/tiles_test.php | 87 +++++++++++++++++++ apps/gallery/templates/index.php | 111 ++++++++++++++++++------ 6 files changed, 451 insertions(+), 31 deletions(-) create mode 100644 apps/gallery/lib/managers.php create mode 100644 apps/gallery/lib/testimg.jpg create mode 100644 apps/gallery/lib/tiles.php create mode 100644 apps/gallery/lib/tiles_test.php (limited to 'apps') diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php index ff0cb44022c..4fc9eba992d 100644 --- a/apps/gallery/ajax/thumbnail.php +++ b/apps/gallery/ajax/thumbnail.php @@ -20,14 +20,15 @@ * License along with this library. If not, see . * */ - OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('gallery'); +require_once('apps/gallery/lib/managers.php'); + -$img = $_GET['img']; +$img = $_GET['filepath']; -$image = OC_Gallery_Photo::getThumbnail($img); +$image = \OC\Pictures\ThumbnailsManager::getInstance()->getThumbnail($img); if ($image) { OCP\Response::enableCaching(3600 * 24); // 24 hour $image->show(); diff --git a/apps/gallery/lib/managers.php b/apps/gallery/lib/managers.php new file mode 100644 index 00000000000..96669da2727 --- /dev/null +++ b/apps/gallery/lib/managers.php @@ -0,0 +1,94 @@ +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())); + unset($image); + return $this->getFileData($path); + } + + 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((200*$image->width())/$image->height()), 200); + + if (!$ret) { + \OC_Log::write(self::TAG, 'Couldn\'t resize image', \OC_Log::ERROR); + unset($image); + return false; + } + + $image->save($gallery_path.'/'.$path); + return $image; + } + + public function getThumbnailInfo($path) { + $arr = DatabaseManager::getInstance()->getFileData($path); + $ret = array('filepath' => $arr['path'], + 'width' => $arr['width'], + 'height' => $arr['height']); + return $ret; + } + + public function delete($path) { + unlink(\OC::$CONFIG_DATADIRECTORY_ROOT.'/'.\OC_User::getUser()."/gallery".$path); + } + + private function __construct() {} + +} +?> \ No newline at end of file diff --git a/apps/gallery/lib/testimg.jpg b/apps/gallery/lib/testimg.jpg new file mode 100644 index 00000000000..0d9a2bd8812 Binary files /dev/null and b/apps/gallery/lib/testimg.jpg differ diff --git a/apps/gallery/lib/tiles.php b/apps/gallery/lib/tiles.php new file mode 100644 index 00000000000..d7f5208ff83 --- /dev/null +++ b/apps/gallery/lib/tiles.php @@ -0,0 +1,183 @@ +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 = ''; + 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 forceSize($width_must_fit=false) { + $current_height = $this->image->height(); + $current_width = $this->image->width(); + + // we need height of 250px but not for tiles stack + if ($current_width > $current_height && !$width_must_fit) { + $this->image->resize(floor((250*$current_width)/$current_height)); + } else { + $this->image->resize(200); + } + } + + public function get($extra = '') { + return ''; + } + + public function getMiniatureSrc() { + return GET_THUMBNAIL_PATH.urlencode($this->getPath()); + } + + public function getPath() { + return $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(200, $max); + } + + public function get() { + $r = ''; + 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 < 200) { + $extra = 'width:'.$img_w.'px;'; + } + $r .= ''; +// $r .= $this->tiles_array[$i]->get(' style="margin-top:'.$top.'px; margin-left:'.$left.'px; "'); + } + return $r; + } + + public function getOnHoverAction() { + return 'javascript:t(this);return false;'; + } + + public function getOnOutAction() { + return 'javascript:o(this);return false;'; + } + + public function getCount() { + return count($this->tiles_array); + } + + private $tiles_array; + private $stack_name; +} + +?> diff --git a/apps/gallery/lib/tiles_test.php b/apps/gallery/lib/tiles_test.php new file mode 100644 index 00000000000..022a88f75cc --- /dev/null +++ b/apps/gallery/lib/tiles_test.php @@ -0,0 +1,87 @@ + + + + + +addTile(new \OC\Pictures\TileSingle($images[$i])); + continue; + } + if (strcmp($prev_dir_arr[0], $dir_arr[0])!=0) { + $tl->addTile(new \OC\Pictures\TileStack($arr, $prev_dir_arr[0])); + $arr = array(); + } + $arr[] = $root.$images[$i]; + $previous_element = $images[$i]; +} + +$dir_arr = explode('/', $previous_element); + +if (count($dir_arr)==0) { + $tl->addTile(new \OC\Pictures\TileSingle($previous_element)); +} else if (count($dir_arr) && $ts->getCount() == 0){ + $ts = new \OC\Pictures\TileStack(array($previous_element), $dir_arr[0]); +} else { + $arr[] = $previous_element; + $ts->addTile($arr); +} + +if ($ts->getCount() != 0) { + $tl->addTile($ts); +} + +echo $tl->get(); + +?> diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index 99af3bda0a3..55710038c0a 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -1,31 +1,86 @@ - -
-
-
- - - - -
-
-
- main -
-
- -
- + + + + +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($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(); + +?> -- cgit v1.2.3 From 34a21a63ce5730a4f45af6745b4acd6f702e6e79 Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Sat, 2 Jun 2012 15:30:30 +0200 Subject: new db scheme --- apps/gallery/appinfo/database.xml | 42 ++++----------------------------------- 1 file changed, 4 insertions(+), 38 deletions(-) (limited to 'apps') diff --git a/apps/gallery/appinfo/database.xml b/apps/gallery/appinfo/database.xml index f370e1521e4..d1ccd6b5a24 100644 --- a/apps/gallery/appinfo/database.xml +++ b/apps/gallery/appinfo/database.xml @@ -5,16 +5,8 @@ false latin1 - *dbprefix*gallery_albums + *dbprefix*pictures_images_cache - - album_id - integer - 0 - true - 1 - 4 - uid_owner text @@ -22,49 +14,23 @@ 64 - album_name - text - true - 100 - - - album_path - text - true - 256 - - - parent_path + path text true 256 - -
- - *dbprefix*gallery_photos - - photo_id + width integer - 0 true - 1 4 - album_id + height integer - 0 true 4 - - file_path - text - true - 256 -
-- cgit v1.2.3 From 76e7e361aef51badd048727db7ffc104e19e231a Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Sun, 3 Jun 2012 00:29:10 +0200 Subject: navigate on galleries --- apps/gallery/lib/managers.php | 4 +++- apps/gallery/lib/tiles.php | 32 ++++++++++++++------------------ apps/gallery/templates/index.php | 34 ++++++++++++++++++++++++++++------ 3 files changed, 45 insertions(+), 25 deletions(-) (limited to 'apps') diff --git a/apps/gallery/lib/managers.php b/apps/gallery/lib/managers.php index 96669da2727..6cb9b420ac6 100644 --- a/apps/gallery/lib/managers.php +++ b/apps/gallery/lib/managers.php @@ -29,9 +29,11 @@ class DatabaseManager { if (!$image->loadFromFile($path)) { return false; } + \OCP\DB::beginTransaction(); $stmt = \OCP\DB::prepare('INSERT INTO *PREFIX*pictures_images_cache (uid_owner, path, width, height) VALUES (?, ?, ?, ?)'); $stmt->execute(array(\OCP\USER::getUser(), $path, $image->width(), $image->height())); unset($image); + \OCP\DB::commit(); return $this->getFileData($path); } @@ -64,7 +66,7 @@ class ThumbnailsManager { $image->fixOrientation(); - $ret = $image->preciseResize(floor((200*$image->width())/$image->height()), 200); + $ret = $image->preciseResize(floor((150*$image->width())/$image->height()), 150); if (!$ret) { \OC_Log::write(self::TAG, 'Couldn\'t resize image', \OC_Log::ERROR); diff --git a/apps/gallery/lib/tiles.php b/apps/gallery/lib/tiles.php index d7f5208ff83..26ff3cbb9f8 100644 --- a/apps/gallery/lib/tiles.php +++ b/apps/gallery/lib/tiles.php @@ -9,11 +9,12 @@ const TILE_PROPORTION_HORIZONTAL = 0; const TILE_PROPORTION_VERTICAL = 0; const GET_THUMBNAIL_PATH = '?app=gallery&getfile=ajax/thumbnail.php&filepath='; const TAG = 'Pictures'; +const IMAGE_WIDTH = 150; class TileBase { public function getWidth() { return false; } - public function getHeight() { return 200; } + public function getHeight() { return 150; } public function getOnHoverAction() { return false; } @@ -64,8 +65,8 @@ class TilesLine { for ($i = 0; $i < count($this->tiles_array); $i++) { $img_w = $this->tiles_array[$i]->getWidth(); $extra = ''; - if ($img_w != 200) $extra = ' style="width:'.$img_w.'px"'; - $r .= ''; + if ($img_w != 150) $extra = ' style="width:'.$img_w.'px"'; + $r .= ''; } $r .= ''; @@ -93,18 +94,6 @@ class TileSingle extends TileBase { $a = ThumbnailsManager::getInstance()->getThumbnailInfo($this->file_path); return $a['width']; } - - public function forceSize($width_must_fit=false) { - $current_height = $this->image->height(); - $current_width = $this->image->width(); - - // we need height of 250px but not for tiles stack - if ($current_width > $current_height && !$width_must_fit) { - $this->image->resize(floor((250*$current_width)/$current_height)); - } else { - $this->image->resize(200); - } - } public function get($extra = '') { return ''; @@ -117,6 +106,10 @@ class TileSingle extends TileBase { public function getPath() { return $this->file_path; } + + public function getOnClickAction() { + return 'javascript:openFile(\''.$this->file_path.'\');'; + } private $file_path; private $image; @@ -145,7 +138,7 @@ class TileStack extends TileBase { for ($i = 0; $i < count($this->tiles_array); $i++) { $max = max($max, $this->tiles_array[$i]->getWidth()); } - return min(200, $max); + return min(IMAGE_WIDTH, $max); } public function get() { @@ -155,11 +148,10 @@ class TileStack extends TileBase { $left = rand(-5, 5); $img_w = $this->tiles_array[$i]->getWidth(); $extra = ''; - if ($img_w < 200) { + if ($img_w < IMAGE_WIDTH) { $extra = 'width:'.$img_w.'px;'; } $r .= ''; -// $r .= $this->tiles_array[$i]->get(' style="margin-top:'.$top.'px; margin-left:'.$left.'px; "'); } return $r; } @@ -175,6 +167,10 @@ class TileStack extends TileBase { public function getCount() { return count($this->tiles_array); } + + public function getOnClickAction() { + return 'javascript:openNewGal(\''.$this->stack_name.'\');'; + } private $tiles_array; private $stack_name; diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index 55710038c0a..d3b281a2c38 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -1,17 +1,25 @@ Date: Tue, 5 Jun 2012 18:32:42 +0200 Subject: use fancybox to display image preview --- apps/gallery/lib/tiles.php | 4 ++-- apps/gallery/templates/index.php | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) (limited to 'apps') diff --git a/apps/gallery/lib/tiles.php b/apps/gallery/lib/tiles.php index 26ff3cbb9f8..c2d7fede786 100644 --- a/apps/gallery/lib/tiles.php +++ b/apps/gallery/lib/tiles.php @@ -96,7 +96,7 @@ class TileSingle extends TileBase { } public function get($extra = '') { - return ''; + return ''; } public function getMiniatureSrc() { @@ -108,7 +108,7 @@ class TileSingle extends TileBase { } public function getOnClickAction() { - return 'javascript:openFile(\''.$this->file_path.'\');'; + return '';//'javascript:openFile(\''.$this->file_path.'\');'; } private $file_path; diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index d3b281a2c38..3dc722f0666 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -1,8 +1,4 @@ @@ -15,7 +11,6 @@ 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;} - -- cgit v1.2.3 From aa0fc3c69a9a92cd041c329bf228ba6d30daff20 Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Wed, 6 Jun 2012 22:10:09 +0200 Subject: aviod incorrect image size returning in gallery listing --- apps/gallery/lib/managers.php | 7 ++++--- apps/gallery/templates/index.php | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'apps') diff --git a/apps/gallery/lib/managers.php b/apps/gallery/lib/managers.php index 6cb9b420ac6..2444659d0a4 100644 --- a/apps/gallery/lib/managers.php +++ b/apps/gallery/lib/managers.php @@ -32,9 +32,10 @@ class DatabaseManager { \OCP\DB::beginTransaction(); $stmt = \OCP\DB::prepare('INSERT INTO *PREFIX*pictures_images_cache (uid_owner, path, width, height) VALUES (?, ?, ?, ?)'); $stmt->execute(array(\OCP\USER::getUser(), $path, $image->width(), $image->height())); - unset($image); \OCP\DB::commit(); - return $this->getFileData($path); + $ret = array('filepath' => $path, 'width' => $image->width(), 'height' => $image->height()); + unset($image); + return $ret; } private function __construct() {} @@ -93,4 +94,4 @@ class ThumbnailsManager { private function __construct() {} } -?> \ No newline at end of file +?> diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index 3dc722f0666..39e3bbf47b3 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -42,7 +42,7 @@ function o(element) { function openNewGal(album_name) { root = root + album_name + "/"; var url = window.location.toString().replace(window.location.search, ''); - url = url + "?app=gallery&root="+root; + url = url + "?app=gallery&root="+encodeURIComponent(root); window.location = url; } @@ -85,13 +85,15 @@ for($i = 0; $i < count($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($root.$previous_element), $dir_arr[0]); -} else { - $arr[] = $previous_element; - $ts->addTile($arr); +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) { -- cgit v1.2.3 From 7c88081acb3c7b4d3b88fe4d151fb10a200a9502 Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Wed, 6 Jun 2012 22:13:25 +0200 Subject: removing test image --- apps/gallery/lib/testimg.jpg | Bin 839297 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 apps/gallery/lib/testimg.jpg (limited to 'apps') diff --git a/apps/gallery/lib/testimg.jpg b/apps/gallery/lib/testimg.jpg deleted file mode 100644 index 0d9a2bd8812..00000000000 Binary files a/apps/gallery/lib/testimg.jpg and /dev/null differ -- cgit v1.2.3 From a90089c79200c4665e28acb07215f08c2039c1a1 Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Wed, 6 Jun 2012 22:20:56 +0200 Subject: hack for file download --- apps/gallery/lib/tiles.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/gallery/lib/tiles.php b/apps/gallery/lib/tiles.php index c2d7fede786..3805b6dd25c 100644 --- a/apps/gallery/lib/tiles.php +++ b/apps/gallery/lib/tiles.php @@ -96,7 +96,9 @@ class TileSingle extends TileBase { } public function get($extra = '') { - return ''; + // !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 ''; } public function getMiniatureSrc() { -- cgit v1.2.3 From 5417d803c454a60c83e55ab574f56b88c8dba2a1 Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Wed, 6 Jun 2012 23:23:23 +0200 Subject: replace spaces with tabs, use const and linkTo instead of static path --- apps/gallery/lib/tiles.php | 299 ++++++++++++++++++++++----------------------- 1 file changed, 148 insertions(+), 151 deletions(-) (limited to 'apps') diff --git a/apps/gallery/lib/tiles.php b/apps/gallery/lib/tiles.php index 3805b6dd25c..6f8b8aa7fe7 100644 --- a/apps/gallery/lib/tiles.php +++ b/apps/gallery/lib/tiles.php @@ -5,177 +5,174 @@ namespace OC\Pictures; require_once('lib/base.php'); require_once('managers.php'); -const TILE_PROPORTION_HORIZONTAL = 0; -const TILE_PROPORTION_VERTICAL = 0; -const GET_THUMBNAIL_PATH = '?app=gallery&getfile=ajax/thumbnail.php&filepath='; const TAG = 'Pictures'; const IMAGE_WIDTH = 150; class TileBase { - public function getWidth() { return false; } + public function getWidth() { return false; } - public function getHeight() { return 150; } + public function getHeight() { return IMAGE_WIDTH; } - public function getOnHoverAction() { return false; } - - public function getOnOutAction() { return false; } - - public function getOnClickAction() { return false; } + public function getOnHoverAction() { return false; } + + public function getOnOutAction() { return false; } + + public function getOnClickAction() { return false; } - public function getDisplayedLayer() { return false; } + public function getDisplayedLayer() { return false; } - public function getTileProportion() { return false; } - - public function get() { 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 = ''; - return $r; - } - - private $tiles_array; - private $available_space; + 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 = ''; + 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 ''; - } - - public function getMiniatureSrc() { - return GET_THUMBNAIL_PATH.urlencode($this->getPath()); - } - - public function getPath() { - return $this->file_path; - } - - public function getOnClickAction() { - return '';//'javascript:openFile(\''.$this->file_path.'\');'; - } - - private $file_path; - private $image; + 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 ''; + } + + 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 = ''; - 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 .= ''; - } - return $r; - } - - public function getOnHoverAction() { - return 'javascript:t(this);return false;'; - } - - public function getOnOutAction() { - return 'javascript:o(this);return false;'; - } - - public function getCount() { - return count($this->tiles_array); - } - - public function getOnClickAction() { - return 'javascript:openNewGal(\''.$this->stack_name.'\');'; - } - - private $tiles_array; - private $stack_name; + 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 = ''; + 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 .= ''; + } + return $r; + } + + public function getOnHoverAction() { + return 'javascript:t(this);return false;'; + } + + public function getOnOutAction() { + return 'javascript:o(this);return false;'; + } + + public function getCount() { + return count($this->tiles_array); + } + + public function getOnClickAction() { + return 'javascript:openNewGal(\''.$this->stack_name.'\');'; + } + + private $tiles_array; + private $stack_name; } ?> -- cgit v1.2.3 From 8fd6cdf4074a568c188191d1f5bfe2bd64789f1b Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Wed, 6 Jun 2012 23:29:23 +0200 Subject: adding title when fancybox is displayed --- apps/gallery/lib/tiles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/gallery/lib/tiles.php b/apps/gallery/lib/tiles.php index 6f8b8aa7fe7..ff9519142ac 100644 --- a/apps/gallery/lib/tiles.php +++ b/apps/gallery/lib/tiles.php @@ -95,7 +95,7 @@ class TileSingle extends TileBase { 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 ''; + return ''; } public function getMiniatureSrc() { -- cgit v1.2.3 From 9c841491192ddf249b73107346949be1889f4440 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Wed, 6 Jun 2012 19:13:57 +0200 Subject: A bit of pixel-pushing. --- apps/contacts/css/contacts.css | 14 +++++++++++--- apps/contacts/templates/part.edit_address_dialog.php | 13 ++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'apps') diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css index 1d02b3722dd..8de68fbf052 100644 --- a/apps/contacts/css/contacts.css +++ b/apps/contacts/css/contacts.css @@ -31,8 +31,9 @@ dl.form { width: 100%; float: left; clear: right; margin: 0; padding: 0; } .form dt { display: table-cell; clear: left; float: left; width: 7em; margin: 0; padding: 0.8em 0.5em 0 0; text-align:right; text-overflow:ellipsis; o-text-overflow: ellipsis; vertical-align: text-bottom; color: #bbb;/* white-space: pre-wrap; white-space: -moz-pre-wrap !important; white-space: -pre-wrap; white-space: -o-pre-wrap;*/ } .form dd { display: table-cell; clear: right; float: left; margin: 0; padding: 0px; white-space: nowrap; vertical-align: text-bottom; } label:hover, dt:hover { color: #333; } -#address.form dt { min-width: 5em; } -#address.form dl { min-width: 10em; } +/*::-webkit-input-placeholder { color: #bbb; } +:-moz-placeholder { color: #bbb; } +:-ms-input-placeholder { color: #bbb; }*/ .droptarget { margin: 0.5em; padding: 0.5em; border: thin solid #ccc; -moz-border-radius:.3em; -webkit-border-radius:.3em; border-radius:.3em; } .droppable { margin: 0.5em; padding: 0.5em; border: thin dashed #333; -moz-border-radius:.3em; -webkit-border-radius:.3em; border-radius:.3em; } .loading { background: url('%webroot%/core/img/loading.gif') no-repeat center !important; /*cursor: progress; */ cursor: wait; } @@ -79,10 +80,17 @@ label:hover, dt:hover { color: #333; } #addressdisplay { padding: 0.5em; } dl.addresscard { background-color: #fff; float: left; width: auto; margin: 0 0.3em 0.3em 0.3em; padding: 0; border: 0; } dl.addresscard dd {} -dl.addresscard dt { padding: 0.3em; font-weight: bold; clear: both; color: #bbb;} +dl.addresscard dt { padding: 0.3em; font-weight: bold; clear: both; color: #aaa; } dl.addresscard dt:hover { color:#777; } dl.addresscard dd > ul { margin: 0.3em; padding: 0.3em; } dl.addresscard .action { float: right; } +#address dt { width: 30%; white-space:nowrap; } +#address dd { width: 66%; } +#address input { width: 12em; padding: 0.6em 0.5em 0.4em; } +#address input:-moz-placeholder { color: #aaa; } +#address input::-webkit-input-placeholder { color: #aaa; } +#address input:-ms-input-placeholder { color: #aaa; } +#address input:placeholder { color: #aaa; } #adr_type {} /* Select */ #adr_pobox {} #adr_extended {} diff --git a/apps/contacts/templates/part.edit_address_dialog.php b/apps/contacts/templates/part.edit_address_dialog.php index 8b3425033cc..7684795f348 100644 --- a/apps/contacts/templates/part.edit_address_dialog.php +++ b/apps/contacts/templates/part.edit_address_dialog.php @@ -24,18 +24,17 @@ foreach(isset($adr['parameters']['TYPE'])?array($adr['parameters']['TYPE']):arra
-
- +
- +
- +
- +
@@ -47,13 +46,13 @@ foreach(isset($adr['parameters']['TYPE'])?array($adr['parameters']['TYPE']):arra
- +
- +
-- cgit v1.2.3 From 3804f68ff568bf0d219502b5aa4e3979484581e6 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Thu, 7 Jun 2012 10:54:25 +0200 Subject: Contacts: Import upload button was obscured on Android browser. --- apps/contacts/js/contacts.js | 2 +- apps/contacts/templates/part.importaddressbook.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'apps') diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index e15dc0278f6..6c9c1a52626 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -1290,7 +1290,7 @@ Contacts={ $.getJSON(OC.filePath('contacts', 'ajax', 'chooseaddressbook.php'), function(jsondata){ if(jsondata.status == 'success'){ $('#addressbook_dialog').html(jsondata.data.page).find('#chooseaddressbook_dialog').dialog({ - width : 600, + minWidth : 600, close : function(event, ui) { $(this).dialog('destroy').remove(); $('#addressbook_dialog').remove(); diff --git a/apps/contacts/templates/part.importaddressbook.php b/apps/contacts/templates/part.importaddressbook.php index 6702262f231..cb5d68149ec 100644 --- a/apps/contacts/templates/part.importaddressbook.php +++ b/apps/contacts/templates/part.importaddressbook.php @@ -22,7 +22,7 @@ if(OCP\App::isEnabled('files_encryption')) { echo OCP\html_select_options($contacts_options, $contacts_options[0]['id'], array('value'=>'id', 'label'=>'displayname')); ?> - t("Drop a VCF file to import contacts."); ?> (Max. ) + t("Drop a VCF file
to import contacts."); ?> (Max. )
-- cgit v1.2.3 From e1f4978150a836ac9c7b2cb71e875fce32759b3f Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Thu, 7 Jun 2012 12:21:24 +0200 Subject: Calendar: Added more explicit sync links and fixed indentation. --- apps/calendar/templates/settings.php | 73 +++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 34 deletions(-) (limited to 'apps') diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php index 12117750ca5..feb06655120 100644 --- a/apps/calendar/templates/settings.php +++ b/apps/calendar/templates/settings.php @@ -8,45 +8,50 @@ */ ?>
-
+
t('Calendar'); ?> -
-
+ + $continent=$ex[0]; + echo ''; + endforeach;?> + - + - + -
- -
+ +
- -
+ +
+
- t('Calendar CalDAV syncing address:');?> -
+ t('Calendar CalDAV syncing addresses'); ?> (t('more info'); ?>) +
+
t('Primary address (Kontact et al)'); ?>
+
+
t('iOS/OS X'); ?>
+
principals//
+
-- cgit v1.2.3 From 312536dbf951a72ff849cdd57138eded6c4668e6 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Thu, 7 Jun 2012 13:08:42 +0200 Subject: Migration: Fixed wrong download URL: http://forum.owncloud.org/viewtopic.php?f=4&t=2511 --- apps/user_migrate/js/export.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/user_migrate/js/export.js b/apps/user_migrate/js/export.js index 2d660b2de6b..aef45c45a7b 100644 --- a/apps/user_migrate/js/export.js +++ b/apps/user_migrate/js/export.js @@ -9,7 +9,7 @@ $(document).ready(function(){ function(result){ if(result.status == 'success'){ // Download the file - window.location = OC.filePath('user_migrate','ajax','export.php?operation=download') ; + window.location = OC.linkTo('user_migrate','ajax/export.php') + '?operation=download'; $('.loading').hide(); $('#exportbtn').val(t('user_migrate', 'Export')); } else { -- cgit v1.2.3 From 470cb17f90840e9bb997d30c0e4575384fc5df72 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 7 Jun 2012 12:44:59 +0200 Subject: ldap: check index carefully, can be 0 --- apps/user_ldap/lib_ldap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php index f6942ad326e..6f4c0b0aad9 100644 --- a/apps/user_ldap/lib_ldap.php +++ b/apps/user_ldap/lib_ldap.php @@ -258,7 +258,7 @@ class OC_LDAP { $key = self::recursiveArraySearch($knownObjects, $ldapObject['dn']); //everything is fine when we know the group - if($key) { + if($key !== false) { $ownCloudNames[] = $knownObjects[$key]['owncloud_name']; continue; } -- cgit v1.2.3 From 6894882ca95033882526306b6a6794f41706eec2 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 7 Jun 2012 13:36:34 +0200 Subject: ldap: correct query condition and determining of success --- apps/user_ldap/lib_ldap.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'apps') diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php index 6f4c0b0aad9..753243f2c4a 100644 --- a/apps/user_ldap/lib_ldap.php +++ b/apps/user_ldap/lib_ldap.php @@ -380,12 +380,22 @@ class OC_LDAP { SELECT 1 FROM '.$table.' WHERE ldap_dn = ? - AND owncloud_name = ? ) + OR owncloud_name = ? ) '); $res = $insert->execute(array($dn, $ocname, $dn, $ocname)); - return !OCP\DB::isError($res); + if(OCP\DB::isError($res)) { + return false; + } + + $insRows = $res->numRows(); + + if($insRows == 0) { + return false; + } + + return true; } static public function fetchListOfUsers($filter, $attr) { -- cgit v1.2.3 From 44880ab3fa31d8b0ad1475d277315e57407f9341 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 7 Jun 2012 13:39:15 +0200 Subject: ldap: remove unused private functions --- apps/user_ldap/lib_ldap.php | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'apps') diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php index 753243f2c4a..8ca5c978b3b 100644 --- a/apps/user_ldap/lib_ldap.php +++ b/apps/user_ldap/lib_ldap.php @@ -329,30 +329,6 @@ class OC_LDAP { return $query->execute()->fetchAll(); } - /** - * @brief inserts a new group into the mappings table - * @param $dn the record in question - * @param $ocname the name to use in ownCloud - * @returns true on success, false otherwise - * - * inserts a new group into the mappings table - */ - static private function mapGroup($dn, $ocname) { - return self::mapComponent($dn, $ocname, false); - } - - /** - * @brief inserts a new user into the mappings table - * @param $dn the record in question - * @param $ocname the name to use in ownCloud - * @returns true on success, false otherwise - * - * inserts a new user into the mappings table - */ - static private function mapUser($dn, $ocname) { - return self::mapComponent($dn, $ocname, true); - } - /** * @brief inserts a new user or group into the mappings table * @param $dn the record in question -- cgit v1.2.3 From d2a8746c49884e6757338d2dbcf90e90dea62e35 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sat, 12 May 2012 13:42:41 +0200 Subject: Edited combobox to adhere to coding standards and added a dblclick handler. --- apps/contacts/js/jquery.combobox.js | 43 +++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'apps') diff --git a/apps/contacts/js/jquery.combobox.js b/apps/contacts/js/jquery.combobox.js index f12d1d7dd20..d9959eb6cde 100644 --- a/apps/contacts/js/jquery.combobox.js +++ b/apps/contacts/js/jquery.combobox.js @@ -23,16 +23,16 @@ minLength: 0, source: function( request, response ) { var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); - response( select.children( "option" ).map(function() { + response( select.children('option').map(function() { var text = $( this ).text(); if ( this.value && ( !request.term || matcher.test(text) ) ) return { label: text.replace( new RegExp( - "(?![^&;]+;)(?!<[^<>]*)(" + + '(?![^&;]+;)(?!<[^<>]*)(' + $.ui.autocomplete.escapeRegex(request.term) + - ")(?![^<>]*>)(?![^&;]+;)", "gi" - ), "$1" ), + ')(?![^<>]*>)(?![^&;]+;)', 'gi' + ), '$1'), value: text, option: this }; @@ -42,17 +42,17 @@ self.input.val($(ui.item.option).text()); self.input.trigger('change'); ui.item.option.selected = true; - self._trigger( "selected", event, { + self._trigger('selected', event, { item: ui.item.option }); }, change: function( event, ui ) { if ( !ui.item ) { - var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ), + var matcher = new RegExp( '^' + $.ui.autocomplete.escapeRegex( $(this).val() ) + '$', 'i' ), valid = false; self.input.val($(this).val()); //self.input.trigger('change'); - select.children( "option" ).each(function() { + select.children('option').each(function() { if ( $( this ).text().match( matcher ) ) { this.selected = valid = true; return false; @@ -62,36 +62,41 @@ // remove invalid value, as it didn't match anything $( this ).val( "" ); select.val( "" ); - input.data( "autocomplete" ).term = ""; + input.data('autocomplete').term = ''; return false; } } } }) - .addClass( "ui-widget ui-widget-content ui-corner-left" ); + .addClass('ui-widget ui-widget-content ui-corner-left'); - input.data( "autocomplete" )._renderItem = function( ul, item ) { - return $( "
  • " ) - .data( "item.autocomplete", item ) - .append( "" + item.label + "" ) + input.data('autocomplete')._renderItem = function( ul, item ) { + return $('
  • ') + .data('item.autocomplete', item ) + .append('' + item.label + '') .appendTo( ul ); }; $.each(this.options, function(key, value) { self._setOption(key, value); }); + input.dblclick(function() { + // pass empty string as value to search for, displaying all results + input.autocomplete('search', ''); + }); + if(this.options['showButton']) { - this.button = $( "" ) - .attr( "tabIndex", -1 ) - .attr( "title", "Show All Items" ) + this.button = $('') + .attr('tabIndex', -1 ) + .attr('title', 'Show All Items') .insertAfter( input ) .addClass('svg') .addClass('action') .addClass('combo-button') .click(function() { // close if already visible - if ( input.autocomplete( "widget" ).is( ":visible" ) ) { - input.autocomplete( "close" ); + if ( input.autocomplete('widget').is(':visible') ) { + input.autocomplete('close'); return; } @@ -99,7 +104,7 @@ $( this ).blur(); // pass empty string as value to search for, displaying all results - input.autocomplete( "search", "" ); + input.autocomplete('search', ''); input.focus(); }); } -- cgit v1.2.3 From 14e1be56a0927db5344af062a06839f08f674805 Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Thu, 7 Jun 2012 17:07:51 +0200 Subject: pictures: update script and removal some all stuff --- apps/gallery/appinfo/update.php | 9 +++++++++ apps/gallery/appinfo/version | 2 +- apps/gallery/index.php | 24 ++---------------------- 3 files changed, 12 insertions(+), 23 deletions(-) create mode 100644 apps/gallery/appinfo/update.php (limited to 'apps') diff --git a/apps/gallery/appinfo/update.php b/apps/gallery/appinfo/update.php new file mode 100644 index 00000000000..dd248e21b3e --- /dev/null +++ b/apps/gallery/appinfo/update.php @@ -0,0 +1,9 @@ +execute(); +$stmt = OCP\DB::prepare('DROP TABLE IF EXISTS *PREFIX*gallery_albums'); +$stmt->execute(); + +\OC_DB::createDbFromStructure('./database.xml'); + diff --git a/apps/gallery/appinfo/version b/apps/gallery/appinfo/version index 17b2ccd9bf9..8f0916f768f 100644 --- a/apps/gallery/appinfo/version +++ b/apps/gallery/appinfo/version @@ -1 +1 @@ -0.4.3 +0.5.0 diff --git a/apps/gallery/index.php b/apps/gallery/index.php index a9fe200c4e4..9d4654a7cc5 100644 --- a/apps/gallery/index.php +++ b/apps/gallery/index.php @@ -27,26 +27,6 @@ OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('gallery'); OCP\App::setActiveNavigationEntry( 'gallery_index' ); -if (!isset($_GET['view'])) { - $result = OC_Gallery_Album::find(OCP\USER::getUser()); - - $r = array(); - while ($row = $result->fetchRow()) - $r[] = $row; - - $tmpl = new OCP\Template( 'gallery', 'index', 'user' ); - $tmpl->assign('r', $r); - $tmpl->printPage(); -} else { - $result = OC_Gallery_Photo::findForAlbum(OCP\USER::getUser(), $_GET['view']); - - $photos = array(); - while ($p = $result->fetchRow()) - $photos[] = $p['file_path']; - - $tmpl = new OCP\Template( 'gallery', 'view_album', 'user' ); - $tmpl->assign('photos', $photos); - $tmpl->assign('albumName', $_GET['view']); - $tmpl->printPage(); -} +$tmpl = new OCP\Template( 'gallery', 'index', 'user' ); +$tmpl->printPage(); ?> -- cgit v1.2.3 From 66265984352850c4045fb5e921ebc1322aa471cd Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 7 Jun 2012 18:13:41 +0200 Subject: ldap: enable the destructor --- apps/user_ldap/lib_ldap.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'apps') diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php index 8ca5c978b3b..22d464b65a2 100644 --- a/apps/user_ldap/lib_ldap.php +++ b/apps/user_ldap/lib_ldap.php @@ -52,6 +52,8 @@ class OC_LDAP { static protected $ldapGroupDisplayName; static protected $ldapLoginFilter; + static protected $__d; + /** * @brief initializes the LDAP backend * @param $force read the config settings no matter what @@ -59,6 +61,9 @@ class OC_LDAP { * initializes the LDAP backend */ static public function init($force = false) { + if(is_null(self::$__d)) { + self::$__d = new OC_LDAP_DESTRUCTOR(); + } self::readConfiguration($force); self::establishConnection(); } -- cgit v1.2.3 From c2f557f1dd89b2ca5a612d7cbf7ab940ea8d1b68 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 7 Jun 2012 18:55:32 +0200 Subject: LDAP: cache the results, reduce LDAP searches --- apps/user_ldap/group_ldap.php | 40 ++++++++++++++++++++++++++++++---------- apps/user_ldap/user_ldap.php | 13 +++++++++---- 2 files changed, 39 insertions(+), 14 deletions(-) (limited to 'apps') diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index baca1d32bad..62e7c8ca6bc 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -27,6 +27,11 @@ class OC_GROUP_LDAP extends OC_Group_Backend { protected $ldapGroupMemberAssocAttr; protected $configured = false; + protected $_group_user = array(); + protected $_user_groups = array(); + protected $_group_users = array(); + protected $_groups = array(); + public function __construct() { $this->ldapGroupFilter = OCP\Config::getAppValue('user_ldap', 'ldap_group_filter', '(objectClass=posixGroup)'); $this->ldapGroupMemberAssocAttr = OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember'); @@ -48,6 +53,9 @@ class OC_GROUP_LDAP extends OC_Group_Backend { if(!$this->configured) { return false; } + if(isset($this->_group_user[$gid][$uid])) { + return $this->_group_user[$gid][$uid]; + } $dn_user = OC_LDAP::username2dn($uid); $dn_group = OC_LDAP::groupname2dn($gid); // just in case @@ -64,8 +72,8 @@ class OC_GROUP_LDAP extends OC_Group_Backend { //TODO: this can be done with one LDAP query if(strtolower($this->ldapGroupMemberAssocAttr) == 'memberuid') { $dns = array(); - foreach($members as $uid) { - $filter = str_replace('%uid', $uid, OC_LDAP::conf('ldapLoginFilter')); + foreach($members as $mid) { + $filter = str_replace('%uid', $mid, OC_LDAP::conf('ldapLoginFilter')); $ldap_users = OC_LDAP::fetchListOfUsers($filter, 'dn'); if(count($ldap_users) < 1) { continue; @@ -75,7 +83,8 @@ class OC_GROUP_LDAP extends OC_Group_Backend { $members = $dns; } - return in_array($dn_user, $members); + $this->_group_user[$gid][$uid] = in_array($dn_user, $members); + return $this->_group_user[$gid][$uid]; } /** @@ -90,8 +99,12 @@ class OC_GROUP_LDAP extends OC_Group_Backend { if(!$this->configured) { return array(); } + if(isset($this->_user_groups[$uid])) { + return $this->_user_groups[$uid]; + } $userDN = OC_LDAP::username2dn($uid); if(!$userDN) { + $this->_user_groups[$uid] = array(); return array(); } @@ -112,9 +125,9 @@ class OC_GROUP_LDAP extends OC_Group_Backend { $this->ldapGroupMemberAssocAttr.'='.$uid )); $groups = OC_LDAP::fetchListOfGroups($filter, array(OC_LDAP::conf('ldapGroupDisplayName'),'dn')); - $userGroups = OC_LDAP::ownCloudGroupNames($groups); + $this->_user_groups[$uid] = array_unique(OC_LDAP::ownCloudGroupNames($groups), SORT_LOCALE_STRING); - return array_unique($userGroups, SORT_LOCALE_STRING); + return $this->_user_groups[$uid]; } /** @@ -125,14 +138,19 @@ class OC_GROUP_LDAP extends OC_Group_Backend { if(!$this->configured) { return array(); } + if(isset($this->_group_users[$gid])) { + return $this->_group_users[$gid]; + } $groupDN = OC_LDAP::groupname2dn($gid); if(!$groupDN) { + $this->_group_users[$gid] = array(); return array(); } $members = OC_LDAP::readAttribute($groupDN, $this->ldapGroupMemberAssocAttr); if(!$members) { + $this->_group_users[$gid] = array(); return array(); } @@ -154,7 +172,8 @@ class OC_GROUP_LDAP extends OC_Group_Backend { if(!$isMemberUid) { $result = array_intersect($result, OCP\User::getUsers()); } - return array_unique($result, SORT_LOCALE_STRING); + $this->_group_users[$gid] = array_unique($result, SORT_LOCALE_STRING); + return $this->_group_users[$gid]; } /** @@ -167,10 +186,11 @@ class OC_GROUP_LDAP extends OC_Group_Backend { if(!$this->configured) { return array(); } - - $ldap_groups = OC_LDAP::fetchListOfGroups($this->ldapGroupFilter, array(OC_LDAP::conf('ldapGroupDisplayName'), 'dn')); - $groups = OC_LDAP::ownCloudGroupNames($ldap_groups); - return $groups; + if(is_null($this->_groups)) { + $ldap_groups = OC_LDAP::fetchListOfGroups($this->ldapGroupFilter, array(OC_LDAP::conf('ldapGroupDisplayName'), 'dn')); + $this->_groups = OC_LDAP::ownCloudGroupNames($ldap_groups); + } + return $this->groups; } /** diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index ba66c7a9ca8..9281aebe81d 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -34,6 +34,9 @@ class OC_USER_LDAP extends OC_User_Backend { // will be retrieved from LDAP server protected $ldap_dc = false; + // cache getUsers() + protected $_users = null; + public function __construct() { $this->ldapUserFilter = OCP\Config::getAppValue('user_ldap', 'ldap_userlist_filter', '(objectClass=posixAccount)'); $this->ldapQuotaAttribute = OCP\Config::getAppValue('user_ldap', 'ldap_quota_attr', ''); @@ -108,9 +111,11 @@ class OC_USER_LDAP extends OC_User_Backend { * Get a list of all users. */ public function getUsers(){ - $ldap_users = OC_LDAP::fetchListOfUsers($this->ldapUserFilter, array(OC_LDAP::conf('ldapUserDisplayName'), 'dn')); - $users = OC_LDAP::ownCloudUserNames($ldap_users); - return $users; + if(is_null($this->_users)) { + $ldap_users = OC_LDAP::fetchListOfUsers($this->ldapUserFilter, array(OC_LDAP::conf('ldapUserDisplayName'), 'dn')); + $this->_users = OC_LDAP::ownCloudUserNames($ldap_users); + } + return $this->_users; } /** @@ -119,7 +124,7 @@ class OC_USER_LDAP extends OC_User_Backend { * @return boolean */ public function userExists($uid){ - return in_array($uid, self::getUsers()); + return in_array($uid, $this->getUsers()); } } -- cgit v1.2.3 From 33c802dcaa77a1e30a8ca5223be817f81679747e Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Thu, 7 Jun 2012 20:27:53 +0200 Subject: Break text to fit in dialog. --- apps/contacts/js/contacts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 6c9c1a52626..35d4a4a216d 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -1281,7 +1281,7 @@ Contacts={ }, Addressbooks:{ droptarget:undefined, - droptext:t('contacts', 'Drop a VCF file to import contacts.'), + droptext:t('contacts', 'Drop a VCF file
    to import contacts.'), overview:function(){ if($('#chooseaddressbook_dialog').dialog('isOpen') == true){ $('#chooseaddressbook_dialog').dialog('moveToTop'); -- cgit v1.2.3 From d4f6f3e9355979aedb174d6f9b5f60380934aca9 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Thu, 7 Jun 2012 20:28:28 +0200 Subject: Contacts: Attempt to make file upload work in ICS Chrome. --- apps/contacts/templates/part.importaddressbook.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/contacts/templates/part.importaddressbook.php b/apps/contacts/templates/part.importaddressbook.php index cb5d68149ec..0e2956ddaf4 100644 --- a/apps/contacts/templates/part.importaddressbook.php +++ b/apps/contacts/templates/part.importaddressbook.php @@ -36,5 +36,7 @@ if(OCP\App::isEnabled('files_encryption')) { \ No newline at end of file -- cgit v1.2.3