From c660284236c81f8f374f176644c4b50c28a5e2db Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 23 Mar 2011 10:21:05 +1300 Subject: [PATCH] MINOR Moved SilverStripeNavigator from 'sapphire' to 'cms' --- code/SilverStripeNavigatorItem.php | 189 +++++++++++++++++++++++++ css/SilverStripeNavigator.css | 111 +++++++++++++++ javascript/SilverStripeNavigator.js | 35 +++++ templates/SilverStripeNavigatorLink.ss | 10 ++ 4 files changed, 345 insertions(+) create mode 100644 code/SilverStripeNavigatorItem.php create mode 100755 css/SilverStripeNavigator.css create mode 100644 javascript/SilverStripeNavigator.js create mode 100644 templates/SilverStripeNavigatorLink.ss diff --git a/code/SilverStripeNavigatorItem.php b/code/SilverStripeNavigatorItem.php new file mode 100644 index 0000000000..762e39887a --- /dev/null +++ b/code/SilverStripeNavigatorItem.php @@ -0,0 +1,189 @@ +getHTML($record); + if($text) $items .= $text; + $newMessage = $obj->getMessage($record); + if($newMessage) $message = $newMessage; + } + + return array( + 'items' => $items, + 'message' => $message + ); + } +} + +/** + * Navigator items are links that appear in the $SilverStripeNavigator bar. + * To add an item, extends this class. + * + * @package cms + * @subpackage content + */ +class SilverStripeNavigatorItem extends Object { + function getHTML($page) {} + function getMessage($page) {} +} + +/** + * @package cms + * @subpackage content + */ +class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem { + static $priority = 10; + + function getHTML($page) { + if(is_a(Controller::curr(), 'CMSMain')) { + return 'CMS'; + } else { + $cmsLink = 'admin/show/' . $page->ID; + $cmsLink = "". _t('ContentController.CMS', 'CMS') .""; + + return $cmsLink; + } + } + + function getLink($page) { + if(is_a(Controller::curr(), 'CMSMain')) { + return Controller::curr()->AbsoluteLink('show') . $page->ID; + } + } + +} + +/** + * @package cms + * @subpackage content + */ +class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem { + static $priority = 20; + + function getHTML($page) { + if(Versioned::current_stage() == 'Stage' && !(ClassInfo::exists('SiteTreeFutureState') && SiteTreeFutureState::get_future_datetime())) { + return "". _t('ContentController.DRAFTSITE', 'Draft Site') .""; + } else { + $draftPage = Versioned::get_one_by_stage('SiteTree', 'Stage', '"SiteTree"."ID" = ' . $page->ID); + if($draftPage) { + $pageLink = Controller::join_links($draftPage->AbsoluteLink(), "?stage=Stage"); + return "". _t('ContentController.DRAFTSITE', 'Draft Site') .""; + } + } + } + + function getMessage($page) { + if(Versioned::current_stage() == 'Stage') { + return "
". _t('ContentController.DRAFTSITE', 'Draft Site') ."
"; + } + } + + function getLink($page) { + if(Versioned::current_stage() == 'Stage') { + return Controller::join_links($page->AbsoluteLink(), '?stage=Stage'); + } + } +} + +/** + * @package cms + * @subpackage content + */ +class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem { + static $priority = 30; + + function getHTML($page) { + if(Versioned::current_stage() == 'Live') { + return "". _t('ContentController.PUBLISHEDSITE', 'Published Site') .""; + } else { + $livePage = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $page->ID); + if($livePage) { + $pageLink = Controller::join_links($livePage->AbsoluteLink(), "?stage=Live"); + return "". _t('ContentController.PUBLISHEDSITE', 'Published Site') .""; + } + } + } + + function getMessage($page) { + if(Versioned::current_stage() == 'Live') { + return "
". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."
"; + } + } + + function getLink($page) { + if(Versioned::current_stage() == 'Live') { + return Controller::join_links($page->AbsoluteLink(), '?stage=Live'); + } + } +} + +/** + * @package cms + * @subpackage content + */ +class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem { + static $priority = 40; + + function getHTML($page) { + if(Versioned::current_archived_date()) { + return "". _t('ContentController.ARCHIVEDSITE', 'Archived Site') .""; + } else { + // Display the archive link if the page currently displayed in the CMS is other version than live and draft + $currentDraft = Versioned::get_one_by_stage('SiteTree', 'Draft', '"SiteTree"."ID" = ' . $page->ID); + $currentLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $page->ID); + if( + (!$currentDraft || ($currentDraft && $page->Version != $currentDraft->Version)) + && (!$currentLive || ($currentLive && $page->Version != $currentLive->Version)) + ) { + $pageLink = $page->AbsoluteLink(); + return "LastEdited}\" class=\"newWindow\" target=\"site\" style=\"left : -3px;\">". _t('ContentController.ARCHIVEDSITE', 'Archived Site') .""; + } + } + } + + function getMessage($page) { + if($date = Versioned::current_archived_date()) { + $dateObj = Object::create('Datetime'); + $dateObj->setValue($date); + return "
". _t('ContentController.ARCHIVEDSITEFROM', 'Archived site from') ."
" . $dateObj->Nice() . "
"; + } + } + + function getLink($page) { + if($date = Versioned::current_archived_date()) { + return $page->AbsoluteLink() . '?archiveDate=' . $date; + } + } +} + +?> \ No newline at end of file diff --git a/css/SilverStripeNavigator.css b/css/SilverStripeNavigator.css new file mode 100755 index 0000000000..f30c1ce97d --- /dev/null +++ b/css/SilverStripeNavigator.css @@ -0,0 +1,111 @@ + +#SilverStripeNavigator { + position: fixed; + bottom: 0; + left: 0; + width: 100%; + border-top: 2px solid #d4d0c8; + background-color:#81858d; + height: 22px; + background: #4d4e5a url(../../cms/images/textures/footerBg.gif) repeat-x left top; +} + +#SilverStripeNavigator * { + font-family: Arial,Helvetica,sans-serif; + font-size: 10px !important; +} + +#SilverStripeNavigator .holder { + text-align: center; + padding-top : 4px; + padding-left : 3px; + padding-right : 6px; + color: white; + border-top: 1px solid #555555; +} +#SilverStripeNavigator #logInStatus { + float: right; +} +#SilverStripeNavigator #switchView { + float: left; + +} + +#SilverStripeNavigator a { + color: #fff; + background-color: transparent; + text-decoration: underline; +} +#SilverStripeNavigator a:hover { + background-color: transparent; +} + +#SilverStripeNavigator .bottomTabs a { + margin-right: 8px; + text-decoration: underline; +} + +#SilverStripeNavigator .bottomTabs div.blank { + display: block; + float : left; + height : 13px; + position:relative; + top : -2px; + cursor: pointer; + border : none; + background-color: transparent; + padding: 2px 4px 2px 2px; + font-weight: bold; +} + + +#SilverStripeNavigator .bottomTabs a.current { + font-weight:bold; + text-decoration: none; +} + +#SilverStripeNavigatorMessage { + font-family: 'Lucida Grande', Verdana, Arial, 'sans-serif'; + position: absolute; + right: 20px; + top: 40px; + padding: 10px; + border-color: #c99; + color: #fff; + background-color: #c00; + border: 1px solid #000; +} + +#SilverStripeNavigator #logInStatus { + background:transparent url(../../cms/images/logout.gif) no-repeat scroll right top !important; + padding-bottom:4px; + padding-right:20px; +} + +#SilverStripeNavigatorLinkPopup { + display: none; + position: absolute; + top: -60px; + height: 50px; + width: 350px; + left: 200px; + background-color: white; + border: 1px solid black; + z-index: 100; + color: black; + padding: 5px; +} + +#SilverStripeNavigatorLinkPopup input { + width: 250px; +} + +#SilverStripeNavigatorLinkPopup a.close { + color: blue; + text-align: right; + width: 80%; + border: none !important; + cursor: pointer; +} + + diff --git a/javascript/SilverStripeNavigator.js b/javascript/SilverStripeNavigator.js new file mode 100644 index 0000000000..f57a78b071 --- /dev/null +++ b/javascript/SilverStripeNavigator.js @@ -0,0 +1,35 @@ +function windowName(suffix) { + var base = document.getElementsByTagName('base')[0].href.replace('http://','').replace(/\//g,'_').replace(/\./g,'_'); + return base + suffix; +} + +(function($) { + $('#switchView a.newWindow').live('click', + function() { + var w = window.open(this.href, windowName(this.target)); + w.focus(); + return false; + } + ); + + $('#SilverStripeNavigatorLink').live('click', + function() { + $('#SilverStripeNavigatorLinkPopup').toggle(); + return false; + } + ); + + $('#SilverStripeNavigatorLinkPopup a.close').live('click', + function() { + $('#SilverStripeNavigatorLinkPopup').hide(); + return false; + } + ); + + $('#SilverStripeNavigatorLinkPopup input').live('focus', + function() { + this.select(); + } + ); + +})(jQuery); diff --git a/templates/SilverStripeNavigatorLink.ss b/templates/SilverStripeNavigatorLink.ss new file mode 100644 index 0000000000..89a13a6137 --- /dev/null +++ b/templates/SilverStripeNavigatorLink.ss @@ -0,0 +1,10 @@ +    + + <% _t('SilverStripeNavigatorLink.ShareLink','Share link') %> + +
+ <% _t('SilverStripeNavigatorLinkl.CloseLink','Close') %> +

+ <% _t('SilverStripeNavigatorLink.ShareInstructions','To share a this to this page, copy and paste the link below.') %>

+ +