/** * @param \Render\APIs\APIv1\RenderAPI $renderApi * @param \Render\Unit $unit * @param \Render\APIs\APIv1\Navigation $navigation * @param array $navigatorIds * @param \Render\APIs\APIv1\Page $page * @param int $level * @param string $childrenMarkup * * @return string */ protected function getNavItemMarkup($renderApi, $unit, $navigation, array &$navigatorIds, $page, $level, $childrenMarkup) { $pageId = $page->getPageId(); $linkTag = new HtmlTagBuilder('a', array('class' => 'navLink'), array($page->getNavigationTitle())); $listTag = new HtmlTagBuilder('li', array('class' => 'navItem'), array($linkTag, $childrenMarkup)); // get url if ($renderApi->isEditMode()) { $linkTag->set('href', 'javascript:void(0);'); } else { $linkTag->set('href', $page->getUrl()); } // collect classes if ($this->isItemActive($pageId, $navigatorIds)) { $listTag->addClass('navItemActive'); $linkTag->addClass('navLinkActive'); } if ($pageId == $navigation->getCurrentPageId()) { $listTag->addClass('navItemCurrent'); $linkTag->addClass('navLinkCurrent'); } if ($this->hasChildPages($pageId, $navigation)) { $listTag->addClass('hasChildPages'); $linkTag->addClass('hasChildPages'); } return $listTag; // return $listTag->toString(); }
/** * @param \Render\APIs\APIv1\RenderAPI $renderApi * @param \Render\APIs\APIv1\Page $page * @return string */ private function getUrl($renderApi, $page) { return $renderApi->isEditMode() ? 'javascript:void(0);' : $page->getUrl(); }
public function test_getGlobalReturnsExpectedValueForGivenNameAndIndex() { // ARRANGE $pageId = 'PAGE-render00-test-api0-page-000000000001-PAGE'; $infoStorageMock = $this->createNavigationInfoStorageMock(); $infoStorageMock->expects($this->atLeastOnce())->method('getPageGlobals')->with($this->equalTo($pageId))->will($this->returnValue(array('teaserTitle' => array('index0', 'index1', 'index2')))); // ACT $page = new Page($infoStorageMock, $pageId); // ASSERT $this->assertEquals(array('index0', 'index1', 'index2'), $page->getGlobal('teaserTitle')); $this->assertEquals('index0', $page->getGlobal('teaserTitle', 0)); $this->assertEquals('index1', $page->getGlobal('teaserTitle', 1)); $this->assertEquals('index2', $page->getGlobal('teaserTitle', 2)); $this->assertNull($page->getGlobal('teaserTitle', 3)); $this->assertEquals('index2', $page->getGlobal('teaserTitle', -1)); $this->assertEquals('index1', $page->getGlobal('teaserTitle', -2)); $this->assertEquals('index0', $page->getGlobal('teaserTitle', -3)); $this->assertNull($page->getGlobal('teaserTitle', -4)); }