getFolderPathPlain(): add sep as prefix if skiproot is true

This commit is contained in:
Uwe Steinmann 2022-12-08 14:44:49 +01:00
parent 6f9ec7cdc3
commit 291b62eeb2

View File

@ -778,8 +778,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
/**
* Returns a file system path
*
* This path contains spaces around the slashes for better readability.
* Run str_replace(' / ', '/', $path) on it to get a valid unix
* This path contains by default spaces around the slashes for better readability.
* Run str_replace(' / ', '/', $path) on it or pass '/' as $sep to get a valid unix
* file system path.
*
* @param bool $skiproot skip the name of the root folder and start with $sep
@ -787,13 +787,14 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
* @return string path separated with ' / '
*/
function getFolderPathPlain($skiproot = false, $sep = ' / ') { /* {{{ */
$path="";
$path="".$sep;
$folderPath = $this->getPath();
for ($i = 0; $i < count($folderPath); $i++) {
if($i > 0 || !$skiproot)
if($i > 0 || !$skiproot) {
$path .= $folderPath[$i]->getName();
if ($i +1 < count($folderPath))
$path .= $sep;
if ($i+1 < count($folderPath))
$path .= $sep;
}
}
return trim($path);
} /* }}} */