$linkDialog->create($linktext, MOD_STANDARD_CODENAME, $cms_page->getID()); $link = $linkDialog->getHref(); $data['value'] = $link->getTextDefinition(); $cms_block->writeToPersistence($cms_page->getID(), $cs, $rowTag, RESOURCE_LOCATION_EDITION, false, $data); //instanciate the clientspace $clientSpace = CMS_moduleClientSpace_standard_catalog::getByTemplateAndTagID($tpl, $cs, $visualMode == PAGE_VISUALMODE_FORM); //get block's row from CS $row = $clientSpace->getRow($rowId, $rowTag); if ($row) { //get row datas $datas = $row->getData($cms_language, $cms_page, $clientSpace, PAGE_VISUALMODE_FORM); //instanciate modules treatments for page content tags $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_PAGECONTENT_TAGS, PAGE_VISUALMODE_FORM, $cms_page); $modulesTreatment->setTreatmentParameters(array("language" => $cms_language, 'replaceVars' => true)); $modulesTreatment->setDefinition($datas); $datas = $modulesTreatment->treatContent(true); //set datas as returned content $view->setContent($datas); $edited = true; } else { CMS_grandFather::raiseError('Can\'t get row type ' . $rowId . ' from clientspace ' . $cs . ' of page ' . $cms_page->getID() . ' with row id ' . $rowTag); $view->setActionMessage($cms_language->getJsMessage(MESSAGE_PAGE_ERROR_UPDATE_BLOCK_CONTENT)); } } else { CMS_grandFather::raiseError('Can\'t get block class type ' . $blockClass . ' to update content'); $view->setActionMessage($cms_language->getJsMessage(MESSAGE_PAGE_ERROR_UPDATE_BLOCK_CONTENT)); } break; default: CMS_grandFather::raiseError('Unknown action ' . $action . ' to do for page ' . $currentPage); $view->show();
/** * Parse content coming out of the WYSIWYG editor to handle all plugins tags * * @param string $text The outputed text of fckeditor * @param string $module The module codename which made the request * @return string the text with all plugin tags * @access public */ function parseOuterContent($text, $module = MOD_STANDARD_CODENAME) { //if post only contain a space or empty div or paragraph then the block is empty. $cleanedText = trim(str_replace(array(' ', ' ', ' '), '', $text)); if ($cleanedText == '<p></p>' || $cleanedText == '<div></div>') { $text = ''; } if ($text) { /* * we need to do some replacements to be completely conform with Automne * you can add here all dirty tags to be removed from editor's output */ $replace = array('{' => '{', '}' => '}', '{{' => '{{', '}}' => '}}', "%7B%7B" => "{{", "%7D%7D" => "}}", "/>" => " />", "<o:p>" => "", "</o:p>" => "", "<!--[if !supportLists]-->" => "", "<!--[endif]-->" => "", "<?php" => "", "<?" => "", "?>" => ""); $text = str_replace(array_keys($replace), $replace, $text); $text = sensitiveIO::decodeWindowsChars($text); $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_WYSIWYG_OUTER_TAGS, RESOURCE_DATA_LOCATION_EDITION, new CMS_date()); $wantedTags = $modulesTreatment->getWantedTags(); //create regular expression on wanted tags $exp = ''; foreach ($wantedTags as $aWantedTag) { $exp .= $exp ? '|<' . $aWantedTag["tagName"] : '<' . $aWantedTag["tagName"]; } //is parsing needed (value contain some of these wanted tags) if (is_array($wantedTags) && $wantedTags && preg_match('#(' . $exp . ')+#', $text) !== false) { $modulesTreatment->setTreatmentParameters(array('module' => $module)); $modulesTreatment->setDefinition($text); $text = $modulesTreatment->treatContent(true); } } return $text; }
/** * Regenerate the page file, either from scratch or from the linx file. * If linx file doesn't exists, the file is regenerated from scratch (obviously). * * @param boolean $fromScratch If false, regenerate from the linx file, otherwise regenerate linx file first. * @return boolean true on success, false on failure * @access public */ function regenerate($fromScratch = false) { //regenerate don't work on pages that are not public or which not have website if ($this->getPublication() != RESOURCE_PUBLICATION_PUBLIC || !$this->_checkWebsite()) { return true; } //need pageTemplate for regeneration $this->_checkTemplate(); //get linx file path $linxFile = new CMS_file($this->getLinxFilePath()); //should we regenerate the linx file ? if ($fromScratch || !$linxFile->exists()) { if (!$this->_template) { $this->raiseError('Can\'t find page template for page ' . $this->getID()); return false; } if (!$this->writeLinxFile()) { return false; } //reload linx file $linxFile = new CMS_file($this->getLinxFilePath()); } //unregister all linxes CMS_linxesCatalog::deleteLinxes($this); //instanciate modules treatments for page linx tags $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_LINXES_TAGS, PAGE_VISUALMODE_HTML_PUBLIC, $this); $modulesTreatment->setDefinition($linxFile->getContent()); if ($content = $modulesTreatment->treatContent(true)) { $pageHTMLPath = $this->_getHTMLFilePath(PATH_RELATIVETO_FILESYSTEM) . "/" . $this->_getHTMLFilename(); $pageFile = new CMS_file($pageHTMLPath, CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE); $pageFile->setContent($content); $pageFile->writeToPersistence(); $this->_lastFileCreation->setNow(); $this->writeToPersistence(); //if the page is a website root, create the index page redirecting to this one if ($fromScratch && CMS_websitesCatalog::isWebsiteRoot($this->getID())) { CMS_websitesCatalog::writeRootRedirection(); } } else { $this->raiseError('Malformed linx file'); return false; } //write significant url page $pagePath = $this->_getFilePath(PATH_RELATIVETO_FILESYSTEM) . "/" . $this->_getFilename(); $redirectionFile = new CMS_file($pagePath, CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE); $redirectionFile->setContent($this->redirectionCode($pageHTMLPath)); $redirectionFile->writeToPersistence(true, true); //write website index if (CMS_websitesCatalog::isWebsiteRoot($this->getID())) { $ws = $this->getWebsite(); if ($ws && !$ws->isMain()) { $wsPath = $ws->getPagesPath(PATH_RELATIVETO_FILESYSTEM) . '/index.php'; $redirectionFile = new CMS_file($wsPath, CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE); $redirectionFile->setContent($this->redirectionCode($pageHTMLPath)); $redirectionFile->writeToPersistence(true, true); } } //write print page if any if (USE_PRINT_PAGES && $this->_template->getPrintingClientSpaces()) { //reload linx file $printLinxFile = new CMS_file($this->getLinxFilePath() . '.print', CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE); if ($printLinxFile->exists()) { $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_LINXES_TAGS, PAGE_VISUALMODE_PRINT, $this); $modulesTreatment->setDefinition($printLinxFile->getContent()); if ($content = $modulesTreatment->treatContent(true)) { $printHTMLPath = $this->_getHTMLFilePath(PATH_RELATIVETO_FILESYSTEM) . "/print-" . $this->_getHTMLFilename(); $printFile = new CMS_file($printHTMLPath); $printFile->setContent($content); $printFile->writeToPersistence(); } else { $this->raiseError('Malformed print linx file'); return false; } //write significant url print page $printPath = $this->_getFilePath(PATH_RELATIVETO_FILESYSTEM) . "/print-" . $this->_getFilename(); $redirectionFile = new CMS_file($printPath); $redirectionFile->setContent($this->redirectionCode($printHTMLPath)); $redirectionFile->writeToPersistence(); } else { $this->raiseError('Malformed print linx file'); return false; } } return true; }
public static function getNewsletterContent($pageId) { $page = CMS_tree::getPageByID($pageId); if ($page->hasError()) { return; } $website = $page->getWebsite(); $websiteUrl = $website->getURL(); $language = CMS_languagesCatalog::getByCode($page->getLanguage()); $content = $page->getContent($language, PAGE_VISUALMODE_HTML_PUBLIC); $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_LINXES_TAGS, PAGE_VISUALMODE_HTML_PUBLIC, $page); $modulesTreatment->setDefinition($content); $content = $modulesTreatment->treatContent(true); //eval all php code in page $php_evalued_content = io::evalPHPCode($content); //change all relative URL in page $parsed_content = self::prepareHTML($php_evalued_content, $websiteUrl); return $parsed_content; }