mirror of
https://github.com/jonom/silverstripe-betternavigator.git
synced 2024-10-22 14:05:51 +02:00
Add support for Silverstripe 5
This commit is contained in:
parent
aaa76deba0
commit
71a3ce1327
@ -17,13 +17,17 @@ This module is intended to replicate and expand upon the functionality provided
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Silverstripe 4.0 (3.1+ through previous releases)
|
Silverstripe 5.0 (4.0+ and 3.1+ through previous releases)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
**Composer / Packagist ([best practice](http://doc.silverstripe.org/framework/en/trunk/installation/composer))**
|
**Composer / Packagist ([best practice](http://doc.silverstripe.org/framework/en/trunk/installation/composer))**
|
||||||
Add "jonom/silverstripe-betternavigator" to your requirements.
|
Add "jonom/silverstripe-betternavigator" to your requirements.
|
||||||
|
|
||||||
|
```
|
||||||
|
composer require jonom/silverstripe-betternavigator
|
||||||
|
```
|
||||||
|
|
||||||
**Manually**
|
**Manually**
|
||||||
Download, place the folder in your project root, rename it to 'betternavigator' (if applicable) and run a dev/build?flush=1.
|
Download, place the folder in your project root, rename it to 'betternavigator' (if applicable) and run a dev/build?flush=1.
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"silverstripe/framework": "^4.0"
|
"silverstripe/framework": "^5"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"installer-name": "betternavigator",
|
"installer-name": "betternavigator",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace JonoM\BetterNavigator\Extension;
|
namespace JonoM\BetterNavigator\Extension;
|
||||||
|
|
||||||
use SilverStripe\CMS\Controllers\SilverStripeNavigator;
|
use SilverStripe\Admin\Navigator\SilverStripeNavigator;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
use SilverStripe\Control\Director;
|
use SilverStripe\Control\Director;
|
||||||
@ -23,6 +23,11 @@ class BetterNavigatorExtension extends DataExtension
|
|||||||
private static $better_navigator_edit_permission = 'CMS_ACCESS_CMSMain';
|
private static $better_navigator_edit_permission = 'CMS_ACCESS_CMSMain';
|
||||||
private static $better_navigator_edit_permission_mode = 'any';
|
private static $better_navigator_edit_permission_mode = 'any';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extensions are singleton, so any cached results need to use a unique key
|
||||||
|
*/
|
||||||
|
private $shouldDisplay = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $request
|
* @param $request
|
||||||
* @param $action
|
* @param $action
|
||||||
@ -161,13 +166,16 @@ class BetterNavigatorExtension extends DataExtension
|
|||||||
*/
|
*/
|
||||||
private function shouldDisplay()
|
private function shouldDisplay()
|
||||||
{
|
{
|
||||||
if ($this->owner->getField('_betterNavigatorShouldDisplay') !== null) {
|
$key = $this->owner->getUniqueKey();
|
||||||
return $this->owner->getField('_betterNavigatorShouldDisplay');
|
|
||||||
|
if (array_key_exists($key, $this->shouldDisplay)) {
|
||||||
|
return $this->shouldDisplay[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure this is a page
|
// Make sure this is a page
|
||||||
if (!$this->owner->showBetterNavigator()) {
|
if (!$this->owner->showBetterNavigator()) {
|
||||||
$this->owner->setField('_betterNavigatorShouldDisplay', false);
|
$this->shouldDisplay[$key] = false;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +184,8 @@ class BetterNavigatorExtension extends DataExtension
|
|||||||
$canViewDraft = (Permission::check('VIEW_DRAFT_CONTENT') || Permission::check('CMS_ACCESS_CMSMain'));
|
$canViewDraft = (Permission::check('VIEW_DRAFT_CONTENT') || Permission::check('CMS_ACCESS_CMSMain'));
|
||||||
|
|
||||||
$result = ($isDev || $canViewDraft);
|
$result = ($isDev || $canViewDraft);
|
||||||
$this->owner->setField('_betterNavigatorShouldDisplay', $result);
|
$this->shouldDisplay[$key] = $result;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,14 +62,14 @@
|
|||||||
<span class="bn-icon-flush"></span>
|
<span class="bn-icon-flush"></span>
|
||||||
<%t JonoM\BetterNavigator.FLUSH_CACHE_LABEL 'Flush caches' %>
|
<%t JonoM\BetterNavigator.FLUSH_CACHE_LABEL 'Flush caches' %>
|
||||||
</a>
|
</a>
|
||||||
<a href="{$AbsoluteBaseURL}dev/build/?flush=1"
|
<a href="/dev/build/?flush=1"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
title="<%t JonoM\BetterNavigator.BUILD_DATABASE_TITLE 'Build database and flush caches (excludes template caches pre SS-3.1.7)' %>"
|
title="<%t JonoM\BetterNavigator.BUILD_DATABASE_TITLE 'Build database and flush caches (excludes template caches pre SS-3.1.7)' %>"
|
||||||
>
|
>
|
||||||
<span class="bn-icon-db"></span>
|
<span class="bn-icon-db"></span>
|
||||||
<%t JonoM\BetterNavigator.BUILD_DATABASE_LABEL 'Build database' %>
|
<%t JonoM\BetterNavigator.BUILD_DATABASE_LABEL 'Build database' %>
|
||||||
</a>
|
</a>
|
||||||
<a href="{$AbsoluteBaseURL}dev/" target="_blank"><span class="bn-icon-tools"></span><%t JonoM\BetterNavigator.DEV_MENU_LABEL 'Dev menu' %></a>
|
<a href="/dev/" target="_blank"><span class="bn-icon-tools"></span><%t JonoM\BetterNavigator.DEV_MENU_LABEL 'Dev menu' %></a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user