$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; default:
/** * Get the content of the template for the specified page and visualization mode. * Doesn't translates the atm-linx tags. * * @param CMS_language $language The language of the administration frontend (for FORM visualization mode) * @param CMS_page $page The page we want the content of * @param integer $visualizationMode The visualization mode of the page * @return string the content * @access private */ function getContent(&$language, &$page, $visualizationMode) { if (!$page instanceof CMS_page || !SensitiveIO::isInSet($visualizationMode, CMS_page::getAllvisualizationModes())) { $this->raiseError("Page must be a CMS_page and visualization mode in the possibles"); return false; } $returnIndexableContent = false; if ($visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC_INDEXABLE) { $visualizationMode = PAGE_VISUALMODE_PRINT; $returnIndexableContent = true; } $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_CLIENTSPACE_TAGS, $visualizationMode, $this); $modulesTreatment->setTreatmentParameters(array("page" => $page, "language" => $language)); if ($this->_parseDefinitionFile($modulesTreatment) === true) { if ($visualizationMode == PAGE_VISUALMODE_PRINT || $returnIndexableContent) { $data = ''; $tags = $modulesTreatment->getTags(array(), true); foreach ($tags as $tag) { $data .= $modulesTreatment->treatWantedTag($tag); } } else { $data = $modulesTreatment->treatContent(true); } //if we only need indexable content, return data here without any treatment on template if ($returnIndexableContent) { return '<html><body>' . $data . '</body></html>'; } //separate processing for PRINT visualmode if ($visualizationMode == PAGE_VISUALMODE_PRINT) { //now put the data inside the template $template_data = file_get_contents(PATH_PRINT_TEMPLATES_FS); //we need to remove doctype if any $template_data = preg_replace('#<!doctype[^>]*>#siU', '', $template_data); return '<?php /* Template [' . str_replace(PATH_TEMPLATES_FS . '/', '', PATH_PRINT_TEMPLATES_FS) . '] */?>' . str_replace("{{data}}", $data, $template_data); } else { return '<?php /* Template [' . $this->getLabel() . ' - ' . $this->getDefinitionFile() . '] */?>' . $data; } return false; } else { return false; } }
/** * Gets the data, using the specified visualization mode. * The data is taken from the blocks and reintroduced into the definition file which may itself contain HTML instructions. * * @param CMS_language &$language The language of the administration frontend * @param CMS_page &$page the page parsed * @param CMS_clientSpace &$clientSpace the client space parsed * @param integer $visualizationMode the visualization mode * @param boolean $templateHasPages, set to true will die access to up/down buttons * @param boolean $rowCanBeEdited determine we can edit it this page (Display form) * @return string the data from the blocks and the definition file. * @access public */ function getData(&$language, &$page, &$clientSpace, $visualizationMode, $templateHasPages = false, $rowCanBeEdited = true) { global $cms_user; $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_BLOCK_TAGS, $visualizationMode, $this); $modulesTreatment->setTreatmentParameters(array("page" => $page, "language" => $language, "clientSpace" => $clientSpace)); if (!$this->_parseDefinitionFile($modulesTreatment)) { //here we expect a false (otherwise, it is an error) $data = $modulesTreatment->treatContent(); //if $visualizationMode is CLIENTSPACES_FORM and //no page uses the template calling this row, add the form here if ($visualizationMode == PAGE_VISUALMODE_CLIENTSPACES_FORM || $visualizationMode == PAGE_VISUALMODE_FORM) { //append atm-row class and row-id to all first level tags found in row datas $domdocument = new CMS_DOMDocument(); try { $domdocument->loadXML('<row>' . $data . '</row>'); } catch (DOMException $e) { //$this->raiseError('Parse error for row : Page '.$page->getID().' - Row "'.$this->getTagID().'" : '.$e->getMessage()); //$data = '<div class="atm-error-block atm-block-helper">'.$language->getMessage(self::MESSAGE_BLOCK_CONTENT_ERROR).'</div>'; //$domdocument = new CMS_DOMDocument(); //$domdocument->loadXML('<row>'.$data.'</row>'); $this->raiseError('Parse error for row : ' . $e->getMessage() . " :\n" . $data, true); return ''; } $rowNodes = $domdocument->getElementsByTagName('row'); if ($rowNodes->length == 1) { $rowXML = $rowNodes->item(0); } //search for valid tags $hasNode = false; foreach ($rowXML->childNodes as $rowChildNode) { //scripts tags and p tags are not correctly handled by javascript if (is_a($rowChildNode, 'DOMElement') && $rowChildNode->tagName != 'script') { $hasNode = true; } } foreach ($rowXML->childNodes as $rowChildNode) { //scripts tags and p tags are not correctly handled by javascript if (is_a($rowChildNode, 'DOMElement') && ($rowChildNode->tagName != 'p' || io::substr($rowChildNode->tagName, 0, 4) != 'atm-')) { $hasNode = false; } } if (!$hasNode) { //append atm-row class and row-id to all first level tags found in row datas $domdocument = new CMS_DOMDocument(); try { $domdocument->loadXML('<row><div class="atm-dummy-row-tag">' . $data . '</div></row>'); } catch (DOMException $e) { $this->raiseError('Parse error for row : ' . $e->getMessage() . " :\n" . $data, true); return ''; } $rowNodes = $domdocument->getElementsByTagName('row'); if ($rowNodes->length == 1) { $rowXML = $rowNodes->item(0); } } $elements = array(); $rowId = 'row-' . $this->_tagID; foreach ($rowXML->childNodes as $rowChildNode) { if (is_a($rowChildNode, 'DOMElement') && $rowChildNode->tagName != 'script' && $rowChildNode->tagName != 'p' && io::substr($rowChildNode->tagName, 0, 4) != 'atm-') { if ($rowChildNode->hasAttribute('id')) { $elementId = $rowChildNode->getAttribute('id'); } else { $elementId = 'el-' . md5(mt_rand() . microtime()); $rowChildNode->setAttribute('id', $elementId); } $elements[] = $elementId; } } $data = CMS_DOMDocument::DOMElementToString($rowXML, true); //add row specification $data = ' <script type="text/javascript"> atmRowsDatas[\'' . $rowId . '\'] = { id: \'' . $rowId . '\', template: \'' . $clientSpace->getTemplateID() . '\', clientSpaceTagID: \'' . $clientSpace->getTagID() . '\', rowTagID: \'' . $this->_tagID . '\', rowType: \'' . $this->_id . '\', label: \'' . sensitiveIO::sanitizeJSString($this->getLabel()) . '\', userRight: \'' . $this->hasUserRight($cms_user) . '\', visualMode: \'' . $visualizationMode . '\', document: document, elements: [' . ($elements ? '\'' . implode('\',\'', $elements) . '\'' : '') . '] }; </script> ' . $data; //decode brackets encoded in CMS_block_text::_getHTMLForm $replace = array('||bo||' => '{', '||bc||' => '}'); $data = str_replace(array_keys($replace), $replace, $data); } $data = '<?php /* Start row [' . $this->getLabel() . ' - ' . $this->getDefinitionFileName() . '] */?>' . $data . '<?php /* End row [' . $this->getLabel() . ' - ' . $this->getDefinitionFileName() . '] */?>'; return $data; } else { $this->raiseError('Can not use row template file ' . $this->_definitionFile); return false; } }
/** * Get the page content for the specified visualization mode and language. * * @return string The content of the page. * @access public */ function getContent(&$language, $visualizationMode = false) { if (!$language instanceof CMS_language || !SensitiveIO::isInSet($visualizationMode, CMS_page::getAllVisualizationModes())) { $this->raiseError("Language must be a valid language and visualization mode in the set of possibles"); return false; } $this->_checkTemplate(); if ($this->_template) { //get parsed content definition from template (including CS block contents) $definition = $this->_template->getContent($language, $this, $visualizationMode); //instanciate modules treatments for page content tags $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_PAGECONTENT_TAGS, $visualizationMode, $this); $modulesTreatment->setTreatmentParameters(array("language" => $language)); $modulesTreatment->setDefinition($definition); $content = $modulesTreatment->treatContent(true); //instanciate modules treatments for page header tags $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_PAGEHEADER_TAGS, $visualizationMode, $this); $modulesTreatment->setTreatmentParameters(array("language" => $language, 'replaceVars' => true)); $modulesTreatment->setDefinition($content); $content = $modulesTreatment->treatContent(true); /*if ($visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC_INDEXABLE) { //eval() the PHP code $content = sensitiveIO::evalPHPCode($content); return $content; }*/ //include modules header codes on top of output file $modulesCodes = new CMS_modulesCodes(); $headerInclude = $modulesCodes->getModulesCodes(MODULE_TREATMENT_PAGECONTENT_HEADER_CODE, $visualizationMode, $this); if (is_array($headerInclude) && $headerInclude) { $content = implode("\n", $headerInclude) . $content; } //include modules footers codes on bottom of output file $footerInclude = $modulesCodes->getModulesCodes(MODULE_TREATMENT_PAGECONTENT_FOOTER_CODE, $visualizationMode, $this); if (is_array($footerInclude) && $footerInclude) { $content .= implode("\n", $footerInclude); } //replace {{pageID}} tag in all page content. $content = str_replace('{{pageID}}', $this->getID(), $content); if ($visualizationMode != PAGE_VISUALMODE_HTML_PUBLIC && $visualizationMode != PAGE_VISUALMODE_PRINT) { //eval() the PHP code $content = sensitiveIO::evalPHPCode($content); } return $content; } else { return false; } }
/** * 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; }