Permalink
Browse files

BUG SilverStripeNavigator shows wrong message.

The message was always 'Published Site'.
Also there were no 'active' class on links.
  • Loading branch information...
1 parent 0f8d7a0 commit 5c933b40e53f10a5f89bbcccdd5da79f492ec650 @uniun uniun committed Mar 18, 2013
Showing with 6 additions and 7 deletions.
  1. +6 −7 code/controllers/SilverStripeNavigator.php
View
13 code/controllers/SilverStripeNavigator.php
@@ -82,7 +82,7 @@ static public function get_for_record($record) {
$text = $item->getHTML();
if($text) $html .= $text;
$newMessage = $item->getMessage();
- if($newMessage) $message = $newMessage;
+ if($newMessage && $item->isActive()) $message = $newMessage;
}
return array(
@@ -217,7 +217,7 @@ public function getHTML() {
$draftPage = $this->getDraftPage();
if($draftPage) {
$this->recordLink = Controller::join_links($draftPage->AbsoluteLink(), "?stage=Stage");
- return "<a href=\"$this->recordLink\">". _t('ContentController.DRAFTSITE', 'Draft Site') ."</a>";
+ return "<a ". ($this->isActive() ? 'class="current" ' : '') ."href=\"$this->recordLink\">". _t('ContentController.DRAFTSITE', 'Draft Site') ."</a>";
}
}
@@ -265,7 +265,7 @@ public function getHTML() {
$livePage = $this->getLivePage();
if($livePage) {
$this->recordLink = Controller::join_links($livePage->AbsoluteLink(), "?stage=Live");
- return "<a href=\"$this->recordLink\">". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."</a>";
+ return "<a ". ($this->isActive() ? 'class="current" ' : '') ."href=\"$this->recordLink\">". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."</a>";
}
}
@@ -286,7 +286,7 @@ public function canView($member = null) {
}
public function isActive() {
- return (!Versioned::current_stage() || Versioned::current_stage() == 'Live');
+ return ((!Versioned::current_stage() || Versioned::current_stage() == 'Live') && !Versioned::current_archived_date());
}
protected function getLivePage() {
@@ -308,13 +308,12 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
public function getHTML() {
$this->recordLink = $this->record->AbsoluteLink();
- return "<a class=\"ss-ui-button\" href=\"$this->recordLink?archiveDate={$this->record->LastEdited}\" target=\"_blank\">". _t('ContentController.ARCHIVEDSITE', 'Preview version') ."</a>";
+ return "<a class=\"ss-ui-button". ($this->isActive() ? ' current' : '') ."\" href=\"$this->recordLink?archiveDate={$this->record->LastEdited}\" target=\"_blank\">". _t('ContentController.ARCHIVEDSITE', 'Preview version') ."</a>";
}
public function getMessage() {
if($date = Versioned::current_archived_date()) {
- $dateObj = Datetime::create();
- $dateObj->setValue($date);
+ $dateObj = DBField::create_field('Datetime', $date);
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>";
}
}

0 comments on commit 5c933b4

Please sign in to comment.