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');
 }
Exemplo n.º 2
0
 private function correctNavigationIfEmpty($parentSection, $pathBuilder, $menu)
 {
     $prev = $next = '';
     if (!is_array($parentSection)) {
         return array('next' => $menu['next'], 'prev' => $menu['prev']);
     }
     $sectionIterator = new contentTreeSectionIterator(new ArrayIterator($parentSection));
     foreach ($sectionIterator as $key => $topic) {
         if ($sectionIterator->key() == $pathBuilder->getParentName()) {
             $prev = $sectionIterator->getPrevTopicData();
             $next = $sectionIterator->getNextTopicData();
             if (is_array($next)) {
                 $next['href'] = '../' . $next['href'];
             }
             if (is_array($prev)) {
                 $prev['href'] = '../' . $prev['href'];
             }
             break;
         }
     }
     $next = $menu['next'] ? $menu['next'] : $next;
     $prev = $menu['prev'] ? $menu['prev'] : $prev;
     return array('next' => $next, 'prev' => $prev);
 }