Skip to content
Snippets Groups Projects
Commit f6ddc4f9 authored by Alex Arnaud's avatar Alex Arnaud Committed by Patrick Barroca
Browse files

dev #23802 - Sitotheque: Breadcrumb starts with clicked category in sito box

parent 5faabc3b
Branches
Tags
3 merge requests!896Master,!846Dev#23802 add sito arborescence,!839Dev#23802 add sito arborescence
<?php
echo $this->publicListViewMode($this->list);
// echo $this->sitoTree($this->id_category);
?>
......@@ -30,7 +30,7 @@ class ZendAfi_Controller_Action_Helper_ListViewMode extends Zend_Controller_Acti
$helper_class = 'ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_'.ucfirst($strategy);
return $list
->setStrategy(new $helper_class())
->setStrategy(new $helper_class($this))
->buildList();
}
......
......@@ -27,6 +27,13 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy {
protected $_visitor;
protected $_helper;
public function __construct($helper) {
$this->_helper = $helper;
}
public function visit($visitor) {
$this->_visitor = $visitor;
......@@ -152,5 +159,10 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy {
public function getItemsLabelAttrib() {
return '';
}
public function getRequestParam($key, $default = null) {
return $this->_helper->getRequest()->getParam($key, $default);
}
}
?>
\ No newline at end of file
......@@ -79,10 +79,22 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Sitotheque extends
if($this->_visitor->getSearchValue())
return $breadcrumb;
return array_merge($breadcrumb, $this->getBreadcrumbFor($this->_visitor->getModel()));
$breadcrumb = array_merge($breadcrumb, $this->getBreadcrumbFor($this->_visitor->getModel()));
return $this->_shiftBreadcrumb($breadcrumb);
}
protected function _shiftBreadcrumb($breadcrumb = []) {
$start_cat = $this->getRequestParam('start_cat');
foreach ($breadcrumb as $cat) {
if ($cat['url']['id_cat'] != $start_cat)
array_shift($breadcrumb);
}
return $breadcrumb;
}
public function getDefaultModel() {
return Class_SitothequeCategorie::find($this->_visitor->getParams()['id_cat']);
......
......@@ -64,7 +64,8 @@ class ZendAfi_View_Helper_SitoTree extends Zend_View_Helper_Abstract {
return '<li><h2><a href="'.$this->view->url(['controller' => 'sito',
'action' => 'viewcategory',
'id_cat' => $category->getId()],null,true).'">' . $category->getLibelle() . '</a></h2>';
'id_cat' => $category->getId(),
'start_cat' => $category->getId()],null,true).'">' . $category->getLibelle() . '</a></h2>';
}
......
......@@ -95,22 +95,34 @@ class SitoControllerHierarchicViewTest extends SitoControllerTestCase {
],
'options' => []]);
$this->dispatch('/sito/viewcategory/id_cat/12', true);
$this->dispatch('/sito/viewcategory/id_cat/12/start_cat/12', true);
}
/** @test */
public function LinuxFrShouldNotBeShown() {
$this->assertNotXPath('//ul[@class="sitotheque"]//a[@href="http://linuxfr.org"]',
$this->_response->getBody());
}
/** @test */
/** @test */
public function FramasoftShouldBeShown() {
$this->assertXPath('//ul[@class="sitotheque"]//a[@href="http://framasoft.org"]',
$this->_response->getBody());
}
/** @test */
public function breadCrumbShouldStartWithCollectifs() {
$this->assertXPath('//div/a[1][@href="/sito/viewcategory/id_cat/12"]');
}
}
class SitoControllerViewRecentTest extends SitoControllerTestCase {
public function setUp() {
parent::setUp();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment