Permalink
Browse files

API CHANGE Using $Link instead of $ApplicationTitle and $SectionTitle…

… in LeftAndMain.ss. Adding new 'X-Title' HTTP header in order to support title changes for history.pushState
  • Loading branch information...
1 parent 2f2096c commit d68ec395a3c8c9f01a4453db4196c884c8f1f058 @chillu chillu committed Jun 9, 2011
Showing with 22 additions and 5 deletions.
  1. +6 −4 admin/code/CMSMenu.php
  2. +11 −0 admin/code/LeftAndMain.php
  3. +4 −0 admin/javascript/LeftAndMain.js
  4. +1 −1 admin/templates/LeftAndMain.ss
@@ -208,10 +208,12 @@ public static function get_viewable_menu_items($member = null) {
// checks on
if($menuItem->controller) {
$controllerObj = singleton($menuItem->controller);
- // Necessary for canView() to have request data available,
- // e.g. to check permissions against LeftAndMain->currentPage()
- $controllerObj->setRequest(Controller::curr()->getRequest());
- if(!$controllerObj->canView($member)) continue;
+ if(Controller::has_curr()) {
+ // Necessary for canView() to have request data available,
+ // e.g. to check permissions against LeftAndMain->currentPage()
+ $controllerObj->setRequest(Controller::curr()->getRequest());
+ if(!$controllerObj->canView($member)) continue;
+ }
}
$viewableMenuItems[$code] = $menuItem;
@@ -342,8 +342,12 @@ function init() {
}
function handleRequest($request) {
+ $title = $this->Title();
+
$response = parent::handleRequest($request);
$response->addHeader('X-Controller', $this->class);
+ $response->addHeader('X-Title', $title);
+
return $response;
}
@@ -1175,6 +1179,13 @@ static function setApplicationName($name) {
function getApplicationName() {
return self::$application_name;
}
+
+ /**
+ * @return String
+ */
+ function Title() {
+ return sprintf('%s | %s', $this->getApplicationName(), $this->SectionTitle());
+ }
/**
* Return the title of the current section, as shown on the main menu
@@ -122,6 +122,10 @@
var xhr = $.ajax({
url: state.url,
success: function(data, status, xhr) {
+ // Update title
+ var title = xhr.getResponseHeader('X-Title');
+ if(title) document.title = title;
+
// Update panels
contentEl.afterLoad(data, status, xhr);
self.redraw();
@@ -4,7 +4,7 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-language" content="$i18nLocale" />
<% base_tag %>
-<title>$ApplicationName | $SectionTitle</title>
+<title>$Title</title>
</head>
<body class="loading cms $CSSClasses">

0 comments on commit d68ec39

Please sign in to comment.