Пример #1
0
 /**
  * Test Has Links False
  *
  * @return void
  * @covers \RcmDynamicNavigation\Model\NavLink::hasLinks
  */
 public function testHasLinksFalse()
 {
     $this->assertFalse($this->link->hasLinks());
 }
Пример #2
0
 /**
  * Get the li and link html for a link
  *
  * @param \RcmDynamicNavigation\Model\NavLink $link Link to render
  * @param boolean $admin Render in admin mode
  *
  * @return string
  */
 protected function getLi(NavLink $link, $admin)
 {
     $target = $link->getTarget();
     $objectClass = $link->getClass();
     $systemClass = $link->getSystemClass();
     if ($link->hasLinks()) {
         $objectClass .= ' dropdown';
     }
     $permissionsArray = $link->getPermissions();
     $html = '<li';
     if (!empty($objectClass) || !empty($systemClass)) {
         $html .= ' class="' . $objectClass . ' ' . $systemClass . '"';
     }
     if ($admin) {
         $html .= ' data-permissions="' . implode(',', $permissionsArray) . '"';
     }
     $html .= '>' . "\n";
     $html .= '<a href="' . $link->getHref() . '"';
     if ($link->hasLinks()) {
         $html .= 'class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"';
     }
     if (!empty($target)) {
         $html .= ' target="' . $target . '"';
     }
     $html .= '>';
     $html .= '<span class="linkText">' . $link->getDisplay() . '</span>';
     if ($link->hasLinks()) {
         $html .= '<span class="caret"></span>';
     }
     $html .= '</a>' . "\n";
     if ($link->hasLinks()) {
         $html .= $this->getUl($link->getLinks(), $admin);
     }
     $html .= '</li>' . "\n";
     return $html;
 }
 /**
  * Check an individual link
  *
  * @param NavLink $link Link to check
  *
  * @return bool
  */
 public function checkLink(NavLink $link)
 {
     $siteAdmin = $this->permissionChecks->siteAdminCheck($this->currentSite);
     $userHasPermissions = $this->usersRoleHasPermissions($link->getPermissions());
     if ($link->isLoginLink() && $this->permissionChecks->isCurrentUserLoggedIn()) {
         $link->addSystemClass('HiddenLink');
     } elseif ($link->isLogoutLink() && !$this->permissionChecks->isCurrentUserLoggedIn()) {
         $link->addSystemClass('HiddenLink');
     } elseif ($siteAdmin && !$userHasPermissions) {
         $link->addSystemClass('HiddenLink');
     }
     if ($siteAdmin || $userHasPermissions) {
         return true;
     }
     return false;
 }