//Link
     $link = $old_data['value'] ? new CMS_href($old_data['value']) : new CMS_href();
     $linkDialog = new CMS_dialog_href($link);
     $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;
Beispiel #2
0
 /**
  * Parse the definition file as to get the client spaces
  *
  * @param CMS_modulesTags $modulesTreatment tags object treatment
  * @return string The error string from the parser, false if no error
  * @access private
  */
 protected function _parseDefinitionFile(&$modulesTreatment, $convert = null)
 {
     global $cms_language;
     if (!$this->_definitionFile) {
         return false;
     }
     $filename = PATH_TEMPLATES_FS . "/" . $this->_definitionFile;
     $tpl = new CMS_file(PATH_TEMPLATES_FS . "/" . $this->_definitionFile);
     if (!$tpl->exists()) {
         $this->raiseError('Can not found template file ' . PATH_TEMPLATES_FS . "/" . $this->_definitionFile);
         return false;
     }
     $definition = $tpl->readContent();
     //we need to remove doctype if any
     $definition = trim(preg_replace('#<!doctype[^>]*>#siU', '', $definition));
     $modulesTreatment->setDefinition($definition);
     //get client spaces modules codename
     $this->_clientSpacesTags = $modulesTreatment->getTags(array('atm-clientspace'), true);
     if (is_array($this->_clientSpacesTags)) {
         $modules = array();
         foreach ($this->_clientSpacesTags as $cs_tag) {
             if ($cs_tag->getAttribute("module")) {
                 $modules[] = $cs_tag->getAttribute("module");
             }
         }
         $blocks = $modulesTreatment->getTags(array('block'), true);
         foreach ($blocks as $block) {
             if ($block->getAttribute("module")) {
                 $modules[] = $block->getAttribute("module");
             } else {
                 return $cms_language->getMessage(self::MESSAGE_TPL_SYNTAX_ERROR, array($cms_language->getMessage(self::MESSAGE_BLOCK_SYNTAX_ERROR)));
             }
         }
         $modules = array_unique($modules);
         $this->_modules->emptyStack();
         foreach ($modules as $module) {
             $this->_modules->add($module);
         }
         if ($convert !== null) {
             $tplConverted = false;
             foreach ($modules as $moduleCodename) {
                 if (CMS_modulesCatalog::isPolymod($moduleCodename)) {
                     $tplConverted = true;
                     $module = CMS_modulesCatalog::getByCodename($moduleCodename);
                     $definition = $module->convertDefinitionString($definition, $convert == self::CONVERT_TO_HUMAN);
                 }
             }
             if ($tplConverted) {
                 //check definition parsing
                 $parsing = new CMS_polymod_definition_parsing($definition, true, CMS_polymod_definition_parsing::CHECK_PARSING_MODE);
                 $errors = $parsing->getParsingError();
                 if ($errors) {
                     return $cms_language->getMessage(self::MESSAGE_TPL_SYNTAX_ERROR, array($errors));
                 }
                 $filename = $this->getDefinitionFile();
                 $file = new CMS_file(PATH_TEMPLATES_FS . "/" . $filename);
                 $file->setContent($definition);
                 $file->writeToPersistence();
             }
         }
         return true;
     } else {
         $this->raiseError("Malformed definition file : " . $this->_definitionFile . "<br />" . $modulesTreatment->getParsingError());
         return $modulesTreatment->getParsingError();
     }
 }
Beispiel #3
0
 /**
  * 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;
 }
Beispiel #4
0
 /**
  * Parse the definition file to instanciate the _blocks attribute
  *
  * @param CMS_modulesTags $modulesTreatment tags object treatment
  * @return string false on success, the parsing error string if any
  * @access public
  */
 protected function _parseDefinitionFile(&$modulesTreatment)
 {
     if ($this->_definitionFile) {
         $filename = PATH_TEMPLATES_ROWS_FS . "/" . $this->_definitionFile;
         $tplrow = new CMS_file(PATH_TEMPLATES_ROWS_FS . "/" . $this->_definitionFile);
         if (!$tplrow->exists()) {
             $this->raiseError('Can not found row template file ' . PATH_TEMPLATES_ROWS_FS . "/" . $this->_definitionFile);
             return true;
         }
         $modulesTreatment->setDefinition($tplrow->readContent());
         $this->_blocks = $modulesTreatment->getTags(array('block'));
         if (is_array($this->_blocks)) {
             return false;
         } else {
             $this->raiseError("Malformed definition file : " . $this->_definitionFile . "<br />" . $modulesTreatment->getParsingError());
             return $modulesTreatment->getParsingError();
         }
     } else {
         $this->raiseError('No row definition file found for row : ' . $this->getLabel());
         return true;
     }
 }
Beispiel #5
0
 /**
  * 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('&#160;', '&nbsp;', ' '), '', $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('{' => '&#123;', '}' => '&#125;', '&#123;&#123;' => '{{', '&#125;&#125;' => '}}', "%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;
 }
 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;
 }