예제 #1
0
 protected function actRenderCM()
 {
     global $_ARRAYLANG, $_CORELANG, $_CONFIG;
     \JS::activate('jqueryui');
     \JS::activate('cx');
     \JS::activate('ckeditor');
     \JS::activate('cx-form');
     \JS::activate('jstree');
     \JS::registerJS('lib/javascript/lock.js');
     \JS::registerJS('lib/javascript/jquery/jquery.history.max.js');
     // this can be used to debug the tree, just add &tree=verify or &tree=fix
     $tree = null;
     if (isset($_GET['tree'])) {
         $tree = contrexx_input2raw($_GET['tree']);
     }
     if ($tree == 'verify') {
         echo '<pre>';
         print_r($this->nodeRepository->verify());
         echo '</pre>';
     } else {
         if ($tree == 'fix') {
             // this should print "bool(true)"
             var_dump($this->nodeRepository->recover());
         }
     }
     $objCx = \ContrexxJavascript::getInstance();
     $themeRepo = new \Cx\Core\View\Model\Repository\ThemeRepository();
     $defaultTheme = $themeRepo->getDefaultTheme();
     $objCx->setVariable('themeId', $defaultTheme->getId(), 'contentmanager/theme');
     foreach ($themeRepo->findAll() as $theme) {
         if ($theme == $defaultTheme) {
             $objCx->setVariable('themeName', $theme->getFoldername(), 'contentmanager/theme');
         }
     }
     $this->template->addBlockfile('ADMIN_CONTENT', 'content_manager', 'Skeleton.html');
     // user has no permission to create new page, hide navigation item in admin navigation
     if (!\Permission::checkAccess(127, 'static', true)) {
         $this->template->hideBlock('content_manager_create_new_page_navigation_item');
     }
     $this->template->touchBlock('content_manager');
     $this->template->addBlockfile('CONTENT_MANAGER_MEAT', 'content_manager_meat', 'Page.html');
     $this->template->touchBlock('content_manager_meat');
     if (\Permission::checkAccess(78, 'static', true)) {
         \JS::registerCode("var publishAllowed = true;");
     } else {
         \JS::registerCode("var publishAllowed = false;");
     }
     if (\Permission::checkAccess(78, 'static', true) && \Permission::checkAccess(115, 'static', true)) {
         \JS::registerCode("var aliasManagementAllowed = true;");
         $alias_permission = "block";
         $alias_denial = "none !important";
     } else {
         \JS::registerCode("var aliasManagementAllowed = false;");
         $alias_permission = "none !important";
         $alias_denial = "block";
     }
     $mediaBrowser = new MediaBrowser();
     $mediaBrowser->setCallback('target_page_callback');
     $mediaBrowser->setOptions(array('type' => 'button', 'data-cx-mb-views' => 'sitestructure', 'id' => 'page_target_browse'));
     $mediaBrowserCkeditor = new MediaBrowser();
     $mediaBrowserCkeditor->setCallback('ckeditor_image_callback');
     $mediaBrowserCkeditor->setOptions(array('id' => 'ckeditor_image_button', 'type' => 'button', 'style' => 'display:none'));
     $this->template->setVariable(array('MEDIABROWSER_BUTTON' => $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE']), 'MEDIABROWSER_BUTTON_CKEDITOR' => $mediaBrowserCkeditor->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE'])));
     $this->template->setVariable(array('ALIAS_PERMISSION' => $alias_permission, 'ALIAS_DENIAL' => $alias_denial, 'CONTREXX_BASE_URL' => ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . '/', 'CONTREXX_LANG' => \FWLanguage::getLanguageCodeById(BACKEND_LANG_ID)));
     global $_CORELANG;
     $this->template->setVariable($_CORELANG);
     $objCx->setVariable('TXT_CORE_CM_VIEW', $_CORELANG['TXT_CORE_CM_VIEW'], 'contentmanager/lang');
     $objCx->setVariable('TXT_CORE_CM_ACTIONS', $_CORELANG['TXT_CORE_CM_ACTIONS'], 'contentmanager/lang');
     $objCx->setVariable('TXT_CORE_CM_VALIDATION_FAIL', $_CORELANG['TXT_CORE_CM_VALIDATION_FAIL'], 'contentmanager/lang');
     $objCx->setVariable('TXT_CORE_CM_HOME_FAIL', $_CORELANG['TXT_CORE_CM_HOME_FAIL'], 'contentmanager/lang');
     $arrLangVars = array('actions' => array('new' => 'TXT_CORE_CM_ACTION_NEW', 'copy' => 'TXT_CORE_CM_ACTION_COPY', 'activate' => 'TXT_CORE_CM_ACTION_PUBLISH', 'deactivate' => 'TXT_CORE_CM_ACTION_UNPUBLISH', 'publish' => 'TXT_CORE_CM_ACTION_PUBLISH_DRAFT', 'show' => 'TXT_CORE_CM_ACTION_SHOW', 'hide' => 'TXT_CORE_CM_ACTION_HIDE', 'delete' => 'TXT_CORE_CM_ACTION_DELETE', 'recursiveQuestion' => 'TXT_CORE_CM_RECURSIVE_QUESTION'), 'tooltip' => array('TXT_CORE_CM_LAST_MODIFIED' => 'TXT_CORE_CM_LAST_MODIFIED', 'TXT_CORE_CM_PUBLISHING_INFO_STATUSES' => 'TXT_CORE_CM_PUBLISHING_INFO_STATUSES', 'TXT_CORE_CM_PUBLISHING_INFO_ACTION_ACTIVATE' => 'TXT_CORE_CM_PUBLISHING_INFO_ACTION_ACTIVATE', 'TXT_CORE_CM_PUBLISHING_INFO_ACTION_DEACTIVATE' => 'TXT_CORE_CM_PUBLISHING_INFO_ACTION_DEACTIVATE', 'TXT_CORE_CM_PUBLISHING_DRAFT' => 'TXT_CORE_CM_PUBLISHING_DRAFT', 'TXT_CORE_CM_PUBLISHING_DRAFT_WAITING' => 'TXT_CORE_CM_PUBLISHING_DRAFT_WAITING', 'TXT_CORE_CM_PUBLISHING_LOCKED' => 'TXT_CORE_CM_PUBLISHING_LOCKED', 'TXT_CORE_CM_PUBLISHING_PUBLISHED' => 'TXT_CORE_CM_PUBLISHING_PUBLISHED', 'TXT_CORE_CM_PUBLISHING_UNPUBLISHED' => 'TXT_CORE_CM_PUBLISHING_UNPUBLISHED', 'TXT_CORE_CM_PAGE_INFO_STATUSES' => 'TXT_CORE_CM_PAGE_INFO_STATUSES', 'TXT_CORE_CM_PUBLISHING_INFO_TYPES' => 'TXT_CORE_CM_PUBLISHING_INFO_TYPES', 'TXT_CORE_CM_PAGE_INFO_ACTION_SHOW' => 'TXT_CORE_CM_PAGE_INFO_ACTION_SHOW', 'TXT_CORE_CM_PAGE_INFO_ACTION_HIDE' => 'TXT_CORE_CM_PAGE_INFO_ACTION_HIDE', 'TXT_CORE_CM_PAGE_STATUS_BROKEN' => 'TXT_CORE_CM_PAGE_STATUS_BROKEN', 'TXT_CORE_CM_PAGE_STATUS_VISIBLE' => 'TXT_CORE_CM_PAGE_STATUS_VISIBLE', 'TXT_CORE_CM_PAGE_STATUS_INVISIBLE' => 'TXT_CORE_CM_PAGE_STATUS_INVISIBLE', 'TXT_CORE_CM_PAGE_STATUS_PROTECTED' => 'TXT_CORE_CM_PAGE_STATUS_PROTECTED', 'TXT_CORE_CM_PAGE_TYPE_HOME' => 'TXT_CORE_CM_PAGE_TYPE_HOME', 'TXT_CORE_CM_PAGE_TYPE_CONTENT_SITE' => 'TXT_CORE_CM_PAGE_TYPE_CONTENT_SITE', 'TXT_CORE_CM_PAGE_TYPE_APPLICATION' => 'TXT_CORE_CM_PAGE_TYPE_APPLICATION', 'TXT_CORE_CM_PAGE_TYPE_REDIRECTION' => 'TXT_CORE_CM_PAGE_TYPE_REDIRECTION', 'TXT_CORE_CM_PAGE_TYPE_SYMLINK' => 'TXT_CORE_CM_PAGE_TYPE_SYMLINK', 'TXT_CORE_CM_PAGE_TYPE_FALLBACK' => 'TXT_CORE_CM_PAGE_TYPE_FALLBACK', 'TXT_CORE_CM_PAGE_MOVE_INFO' => 'TXT_CORE_CM_PAGE_MOVE_INFO', 'TXT_CORE_CM_TRANSLATION_INFO' => 'TXT_CORE_CM_TRANSLATION_INFO', 'TXT_CORE_CM_PREVIEW_INFO' => 'TXT_CORE_CM_PREVIEW_INFO'));
     foreach ($arrLangVars as $subscope => $arrLang) {
         foreach ($arrLang as $name => $value) {
             $objCx->setVariable($name, $_CORELANG[$value], 'contentmanager/lang/' . $subscope);
         }
     }
     // Mediabrowser
     $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser();
     $mediaBrowser->setOptions(array('type' => 'button'));
     $mediaBrowser->setCallback('setWebPageUrlCallback');
     $mediaBrowser->setOptions(array('data-cx-mb-startview' => 'sitestructure', 'id' => 'page_target_browse'));
     $this->template->setVariable(array('CM_MEDIABROWSER_BUTTON' => $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE'])));
     $toggleTitles = !empty($_SESSION['contentManager']['toggleStatuses']['toggleTitles']) ? $_SESSION['contentManager']['toggleStatuses']['toggleTitles'] : 'block';
     $toggleType = !empty($_SESSION['contentManager']['toggleStatuses']['toggleType']) ? $_SESSION['contentManager']['toggleStatuses']['toggleType'] : 'block';
     $toggleNavigation = !empty($_SESSION['contentManager']['toggleStatuses']['toggleNavigation']) ? $_SESSION['contentManager']['toggleStatuses']['toggleNavigation'] : 'block';
     $toggleBlocks = !empty($_SESSION['contentManager']['toggleStatuses']['toggleBlocks']) ? $_SESSION['contentManager']['toggleStatuses']['toggleBlocks'] : 'block';
     $toggleThemes = !empty($_SESSION['contentManager']['toggleStatuses']['toggleThemes']) ? $_SESSION['contentManager']['toggleStatuses']['toggleThemes'] : 'block';
     $toggleApplication = !empty($_SESSION['contentManager']['toggleStatuses']['toggleApplication']) ? $_SESSION['contentManager']['toggleStatuses']['toggleApplication'] : 'block';
     $toggleSidebar = !empty($_SESSION['contentManager']['toggleStatuses']['sidebar']) ? $_SESSION['contentManager']['toggleStatuses']['sidebar'] : 'block';
     $objCx->setVariable('toggleTitles', $toggleTitles, 'contentmanager/toggle');
     $objCx->setVariable('toggleType', $toggleType, 'contentmanager/toggle');
     $objCx->setVariable('toggleNavigation', $toggleNavigation, 'contentmanager/toggle');
     $objCx->setVariable('toggleBlocks', $toggleBlocks, 'contentmanager/toggle');
     $objCx->setVariable('toggleThemes', $toggleThemes, 'contentmanager/toggle');
     $objCx->setVariable('toggleApplication', $toggleApplication, 'contentmanager/toggle');
     $objCx->setVariable('sidebar', $toggleSidebar, 'contentmanager/toggle');
     // get initial tree data
     $objJsonData = new \Cx\Core\Json\JsonData();
     $treeData = $objJsonData->jsondata('node', 'getTree', array('get' => $_GET), false);
     $objCx->setVariable('tree-data', $treeData, 'contentmanager/tree');
     if (!empty($_GET['act']) && $_GET['act'] == 'new') {
         $this->template->setVariable(array('TITLES_DISPLAY_STYLE' => 'display: block;', 'TITLES_TOGGLE_CLASS' => 'open', 'TYPE_DISPLAY_STYLE' => 'display: block;', 'TYPE_TOGGLE_CLASS' => 'open', 'NAVIGATION_DISPLAY_STYLE' => 'display: block;', 'NAVIGATION_TOGGLE_CLASS' => 'open', 'BLOCKS_DISPLAY_STYLE' => 'display: block;', 'BLOCKS_TOGGLE_CLASS' => 'open', 'THEMES_DISPLAY_STYLE' => 'display: block;', 'THEMES_TOGGLE_CLASS' => 'open', 'APPLICATION_DISPLAY_STYLE' => 'display: block;', 'APPLICATION_TOGGLE_CLASS' => 'open', 'MULTIPLE_ACTIONS_STRIKE_STYLE' => 'display: none;'));
     } else {
         $this->template->setVariable(array('TITLES_DISPLAY_STYLE' => $toggleTitles == 'none' ? 'display: none;' : 'display: block;', 'TITLES_TOGGLE_CLASS' => $toggleTitles == 'none' ? 'closed' : 'open', 'TYPE_DISPLAY_STYLE' => $toggleType == 'none' ? 'display: none;' : 'display: block;', 'TYPE_TOGGLE_CLASS' => $toggleType == 'none' ? 'closed' : 'open', 'NAVIGATION_DISPLAY_STYLE' => $toggleNavigation == 'none' ? 'display: none;' : 'display: block;', 'NAVIGATION_TOGGLE_CLASS' => $toggleNavigation == 'none' ? 'closed' : 'open', 'BLOCKS_DISPLAY_STYLE' => $toggleBlocks == 'none' ? 'display: none;' : 'display: block;', 'BLOCKS_TOGGLE_CLASS' => $toggleBlocks == 'none' ? 'closed' : 'open', 'THEMES_DISPLAY_STYLE' => $toggleThemes == 'none' ? 'display: none;' : 'display: block;', 'THEMES_TOGGLE_CLASS' => $toggleThemes == 'none' ? 'closed' : 'open', 'APPLICATION_DISPLAY_STYLE' => $toggleApplication == 'none' ? 'display: none;' : 'display: block;', 'APPLICATION_TOGGLE_CLASS' => $toggleApplication == 'none' ? 'closed' : 'open'));
     }
     $modules = $this->db->Execute("SELECT * FROM " . DBPREFIX . "modules WHERE `status` = 'y' ORDER BY `name`");
     while (!$modules->EOF) {
         $this->template->setVariable('MODULE_KEY', $modules->fields['name']);
         //            $this->template->setVariable('MODULE_TITLE', $_CORELANG[$modules->fields['description_variable']]);
         $this->template->setVariable('MODULE_TITLE', ucwords($modules->fields['name']));
         $this->template->parse('module_option');
         $modules->MoveNext();
     }
     $newPageFirstLevel = isset($_GET['act']) && $_GET['act'] == 'new';
     if (\Permission::checkAccess(36, 'static', true)) {
         $this->template->touchBlock('page_permissions_tab');
         $this->template->touchBlock('page_permissions');
     } else {
         $this->template->hideBlock('page_permissions_tab');
         $this->template->hideBlock('page_permissions');
     }
     //show the caching options only if the caching system is actually active
     if ($_CONFIG['cacheEnabled'] == 'on') {
         $this->template->touchBlock('show_caching_option');
     } else {
         $this->template->hideBlock('show_caching_option');
     }
     if (\Permission::checkAccess(78, 'static', true)) {
         $this->template->hideBlock('release_button');
     } else {
         $this->template->hideBlock('publish_button');
         $this->template->hideBlock('refuse_button');
     }
     // show no access page if the user wants to create new page in first level but he does not have enough permissions
     if ($newPageFirstLevel) {
         \Permission::checkAccess(127, 'static');
     }
     $editViewCssClass = '';
     if ($newPageFirstLevel) {
         $editViewCssClass = 'edit_view';
         $this->template->hideBlock('refuse_button');
     }
     $cxjs = \ContrexxJavascript::getInstance();
     $cxjs->setVariable('confirmDeleteQuestion', $_ARRAYLANG['TXT_CORE_CM_CONFIRM_DELETE'], 'contentmanager/lang');
     $cxjs->setVariable('cleanAccessData', $objJsonData->jsondata('page', 'getAccessData', array(), false), 'contentmanager');
     $cxjs->setVariable('contentTemplates', $this->getCustomContentTemplates(), 'contentmanager');
     $cxjs->setVariable('defaultTemplates', $this->getDefaultTemplates(), 'contentmanager/themes');
     $cxjs->setVariable('templateFolders', $this->getTemplateFolders(), 'contentmanager/themes');
     $cxjs->setVariable('availableBlocks', $objJsonData->jsondata('Block', 'getBlocks', array(), false), 'contentmanager');
     // TODO: move including of add'l JS dependencies to cx obj from /cadmin/index.html
     $getLangOptions = $this->getLangOptions();
     $statusPageLayout = '';
     $languageDisplay = '';
     if ((!empty($_GET['act']) && $_GET['act'] == 'new' || !empty($_GET['page'])) && $getLangOptions == "") {
         $statusPageLayout = 'margin0';
         $languageDisplay = 'display:none';
     }
     $this->template->setVariable('ADMIN_LIST_MARGIN', $statusPageLayout);
     $this->template->setVariable('LANGUAGE_DISPLAY', $languageDisplay);
     // TODO: move including of add'l JS dependencies to cx obj from /cadmin/index.html
     $this->template->setVariable('SKIN_OPTIONS', $this->getSkinOptions());
     $this->template->setVariable('LANGSWITCH_OPTIONS', $this->getLangOptions());
     $this->template->setVariable('LANGUAGE_ARRAY', json_encode($this->getLangArray()));
     $this->template->setVariable('FALLBACK_ARRAY', json_encode($this->getFallbackArray()));
     $this->template->setVariable('LANGUAGE_LABELS', json_encode($this->getLangLabels()));
     $this->template->setVariable('EDIT_VIEW_CSS_CLASS', $editViewCssClass);
     $this->template->touchBlock('content_manager_language_selection');
     $editmodeTemplate = new \Cx\Core\Html\Sigma(ASCMS_CORE_PATH . '/ContentManager/View/Template/Backend');
     $editmodeTemplate->loadTemplateFile('content_editmode.html');
     $editmodeTemplate->setVariable(array('TXT_EDITMODE_TEXT' => $_CORELANG['TXT_FRONTEND_EDITING_SELECTION_TEXT'], 'TXT_EDITMODE_CODE' => $_CORELANG['TXT_FRONTEND_EDITING_SELECTION_MODE_PAGE'], 'TXT_EDITMODE_CONTENT' => $_CORELANG['TXT_FRONTEND_EDITING_SELECTION_MODE_CONTENT']));
     $cxjs->setVariable(array('editmodetitle' => $_CORELANG['TXT_FRONTEND_EDITING_SELECTION_TITLE'], 'editmodecontent' => $editmodeTemplate->get(), 'ckeditorconfigpath' => substr(\Env::get('ClassLoader')->getFilePath(ASCMS_CORE_PATH . '/Wysiwyg/ckeditor.config.js.php'), strlen(ASCMS_DOCUMENT_ROOT) + 1), 'regExpUriProtocol' => \FWValidator::REGEX_URI_PROTO, 'contrexxBaseUrl' => ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . '/', 'contrexxPathOffset' => ASCMS_PATH_OFFSET), 'contentmanager');
 }
예제 #2
0
 /**
  * Delete selected theme and its theme folder 
  * 
  * @global type $_ARRAYLANG
  * @return array status
  */
 function deleteThemeById()
 {
     global $_ARRAYLANG;
     $_ARRAYLANG = \Env::get('init')->loadLanguageData('ViewManager');
     $delThemeId = isset($_GET['delThemeId']) ? $_GET['delThemeId'] : 0;
     $themeRepository = new \Cx\Core\View\Model\Repository\ThemeRepository();
     if (!empty($delThemeId)) {
         $theme = $themeRepository->findById($delThemeId);
         if (!$theme) {
             return array('status' => 'error', 'message' => $_ARRAYLANG['TXT_STATUS_CANNOT_DELETE']);
         }
         $themeFolderPath = \Env::get('cx')->getWebsiteThemesPath() . '/' . $theme->getFoldername();
         //Check whether the selected theme is selected for any of the active languages
         $activeLanguages = $theme->getLanguages();
         if (!empty($activeLanguages) && file_exists($themeFolderPath)) {
             return array('status' => 'error', 'message' => $_ARRAYLANG['TXT_STATUS_CANNOT_DELETE']);
         }
         // delete whole folder with subfolders in case it exists
         if (file_exists($themeFolderPath) && !\Cx\Lib\FileSystem\FileSystem::delete_folder($themeFolderPath, true)) {
             //error
             return array('status' => 'error', 'message' => $_ARRAYLANG['TXT_STATUS_CANNOT_DELETE']);
         }
         //setting 0 for the custom theme for any of the content pages of the active frontend languages
         $pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
         $pages = $pageRepo->findBy(array('skin' => intval($theme->getId())));
         foreach ($pages as $page) {
             $page->setSkin(0);
             \Env::get('em')->persist($page);
         }
         \Env::get('em')->flush();
         //Remove theme details from the database.
         if ($themeRepository->remove($theme)) {
             return array('status' => 'success', 'message' => contrexx_raw2xhtml($theme->getThemesname()) . ": " . $_ARRAYLANG['TXT_STATUS_SUCCESSFULLY_DELETE']);
         }
     }
 }
 /**
  * find all custom css variables and return an array with the values
  * 
  * @param integer $skinId skin id, default is 0
  * @return array List with needed wysiwyg options
  */
 public function getCustomCSSVariables($skinId)
 {
     $themeRepo = new \Cx\Core\View\Model\Repository\ThemeRepository();
     $skin = '';
     $content = '';
     $cssArr = array();
     $ymlOption = array();
     $componentData = array();
     \Cx\Core\Setting\Controller\Setting::init('Wysiwyg', 'config', 'Yaml');
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('specificStylesheet') && !\Cx\Core\Setting\Controller\Setting::add('specificStylesheet', '0', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX, '1', 'config')) {
         throw new \Exception("Failed to add new configuration option");
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('replaceActualContents') && !\Cx\Core\Setting\Controller\Setting::add('replaceActualContents', '0', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX, '1', 'config')) {
         throw new \Exception("Failed to add new configuration option");
     }
     //0 is default theme so you dont must change the themefolder
     if (!empty($skinId)) {
         $skin = $themeRepo->findById($skinId)->getFoldername();
         $componentData = $themeRepo->findById($skinId)->getComponentData();
     } else {
         $skin = $themeRepo->getDefaultTheme()->getFoldername();
         $componentData = $themeRepo->getDefaultTheme()->getComponentData();
     }
     if (\Cx\Core\Setting\Controller\Setting::getValue('specificStylesheet', 'Wysiwyg')) {
         $path = $this->cx->getClassLoader()->getFilePath($this->cx->getCodeBaseThemesPath() . '/' . $skin . '/index.html');
         if ($path) {
             $content = file_get_contents($path);
             $cssArr = \JS::findCSS($content);
         }
     }
     if (!empty($componentData['rendering']['wysiwyg'])) {
         $ymlOption = $componentData['rendering']['wysiwyg'];
     }
     if (!empty($ymlOption['css'])) {
         if ($this->cx->getClassLoader()->getFilePath($this->cx->getCodeBaseThemesPath() . '/' . $skin . '/' . $ymlOption['css'])) {
             $cssArr[] = $this->cx->getWebsiteOffsetPath() . '/' . $skin . '/' . $ymlOption['css'];
         }
     }
     return array('css' => $cssArr, 'bodyClass' => !empty($ymlOption['bodyClass']) ? $ymlOption['bodyClass'] : '', 'bodyId' => !empty($ymlOption['bodyId']) ? $ymlOption['bodyId'] : '');
 }
예제 #4
0
 private function loadCustomContent($page)
 {
     global $objDatabase;
     // OPTION USE FOR OUTPUT CHANNEL
     $themeFolder = '';
     $themeRepository = new \Cx\Core\View\Model\Repository\ThemeRepository();
     if ($page->getUseCustomContentForAllChannels()) {
         $theme = $themeRepository->findById($page->getSkin());
         if (!$theme) {
             $theme = $themeRepository->getDefaultTheme($page->getLang());
         }
         $themeFolder = $theme->getFoldername();
     } elseif (!empty($this->customContentTemplate)) {
         $themeFolder = $themeRepository->findById($this->channelThemeId)->getFoldername();
     }
     if ($themeFolder) {
         $content = $this->getThemeFileContent($themeFolder, $page->getCustomContent());
         if ($content) {
             $this->templates['content'] = $content;
             return true;
         }
     }
     //only include the custom template if it really exists.
     //if the user selected custom_x.html as a page's custom template, a print-view request will
     //try to get the file "themes/<printtheme>/custom_x.html" - we do not know if this file
     //exists. trying to read a non-existant file would lead to an empty content-template.
     //to omit this, we read the standard print content template instead.
     //another possible behaviour would be to read the standard theme's custom content template instead.
     //this is not done, because customcontent files are mostly used for sidebars etc. -
     //stuff that should not change the print representation of the content.
     $content = $this->getThemeFileContent($this->themesPath, $this->customContentTemplate);
     if ($content) {
         $this->templates['content'] = $content;
         return true;
     }
     return false;
 }
예제 #5
0
 /**
  * Fetch the application template of a content page.
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page The page object of which to fetch the application template from
  * @param String $component Optional argument to specify the component to load the template from, instead of using the page's module-attribute
  * @param String $themeType Optional argument to specify the output channel
  * @return String The content of the application template
  */
 public static function getContentTemplateOfPage($page, $component = null, $themeType = \Cx\Core\View\Model\Entity\Theme::THEME_TYPE_WEB)
 {
     try {
         $component = empty($component) ? $page->getModule() : $component;
         $cmd = !$page->getCmd() ? 'Default' : ucfirst($page->getCmd());
         $customAppTemplate = !$page->getApplicationTemplate() ? $cmd . '.html' : $page->getApplicationTemplate();
         $moduleFolderName = contrexx_isCoreModule($page->getModule()) ? 'core_modules' : 'modules';
         $themeFolderName = \Env::get('init')->getCurrentThemesPath();
         // use application template for all output channels
         if ($page->getUseCustomApplicationTemplateForAllChannels() && $page->getSkin()) {
             $themeRepo = new \Cx\Core\View\Model\Repository\ThemeRepository();
             $themeFolderName = $themeRepo->findById($page->getSkin())->getFoldername();
         }
         // use default theme in case a custom set theme is no longer available
         if (empty($themeFolderName)) {
             $themeRepo = new \Cx\Core\View\Model\Repository\ThemeRepository();
             $themeFolderName = $themeRepo->getDefaultTheme($themeType, $page->getLang())->getFoldername();
         }
         $cx = \Cx\Core\Core\Controller\Cx::instanciate();
         // load custom application template from page's theme
         $themePath = $cx->getClassLoader()->getFilePath($cx->getWebsiteThemesPath() . '/' . $themeFolderName . '/' . $moduleFolderName . '/' . $component . '/Template/Frontend/' . $customAppTemplate);
         if ($themePath) {
             return file_get_contents($themePath);
         }
         // load default application template from page's theme
         if ($customAppTemplate != $cmd . '.html') {
             $themePath = $cx->getClassLoader()->getFilePath($cx->getWebsiteThemesPath() . '/' . $themeFolderName . '/' . $moduleFolderName . '/' . $component . '/Template/Frontend/' . $cmd . '.html');
             if ($themePath) {
                 return file_get_contents($themePath);
             }
         }
         // load default application template from component
         $modulePath = $cx->getClassLoader()->getFilePath($cx->getCodeBaseDocumentRootPath() . '/' . $moduleFolderName . '/' . $component . '/View/Template/Frontend/' . $cmd . '.html');
         if ($modulePath) {
             return file_get_contents($modulePath);
         }
         return;
     } catch (\Exception $e) {
         throw new \Exception('Error fetching the content template:' . $e);
     }
 }
예제 #6
0
function contentManagerUpdates()
{
    //Database migration
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "modules` (`id`, `name`, `distributor`, `description_variable`, `status`, `is_required`, `is_core`, `is_active`, `is_licensed`) VALUES ('72', 'ContentManager', 'DEV', 'TXT_CONTENTMANAGER_MODULE_DESCRIPTION', 'n', '0', '1', '1', '1')");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=ContentManager&act=new' WHERE `area_id` = 5");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=ContentManager' WHERE `area_id` = 6");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=ContentManager' WHERE `area_id` = 161");
        //Alter the content_page table structure
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'content_page', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'node_id' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'id'), 'nodeIdShadowed' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'node_id'), 'lang' => array('type' => 'INT(11)', 'after' => 'nodeIdShadowed'), 'type' => array('type' => 'VARCHAR(16)', 'after' => 'lang'), 'caching' => array('type' => 'TINYINT(1)', 'after' => 'type'), 'updatedAt' => array('type' => 'timestamp', 'after' => 'caching'), 'updatedBy' => array('type' => 'CHAR(40)', 'after' => 'updatedAt'), 'title' => array('type' => 'VARCHAR(255)', 'after' => 'updatedBy'), 'linkTarget' => array('type' => 'VARCHAR(16)', 'notnull' => false, 'after' => 'title'), 'contentTitle' => array('type' => 'VARCHAR(255)', 'after' => 'linkTarget'), 'slug' => array('type' => 'VARCHAR(255)', 'after' => 'contentTitle'), 'content' => array('type' => 'longtext', 'after' => 'slug'), 'sourceMode' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'content'), 'customContent' => array('type' => 'VARCHAR(64)', 'notnull' => false, 'after' => 'sourceMode'), 'useCustomContentForAllChannels' => array('type' => 'INT(2)', 'notnull' => false, 'after' => 'customContent'), 'applicationTemplate' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'after' => 'useCustomContentForAllChannels'), 'useCustomApplicationTemplateForAllChannels' => array('type' => 'TINYINT(2)', 'after' => 'applicationTemplate'), 'cssName' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'useCustomApplicationTemplateForAllChannels'), 'cssNavName' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'cssName'), 'skin' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'cssNavName'), 'useSkinForAllChannels' => array('type' => 'INT(2)', 'notnull' => false, 'after' => 'skin'), 'metatitle' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'useSkinForAllChannels'), 'metadesc' => array('type' => 'text', 'after' => 'metatitle'), 'metakeys' => array('type' => 'text', 'after' => 'metadesc'), 'metarobots' => array('type' => 'VARCHAR(7)', 'notnull' => false, 'after' => 'metakeys'), 'start' => array('type' => 'timestamp', 'after' => 'metarobots'), 'end' => array('type' => 'timestamp', 'after' => 'start'), 'editingStatus' => array('type' => 'VARCHAR(16)', 'after' => 'end'), 'protection' => array('type' => 'INT(11)', 'after' => 'editingStatus'), 'frontendAccessId' => array('type' => 'INT(11)', 'after' => 'protection'), 'backendAccessId' => array('type' => 'INT(11)', 'after' => 'frontendAccessId'), 'display' => array('type' => 'TINYINT(1)', 'after' => 'backendAccessId'), 'active' => array('type' => 'TINYINT(1)', 'after' => 'display'), 'target' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'active'), 'module' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'target'), 'cmd' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '', 'after' => 'module')), array('node_id' => array('fields' => array('node_id', 'lang'), 'type' => 'UNIQUE'), 'IDX_D8E86F54460D9FD7' => array('fields' => array('node_id'))), 'InnoDB', '', array('node_id' => array('table' => DBPREFIX . 'content_node', 'column' => 'id', 'onDelete' => 'SET NULL', 'onUpdate' => 'NO ACTION')));
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    $virtualComponents = array('Agb', 'Ids', 'Imprint', 'Privacy');
    //migrating custom application template
    $pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
    $themeRepo = new \Cx\Core\View\Model\Repository\ThemeRepository();
    $pages = $pageRepo->findBy(array('type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION));
    foreach ($pages as $page) {
        try {
            //virtual components do not migrating custom application template
            if (in_array(ucfirst($page->getModule()), $virtualComponents)) {
                continue;
            }
            $designTemplateName = $page->getSkin() ? $themeRepo->findById($page->getSkin())->getFoldername() : $themeRepo->getDefaultTheme()->getFoldername();
            $cmd = !$page->getCmd() ? 'Default' : ucfirst($page->getCmd());
            $moduleFolderName = contrexx_isCoreModule($page->getModule()) ? 'core_modules' : 'modules';
            $themesPath = ASCMS_THEMES_PATH . '/' . $designTemplateName;
            //check common module or core_module folder exists
            if (!file_exists($themesPath . '/' . $moduleFolderName)) {
                \Cx\Lib\FileSystem\FileSystem::make_folder($themesPath . '/' . $moduleFolderName);
            }
            //check module's folder exists
            if (!file_exists($themesPath . '/' . $moduleFolderName . '/' . $page->getModule())) {
                \Cx\Lib\FileSystem\FileSystem::make_folder($themesPath . '/' . $moduleFolderName . '/' . $page->getModule());
            }
            //check module's template folder exists
            if (!file_exists($themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template')) {
                \Cx\Lib\FileSystem\FileSystem::make_folder($themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template');
            }
            //check module's Frontend folder exists
            if (!file_exists($themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template/Frontend')) {
                \Cx\Lib\FileSystem\FileSystem::make_folder($themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template/Frontend');
            }
            $targetPath = $themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template/Frontend';
            $applicationTemplateName = getFilename($targetPath, $cmd . '_custom_' . FWLanguage::getLanguageCodeById($page->getLang()));
            if (file_exists($targetPath)) {
                //create a application template file
                $file = new \Cx\Lib\FileSystem\File($targetPath . '/' . $applicationTemplateName);
                $file->write($page->getContent());
            }
            //update application template
            $page->setContent('{APPLICATION_DATA}');
            $page->setApplicationTemplate($applicationTemplateName);
            $page->setUseCustomApplicationTemplateForAllChannels(1);
            \Env::get('em')->persist($page);
            \Env::get('em')->flush();
        } catch (\Exception $e) {
            throw new \Exception('Error :' . $e);
        }
    }
    return 'Application template migrated successfully.';
}
예제 #7
0
 /**
  * load the application template based on the application, cmd and theme name
  * 
  * @return array
  */
 public function loadApplicationTemplate()
 {
     $application = isset($_GET['app']) ? contrexx_input2raw($_GET['app']) : '';
     $section = preg_match('#^Media\\d+# i', $application) ? 'Media' : $application;
     $cmd = isset($_GET['area']) && $_GET['area'] != '' ? contrexx_input2raw($_GET['area']) : 'default';
     $template = isset($_GET['template']) ? contrexx_input2raw($_GET['template']) : '';
     $result = array('files' => array(), 'area' => '', 'path' => '');
     $themeRepo = new \Cx\Core\View\Model\Repository\ThemeRepository();
     if (!empty($section)) {
         if ($template > 0) {
             $theme = $themeRepo->findOneBy(array('id' => $template));
         } else {
             $theme = $themeRepo->getDefaultTheme();
         }
         $themeFolderName = $theme->getFoldername();
         $moduleFolderName = contrexx_isCoreModule($application) ? 'core_modules' : 'modules';
         $themePath = ASCMS_THEMES_PATH . '/' . $themeFolderName . '/' . $moduleFolderName . '/' . $section . '/Template/Frontend';
         if (file_exists($themePath)) {
             $templateFiles = $this->readDirs($themePath);
             foreach ($templateFiles as $templateFile) {
                 if (preg_match('#^' . ucfirst($cmd) . '_custom_# i', $templateFile) && preg_match('#\\.html# i', $templateFile)) {
                     $result['files'][] = $templateFile;
                 }
             }
         }
         $result['area'] = ucfirst($cmd);
         $result['path'] = '/themes/' . $themeFolderName . '/' . $moduleFolderName . '/' . $section . '/Template/Frontend';
         $additionalArguments = new \Cx\Core\Model\RecursiveArrayAccess(array());
         $cx = \Cx\Core\Core\Controller\Cx::instanciate();
         $evm = $cx->getEvents();
         $evm->triggerEvent('wysiwygCssReload', array(array('skin' => $template), $additionalArguments));
         $result['wysiwygCssReload'] = $additionalArguments->toArray();
     }
     return $result;
 }
예제 #8
0
function _convertThemes2Component()
{
    global $objDatabase, $_CORELANG;
    // Find all themes
    $result = $objDatabase->Execute('SELECT `themesname`, `foldername` FROM `' . DBPREFIX . 'skins`');
    if ($result->EOF) {
        \DBG::msg('No themes found!');
        return false;
    }
    $errorMessages = '';
    $themeRepository = new \Cx\Core\View\Model\Repository\ThemeRepository();
    while (!$result->EOF) {
        $themePath = ASCMS_THEMES_PATH . '/' . $result->fields['foldername'];
        if (!is_dir($themePath)) {
            \DBG::msg('Skipping theme "' . $result->fields['themesname'] . '"; No such folder!');
            $errorMessages .= '<div class="message-warning">' . sprintf($_CORELANG['TXT_CSS_UPDATE_MISSING_FOLDER'], $result->fields['themesname']) . '</div>';
            $result->MoveNext();
            continue;
        }
        // create a new one if no component.yml exists
        if (!file_exists($themePath . '/component.yml')) {
            \DBG::msg('Converting theme "' . $result->fields['themesname'] . ' to component');
            $themeRepository->convertThemeToComponent($result->fields['foldername']);
        }
        $result->MoveNext();
    }
    if (!empty($errorMessages)) {
        setUpdateMsg($errorMessages, 'msg');
        setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_CONTINUE_UPDATE'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button');
        $_SESSION['contrexx_update']['update']['done'][] = 'convertTemplates';
        return false;
    }
    return true;
}