/** * loadPage * @author Cornelius Hansjakob <*****@*****.**> * @version 1.0 */ public function loadPage($blnLoadByParentId = false, $blnLoadGlobalTreeStartPage = true) { try { $this->getModel(); $objPageData = $blnLoadByParentId == true ? $this->objModel->loadByParentId($this->intParentId, $this->intTypeId, true) : $this->objModel->loadByIdAndVersion($this->strPageId, $this->intPageVersion); if (count($objPageData) > 0) { $objPage = $objPageData->current(); $this->setPageId($objPage->relationId); $this->setPageVersion($objPage->version); $this->setElementId($objPage->id); $this->setTemplateFile($objPage->filename); $this->setTemplateId($objPage->idTemplates); $this->setPublisherName($objPage->publisher); $this->setPublishDate($objPage->published); $this->setCreatorName($objPage->creator); $this->setCreateDate($objPage->created); $this->setChangeUserName($objPage->changeUser); $this->setChangeDate($objPage->changed); if (isset($objPage->idPageTypes)) { $this->setTypeId($objPage->idPageTypes); } if (isset($objPage->idGlobalTypes)) { $this->setTypeId($objPage->idGlobalTypes); } if (isset($objPage->linkId)) { $this->setElementLinkId($objPage->linkId); } $this->setIsStartElement($objPage->isStartElement); $this->setShowInNavigation($objPage->showInNavigation); $this->setStatus($objPage->idStatus); $this->setParentId($objPage->idParent); $this->setParentTypeId($objPage->idParentTypes); /** * navigation parent properties */ if ($this->intNavParentId === null) { $this->setNavParentId($objPage->idParent); $this->setNavParentTypeId($objPage->idParentTypes); } $this->objGenericData = new GenericData(); $this->objGenericData->Setup()->setRootLevelId($this->intRootLevelId); $this->objGenericData->Setup()->setRootLevelGroupId($this->intRootLevelGroupId); $this->objGenericData->Setup()->setFormId($objPage->genericFormId); $this->objGenericData->Setup()->setFormVersion($objPage->version); $this->objGenericData->Setup()->setFormTypeId($objPage->idGenericFormTypes); $this->objGenericData->Setup()->setTemplateId($objPage->idTemplates); $this->objGenericData->Setup()->setElementId($objPage->id); $this->objGenericData->Setup()->setElementLinkId($this->getElementLinkId()); $this->objGenericData->Setup()->setActionType($this->core->sysConfig->generic->actions->edit); $this->objGenericData->Setup()->setFormLanguageId($this->core->sysConfig->languages->default->id); $this->objGenericData->Setup()->setLanguageId($this->intLanguageId); $this->objGenericData->Setup()->setParentId($this->getParentId()); $this->objGenericData->Setup()->setParentTypeId($this->getParentTypeId()); $this->objGenericData->Setup()->setModelSubPath($this->getModelSubPath()); $this->objGenericData->loadData(); if ($this->objGenericData->Setup()->getLanguageFallbackId() > 0 && $this->objGenericData->Setup()->getLanguageFallbackId() != $this->getLanguageId()) { $this->objFallbackPage = clone $this; $this->setLanguageId($this->objGenericData->Setup()->getLanguageFallbackId()); $this->loadPage(); } else { if ($this->objFallbackPage instanceof Page) { $this->objGenericData->Setup()->setLanguageFallbackId($this->objFallbackPage->getLanguageId()); } /** * page type based fallbacks */ if (isset($objPage->idPageTypes)) { switch ($objPage->idPageTypes) { case $this->core->sysConfig->page_types->external->id: if (filter_var($this->getFieldValue('external'), FILTER_VALIDATE_URL)) { header('Location: ' . $this->getFieldValue('external')); } else { if (filter_var('http://' . $this->getFieldValue('external'), FILTER_VALIDATE_URL)) { header('Location: http://' . $this->getFieldValue('external')); } else { header('Location: http://' . $_SERVER['HTTP_HOST']); } } exit; case $this->core->sysConfig->page_types->link->id: header('Location: http://' . $_SERVER['HTTP_HOST'] . $this->getField('internal_link')->strLinkedPageUrl); exit; case $this->core->sysConfig->page_types->product_tree->id: case $this->core->sysConfig->page_types->press_area->id: case $this->core->sysConfig->page_types->courses->id: case $this->core->sysConfig->page_types->events->id: if ($blnLoadGlobalTreeStartPage == true) { $this->objParentPage = clone $this; $this->setType('global'); $this->setModelSubPath('global/models/'); $this->setParentId($this->getFieldValue('entry_point')); $this->setNavParentId($this->getFieldValue('entry_point')); $this->setParentTypeId($this->core->sysConfig->parent_types->folder); $this->objModel = null; $this->loadPage(true); } break; } } if ($this->objBaseUrl instanceof Zend_Db_Table_Row_Abstract) { $this->objParentPage = new Page(); $this->objParentPage->setRootLevelId($this->intRootLevelId); $this->objParentPage->setRootLevelTitle($this->strRootLevelTitle); $this->objParentPage->setPageId($this->objBaseUrl->relationId); $this->objParentPage->setPageVersion($this->objBaseUrl->version); $this->objParentPage->setLanguageId($this->objBaseUrl->idLanguages); $this->objParentPage->setType('page'); $this->objParentPage->setModelSubPath('cms/models/'); $this->objParentPage->loadPage(false, false); $this->objParentPage->setChildPage($this); } } } else { throw new Exception('Not able to load page, because no page found in database!'); } } catch (Exception $exc) { $this->core->logger->err($exc); } }
/** * indexGlobal * @param string $strGlobalId * @param integer $intGlobalLinkId * @param integer $intGlobalVersion * @param integer $intLanguageId * @param integer $intRootLevelId * @return void * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ public function indexGlobal($strGlobalId, $intGlobalLinkId, $intGlobalVersion, $intLanguageId, $intRootLevelId) { try { $this->core->logger->debug('massiveart->website->index->indexGlobal(' . $strGlobalId . ', ' . $intGlobalLinkId . ', ' . $intGlobalVersion . ', ' . $intLanguageId . ', ' . $intRootLevelId . ')'); $objPage = new Page(); $objPage->setPageId($strGlobalId); $objPage->setPageVersion($intGlobalVersion); $objPage->setLanguageId($intLanguageId); $objPage->setElementLinkId($intGlobalLinkId); $objPage->setRootLevelId($intRootLevelId); $objPage->setType('global'); $objPage->setModelSubPath('global/models/'); $objPage->loadPage(); $objPage->indexGlobal(); $objPage = null; unset($objPage); } catch (Exception $exc) { $this->core->logger->err($exc); } }
/** * indexAction * @author Cornelius Hansjakob <*****@*****.**> * @version 1.0 */ public function indexAction() { $this->view->addFilter('PageReplacer'); /** * get uri */ $strUrl = $_SERVER['REQUEST_URI']; if (preg_match('/^\\/[a-zA-Z\\-]{2,5}\\//', $strUrl)) { $strUrl = preg_replace('/^\\/[a-zA-Z\\-]{2,5}\\//', '', $strUrl); } else { $strUrl = preg_replace('/^\\//', '', $strUrl); } // load theme $this->loadTheme(); // check portal security $this->checkPortalSecuirty(); // validate language $this->validateLanguage(); // set translate $this->setTranslate(); // init page cache $this->initPageCache($strUrl); /** * check if "q" param is in the url for the search */ if (strpos($strUrl, '?q=') !== false) { $this->blnSearch = true; $strUrl = ''; } // check, if cached page exists if ($this->core->sysConfig->cache->page == 'false' || $this->core->sysConfig->cache->page == 'true' && $this->objCache->test($this->strCacheId) == false || $this->core->sysConfig->cache->page == 'true' && isset($_SESSION['sesTestMode'])) { $this->getModelUrls(); $this->getModelPages(); if (file_exists(GLOBAL_ROOT_PATH . 'client/website/navigation.class.php')) { require_once GLOBAL_ROOT_PATH . 'client/website/navigation.class.php'; $objNavigation = new Client_Navigation(); } else { $objNavigation = new Navigation(); } $objNavigation->setRootLevelId($this->objTheme->idRootLevels); $objNavigation->setLanguageId($this->intLanguageId); if (file_exists(GLOBAL_ROOT_PATH . 'public/website/themes/' . $this->objTheme->path . '/helpers/NavigationHelper.php')) { require_once GLOBAL_ROOT_PATH . 'public/website/themes/' . $this->objTheme->path . '/helpers/NavigationHelper.php'; $strNavigationHelper = ucfirst($this->objTheme->path) . '_NavigationHelper'; $objNavigationHelper = new $strNavigationHelper(); } else { require_once dirname(__FILE__) . '/../helpers/NavigationHelper.php'; $objNavigationHelper = new NavigationHelper(); } $objNavigationHelper->setNavigation($objNavigation); $objNavigationHelper->setTranslate($this->translate); Zend_Registry::set('NavigationHelper', $objNavigationHelper); $objUrl = $this->objModelUrls->loadByUrl($this->objTheme->idRootLevels, parse_url($strUrl, PHP_URL_PATH) === null ? '' : parse_url($strUrl, PHP_URL_PATH)); if (isset($objUrl->url) && count($objUrl->url) > 0) { $objUrlData = $objUrl->url->current(); // check if url is main if (!$objUrlData->isMain) { $objMainUrl = $this->objModelUrls->loadUrl($objUrlData->relationId, $objUrlData->version, $objUrlData->idUrlTypes); if (count($objMainUrl) > 0) { $objMainUrl = $objMainUrl->current(); $this->getResponse()->setHeader('HTTP/1.1', '301 Moved Permanently'); $this->getResponse()->setHeader('Status', '301 Moved Permanently'); $this->getResponse()->setHttpResponseCode(301); $this->_redirect('/' . strtolower($objMainUrl->languageCode) . '/' . $objMainUrl->url); } } if ($this->core->sysConfig->cache->page == 'true' && !isset($_SESSION['sesTestMode']) && $this->blnSearch == false && (!isset($_POST) || count($_POST) == 0)) { $this->objCache->start($this->strCacheId); $this->blnCachingStart = true; } if (file_exists(GLOBAL_ROOT_PATH . 'client/website/page.class.php')) { require_once GLOBAL_ROOT_PATH . 'client/website/page.class.php'; $this->objPage = new Client_Page(); } else { $this->objPage = new Page(); } $this->objPage->setRootLevelId($this->objTheme->idRootLevels); $this->objPage->setRootLevelTitle($this->core->blnIsDefaultLanguage === true ? $this->objTheme->defaultTitle : $this->objTheme->title); $this->objPage->setRootLevelGroupId($this->objTheme->idRootLevelGroups); $this->objPage->setPageId($objUrlData->relationId); $this->objPage->setPageVersion($objUrlData->version); $this->objPage->setLanguageId($objUrlData->idLanguages); switch ($objUrlData->idUrlTypes) { case $this->core->sysConfig->url_types->page: $this->objPage->setType('page'); $this->objPage->setModelSubPath('cms/models/'); break; case $this->core->sysConfig->url_types->global: $this->objPage->setType('global'); $this->objPage->setModelSubPath('global/models/'); $this->objPage->setElementLinkId($objUrlData->idLink); $this->objPage->setNavParentId($objUrlData->idLinkParent); $this->objPage->setPageLinkId($objUrlData->linkId); break; } /** * preset navigation parent properties * e.g. is a collection page */ if ($objUrlData->idParent !== null) { $this->objPage->setNavParentId($objUrlData->idParent); $this->objPage->setNavParentTypeId($objUrlData->idParentTypes); } /** * has base url object * e.g. prduct tree */ if (isset($objUrl->baseUrl)) { $objNavigation->setBaseUrl($objUrl->baseUrl); $this->objPage->setBaseUrl($objUrl->baseUrl); $this->objPage->setNavParentId($objUrlData->idLinkParent); } $this->objPage->loadPage(); /** * check status */ if ($this->objPage->getStatus() != $this->core->sysConfig->status->live && (!isset($_SESSION['sesTestMode']) || isset($_SESSION['sesTestMode']) && $_SESSION['sesTestMode'] == false)) { $this->_redirect('/'); } if ($this->objPage->ParentPage() instanceof Page) { $objNavigation->setPage($this->objPage->ParentPage()); } else { $objNavigation->setPage($this->objPage); } /** * check page security */ if ($objNavigation->secuirtyZoneCheck()) { // deactivate caching $this->blnCachingStart = false; $objAuth = Zend_Auth::getInstance(); if (!Zend_Auth::getInstance()->hasIdentity()) { $this->_redirect('/login?re=' . urlencode($_SERVER['REQUEST_URI'])); } else { if (!$objNavigation->checkZonePrivileges()) { $this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden'); $this->getResponse()->setHeader('Status', '403 Forbidden'); $this->getResponse()->setHttpResponseCode(401); $this->strRenderScript = 'error-403.php'; } } } /** * set values for replacers */ Zend_Registry::set('TemplateCss', $this->objPage->getTemplateId() == $this->core->sysConfig->page_types->page->portal_startpage_templateId ? '' : ''); Zend_Registry::set('TemplateJs', $this->objPage->getTemplateId() == $this->core->sysConfig->page_types->page->headquarters_templateId ? '<script src="http://maps.google.com/maps?file=api&v=2&key=' . $this->view->mapsKey . '" type="text/javascript"></script>' : ''); if (file_exists(GLOBAL_ROOT_PATH . 'public/website/themes/' . $this->objTheme->path . '/helpers/PageHelper.php')) { require_once GLOBAL_ROOT_PATH . 'public/website/themes/' . $this->objTheme->path . '/helpers/PageHelper.php'; $strPageHelper = ucfirst($this->objTheme->path) . '_PageHelper'; $objPageHelper = new $strPageHelper(); } else { require_once dirname(__FILE__) . '/../helpers/PageHelper.php'; $objPageHelper = new PageHelper(); } $objPageHelper->setTheme($this->objTheme->path); $objPageHelper->setPage($this->objPage); $objPageHelper->setTranslate($this->translate); Zend_Registry::set('PageHelper', $objPageHelper); /** * forward to SearchController */ if ($this->blnSearch == true) { $this->_forward('index', 'Search', null, array('rootLevelId' => $this->objPage->getRootLevelId(), 'theme' => $this->objTheme->path)); } else { /** * get page template filename */ $this->view->template = $this->objPage->getTemplateFile(); $this->view->publisher = $this->objPage->getPublisherName(); $this->view->publishdate = $this->objPage->getPublishDate(); $this->view->setScriptPath(GLOBAL_ROOT_PATH . 'public/website/themes/' . $this->objTheme->path . '/'); $this->renderScript($this->strRenderScript); } } else { // try url with/without slash redirect or error output $this->urlRetryRedirectAndError($strUrl); } } else { $this->blnCachingOutput = true; $this->getResponse()->setBody($this->objCache->load($this->strCacheId)); $this->_helper->viewRenderer->setNoRender(); } }