mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Merge pull request #208 from halkyon/upload_assets_changes
Uploads go to "assets/assets" instead of root of assets
This commit is contained in:
commit
de4f207534
@ -478,10 +478,12 @@ JS
|
|||||||
public function currentPage() {
|
public function currentPage() {
|
||||||
$id = $this->currentPageID();
|
$id = $this->currentPageID();
|
||||||
if($id && is_numeric($id) && $id > 0) {
|
if($id && is_numeric($id) && $id > 0) {
|
||||||
return DataObject::get_by_id('Folder', $id);
|
$folder = DataObject::get_by_id('Folder', $id);
|
||||||
} else {
|
if($folder && $folder->exists()) {
|
||||||
return new Folder();
|
return $folder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return new Folder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $numChildrenMethod = null, $filterFunction = null, $minNodeCount = 30) {
|
public function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $numChildrenMethod = null, $filterFunction = null, $minNodeCount = 30) {
|
||||||
|
@ -23,13 +23,13 @@ class CMSFileAddController extends LeftAndMain {
|
|||||||
*/
|
*/
|
||||||
public function currentPage() {
|
public function currentPage() {
|
||||||
$id = $this->currentPageID();
|
$id = $this->currentPageID();
|
||||||
|
|
||||||
if($id && is_numeric($id) && $id > 0) {
|
if($id && is_numeric($id) && $id > 0) {
|
||||||
return DataObject::get_by_id('Folder', $id);
|
$folder = DataObject::get_by_id('Folder', $id);
|
||||||
} else {
|
if($folder && $folder->exists()) {
|
||||||
// ID is either '0' or 'root'
|
return $folder;
|
||||||
return singleton('Folder');
|
}
|
||||||
}
|
}
|
||||||
|
return new Folder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,12 +64,12 @@ class CMSFileAddController extends LeftAndMain {
|
|||||||
$uploadField->removeExtraClass('ss-uploadfield');
|
$uploadField->removeExtraClass('ss-uploadfield');
|
||||||
$uploadField->setTemplate('AssetUploadField');
|
$uploadField->setTemplate('AssetUploadField');
|
||||||
|
|
||||||
if ($folder->exists() && $folder->getFilename()) {
|
if($folder->exists() && $folder->getFilename()) {
|
||||||
// The Upload class expects a folder relative *within* assets/
|
// The Upload class expects a folder relative *within* assets/
|
||||||
$path = preg_replace('/^' . ASSETS_DIR . '\//', '', $folder->getFilename());
|
$path = preg_replace('/^' . ASSETS_DIR . '\//', '', $folder->getFilename());
|
||||||
$uploadField->setFolderName($path);
|
$uploadField->setFolderName($path);
|
||||||
} else {
|
} else {
|
||||||
$uploadField->setFolderName(ASSETS_DIR);
|
$uploadField->setFolderName('/'); // root of the assets
|
||||||
}
|
}
|
||||||
|
|
||||||
$exts = $uploadField->getValidator()->getAllowedExtensions();
|
$exts = $uploadField->getValidator()->getAllowedExtensions();
|
||||||
|
Loading…
Reference in New Issue
Block a user