mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
MINOR Extending CMSFileAddController off LeftAndMain to fix problems with inherited templates (wrong .cms-content styling when requesting via ajax, due to inherited AssetAdmin templates)
This commit is contained in:
parent
1789287bd2
commit
a30a615de4
@ -549,15 +549,6 @@ 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.
|
|
||||||
// Used in CMSFileAddController subclass as well, so specifically link to AssetAdmin
|
|
||||||
$items[0]->Link = Controller::join_links(singleton('AssetAdmin')->Link('show'), 'root');
|
|
||||||
|
|
||||||
// HACK Force linkage to AssetAdmin, even when current controller is CMSFileAddController
|
|
||||||
foreach($items as $item) {
|
|
||||||
if($item->Link) $item->Link = str_replace('assets/add/show/', 'assets/show/', $item->Link);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
class CMSFileAddController extends AssetAdmin {
|
class CMSFileAddController extends LeftAndMain {
|
||||||
|
|
||||||
static $url_segment = 'assets/add';
|
static $url_segment = 'assets/add';
|
||||||
static $url_priority = 60;
|
static $url_priority = 60;
|
||||||
static $required_permission_codes = 'CMS_ACCESS_AssetAdmin';
|
static $required_permission_codes = 'CMS_ACCESS_AssetAdmin';
|
||||||
|
static $menu_title = 'Files';
|
||||||
|
public static $tree_class = 'Folder';
|
||||||
|
|
||||||
// public function upload($request) {
|
// public function upload($request) {
|
||||||
// $formHtml = $this->renderWith(array('AssetAdmin_UploadContent'));
|
// $formHtml = $this->renderWith(array('AssetAdmin_UploadContent'));
|
||||||
@ -15,10 +17,33 @@ class CMSFileAddController extends AssetAdmin {
|
|||||||
// ))->renderWith(array('AssetAdmin', 'LeftAndMain'));
|
// ))->renderWith(array('AssetAdmin', 'LeftAndMain'));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function Content() {
|
/**
|
||||||
// Disable AssetAdmin layout including the search panel
|
* Custom currentPage() method to handle opening the 'root' folder
|
||||||
return $this->renderWith('LeftAndMain_Content');
|
*/
|
||||||
|
public function currentPage() {
|
||||||
|
$id = $this->currentPageID();
|
||||||
|
if($id && is_numeric($id)) {
|
||||||
|
return DataObject::get_by_id('Folder', $id);
|
||||||
|
} else {
|
||||||
|
// ID is either '0' or 'root'
|
||||||
|
return singleton('Folder');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return fake-ID "root" if no ID is found (needed to upload files into the root-folder)
|
||||||
|
*/
|
||||||
|
public function currentPageID() {
|
||||||
|
if($this->request->requestVar('ID')) {
|
||||||
|
return $this->request->requestVar('ID');
|
||||||
|
} elseif (is_numeric($this->urlParams['ID'])) {
|
||||||
|
return $this->urlParams['ID'];
|
||||||
|
} elseif(Session::get("{$this->class}.currentPage")) {
|
||||||
|
return Session::get("{$this->class}.currentPage");
|
||||||
|
} else {
|
||||||
|
return "root";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,7 +76,7 @@ class CMSFileAddController extends AssetAdmin {
|
|||||||
);
|
);
|
||||||
$form->addExtraClass('center cms-edit-form ' . $this->BaseCSSClasses());
|
$form->addExtraClass('center cms-edit-form ' . $this->BaseCSSClasses());
|
||||||
// Don't use AssetAdmin_EditForm, as it assumes a different panel structure
|
// Don't use AssetAdmin_EditForm, as it assumes a different panel structure
|
||||||
$form->setTemplate('LeftAndMain_EditForm');
|
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
||||||
$form->Fields()->push(
|
$form->Fields()->push(
|
||||||
new LiteralField(
|
new LiteralField(
|
||||||
'BackLink',
|
'BackLink',
|
||||||
@ -68,10 +93,21 @@ class CMSFileAddController extends AssetAdmin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable AssetAdmin search panel
|
* @return ArrayList
|
||||||
*/
|
*/
|
||||||
function Tools() {
|
public function Breadcrumbs($unlinked = false) {
|
||||||
return false;
|
$items = parent::Breadcrumbs($unlinked);
|
||||||
|
|
||||||
|
// 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'), 'root');
|
||||||
|
|
||||||
|
$items->push(new ArrayData(array(
|
||||||
|
'Title' => _t('AssetAdmin.Upload', 'Upload'),
|
||||||
|
'Link' => $this->Link()
|
||||||
|
)));
|
||||||
|
|
||||||
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user