function testSectionIterator() { $structHolder = $this->getTestStructure(); $pathBuilder = new pathBuilder('/appendix/authors.html'); $appendixSection = $structHolder->getPageSection($pathBuilder); $sectionIterator = new contentTreeSectionIterator(new ArrayIterator($appendixSection['curSection'])); $sectionIterator->setIsIndex($pathBuilder->isIndex()); $evaluationResult = $this->evaluateSectionIterator($sectionIterator, $pathBuilder); $this->assertEqual($evaluationResult['menu_topics'], array('topic_index.html' => 'Предметный указатель', 'authors.html' => 'Авторы', 'license.html' => 'Лицензия', 'similar.html' => 'Аналоги', 'roadmap.html' => 'Планы по развитию'), 'Correct collection obtained'); $this->assertEqual($evaluationResult['curTitle'], 'Авторы', 'Correct current topic obtained'); $this->assertEqual($evaluationResult['prev'], array('href' => 'topic_index.html', 'title' => 'Предметный указатель'), 'Correct previous data obtained'); $this->assertEqual($evaluationResult['next'], array('href' => 'license.html', 'title' => 'Лицензия'), 'Correct next data obtained'); }
private function buildMenu($section, $pathBuilder) { if ($section === false) { return $this->getRootMenuData(); } $html = ''; $prev = $next = $curTitle = ''; $sectionIterator = new contentTreeSectionIterator(new ArrayIterator($section)); $sectionIterator->setIsIndex($pathBuilder->isIndex()); foreach ($sectionIterator as $key => $topic) { if ($sectionIterator->key() == $pathBuilder->getPageName()) { $html .= $this->navTemplate->parseItem('active_menu_topic', $topic->getData()); $curTitle = $topic->getTitle(); $prev = $sectionIterator->getPrevTopicData(); $next = $sectionIterator->getNextTopicData(); } else { $html .= $this->navTemplate->parseItem('menu_topic', $topic->getData()); } } return array('menu' => $html, 'next' => $next, 'prev' => $prev, 'curTitle' => $curTitle); }