ENHANCEMENT CMSMain->Breadcrumbs()

This commit is contained in:
Ingo Schommer 2012-02-14 16:01:07 +01:00
parent 023902c4cc
commit f88d4006f8
4 changed files with 39 additions and 2 deletions

View File

@ -222,6 +222,20 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
return $this->getsubtree($this->request);
}
/**
* @return ArrayList
*/
public function Breadcrumbs($unlinked = false) {
$items = parent::Breadcrumbs($unlinked);
// The root element should point to the pages tree view,
// rather than the actual controller (which would just show an empty edit form)
$items[0]->Title = self::menu_title_for_class('CMSPagesController');
$items[0]->Link = singleton('CMSPagesController')->Link();
return $items;
}
/**
* Create serialized JSON string with site tree hints data to be injected into
* 'data-hints' attribute of root node of jsTree.

View File

@ -2,7 +2,9 @@
<div class="cms-content-header north">
<div>
<h2><% _t('AssetAdmin.Title', 'Find &amp; Organize') %></h2>
<h2>
<% include CMSBreadcrumbs %>
</h2>
<div class="cms-content-header-tabs">
<ul>
<li>

View File

@ -2,7 +2,9 @@
<div class="cms-content-header north">
<div>
<h2><% _t('CMSPagesController.Title','Edit & Organize') %></h2>
<h2>
<% include CMSBreadcrumbs %>
</h2>
<div class="cms-content-header-tabs">
<ul>

View File

@ -221,4 +221,23 @@ class CMSMainTest extends FunctionalTest {
// TODO Logout
$this->session()->inst_set('loggedInAs', NULL);
}
function testBreadcrumbs() {
$page3 = $this->objFromFixture('Page', 'page3');
$page31 = $this->objFromFixture('Page', 'page31');
$adminuser = $this->objFromFixture('Member', 'admin');
$this->session()->inst_set('loggedInAs', $adminuser->ID);
$response = $this->get('admin/page/edit/show/' . $page31->ID);
$parser = new CSSContentParser($response->getBody());
$crumbs = $parser->getBySelector('#page-title-heading .crumb');
$this->assertNotNull($crumbs);
$this->assertEquals(3, count($crumbs));
$this->assertEquals('Pages', (string)$crumbs[0]);
$this->assertEquals('Page 3', (string)$crumbs[1]);
$this->assertEquals('Page 3.1', (string)$crumbs[2]);
$this->session()->inst_set('loggedInAs', null);
}
}