diff options
author | Bartek Przybylski <bart.p.pl@gmail.com> | 2012-02-04 15:35:58 +0100 |
---|---|---|
committer | Bartek Przybylski <bart.p.pl@gmail.com> | 2012-02-04 15:35:58 +0100 |
commit | f6a27dfa2898ab23527d4efe8063ff32895b52e8 (patch) | |
tree | 98cecf07fcf4caadf1415a939aa4be5ed75654bb /apps/gallery | |
parent | f1672d7d10477026cfa4f49a8ec7c71e03f3f6ba (diff) | |
download | nextcloud-server-f6a27dfa2898ab23527d4efe8063ff32895b52e8.tar.gz nextcloud-server-f6a27dfa2898ab23527d4efe8063ff32895b52e8.zip |
stripping root from gallery name
Diffstat (limited to 'apps/gallery')
-rw-r--r-- | apps/gallery/lib/scanner.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index 2af63d8bf0e..13800f48e69 100644 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -39,12 +39,19 @@ class OC_Gallery_Scanner { $stmt->execute(array()); } + public static function createName($name) { + $root = OC_Appconfig::getValue('gallery', 'root', '/'); + $name = str_replace('/', '.', str_replace(OC::$CONFIG_DATADIRECTORY, '', $name)); + if (substr($name, 0, strlen($root)) == str_replace('/','.',$root)) { + $name = substr($name, strlen($root)); + } + $name = ($name==='.') ? 'main' : trim($name,'.'); + return $name; + } + public static function scanDir($path, &$albums) { $current_album = array('name'=> $path, 'imagesCount' => 0, 'images' => array()); - $current_album['name'] = str_replace('/', '.', str_replace(OC::$CONFIG_DATADIRECTORY, '', $current_album['name'])); - $current_album['name'] = ($current_album['name']==='.') ? - 'main' : - trim($current_album['name'],'.'); + $current_album['name'] = self::createName($current_album['name']); if ($dh = OC_Filesystem::opendir($path)) { while (($filename = readdir($dh)) !== false) { |