Separated Page and BetterNavigator template data

Fixes #8
This commit is contained in:
Jonathon Menz 2014-11-22 10:28:06 +10:30
parent 2251008ae4
commit fdd895ef9d
2 changed files with 41 additions and 35 deletions

View File

@ -45,17 +45,19 @@ class BetterNavigator extends DataExtension {
$isDeveloper = $member && is_array($devs) ? in_array($member->Email, $devs) : false;
//Add other data for template
$nav = array_merge($nav, array(
$backURL = '?BackURL=' . urlencode($this->owner->Link());
$bNData = array_merge($nav, array(
'Member' => $member,
'Stage' => Versioned::current_stage(),
'LoginLink' => Config::inst()->get('Security', 'login_url'),
'LoginLink' => Config::inst()->get('Security', 'login_url') . $backURL,
'LogoutLink' => 'Security/logout' . $backURL,
'Mode' => Director::get_environment_type(),
'IsDeveloper' => $isDeveloper
));
//Merge with page data, send to template and render
$nav = new ArrayData($nav);
$page = $this->owner->customise($nav);
$bNData = new ArrayData($bNData);
$page = $this->owner->customise(array('BetterNavigator' => $bNData));
return $page->renderWith('BetterNavigator');
}
}

View File

@ -5,58 +5,62 @@
<div id="BetterNavigator" class="collapsed">
<div id="BetterNavigatorStatus" class="$Stage">
<span class="bn-icon-cog"></span>
<% if $LiveLink.Active %>Published<% end_if %>
<% if $StageLink.Active %>Draft<% end_if %>
<% if $ArchiveLink.Active %>Archived<% end_if %>
<span class="bn-icon-close"></span>
</div>
<% with $BetterNavigator %>
<div id="BetterNavigatorStatus" class="$Stage">
<span class="bn-icon-cog"></span>
<% if $LiveLink.Active %>Published<% end_if %>
<% if $StageLink.Active %>Draft<% end_if %>
<% if $ArchiveLink.Active %>Archived<% end_if %>
<span class="bn-icon-close"></span>
</div>
<% end_with %>
<div id="BetterNavigatorContent">
<div class="bn-links">
<% if not $LiveLink.Active %>
<% if $LiveLink.Link %>
<a href="$LiveLink.Link"><span class="bn-icon-view"></span>View Published</a>
<% else %>
<span class="bn-disabled"><span class="bn-icon-view"></span>Not yet published</span>
<% end_if %>
<% end_if %>
<% if not $StageLink.Active %>
<% if $StageLink.Link %>
<a href="$StageLink.Link"><span class="bn-icon-view"></span>View Draft</a>
<% else %>
<span class="bn-disabled"><span class="bn-icon-view"></span>Deleted from draft site</span>
<% end_if %>
<% end_if %>
<a href="$CMSLink.Link" target="_blank"><span class="bn-icon-edit"></span>Edit in CMS</a>
<% if $Member %>
<a href="Security/logout?BackURL=$Link"><span class="bn-icon-user"></span>Log out<% if $Member.FirstName %><span class="light"> ($Member.FirstName)</span><% end_if %></a>
<% else %>
<a href="$LoginLink?BackURL=$Link"><span class="bn-icon-user"></span>Log in</a>
<% end_if %>
<% with $BetterNavigator %>
<% if not $LiveLink.Active %>
<% if $LiveLink.Link %>
<a href="$LiveLink.Link"><span class="bn-icon-view"></span>View Published</a>
<% else %>
<span class="bn-disabled"><span class="bn-icon-view"></span>Not yet published</span>
<% end_if %>
<% end_if %>
<% if not $StageLink.Active %>
<% if $StageLink.Link %>
<a href="$StageLink.Link"><span class="bn-icon-view"></span>View Draft</a>
<% else %>
<span class="bn-disabled"><span class="bn-icon-view"></span>Deleted from draft site</span>
<% end_if %>
<% end_if %>
<a href="$CMSLink.Link" target="_blank"><span class="bn-icon-edit"></span>Edit in CMS</a>
<% if $Member %>
<a href="$LogoutLink"><span class="bn-icon-user"></span>Log out<% if $Member.FirstName %><span class="light"> ($Member.FirstName)</span><% end_if %></a>
<% else %>
<a href="$LoginLink"><span class="bn-icon-user"></span>Log in</a>
<% end_if %>
<% end_with %>
</div>
<% include BetterNavigatorExtraContent %>
<% if $Mode=='dev' || $IsDeveloper %>
<% if $BetterNavigator.Mode=='dev' || $BetterNavigator.IsDeveloper %>
<div class="bn-heading">Developer Tools</div>
<div class="bn-links">
<% if $Mode='dev' %>
<% if $BetterNavigator.Mode='dev' %>
<span class="bn-disabled" title="Log out to end Dev Mode"><span class="bn-icon-tick"></span>Dev Mode On</span>
<% else %>
<a href="$Link?isDev=1"><span class="bn-icon-devmode"></span>Dev Mode</a>
<% end_if %>
<a href="$Link?flush=1" title="Flush templates and manifest, and regenerate images for this page (behaviour varies by Framework version)"><span class="bn-icon-flush"></span>Flush Caches</a>
<a href="dev/build/?flush=1" target="_blank" title="Build database and flush caches (currently excludes template caches)"><span class="bn-icon-db"></span>Build Database</a>
<a href="dev/build/?flush=1" target="_blank" title="Build database and flush caches (excludes template caches pre SS-3.1.7)"><span class="bn-icon-db"></span>Build Database</a>
<a href="dev" target="_blank"><span class="bn-icon-tools"></span>Dev Menu</a>
</div>