summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-08-25 12:48:26 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-11-19 10:17:30 +0100
commitf5bd8e494761ee657ea1f6cc1dc78e0af5b25ef2 (patch)
treef45750172776e075807939f600da592d88215046
parente6e0573756e23485370b28f6455caa3edecb62b3 (diff)
downloadnextcloud-server-f5bd8e494761ee657ea1f6cc1dc78e0af5b25ef2.tar.gz
nextcloud-server-f5bd8e494761ee657ea1f6cc1dc78e0af5b25ef2.zip
Fix code layout before fixing the function
-rw-r--r--lib/private/files/mapper.php22
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/private/files/mapper.php b/lib/private/files/mapper.php
index 666719da12d..93f6f9bab30 100644
--- a/lib/private/files/mapper.php
+++ b/lib/private/files/mapper.php
@@ -177,14 +177,12 @@ class Mapper
/**
* @param integer $index
*/
- public function slugifyPath($path, $index=null) {
+ public function slugifyPath($path, $index = null) {
$path = $this->stripRootFolder($path, $this->unchangedPhysicalRoot);
$pathElements = explode('/', $path);
$sluggedElements = array();
-
- $last= end($pathElements);
-
+
foreach ($pathElements as $pathElement) {
// remove empty elements
if (empty($pathElement)) {
@@ -196,19 +194,18 @@ class Mapper
// apply index to file name
if ($index !== null) {
- $last= array_pop($sluggedElements);
+ $last = array_pop($sluggedElements);
// if filename contains periods - add index number before last period
- if (preg_match('~\.[^\.]+$~i',$last,$extension)){
- array_push($sluggedElements, substr($last,0,-(strlen($extension[0]))).'-'.$index.$extension[0]);
+ if (preg_match('~\.[^\.]+$~i', $last, $extension)) {
+ array_push($sluggedElements, substr($last, 0, -(strlen($extension[0]))) . '-' . $index . $extension[0]);
} else {
// if filename doesn't contain periods add index ofter the last char
- array_push($sluggedElements, $last.'-'.$index);
- }
-
+ array_push($sluggedElements, $last . '-' . $index);
+ }
}
- $sluggedPath = $this->unchangedPhysicalRoot.implode('/', $sluggedElements);
+ $sluggedPath = $this->unchangedPhysicalRoot . implode('/', $sluggedElements);
return $this->stripLast($sluggedPath);
}
@@ -218,8 +215,7 @@ class Mapper
* @param string $text
* @return string
*/
- private function slugify($text)
- {
+ private function slugify($text) {
// replace non letter or digits or dots by -
$text = preg_replace('~[^\\pL\d\.]+~u', '-', $text);