getNodeUrl() public method

public getNodeUrl ( Node | integer | string $nodeOrId, boolean $fullUrl = false, boolean $suppressStartNodeCheck = false ) : string
$nodeOrId Jarves\Model\Node | integer | string
$fullUrl boolean with http://
$suppressStartNodeCheck boolean
return string
コード例 #1
0
ファイル: NodeStorage.php プロジェクト: jarves/jarves
 public function populateRow($clazz, $row, $selects, $relations, $relationFields, $permissionCheck = false)
 {
     $row = parent::populateRow($clazz, $row, $selects, $relations, $relationFields, $permissionCheck);
     if ($row) {
         $row['url'] = $this->pageStack->getNodeUrl($row['id']);
     }
     return $row;
 }
コード例 #2
0
ファイル: FrontendRouter.php プロジェクト: jarves/jarves
 public function checkPageAccess(Node $page)
 {
     /** @var Node $oriPage */
     $oriPage = $page;
     if ($page->getAccessFrom() > 0 && $page->getAccessFrom() > time()) {
         $page = false;
     }
     if ($page->getAccessTo() > 0 && $page->getAccessTo() < time()) {
         $page = false;
     }
     if ($page->getAccessFromGroups() != '') {
         $access = false;
         $groups = ',' . $page->getAccessFromGroups() . ",";
         //eg ,2,4,5,
         $cgroups = null;
         if ($page['access_need_via'] == 0) {
             //we need to move this to a extra listener
             //                $cgroups =& $this->getJarves()->getClient()->getUser()->getGroups();
         } else {
             //                $htuser = $this->getJarves()->getClient()->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
             //
             //                if ($htuser['id'] > 0) {
             //                    $cgroups =& $htuser['groups'];
             //                }
         }
         if ($cgroups) {
             foreach ($cgroups as $group) {
                 if (strpos($groups, "," . $group['group_id'] . ",") !== false) {
                     $access = true;
                 }
             }
         }
         if (!$access) {
             //maybe we have access through the backend auth?
             if ($this->pageStack->isLoggedIn()) {
                 foreach ($this->pageStack->getUser()->getGroupIdsArray() as $groupId) {
                     if (false !== strpos($groups, "," . $groupId . ",")) {
                         $access = true;
                         break;
                     }
                 }
             }
         }
         if (!$access) {
             $page = false;
         }
     }
     if (!$page && ($to = $oriPage->getAccessRedirectTo())) {
         if (intval($to) > 0) {
             $to = $this->pageStack->getNodeUrl($to);
         }
         return new RedirectResponse($to);
     }
     //
     //        if (!$page && $oriPage->getAccessNeedVia() == 1) {
     //            $response = new Response('', 404);
     //
     //            return $response;
     //        }
 }
コード例 #3
0
 /**
  * @param Node|int|string $id Node, node id, or node url
  * @param bool $exact whether it should also return true when a children is active
  * @return bool
  */
 public function isActive($id, $exact = false)
 {
     $current = $this->pageStack->getCurrentPage();
     $url = $this->pageStack->getNodeUrl($current, true, true);
     $purl = $this->pageStack->getNodeUrl($id, true, true);
     if ($url === $purl) {
         return true;
     }
     if (!$exact) {
         if ($url && $purl) {
             $pos = strpos($url, $purl);
             if ($url == '/' || $pos != 0 || $pos === false) {
                 return false;
             } else {
                 return true;
             }
         }
     }
 }
コード例 #4
0
ファイル: PageController.php プロジェクト: jarves/jarves
 /**
  * Build the page and return the PageResponse.
  *
  * Checks for links, mounts etc.
  *
  * @return Response
  * @throws AccessDeniedException
  * @throws \Exception
  */
 public function handleAction()
 {
     $node = $this->pageStack->getCurrentPage();
     //is link
     if ($node->getType() == 1) {
         $to = $node->getLink();
         if (!$to) {
             throw new \Exception('Redirect failed: ' . sprintf('Current page with title %s has no target link.', $node->getTitle()));
         }
         if (intval($to) > 0) {
             return new RedirectResponse($this->pageStack->getNodeUrl($to), 301);
         } else {
             return new RedirectResponse($to, 301);
         }
     }
     if ($this->editMode->isEditMode()) {
         $this->editMode->registerEditor();
     }
     $pageResponse = $this->pageStack->getPageResponse();
     $pageResponse->renderContent();
     return $pageResponse;
     //new Response('<body>ho</body>');
 }
コード例 #5
0
ファイル: NodeUrlExtension.php プロジェクト: jarves/jarves
 public function getUrl($nodeOrId = false)
 {
     return $this->pageStack->getNodeUrl($nodeOrId);
 }