public static function splitPath($path, $makeRelative = true) { if ($makeRelative) { $path = GalleryHelper::makeRelative($path); } $parts = explode('/', $path); $object = new ArrayObject(); $object->filename = JFile::makeSafe(array_pop($parts)); // last element is filename $object->folderPath = JFolder::makeSafe(implode(DS, $parts)); // use rest as path return $object; }
public function getPhotos($recursive = false) { if (isset($this->photos) && !$recursive) { return $this->photos; } $this->photos = new SplDoublyLinkedList(); foreach ($this->getPhotoPaths() as $photoPath) { $relativePhotoPath = GalleryHelper::makeRelative($photoPath); $relativePhotoPath = GalleryHelper::splitPath($relativePhotoPath); $folder = $this->filesystem->getFolder($relativePhotoPath->folderPath); $this->photos->push($this->filesystem->getPhoto($folder, $relativePhotoPath->filename)); } return $this->photos; }