MINOR Fixed merge error

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112616 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-10-15 04:02:54 +00:00
parent a0dd4ff8f0
commit fd6fa62388

View File

@ -31,32 +31,6 @@ class Folder extends File {
if(!$this->Name) $this->Name = _t('AssetAdmin.NEWFOLDER',"NewFolder");
}
function onBeforeWrite() {
// Ensure folders can't contain path information, just a name
$this->Name = basename($this->Name);
// Get the folder to be created
if($this->ParentID) {
if(!is_numeric($this->ParentID)) $this->ParentID = 0;
$parentObj = DataObject::get_by_id($this->class, $this->ParentID);
}
// TODO Check that the $parentObj matches the ASSETS_PATH
if(isset($parentObj->ID)) $path = $parentObj->FullPath . $this->Name;
else $path = ASSETS_PATH . '/' . $this->Name;
// Ensure uniqueness
$i = 2;
$basePath = $path . '-';
while(file_exists($path)) {
$path = $basePath . $i;
$i++;
}
Filesystem::makeFolder($path);
parent::onBeforeWrite();
}
/**
* Find the given folder or create it both as {@link Folder} database records
* and on the filesystem. If necessary, creates parent folders as well.