mirror of
https://github.com/jonom/silverstripe-betternavigator.git
synced 2024-10-22 14:05:51 +02:00
parent
7c78a7e2ed
commit
a050d926de
@ -23,11 +23,13 @@ class BetterNavigator extends DataExtension {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function BetterNavigator() {
|
public function BetterNavigator() {
|
||||||
|
// Make sure this is a page
|
||||||
|
if (!($this->owner && $this->owner->dataRecord && $this->owner->dataRecord instanceof SiteTree && $this->owner->dataRecord->ID > 0)) return false;
|
||||||
|
|
||||||
|
// Only show navigator to appropriate users
|
||||||
$isDev = Director::isDev();
|
$isDev = Director::isDev();
|
||||||
|
$canViewDraft = (Permission::check('VIEW_DRAFT_CONTENT') || Permission::check('CMS_ACCESS_CMSMain'));
|
||||||
if($isDev || Permission::check('CMS_ACCESS_CMSMain') || Permission::check('VIEW_DRAFT_CONTENT')) {
|
if($isDev || $canViewDraft) {
|
||||||
if($this->owner && $this->owner->dataRecord && $this->owner->dataRecord instanceof SiteTree) {
|
|
||||||
|
|
||||||
// Get SilverStripeNavigator links & stage info (CMS/Stage/Live/Archive)
|
// Get SilverStripeNavigator links & stage info (CMS/Stage/Live/Archive)
|
||||||
$nav = array();
|
$nav = array();
|
||||||
$viewing = '';
|
$viewing = '';
|
||||||
@ -46,6 +48,8 @@ class BetterNavigator extends DataExtension {
|
|||||||
if ($name == 'ArchiveLink') $viewing = 'Archived';
|
if ($name == 'ArchiveLink') $viewing = 'Archived';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Only show edit link if user has permission to edit this page
|
||||||
|
$editLink = (($this->owner->dataRecord->canEdit() && Permission::check('CMS_ACCESS_CMSMain')) || $isDev) ? $nav['CMSLink']['Link'] : false;
|
||||||
|
|
||||||
// Is the logged in member nominated as a developer?
|
// Is the logged in member nominated as a developer?
|
||||||
$member = Member::currentUser();
|
$member = Member::currentUser();
|
||||||
@ -60,6 +64,7 @@ class BetterNavigator extends DataExtension {
|
|||||||
'Viewing' => $viewing, // What we're viewing doesn't necessarily align with the active Stage
|
'Viewing' => $viewing, // What we're viewing doesn't necessarily align with the active Stage
|
||||||
'LoginLink' => Config::inst()->get('Security', 'login_url') . $backURL,
|
'LoginLink' => Config::inst()->get('Security', 'login_url') . $backURL,
|
||||||
'LogoutLink' => 'Security/logout' . $backURL,
|
'LogoutLink' => 'Security/logout' . $backURL,
|
||||||
|
'EditLink' => $editLink,
|
||||||
'Mode' => Director::get_environment_type(),
|
'Mode' => Director::get_environment_type(),
|
||||||
'IsDeveloper' => $isDeveloper
|
'IsDeveloper' => $isDeveloper
|
||||||
));
|
));
|
||||||
@ -69,7 +74,6 @@ class BetterNavigator extends DataExtension {
|
|||||||
$page = $this->owner->customise(array('BetterNavigator' => $bNData));
|
$page = $this->owner->customise(array('BetterNavigator' => $bNData));
|
||||||
return $page->renderWith('BetterNavigator');
|
return $page->renderWith('BetterNavigator');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
<% if $ID > 0 %><%-- Only show on 'real' pages --%>
|
|
||||||
|
|
||||||
<% require javascript("betternavigator/javascript/betternavigator.js") %>
|
<% require javascript("betternavigator/javascript/betternavigator.js") %>
|
||||||
<% require css("betternavigator/css/betternavigator.css") %>
|
<% require css("betternavigator/css/betternavigator.css") %>
|
||||||
|
|
||||||
@ -19,7 +17,7 @@
|
|||||||
|
|
||||||
<% with $BetterNavigator %>
|
<% with $BetterNavigator %>
|
||||||
<% if $ArchiveLink.Active %>
|
<% if $ArchiveLink.Active %>
|
||||||
<a href="$CMSLink.Link" target="_blank"><span class="bn-icon-edit"></span>Restore</a>
|
<% if $EditLink %><a href="$EditLink" target="_blank"><span class="bn-icon-edit"></span>Restore</a><% end_if %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if not $LiveLink.Active %>
|
<% if not $LiveLink.Active %>
|
||||||
<% if $LiveLink.Link %>
|
<% if $LiveLink.Link %>
|
||||||
@ -35,7 +33,7 @@
|
|||||||
<span class="bn-disabled"><span class="bn-icon-view"></span>Deleted from draft site</span>
|
<span class="bn-disabled"><span class="bn-icon-view"></span>Deleted from draft site</span>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
<a href="$CMSLink.Link" target="_blank"><span class="bn-icon-edit"></span>Edit in CMS</a>
|
<% if $EditLink %><a href="$EditLink" target="_blank"><span class="bn-icon-edit"></span>Edit in CMS</a><% end_if %>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
<% if $Member %>
|
<% if $Member %>
|
||||||
@ -90,4 +88,3 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<% end_if %>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user