mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
ENHANCEMENT Removing notion of "root" identifier string for the base folder in AssetAdmin, using 0 explicitly = clearer logic. Fixed breadcrumbs to work with this as well.
This commit is contained in:
parent
8fb2755c5b
commit
439b9c1f29
@ -38,14 +38,14 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
* Return fake-ID "root" if no ID is found (needed to upload files into the root-folder)
|
* Return fake-ID "root" if no ID is found (needed to upload files into the root-folder)
|
||||||
*/
|
*/
|
||||||
public function currentPageID() {
|
public function currentPageID() {
|
||||||
if($this->request->requestVar('ID')) {
|
if(is_numeric($this->request->requestVar('ID'))) {
|
||||||
return $this->request->requestVar('ID');
|
return $this->request->requestVar('ID');
|
||||||
} elseif (is_numeric($this->urlParams['ID'])) {
|
} elseif (is_numeric($this->urlParams['ID'])) {
|
||||||
return $this->urlParams['ID'];
|
return $this->urlParams['ID'];
|
||||||
} elseif(Session::get("{$this->class}.currentPage")) {
|
} elseif(Session::get("{$this->class}.currentPage")) {
|
||||||
return Session::get("{$this->class}.currentPage");
|
return Session::get("{$this->class}.currentPage");
|
||||||
} else {
|
} else {
|
||||||
return "root";
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ JS
|
|||||||
|
|
||||||
$form = new Form($this, 'filter', $fields, $actions);
|
$form = new Form($this, 'filter', $fields, $actions);
|
||||||
$form->setFormMethod('GET');
|
$form->setFormMethod('GET');
|
||||||
$form->setFormAction(Controller::join_links($this->Link('show'), $folder->ID ? $folder->ID : 'root'));
|
$form->setFormAction(Controller::join_links($this->Link('show'), $folder->ID));
|
||||||
$form->addExtraClass('cms-search-form');
|
$form->addExtraClass('cms-search-form');
|
||||||
$form->loadDataFrom($this->request->getVars());
|
$form->loadDataFrom($this->request->getVars());
|
||||||
$form->disableSecurityToken();
|
$form->disableSecurityToken();
|
||||||
@ -405,8 +405,7 @@ JS
|
|||||||
mkdir($record->FullPath);
|
mkdir($record->FullPath);
|
||||||
chmod($record->FullPath, Filesystem::$file_create_mask);
|
chmod($record->FullPath, Filesystem::$file_create_mask);
|
||||||
|
|
||||||
$parentID = $parentRecord ? $parentRecord->ID : 'root';
|
$link = Controller::join_links($this->Link('show'), $parentRecord->ID);
|
||||||
$link = Controller::join_links($this->Link('show'), $parentID);
|
|
||||||
$this->getResponse()->addHeader('X-ControllerURL', $link);
|
$this->getResponse()->addHeader('X-ControllerURL', $link);
|
||||||
return $this->redirect($link);
|
return $this->redirect($link);
|
||||||
}
|
}
|
||||||
@ -416,10 +415,9 @@ JS
|
|||||||
*/
|
*/
|
||||||
public function currentPage() {
|
public function currentPage() {
|
||||||
$id = $this->currentPageID();
|
$id = $this->currentPageID();
|
||||||
if($id && is_numeric($id)) {
|
if($id && is_numeric($id) && $id > 0) {
|
||||||
return DataObject::get_by_id('Folder', $id);
|
return DataObject::get_by_id('Folder', $id);
|
||||||
} else {
|
} else {
|
||||||
// ID is either '0' or 'root'
|
|
||||||
return singleton('Folder');
|
return singleton('Folder');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -549,6 +547,10 @@ JS
|
|||||||
public function Breadcrumbs($unlinked = false) {
|
public function Breadcrumbs($unlinked = false) {
|
||||||
$items = parent::Breadcrumbs($unlinked);
|
$items = parent::Breadcrumbs($unlinked);
|
||||||
|
|
||||||
|
// The root element should explicitly point to the root node.
|
||||||
|
// Uses session state for current record otherwise.
|
||||||
|
$items[0]->Link = Controller::join_links(singleton('AssetAdmin')->Link('show'), 0);
|
||||||
|
|
||||||
// If a search is in progress, don't show the path
|
// If a search is in progress, don't show the path
|
||||||
if($this->request->requestVar('q')) {
|
if($this->request->requestVar('q')) {
|
||||||
$items = $items->getRange(0, 1);
|
$items = $items->getRange(0, 1);
|
||||||
|
@ -23,7 +23,8 @@ class CMSFileAddController extends LeftAndMain {
|
|||||||
*/
|
*/
|
||||||
public function currentPage() {
|
public function currentPage() {
|
||||||
$id = $this->currentPageID();
|
$id = $this->currentPageID();
|
||||||
if($id && is_numeric($id)) {
|
|
||||||
|
if($id && is_numeric($id) && $id > 0) {
|
||||||
return DataObject::get_by_id('Folder', $id);
|
return DataObject::get_by_id('Folder', $id);
|
||||||
} else {
|
} else {
|
||||||
// ID is either '0' or 'root'
|
// ID is either '0' or 'root'
|
||||||
@ -35,14 +36,14 @@ class CMSFileAddController extends LeftAndMain {
|
|||||||
* Return fake-ID "root" if no ID is found (needed to upload files into the root-folder)
|
* Return fake-ID "root" if no ID is found (needed to upload files into the root-folder)
|
||||||
*/
|
*/
|
||||||
public function currentPageID() {
|
public function currentPageID() {
|
||||||
if($this->request->requestVar('ID')) {
|
if(is_numeric($this->request->requestVar('ID'))) {
|
||||||
return $this->request->requestVar('ID');
|
return $this->request->requestVar('ID');
|
||||||
} elseif (is_numeric($this->urlParams['ID'])) {
|
} elseif (is_numeric($this->urlParams['ID'])) {
|
||||||
return $this->urlParams['ID'];
|
return $this->urlParams['ID'];
|
||||||
} elseif(Session::get("{$this->class}.currentPage")) {
|
} elseif(Session::get("{$this->class}.currentPage")) {
|
||||||
return Session::get("{$this->class}.currentPage");
|
return Session::get("{$this->class}.currentPage");
|
||||||
} else {
|
} else {
|
||||||
return "root";
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +63,7 @@ class CMSFileAddController extends LeftAndMain {
|
|||||||
$uploadField->addExtraClass('ss-assetuploadfield');
|
$uploadField->addExtraClass('ss-assetuploadfield');
|
||||||
$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());
|
||||||
@ -101,8 +103,15 @@ class CMSFileAddController extends LeftAndMain {
|
|||||||
$items = parent::Breadcrumbs($unlinked);
|
$items = parent::Breadcrumbs($unlinked);
|
||||||
|
|
||||||
// The root element should explicitly point to the root node.
|
// The root element should explicitly point to the root node.
|
||||||
// Used in CMSFileAddController subclass as well, so specifically link to AssetAdmin
|
$items[0]->Link = Controller::join_links(singleton('AssetAdmin')->Link('show'), 0);
|
||||||
$items[0]->Link = Controller::join_links(singleton('AssetAdmin')->Link('show'), 'root');
|
|
||||||
|
// Enforce linkage of hierarchy to AssetAdmin
|
||||||
|
foreach($items as $item) {
|
||||||
|
$baselink = $this->Link('show');
|
||||||
|
if(strpos($item->Link, $baselink) !== false) {
|
||||||
|
$item->Link = str_replace($baselink, singleton('AssetAdmin')->Link('show'), $item->Link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$items->push(new ArrayData(array(
|
$items->push(new ArrayData(array(
|
||||||
'Title' => _t('AssetAdmin.Upload', 'Upload'),
|
'Title' => _t('AssetAdmin.Upload', 'Upload'),
|
||||||
|
Loading…
Reference in New Issue
Block a user