mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FEATURE: Add Link to silverstripe navigator (from r97407)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@99080 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
ed8e75ea8d
commit
2805cfabdb
@ -296,29 +296,7 @@ class ContentController extends Controller {
|
|||||||
$items = '';
|
$items = '';
|
||||||
$message = '';
|
$message = '';
|
||||||
|
|
||||||
if(Director::isDev() || Permission::check('CMS_ACCESS_CMSMain') || Permission::check('VIEW_DRAFT_CONTENT')) {
|
if(Director::isDev() || Permission::check('CMS_ACCESS_CMSMain') || Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||||
Requirements::css(SAPPHIRE_DIR . '/css/SilverStripeNavigator.css');
|
|
||||||
|
|
||||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
|
||||||
Requirements::customScript(<<<JS
|
|
||||||
(function($) {
|
|
||||||
$('#switchView a.newWindow').click(function() {
|
|
||||||
var w = window.open(this.href,windowName(this.target));
|
|
||||||
w.focus();
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
function windowName(suffix) {
|
|
||||||
var base = document.getElementsByTagName('base')[0].href.replace('http://','').replace(/\//g,'_').replace(/\./g,'_');
|
|
||||||
return base + suffix;
|
|
||||||
}
|
|
||||||
window.name = windowName('site');
|
|
||||||
})(jQuery);
|
|
||||||
JS
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($this->dataRecord) {
|
if($this->dataRecord) {
|
||||||
$return = $nav = SilverStripeNavigator::get_for_record($this->dataRecord);
|
$return = $nav = SilverStripeNavigator::get_for_record($this->dataRecord);
|
||||||
$items = $return['items'];
|
$items = $return['items'];
|
||||||
|
@ -53,8 +53,8 @@ class SilverStripeNavigator {
|
|||||||
* @subpackage content
|
* @subpackage content
|
||||||
*/
|
*/
|
||||||
class SilverStripeNavigatorItem extends Object {
|
class SilverStripeNavigatorItem extends Object {
|
||||||
function getHTML($controller) {}
|
function getHTML($page) {}
|
||||||
function getMessage($controller) {}
|
function getMessage($page) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,12 +64,12 @@ class SilverStripeNavigatorItem extends Object {
|
|||||||
class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem {
|
class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem {
|
||||||
static $priority = 10;
|
static $priority = 10;
|
||||||
|
|
||||||
function getHTML($controller) {
|
function getHTML($page) {
|
||||||
if(is_a(Controller::curr(), 'CMSMain')) {
|
if(is_a(Controller::curr(), 'CMSMain')) {
|
||||||
return '<a class="current">CMS</a>';
|
return '<a class="current">CMS</a>';
|
||||||
} else {
|
} else {
|
||||||
$cmsLink = 'admin/show/' . $controller->ID;
|
$cmsLink = 'admin/show/' . $page->ID;
|
||||||
$cmsLink = "<a href=\"$cmsLink\" target=\"cms\">". _t('ContentController.CMS', 'CMS') ."</a>";
|
$cmsLink = "<a href=\"$cmsLink\" class=\"newWindow\" target=\"cms\">". _t('ContentController.CMS', 'CMS') ."</a>";
|
||||||
|
|
||||||
return $cmsLink;
|
return $cmsLink;
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem {
|
|||||||
|
|
||||||
function getLink($page) {
|
function getLink($page) {
|
||||||
if(is_a(Controller::curr(), 'CMSMain')) {
|
if(is_a(Controller::curr(), 'CMSMain')) {
|
||||||
return Controller::curr()->AbsoluteLink() . 'show/' . $page->ID;
|
return Controller::curr()->AbsoluteLink('show') . $page->ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,20 +90,26 @@ class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem {
|
|||||||
class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
|
class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
|
||||||
static $priority = 20;
|
static $priority = 20;
|
||||||
|
|
||||||
function getHTML($controller) {
|
function getHTML($page) {
|
||||||
if(Versioned::current_stage() == 'Stage' && !(ClassInfo::exists('SiteTreeFutureState') && SiteTreeFutureState::get_future_datetime())) {
|
if(Versioned::current_stage() == 'Stage' && !(ClassInfo::exists('SiteTreeFutureState') && SiteTreeFutureState::get_future_datetime())) {
|
||||||
return "<a class=\"current\">". _t('ContentController.DRAFTSITE', 'Draft Site') ."</a>";
|
return "<a class=\"current\">". _t('ContentController.DRAFTSITE', 'Draft Site') ."</a>";
|
||||||
} else {
|
} else {
|
||||||
$thisPage = $controller->Link();
|
$thisPage = $page->Link();
|
||||||
return "<a href=\"$thisPage?stage=Stage\" target=\"site\" style=\"left : -1px;\">". _t('ContentController.DRAFTSITE', 'Draft Site') ."</a>";
|
return "<a href=\"$thisPage?stage=Stage\" class=\"newWindow\" target=\"site\" style=\"left : -1px;\">". _t('ContentController.DRAFTSITE', 'Draft Site') ."</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMessage($controller) {
|
function getMessage($page) {
|
||||||
if(Versioned::current_stage() == 'Stage') {
|
if(Versioned::current_stage() == 'Stage') {
|
||||||
return "<div id=\"SilverStripeNavigatorMessage\" title=\"". _t('ContentControl.NOTEWONTBESHOWN', 'Note: this message will not be shown to your visitors') ."\">". _t('ContentController.DRAFTSITE', 'Draft Site') ."</div>";
|
return "<div id=\"SilverStripeNavigatorMessage\" title=\"". _t('ContentControl.NOTEWONTBESHOWN', 'Note: this message will not be shown to your visitors') ."\">". _t('ContentController.DRAFTSITE', 'Draft Site') ."</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLink($page) {
|
||||||
|
if(Versioned::current_stage() == 'Stage') {
|
||||||
|
return $page->AbsoluteLink() . '?stage=Stage';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,20 +119,26 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
|
|||||||
class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
|
class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
|
||||||
static $priority = 30;
|
static $priority = 30;
|
||||||
|
|
||||||
function getHTML($controller) {
|
function getHTML($page) {
|
||||||
if(Versioned::current_stage() == 'Live') {
|
if(Versioned::current_stage() == 'Live') {
|
||||||
return "<a class=\"current\">". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."</a>";
|
return "<a class=\"current\">". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."</a>";
|
||||||
} else {
|
} else {
|
||||||
$thisPage = $controller->Link();
|
$thisPage = $page->Link();
|
||||||
return "<a href=\"$thisPage?stage=Live\" target=\"site\" style=\"left : -3px;\">". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."</a>";
|
return "<a href=\"$thisPage?stage=Live\" class=\"newWindow\" target=\"site\" style=\"left : -3px;\">". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMessage($controller) {
|
function getMessage($page) {
|
||||||
if(Versioned::current_stage() == 'Live') {
|
if(Versioned::current_stage() == 'Live') {
|
||||||
return "<div id=\"SilverStripeNavigatorMessage\" title=\"". _t('ContentControl.NOTEWONTBESHOWN', 'Note: this message will not be shown to your visitors') ."\">". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."</div>";
|
return "<div id=\"SilverStripeNavigatorMessage\" title=\"". _t('ContentControl.NOTEWONTBESHOWN', 'Note: this message will not be shown to your visitors') ."\">". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLink($page) {
|
||||||
|
if(Versioned::current_stage() == 'Live') {
|
||||||
|
return $page->AbsoluteLink() . '?stage=Live';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -136,19 +148,25 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
|
|||||||
class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
|
class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
|
||||||
static $priority = 40;
|
static $priority = 40;
|
||||||
|
|
||||||
function getHTML($controller) {
|
function getHTML($page) {
|
||||||
if(Versioned::current_archived_date()) {
|
if(Versioned::current_archived_date()) {
|
||||||
return "<a class=\"current\">". _t('ContentController.ARCHIVEDSITE', 'Archived Site') ."</a>";
|
return "<a class=\"current\">". _t('ContentController.ARCHIVEDSITE', 'Archived Site') ."</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMessage($controller) {
|
function getMessage($page) {
|
||||||
if($date = Versioned::current_archived_date()) {
|
if($date = Versioned::current_archived_date()) {
|
||||||
$dateObj = Object::create('Datetime', $date, null);
|
$dateObj = Object::create('Datetime', $date, null);
|
||||||
|
|
||||||
return "<div id=\"SilverStripeNavigatorMessage\" title=\"". _t('ContentControl.NOTEWONTBESHOWN', 'Note: this message will not be shown to your visitors') ."\">". _t('ContentController.ARCHIVEDSITEFROM', 'Archived site from') ."<br>" . $dateObj->Nice() . "</div>";
|
return "<div id=\"SilverStripeNavigatorMessage\" title=\"". _t('ContentControl.NOTEWONTBESHOWN', 'Note: this message will not be shown to your visitors') ."\">". _t('ContentController.ARCHIVEDSITEFROM', 'Archived site from') ."<br>" . $dateObj->Nice() . "</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLink($page) {
|
||||||
|
if($date = Versioned::current_archived_date()) {
|
||||||
|
return $page->AbsoluteLink() . '?archiveDate=' . $date;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -1814,8 +1814,16 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getNavigatorItems() {
|
function getNavigatorItems() {
|
||||||
|
Requirements::css(SAPPHIRE_DIR . '/css/SilverStripeNavigator.css');
|
||||||
|
Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
|
||||||
|
// Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
|
||||||
|
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
|
||||||
|
Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/livequery/jquery.livequery.js');
|
||||||
|
Requirements::javascript(SAPPHIRE_DIR . '/javascript/SilverStripeNavigator.js');
|
||||||
|
|
||||||
$items = '';
|
$items = '';
|
||||||
$message = '';
|
$message = '';
|
||||||
|
$link = '';
|
||||||
|
|
||||||
$navItemClasses = ClassInfo::subclassesFor('SilverStripeNavigatorItem');
|
$navItemClasses = ClassInfo::subclassesFor('SilverStripeNavigatorItem');
|
||||||
array_shift($navItemClasses);
|
array_shift($navItemClasses);
|
||||||
@ -1840,6 +1848,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if($text) $items .= $text;
|
if($text) $items .= $text;
|
||||||
$newMessage = $obj->getMessage($this);
|
$newMessage = $obj->getMessage($this);
|
||||||
if($newMessage) $message = $newMessage;
|
if($newMessage) $message = $newMessage;
|
||||||
|
$newLink = $obj->getLink($this);
|
||||||
|
if($newLink) $link = $newLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($link) {
|
||||||
|
$data = new ArrayData(array('Link' => $link));
|
||||||
|
$items .= $data->renderWith(array('SilverStripeNavigatorLink'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
@ -81,3 +81,21 @@
|
|||||||
padding-bottom:4px;
|
padding-bottom:4px;
|
||||||
padding-right:20px;
|
padding-right:20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#SilverStripeNavigatorLinkPopup {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
top: -50px;
|
||||||
|
height: 40px;
|
||||||
|
width: 280px;
|
||||||
|
left: 200px;
|
||||||
|
background-color: white;
|
||||||
|
border: 1px solid black;
|
||||||
|
z-index: 100;
|
||||||
|
color: black;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#SilverStripeNavigatorLinkPopup input {
|
||||||
|
width: 250px;
|
||||||
|
}
|
||||||
|
5
templates/SilverStripeNavigatorLink.ss
Normal file
5
templates/SilverStripeNavigatorLink.ss
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<a id="SilverStripeNavigatorLink">Link</a>
|
||||||
|
<div id="SilverStripeNavigatorLinkPopup">
|
||||||
|
<p>To share this page, copy and paste the link below.</p>
|
||||||
|
<input value="$Link" />
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user