2016-08-16 03:22:58 +02:00
|
|
|
<?php
|
2016-09-08 09:33:32 +02:00
|
|
|
|
2016-08-16 03:22:58 +02:00
|
|
|
namespace SilverStripe\CMS\Controllers;
|
|
|
|
|
|
|
|
use SilverStripe\Admin\LeftAndMain;
|
|
|
|
use SilverStripe\CMS\Model\RedirectorPage;
|
2016-08-23 04:36:06 +02:00
|
|
|
use SilverStripe\Control\Controller;
|
2016-08-16 03:22:58 +02:00
|
|
|
|
|
|
|
class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem
|
|
|
|
{
|
2017-01-25 21:59:25 +01:00
|
|
|
/** @config */
|
|
|
|
private static $priority = 10;
|
|
|
|
|
|
|
|
public function getHTML()
|
|
|
|
{
|
|
|
|
return sprintf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
$this->record->CMSEditLink(),
|
2017-04-20 03:15:29 +02:00
|
|
|
_t('SilverStripe\\CMS\\Controllers\\ContentController.CMS', 'CMS')
|
2017-01-25 21:59:25 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitle()
|
|
|
|
{
|
2017-04-20 03:15:29 +02:00
|
|
|
return _t('SilverStripe\\CMS\\Controllers\\ContentController.CMS', 'CMS', 'Used in navigation. Should be a short label');
|
2017-01-25 21:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getLink()
|
|
|
|
{
|
|
|
|
return $this->record->CMSEditLink();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isActive()
|
|
|
|
{
|
|
|
|
return (Controller::curr() instanceof LeftAndMain);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function canView($member = null)
|
|
|
|
{
|
|
|
|
return (
|
|
|
|
// Don't show in CMS
|
|
|
|
!(Controller::curr() instanceof LeftAndMain)
|
|
|
|
// Don't follow redirects in preview, they break the CMS editing form
|
|
|
|
&& !($this->record instanceof RedirectorPage)
|
|
|
|
);
|
|
|
|
}
|
2016-08-16 03:22:58 +02:00
|
|
|
}
|