/** * 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'] : ''); }
/** * 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']); } } }
/** * 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); } }
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; }
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.'; }