コード例 #1
0
 private function performLanguageAction($action, $params)
 {
     global $_CORELANG;
     // Global access check
     if (!\Permission::checkAccess(6, 'static', true) || !\Permission::checkAccess(35, 'static', true)) {
         throw new \Cx\Core\ContentManager\ContentManagerException($_CORELANG['TXT_CORE_CM_USAGE_DENIED']);
     }
     if (!\Permission::checkAccess(53, 'static', true)) {
         throw new \Cx\Core\ContentManager\ContentManagerException($_CORELANG['TXT_CORE_CM_COPY_DENIED']);
     }
     if (!isset($params['get']) || !isset($params['get']['to'])) {
         throw new \Cx\Core\ContentManager\ContentManagerException('Illegal parameter list');
     }
     $em = \Env::get('em');
     $nodeRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node');
     $targetLang = contrexx_input2raw($params['get']['to']);
     $fromLang = \FWLanguage::getFallbackLanguageIdById($targetLang);
     if ($fromLang === false) {
         throw new \Cx\Core\ContentManager\ContentManagerException('Language has no fallback to copy/link from');
     }
     $toLangCode = \FWLanguage::getLanguageCodeById($targetLang);
     if ($toLangCode === false) {
         throw new \Cx\Core\ContentManager\ContentManagerException('Could not get id for language #"' . $targetLang . '"');
     }
     $limit = 0;
     $offset = 0;
     if (isset($params['get']['limit'])) {
         $limit = contrexx_input2raw($params['get']['limit']);
     }
     if (isset($params['get']['offset'])) {
         $offset = contrexx_input2raw($params['get']['offset']);
     }
     $result = $nodeRepo->translateRecursive($nodeRepo->getRoot(), $fromLang, $targetLang, $action == 'copy', $limit, $offset);
     return $result;
 }
コード例 #2
0
ファイル: Page.class.php プロジェクト: nahakiole/cloudrexx
 /**
  * Returns the fallback page of this page
  * @return \Cx\Core\ContentManager\Model\Entity\Page Fallback page or null if none
  */
 public function getFallback()
 {
     if ($this->getType() != self::TYPE_FALLBACK) {
         return null;
     }
     $fallbackLanguage = \FWLanguage::getFallbackLanguageIdById($this->getLang());
     if (!$fallbackLanguage) {
         return null;
     }
     return $this->getNode()->getPage($fallbackLanguage);
 }
コード例 #3
0
ファイル: Node.class.php プロジェクト: Cloudrexx/cloudrexx
 /**
  * Creates a translated page in this node
  *
  * Does not flush EntityManager.
  *
  * @param boolean $activate whether the new page should be activated
  * @param int $targetLang target language id
  * @returns \Cx\Core\ContentManager\Model\Entity\Page the copy
  */
 public function translatePage($activate, $targetLang)
 {
     $type = \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK;
     $fallback_language = \FWLanguage::getFallbackLanguageIdById($targetLang);
     $defaultLang = \FWLanguage::getDefaultLangId();
     // copy the corresponding language version (if there is one)
     if ($fallback_language && $this->getPage($fallback_language)) {
         $pageToTranslate = $this->getPage($fallback_language);
         // find best page to copy if no corresponding language version is present
     } else {
         if ($this->getPage($defaultLang)) {
             $pageToTranslate = $this->getPage($defaultLang);
         } else {
             $pages = $this->getPages();
             $pageToTranslate = $pages[0];
         }
         if (!$fallback_language) {
             $type = \Cx\Core\ContentManager\Model\Entity\Page::TYPE_CONTENT;
         }
     }
     // copy page following redirects
     $page = $pageToTranslate->copyToLang($targetLang, true, true, true, true, true, false, true);
     $page->setActive($activate);
     $page->setType($type);
     $pageToTranslate->setupPath($targetLang);
     return $page;
 }
コード例 #4
0
 /**
  * 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;
 }
コード例 #5
0
ファイル: Init.class.php プロジェクト: hbdsklf/LimeCMS
 /**
  * Load the frontend template
  *
  * @return Cx\Core\View\Model\Entity\Theme Template instance
  * @throws \Exception Throws exception when no template was found
  */
 protected function getFrontendTemplate()
 {
     // fetch and return the configured frontend template
     $theme = $this->themeRepository->findById($this->currentThemesId);
     if ($theme) {
         return $theme;
     }
     // The configured frontend template does not exist
     \DBG::msg('Template width ID ' . $this->currentThemesId . ' does not exist!');
     // We will try to load the frontend template of a fallback-language therefore
     $langId = $this->frontendLangId;
     while ($langId = \FWLanguage::getFallbackLanguageIdById($langId)) {
         // fetch and return default template of fallback language
         $theme = $this->themeRepository->getDefaultTheme($this->currentChannel, $langId);
         if ($theme) {
             // reset local variables based on the loaded fallback frontend template
             $this->channelThemeId = $this->currentThemesId = $theme->getId();
             return $theme;
         }
         // template of fallback language does not exist
         \DBG::msg('Default template of language ' . $langId . ' does not exist!');
     }
     // None of the fallback-languages did have an existing frontend template.
     // Therefore, we will abort the system execution now
     throw new \Exception('Unable to load a webdesign template!');
 }