mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Merge pull request #44 from open-sausages/pulls/4.0/namespace-admin
Namespace Admin module
This commit is contained in:
commit
f759a7c6db
@ -154,11 +154,21 @@ class SS_Report extends ViewableData
|
||||
{
|
||||
return Controller::join_links(
|
||||
ReportAdmin::singleton()->Link('show'),
|
||||
get_class($this),
|
||||
$this->sanitiseClassName(get_class($this)),
|
||||
$action
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitise a model class' name for inclusion in a link
|
||||
*
|
||||
* @param string $class
|
||||
* @return string
|
||||
*/
|
||||
protected function sanitiseClassName($class) {
|
||||
return str_replace('\\', '-', $class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* counts the number of objects returned
|
||||
|
@ -4,6 +4,7 @@ use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\PermissionProvider;
|
||||
use SilverStripe\Admin\LeftAndMain;
|
||||
|
||||
/**
|
||||
* Reports section of the CMS.
|
||||
@ -43,6 +44,8 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
|
||||
*/
|
||||
protected $reportObject;
|
||||
|
||||
private static $required_permission_codes = 'CMS_ACCESS_ReportAdmin';
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
@ -93,6 +96,7 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
|
||||
public function Reports()
|
||||
{
|
||||
$output = new ArrayList();
|
||||
/** @var SS_Report $report */
|
||||
foreach (SS_Report::get_reports() as $report) {
|
||||
if ($report->canView()) {
|
||||
$output->push($report);
|
||||
@ -103,7 +107,7 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
|
||||
|
||||
public function handleAction($request, $action)
|
||||
{
|
||||
$this->reportClass = $request->param('ReportClass');
|
||||
$this->reportClass = $this->unsanitiseClassName($request->param('ReportClass'));
|
||||
|
||||
// Check report
|
||||
if ($this->reportClass) {
|
||||
@ -118,6 +122,16 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
|
||||
return parent::handleAction($request, $action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsanitise a model class' name from a URL param
|
||||
*
|
||||
* @param string $class
|
||||
* @return string
|
||||
*/
|
||||
protected function unsanitiseClassName($class) {
|
||||
return str_replace('-', '\\', $class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if we have reports and need
|
||||
* to display the "Reports" main menu item
|
||||
@ -136,6 +150,8 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
|
||||
|
||||
/**
|
||||
* Returns the Breadcrumbs for the ReportAdmin
|
||||
*
|
||||
* @param bool $unlinked
|
||||
* @return ArrayList
|
||||
*/
|
||||
public function Breadcrumbs($unlinked = false)
|
||||
@ -175,10 +191,11 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
|
||||
|
||||
public function providePermissions()
|
||||
{
|
||||
$title = _t("ReportAdmin.MENUTITLE", LeftAndMain::menu_title_for_class($this->class));
|
||||
return array(
|
||||
"CMS_ACCESS_ReportAdmin" => array(
|
||||
'name' => _t('CMSMain.ACCESS', "Access to '{title}' section", array('title' => $title)),
|
||||
'name' => _t('CMSMain.ACCESS', "Access to '{title}' section", array(
|
||||
'title' => static::menu_title()
|
||||
)),
|
||||
'category' => _t('Permission.CMS_ACCESS_CATEGORY', 'CMS Access')
|
||||
)
|
||||
);
|
||||
@ -199,6 +216,7 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
|
||||
new GridFieldFooter()
|
||||
);
|
||||
$gridField = new GridField('Reports', false, $this->Reports(), $gridFieldConfig);
|
||||
/** @var GridFieldDataColumns $columns */
|
||||
$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
|
||||
$columns->setDisplayFields(array(
|
||||
'title' => _t('ReportAdmin.ReportTitle', 'Title'),
|
||||
|
@ -3,9 +3,9 @@
|
||||
<div class="cms-content-header north">
|
||||
<% with $EditForm %>
|
||||
<div class="cms-content-header-info">
|
||||
<% include BackLink_Button %>
|
||||
<% include SilverStripe\\Admin\\BackLink_Button %>
|
||||
<% with $Controller %>
|
||||
<% include CMSBreadcrumbs %>
|
||||
<% include SilverStripe\\Admin\\CMSBreadcrumbs %>
|
||||
<% end_with %>
|
||||
</div>
|
||||
<% end_with %>
|
||||
|
Loading…
Reference in New Issue
Block a user