Merged revisions 51246 via svnmerge from

svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq

........
  r51246 | ischommer | 2008-03-18 11:50:47 +1300 (Tue, 18 Mar 2008) | 1 line
  
  ENHANCEMENT findOrMake() now deals with absolute paths and replaces leading/trailing slashes before checking for existing folder objects in the database
........


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@51240 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-03-17 22:51:25 +00:00
parent 9d025c213a
commit 1b5b3f8627

View File

@ -18,10 +18,16 @@ class Folder extends File {
);
/*
* Find the given folder or create it, recursively
* Find the given folder or create it, recursively.
*
* @param $folderPath string Absolute or relative path to the file
*/
static function findOrMake($folder) {
$parts = explode("/",$folder);
static function findOrMake($folderPath) {
$folderPath = trim(Director::makeRelative($folderPath));
// replace leading and trailing slashes
$folderPath = preg_replace('/^\/?(.*)\/?$/', '$1', $folderPath);
$parts = explode("/",$folderPath);
$parentID = 0;
foreach($parts as $part) {