/** * Generates a list of pages pointing to $page * @param \Cx\Core\ContentManager\Model\Entity\Page $page Page to get referencing pages for * @param array $subPages (optional, by reference) Do not use, internal * @return array List of pages (ID as key, page object as value) */ protected function getPagesPointingTo($page, &$subPages = array()) { $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $em = $cx->getDb()->getEntityManager(); $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); $fallback_lang_codes = \FWLanguage::getFallbackLanguageArray(); $active_langs = \FWLanguage::getActiveFrontendLanguages(); // get all active languages and their fallbacks // $fallbacks[<langId>] = <fallsBackToLangId> // if <langId> has no fallback <fallsBackToLangId> will be null $fallbacks = array(); foreach ($active_langs as $lang) { $fallbacks[\FWLanguage::getLanguageCodeById($lang['id'])] = array_key_exists($lang['id'], $fallback_lang_codes) ? \FWLanguage::getLanguageCodeById($fallback_lang_codes[$lang['id']]) : null; } // get all symlinks and fallbacks to it $query = ' SELECT p FROM Cx\\Core\\ContentManager\\Model\\Entity\\Page p WHERE ( p.type = ?1 AND ( p.target LIKE ?2'; if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) { $query .= ' OR p.target LIKE ?3'; } $query .= ' ) ) OR ( p.type = ?4 AND p.node = ' . $page->getNode()->getId() . ' ) '; $q = $em->createQuery($query); $q->setParameter(1, 'symlink'); $q->setParameter('2', '%NODE_' . $page->getNode()->getId() . '%'); if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) { $q->setParameter('3', '%NODE_' . strtoupper($page->getModule()) . '%'); } $q->setParameter(4, 'fallback'); $result = $q->getResult(); if (!$result) { return $subPages; } foreach ($result as $subPage) { if ($subPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_SYMLINK) { $subPages[$subPage->getId()] = $subPage; } else { if ($subPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK) { // check if $subPage is a fallback to $page $targetLang = \FWLanguage::getLanguageCodeById($page->getLang()); $currentLang = \FWLanguage::getLanguageCodeById($subPage->getLang()); while ($currentLang && $currentLang != $targetLang) { $currentLang = $fallbacks[$currentLang]; } if ($currentLang && !isset($subPages[$subPage->getId()])) { $subPages[$subPage->getId()] = $subPage; // recurse! $this->getPagesPointingTo($subPage, $subPages); } } } } return $subPages; }
/** * Copies the content from the other page given. * @param \Cx\Core\ContentManager\Model\Entity\Page $page */ public function getFallbackContentFrom($page) { $this->isVirtual = true; $this->content = $page->getContent(); $this->module = $page->getModule(); $this->cmd = $page->getCmd(); $this->skin = $page->getSkin(); $this->customContent = $page->getCustomContent(); $this->cssName = $page->getCssName(); $this->cssNavName = $page->getCssNavName(); $this->type = $page->getType(); $this->target = $page->getTarget(); }
/** * Copies the content from the other page given. * @param \Cx\Core\ContentManager\Model\Entity\Page $page * @param boolean $includeThemeOptions (optional) Wheter to adopt theme options as well (default false) */ public function setContentOf($page, $includeThemeOptions = false) { $this->isVirtual = true; $this->content = $page->getContent(); $this->module = $page->getModule(); $this->cmd = $page->getCmd(); if ($includeThemeOptions) { $this->skin = $page->getSkin(); $this->customContent = $page->getCustomContent(); $this->applicationTemplate = $page->getApplicationTemplate(); $this->cssName = $page->getCssName(); } $this->cssNavName = $page->getCssNavName(); $this->type = $page->getType(); $this->target = $page->getTarget(); }
/** * Returns the type of the page as string. * * @param \Cx\Core\ContentManager\Model\Entity\Page $page * @return string $type */ public function getTypeByPage($page) { global $_CORELANG; switch ($page->getType()) { case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_REDIRECT: $criteria = array('nodeIdShadowed' => $page->getTargetNodeId(), 'lang' => $page->getLang()); $targetPage = $this->findOneBy($criteria); $targetTitle = $targetPage ? $targetPage->getTitle() : $page->getTarget(); $type = $_CORELANG['TXT_CORE_CM_TYPE_REDIRECT'] . ': '; $type .= $targetTitle; break; case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION: $type = $_CORELANG['TXT_CORE_CM_TYPE_APPLICATION'] . ': '; $type .= $page->getModule(); $type .= $page->getCmd() != '' ? ' | ' . $page->getCmd() : ''; break; case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK: $fallbackLangId = \FWLanguage::getFallbackLanguageIdById($page->getLang()); if ($fallbackLangId == 0) { $fallbackLangId = \FWLanguage::getDefaultLangId(); } $type = $_CORELANG['TXT_CORE_CM_TYPE_FALLBACK'] . ' '; $type .= \FWLanguage::getLanguageCodeById($fallbackLangId); break; default: $type = $_CORELANG['TXT_CORE_CM_TYPE_CONTENT']; } return $type; }
public function getType() { $this->_load(); return parent::getType(); }