silverstripe-framework/core/control/SilverStripeNavigatorItem.php
Ingo Schommer 1f60bde524 FEATURE: Refactor links in $SilverStripeNavigator so modules can add extras (from r97299)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@99046 467b73ca-7a2a-4603-9d3b-597d59a354a9
2011-02-02 14:18:34 +13:00

81 lines
2.8 KiB
PHP

<?php
/**
* Navigator items are links that appear in the $SilverStripeNavigator bar.
* To add an item, extends this class.
*/
class SilverStripeNavigatorItem extends Object {
function getHTML($controller) {}
function getMessage($controller) {}
}
class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem {
static $priority = 10;
function getHTML($controller) {
$cmsLink = 'admin/show/' . $controller->ID;
$cmsLink = "<a href=\"$cmsLink\" target=\"cms\">". _t('ContentController.CMS', 'CMS') ."</a>";
return $cmsLink;
}
}
class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
static $priority = 20;
function getHTML($controller) {
if(Versioned::current_stage() == 'Stage') {
return "<a class=\"current\">". _t('ContentController.DRAFTSITE', 'Draft Site') ."</a>";
} else {
$thisPage = $controller->Link();
return "<a href=\"$thisPage?stage=Stage\" target=\"site\" style=\"left : -1px;\">". _t('ContentController.DRAFTSITE', 'Draft Site') ."</a>";
}
}
function getMessage($controller) {
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>";
}
}
}
class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
static $priority = 30;
function getHTML($controller) {
if(Versioned::current_stage() == 'Live') {
return "<a class=\"current\">". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."</a>";
} else {
$thisPage = $controller->Link();
return "<a href=\"$thisPage?stage=Live\" target=\"site\" style=\"left : -3px;\">". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."</a>";
}
}
function getMessage($controller) {
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>";
}
}
}
class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
static $priority = 40;
function getHTML($controller) {
if(Versioned::current_archived_date()) {
return "<a class=\"current\">". _t('ContentController.ARCHIVEDSITE', 'Archived Site') ."</a>";
}
}
function getMessage($controller) {
if($date = Versioned::current_archived_date()) {
$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>";
}
}
}
?>