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

This commit is contained in:
Ingo Schommer 2011-06-09 15:47:59 +12:00
parent 2f2096cd3a
commit d68ec395a3
4 changed files with 22 additions and 5 deletions

View File

@ -208,10 +208,12 @@ class CMSMenu extends Object implements IteratorAggregate, i18nEntityProvider
// 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;

View File

@ -342,8 +342,12 @@ class LeftAndMain extends Controller {
}
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 @@ class LeftAndMain extends Controller {
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

View File

@ -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();

View File

@ -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">