Server IP : 184.154.167.98 / Your IP : 3.137.220.199 Web Server : Apache System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : puertode ( 1767) PHP Version : 8.2.26 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/puertode/public_html/nextcloud/apps/gallery/lib/Controller/ |
Upload File : |
<?php /** * Nextcloud - Gallery * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Olivier Paroz <galleryapps@oparoz.com> * * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; /** * @package OCA\Gallery\Controller */ trait PathManipulation { /** * Returns a shortened path for the gallery view * * We only want to keep one folder between the current folder and the found media file * /root/folder/sub1/sub2/file.ext * becomes * /root/folder/file.ext * * @param string $path the full path to a file, which never starts with a slash * @param string $currFolderPath the current folder, which never starts with a slash * * @return string */ private function getReducedPath($path, $currFolderPath) { // Adding a slash to make sure we don't cut a folder in half if ($currFolderPath) { $currFolderPath .= '/'; $relativePath = str_replace($currFolderPath, '', $path); } else { $relativePath = $path; } $subFolders = explode('/', $relativePath); if (count($subFolders) > 2) { $reducedPath = $currFolderPath . $subFolders[0] . '/' . array_pop($subFolders); } else { $reducedPath = $path; } return $reducedPath; } }