From 8d359d170393379df9622188eeba5e6f9c26c63d Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 16 Feb 2010 03:45:20 +0000 Subject: [PATCH] APICHANGE: Use the same navigator items in the CMS that are used on the frontend (from r97395) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@99114 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CMSMain.php | 7 +++++ code/LeftAndMain.php | 9 +++++- css/layout.css | 3 +- javascript/LeftAndMain_right.js | 50 +++++---------------------------- templates/LeftAndMain.ss | 7 ++--- 5 files changed, 25 insertions(+), 51 deletions(-) diff --git a/code/CMSMain.php b/code/CMSMain.php index 42249ead..2989f917 100755 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -117,6 +117,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr function ShowSwitchView() { return true; } + + function SwitchView() { + if($page = $this->currentPage()) { + $nav = $page->getNavigatorItems(); + return $nav['items']; + } + } //------------------------------------------------------------------------------------------// // Main controllers diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 0e16b9d8..7d477c4a 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -361,7 +361,14 @@ class LeftAndMain extends Controller { } $form = $this->EditForm(); - if ($form) return $form->formHtmlContent(); + if ($form) { + $content = $form->formHtmlContent(); + if($this->ShowSwitchView()) { + $content .= '
' . $this->SwitchView() . '
'; + } + + return $content; + } else return ""; } public function getLastFormIn($html) { diff --git a/css/layout.css b/css/layout.css index 78446905..785b8314 100644 --- a/css/layout.css +++ b/css/layout.css @@ -276,7 +276,6 @@ body.stillLoading select { bottom: 0; left: 0; height: 23px; - overflow: hidden; background: #4d4e5a url(../images/textures/footerBg.gif) repeat-x left top; } @@ -720,4 +719,4 @@ iframe { .message.bad { background-color: #FF8080; border-color: #FF0000; - } \ No newline at end of file + } diff --git a/javascript/LeftAndMain_right.js b/javascript/LeftAndMain_right.js index 75214ab7..bdce0c4e 100755 --- a/javascript/LeftAndMain_right.js +++ b/javascript/LeftAndMain_right.js @@ -23,6 +23,13 @@ CMSForm.prototype = { */ prepareForm : function() { ajaxActionsAtTop(this.id, 'form_actions_' + this.formName, this.formName); + + // Update the nav items down the bottom + if($('AjaxSwitchView')) { + $('SwitchView').innerHTML = $('AjaxSwitchView').innerHTML; + $('AjaxSwitchView').innerHTML = ''; + Behaviour.apply('SwitchView'); // This is needed so calendar still works + } }, /** @@ -395,49 +402,6 @@ function autoSave(confirmation, callAfter) { } } - -StageLink = Class.create(); -StageLink.prototype = { - initialize: function(getVars, urlField) { - this.getVars = getVars; - this.urlField = urlField; - - var boundNewPage = this.newPage.bind(this); - - $('Form_EditForm').observeMethod('PageLoaded', boundNewPage); - $('Form_EditForm').observeMethod('PageSaved', boundNewPage); - $('Form_EditForm').observeMethod('PagePublished', boundNewPage); - $('Form_EditForm').observeMethod('PageUnpublished', boundNewPage); - - this.newPage(); - }, - newPage : function() { - var linkField = $('Form_EditForm').elements[this.urlField]; - var linkVal = linkField ? linkField.value : null; - if(linkVal) { - if(this.id != 'viewArchivedSite') this.style.display = ''; - this.href = linkVal + this.getVars; - } else { - if(this.id != 'viewArchivedSite') this.style.display = 'none'; - } - if($('Form_EditForm_Locale')) { - this.href += "&locale=" + $('Form_EditForm_Locale').value; - } - }, - onclick : function() { - var w = window.open(this.href, windowName('site')); - w.focus(); - return false; - }, - baseURL : function() { - return document.getElementsByTagName('base')[0].href; - } -} - -StageLink.applyTo('#viewStageSite', '?stage=Stage', 'StageURLSegment'); -StageLink.applyTo('#viewLiveSite', '?stage=Live', 'LiveURLSegment'); -StageLink.applyTo('#viewArchivedSite', '', 'URLSegment'); - window.name = windowName('cms'); /** diff --git a/templates/LeftAndMain.ss b/templates/LeftAndMain.ss index 130a4137..d7fc7429 100644 --- a/templates/LeftAndMain.ss +++ b/templates/LeftAndMain.ss @@ -48,13 +48,10 @@
<% if ShowSwitchView %>
<% _t('VIEWPAGEIN','Page view:') %>
- <% _t('EDIT','Edit') %> - <% _t('DRAFTS','Draft Site') %> - <% _t('PUBLIS','Published Site') %> - + $SwitchView
<% end_if %> - \ No newline at end of file +