/**
  * loadNavigation
  * @param integer $intDepth
  * @author Cornelius Hansjakob <*****@*****.**>   
  * @version 1.0
  */
 public function loadNavigation($intDepth = 1)
 {
     try {
         $this->getModelFolders();
         $this->evaluateRootFolderId();
         $objNavigationTree = new NavigationTree();
         $objNavigationTree->setId(0);
         if ($this->intRootLevelId > 0) {
             $objNavigationData = $this->objModelFolders->loadWebsiteRootLevelChilds($this->intRootLevelId, $intDepth);
             $intTreeId = 0;
             foreach ($objNavigationData as $objNavigationItem) {
                 if ($objNavigationItem->isStartPage == 1 && $objNavigationItem->depth == 0) {
                     /**
                      * add to parent tree
                      */
                     if (isset($objTree) && is_object($objTree) && $objTree instanceof NavigationTree) {
                         $objNavigationTree->addToParentTree($objTree, 'tree_' . $objTree->getId());
                     }
                     $objTree = new NavigationTree();
                     $objTree->setTitle($objNavigationItem->folderTitle);
                     $objTree->setId($objNavigationItem->idFolder);
                     $objTree->setParentId(0);
                     $objTree->setItemId($objNavigationItem->folderId);
                     $objTree->setUrl($objNavigationItem->idPageTypes == $this->core->sysConfig->page_types->external->id ? $objNavigationItem->external : '/' . strtolower($objNavigationItem->languageCode) . '/' . $objNavigationItem->url);
                     $intTreeId = $objNavigationItem->idFolder;
                 } else {
                     if ($intTreeId != $objNavigationItem->idFolder) {
                         /**
                          * add to parent tree
                          */
                         if (isset($objTree) && is_object($objTree) && $objTree instanceof NavigationTree) {
                             $objNavigationTree->addToParentTree($objTree, 'tree_' . $objTree->getId());
                         }
                         $objTree = new NavigationTree();
                         $objTree->setTitle($objNavigationItem->folderTitle);
                         $objTree->setId($objNavigationItem->idFolder);
                         $objTree->setParentId($objNavigationItem->parentId);
                         $objTree->setItemId($objNavigationItem->folderId);
                         $objTree->setUrl($objNavigationItem->idPageTypes == $this->core->sysConfig->page_types->external->id ? $objNavigationItem->external : '/' . strtolower($objNavigationItem->languageCode) . '/' . $objNavigationItem->url);
                         $intTreeId = $objNavigationItem->idFolder;
                     }
                     if ($objNavigationItem->pageId != null) {
                         if ($objNavigationItem->isStartPage == 1) {
                             $objTree->setUrl($objNavigationItem->idPageTypes == $this->core->sysConfig->page_types->external->id ? $objNavigationItem->external : '/' . strtolower($objNavigationItem->languageCode) . '/' . $objNavigationItem->url);
                         } else {
                             $objItem = new NavigationItem();
                             $objItem->setTitle($objNavigationItem->title);
                             $objItem->setUrl($objNavigationItem->idPageTypes == $this->core->sysConfig->page_types->external->id ? $objNavigationItem->external : '/' . strtolower($objNavigationItem->languageCode) . '/' . $objNavigationItem->url);
                             $objItem->setId($objNavigationItem->idPage);
                             $objItem->setParentId($objNavigationItem->idFolder);
                             $objItem->setItemId($objNavigationItem->pageId);
                             $objTree->addItem($objItem, 'item_' . $objItem->getId());
                         }
                     }
                 }
             }
         }
         /**
          * add to parent tree
          */
         if (isset($objTree) && is_object($objTree) && $objTree instanceof NavigationTree) {
             $objNavigationTree->addToParentTree($objTree, 'tree_' . $objTree->getId());
         }
         $this->objMainNavigation = $objNavigationTree;
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
 /**
  * loadSitemap
  * @retrun NavigationTree
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function loadSitemap()
 {
     try {
         $this->getModelFolders();
         $this->evaluateRootFolderId();
         $objSitemap = new NavigationTree();
         $objSitemap->setId(0);
         if ($this->intRootLevelId > 0) {
             $objNavigationData = $this->objModelFolders->loadWebsiteRootLevelChilds($this->intRootLevelId, 99, -1, true);
             $intTreeId = 0;
             foreach ($objNavigationData as $objNavigationItem) {
                 if ($objNavigationItem->title != '') {
                     if ($objNavigationItem->isStartPage == 1 && $objNavigationItem->depth == 0) {
                         /**
                          * add to parent tree
                          */
                         if (isset($objTree) && is_object($objTree) && $objTree instanceof NavigationTree) {
                             $objSitemap->addToParentTree($objTree, 'tree_' . $objTree->getId());
                         }
                         $objTree = new NavigationTree();
                         $objTree->setTitle($objNavigationItem->folderTitle != '' ? $objNavigationItem->folderTitle : $objNavigationItem->title);
                         $objTree->setId($objNavigationItem->idFolder);
                         $objTree->setParentId(0);
                         $objTree->setTypeId($objNavigationItem->idPageTypes);
                         $objTree->setItemId($objNavigationItem->folderId);
                         $objTree->setOrder($objNavigationItem->folderOrder);
                         $objTree->setUrl($objNavigationItem->idPageTypes == $this->core->sysConfig->page_types->external->id ? $objNavigationItem->external : '/' . strtolower($objNavigationItem->languageCode) . '/' . $objNavigationItem->url);
                         $objTree->setTarget($objNavigationItem->idPageTypes == $this->core->sysConfig->page_types->external->id ? $objNavigationItem->target : '');
                         $objTree->setChanged($objNavigationItem->changed);
                         $arrPageGlobaLinkTypes = array($this->core->sysConfig->page_types->product_tree->id, $this->core->sysConfig->page_types->press_area->id, $this->core->sysConfig->page_types->courses->id, $this->core->sysConfig->page_types->events->id);
                         if (in_array($objNavigationItem->idPageTypes, $arrPageGlobaLinkTypes)) {
                             $arrFilter = array();
                             if ($this->objPage instanceof Page && $this->objPage->getElementId() == $objNavigationItem->idPage) {
                                 $arrFilter = array('CategoryId' => $this->objPage->getFieldValue('entry_category'), 'LabelId' => $this->objPage->getFieldValue('entry_label'), 'SorttypeId' => $this->objPage->getFieldValue('entry_sorttype'), 'ParentId' => $this->objPage->getFieldValue('entry_point'));
                             } else {
                                 $arrFilter = array('CategoryId' => $objNavigationItem->entry_category, 'LabelId' => $objNavigationItem->entry_label, 'SorttypeId' => $objNavigationItem->entry_sorttype, 'ParentId' => $objNavigationItem->entry_point);
                             }
                             if (count($arrFilter) > 0) {
                                 $this->addGlobalTree($objTree, $objNavigationItem->idPageTypes, $arrFilter, 999);
                             }
                         }
                         $intTreeId = $objNavigationItem->idFolder;
                     } else {
                         if ($intTreeId != $objNavigationItem->idFolder) {
                             /**
                              * add to parent tree
                              */
                             if (isset($objTree) && is_object($objTree) && $objTree instanceof NavigationTree) {
                                 $objSitemap->addToParentTree($objTree, 'tree_' . $objTree->getId());
                             }
                             $objTree = new NavigationTree();
                             $objTree->setTitle($objNavigationItem->folderTitle);
                             $objTree->setId($objNavigationItem->idFolder);
                             $objTree->setTypeId($objNavigationItem->idPageTypes);
                             $objTree->setParentId($objNavigationItem->parentId);
                             $objTree->setItemId($objNavigationItem->folderId);
                             $objTree->setOrder($objNavigationItem->folderOrder);
                             $objTree->setUrl($objNavigationItem->idPageTypes == $this->core->sysConfig->page_types->external->id ? $objNavigationItem->external : '/' . strtolower($objNavigationItem->languageCode) . '/' . $objNavigationItem->url);
                             $objTree->setTarget($objNavigationItem->idPageTypes == $this->core->sysConfig->page_types->external->id ? $objNavigationItem->target : '');
                             $objTree->setChanged($objNavigationItem->changed);
                             $arrPageGlobaLinkTypes = array($this->core->sysConfig->page_types->product_tree->id, $this->core->sysConfig->page_types->press_area->id, $this->core->sysConfig->page_types->courses->id, $this->core->sysConfig->page_types->events->id);
                             if (in_array($objNavigationItem->idPageTypes, $arrPageGlobaLinkTypes)) {
                                 $arrFilter = array();
                                 if ($this->objPage instanceof Page && $this->objPage->getElementId() == $objNavigationItem->idPage) {
                                     $arrFilter = array('CategoryId' => $this->objPage->getFieldValue('entry_category'), 'LabelId' => $this->objPage->getFieldValue('entry_label'), 'SorttypeId' => $this->objPage->getFieldValue('entry_sorttype'), 'ParentId' => $this->objPage->getFieldValue('entry_point'));
                                 } else {
                                     $arrFilter = array('CategoryId' => $objNavigationItem->entry_category, 'LabelId' => $objNavigationItem->entry_label, 'SorttypeId' => $objNavigationItem->entry_sorttype, 'ParentId' => $objNavigationItem->entry_point);
                                 }
                                 if (count($arrFilter) > 0) {
                                     $this->addGlobalTree($objTree, $objNavigationItem->idPageTypes, $arrFilter, 999);
                                 }
                             }
                             $intTreeId = $objNavigationItem->idFolder;
                         }
                         if ($objNavigationItem->pageId != null) {
                             if ($objNavigationItem->isStartPage == 1 && isset($objTree)) {
                                 $objTree->setUrl($objNavigationItem->idPageTypes == $this->core->sysConfig->page_types->external->id ? $objNavigationItem->external : '/' . strtolower($objNavigationItem->languageCode) . '/' . $objNavigationItem->url);
                                 $objTree->setTarget($objNavigationItem->idPageTypes == $this->core->sysConfig->page_types->external->id ? $objNavigationItem->target : '');
                             } else {
                                 $objItem = new NavigationItem();
                                 $objItem->setTitle($objNavigationItem->title);
                                 $objItem->setUrl($objNavigationItem->idPageTypes == $this->core->sysConfig->page_types->external->id ? $objNavigationItem->external : '/' . strtolower($objNavigationItem->languageCode) . '/' . $objNavigationItem->url);
                                 $objItem->setTarget($objNavigationItem->idPageTypes == $this->core->sysConfig->page_types->external->id ? $objNavigationItem->target : '');
                                 $objItem->setId($objNavigationItem->idPage);
                                 $objItem->setTypeId($objNavigationItem->idPageTypes);
                                 $objItem->setParentId($objNavigationItem->idFolder);
                                 $objItem->setItemId($objNavigationItem->pageId);
                                 $objItem->setOrder($objNavigationItem->pageOrder);
                                 $objItem->setChanged($objNavigationItem->changed);
                                 if (isset($objTree)) {
                                     $objTree->addItem($objItem, 'item_' . $objItem->getId());
                                 } else {
                                     $objSitemap->addItem($objItem, 'item_' . $objItem->getId());
                                 }
                             }
                         }
                     }
                 }
             }
         }
         /**
          * add to parent tree
          */
         if (isset($objTree) && is_object($objTree) && $objTree instanceof NavigationTree) {
             $objSitemap->addToParentTree($objTree, 'tree_' . $objTree->getId());
         }
         return $objSitemap;
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }