function formatBytes($val, $digits = 3, $mode = "SI", $bB = "B") { $si = array("", "K", "M", "G", "T", "P", "E", "Z", "Y"); $iec = array("", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi"); switch (io::strtoupper($mode)) { case "SI": $factor = 1000; $symbols = $si; break; case "IEC": $factor = 1024; $symbols = $iec; break; default: $factor = 1000; $symbols = $si; break; } switch ($bB) { case "b": $val *= 8; break; default: $bB = "B"; break; } for ($i = 0; $i < count($symbols) - 1 && $val >= $factor; $i++) { $val /= $factor; } $p = io::strpos($val, "."); if ($p !== false && $p > $digits) { $val = round($val); } elseif ($p !== false) { $val = round($val, $digits - $p); } return round($val, $digits) . " " . $symbols[$i] . $bB; }
/** * Get the default language code for this module * Comes from parameters or Constant * Upgrades constant with parameter found * * @return String the language codename * @access public */ function getDefaultLanguageCodename() { if (!defined("MOD_" . io::strtoupper($this->getCodename()) . "_DEFAULT_LANGUAGE")) { $polymodLanguages = CMS_object_i18nm::getAvailableLanguages(); define("MOD_" . io::strtoupper($this->getCodename()) . "_DEFAULT_LANGUAGE", $polymodLanguages[0]); } return constant("MOD_" . io::strtoupper($this->getCodename()) . "_DEFAULT_LANGUAGE"); }
/** * Compute an atm-form-required or atm-form-malformed tag * * @param array $tag : the reference atm-form-required or atm-form-malformed tag to compute * @return string the PHP / HTML content computed * @access private */ protected function _formRequirementsTag(&$tag) { //check tags requirements if (!$this->checkTagRequirements($tag, array('form' => 'alphanum'))) { return; } $tagType = $tag['nodename'] == 'atm-form-required' ? 'required' : 'malformed'; $uniqueID = CMS_XMLTag::getUniqueID(); $return = ' //FORM ' . io::strtoupper($tagType) . ' TAG START ' . $uniqueID . ' if (isset($polymodFormsError[\'' . $tag['attributes']['form'] . '\'][\'' . $tagType . '\'])) { $object_' . $uniqueID . ' = $object[$objectDefinition_' . $tag['attributes']['form'] . ']; //save previous object search if any $replace_' . $uniqueID . ' = $replace; //save previous replace vars if any $count_' . $uniqueID . ' = 0; $content_' . $uniqueID . ' = $content; //save previous content var if any $max' . $tagType . ' = sizeof($polymodFormsError[\'' . $tag['attributes']['form'] . '\'][\'' . $tagType . '\']); foreach ($polymodFormsError[\'' . $tag['attributes']['form'] . '\'][\'' . $tagType . '\'] as $' . $tagType . 'FieldID) { $content = ""; $replace["atm-form-' . $tagType . '"] = array ( "{first' . $tagType . '}" => (!$count_' . $uniqueID . ') ? 1 : 0, "{last' . $tagType . '}" => ($count_' . $uniqueID . ' == sizeof($polymodFormsError[\'' . $tag['attributes']['form'] . '\'][\'' . $tagType . '\'])-1) ? 1 : 0, "{' . $tagType . 'count}" => ($count_' . $uniqueID . '+1), "{max' . $tagType . '}" => $max' . $tagType . ', "{' . $tagType . 'name}" => $object_' . $uniqueID . '->objectValues($' . $tagType . 'FieldID)->getFieldLabel($cms_language), "{' . $tagType . 'field}" => $' . $tagType . 'FieldID, ); ' . $this->computeTags($tag['childrens']) . ' $count_' . $uniqueID . '++; //do all result vars replacement $content_' . $uniqueID . '.= CMS_polymod_definition_parsing::replaceVars($content, $replace); } $content = $content_' . $uniqueID . '; //retrieve previous content var if any unset($content_' . $uniqueID . '); $replace = $replace_' . $uniqueID . '; //retrieve previous replace vars if any unset($replace_' . $uniqueID . '); } //FORM ' . io::strtoupper($tagType) . ' TAG END ' . $uniqueID . ' '; return $return; }
/** * Get the default language code for this module * Comes from parameters or Constant * Upgrades constant with parameter found * * @return String the language codename * @access public */ function getDefaultLanguageCodename() { if ($this->hasParameters() && ($s = $this->getParameters(io::strtolower("default_language")))) { define("MOD_" . io::strtoupper($this->getCodename()) . "_DEFAULT_LANGUAGE", io::strtolower($s)); } else { define("MOD_" . io::strtoupper($this->getCodename()) . "_DEFAULT_LANGUAGE", APPLICATION_DEFAULT_LANGUAGE); } return constant("MOD_" . io::strtoupper($this->getCodename()) . "_DEFAULT_LANGUAGE"); }
//This file is an admin file. Interface must be secure $view->setSecure(); //check user rights if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITUSERS)) { CMS_grandFather::raiseError('User has no users management rights ...'); $view->show(); } //get records / pages $recordsPerPage = CMS_session::getRecordsPerPage(); //groups letters $letters = CMS_profile_usersGroupsCatalog::getLettersForTitle(); //$letters = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); $lettersButtons = ''; foreach ($letters as $letter) { $lettersButtons .= '{ text: \'' . io::strtoupper($letter) . '\', enableToggle: true, handler: clickLetter },'; } //remove last comma $lettersButtons = io::substr($lettersButtons, 0, -1); $jscontent = <<<END \tvar groupsWindow = Ext.getCmp('{$winId}'); \tvar fatherWindow = Ext.getCmp('{$fatherId}'); \t \t//groups store \tvar store = new Automne.JsonStore({ \t\turl: \t\t\t'groups-datas.php', \t\troot: \t\t\t'groups', \t\ttotalProperty:\t'totalCount',
/** * Get the module message constants * * @param string, the constant name to get * @return the constant value * @access public */ function getModuleValidationLabel($label) { $labels = array("edition" => constant("MESSAGE_MOD_" . io::strtoupper($this->getCodename()) . "_VALIDATION_EDITION"), "editionOfResource" => constant("MESSAGE_MOD_" . io::strtoupper($this->getCodename()) . "_VALIDATION_EDITION_OFRESOURCE"), "URLPreviz" => constant("MESSAGE_MOD_" . io::strtoupper($this->getCodename()) . "_URL_PREVIZ"), "locationChange" => constant("MESSAGE_MOD_" . io::strtoupper($this->getCodename()) . "_VALIDATION_LOCATIONCHANGE"), "locationChangeOfResource" => constant("MESSAGE_MOD_" . io::strtoupper($this->getCodename()) . "_VALIDATION_LOCATIONCHANGE_OFRESOURCE")); if ($labels[$label]) { return $labels[$label]; } else { $this->raiseError("Unknown label or constant not set : " . $label); return false; } }
/** * Treat given content tag by this module for the specified treatment mode, visualization mode and object. * * @param string $tag The CMS_XMLTag. * @param string $tagContent previous tag content. * @param integer $treatmentMode The current treatment mode (see constants on top of CMS_modulesTags class for accepted values). * @param integer $visualizationMode The current visualization mode (see constants on top of cms_page class for accepted values). * @param object $treatedObject The reference object to treat. * @param array $treatmentParameters : optionnal parameters used for the treatment. Usually an array of objects. * @return string the tag content treated. * @access public */ function treatWantedTag(&$tag, $tagContent, $treatmentMode, $visualizationMode, &$treatedObject, $treatmentParameters) { switch ($treatmentMode) { case MODULE_TREATMENT_BLOCK_TAGS: if (!$treatedObject instanceof CMS_row) { $this->raiseError('$treatedObject must be a CMS_row object'); return false; } if (!$treatmentParameters["page"] instanceof CMS_page) { $this->raiseError('$treatmentParameters["page"] must be a CMS_page object'); return false; } if (!$treatmentParameters["language"] instanceof CMS_language) { $this->raiseError('$treatmentParameters["language"] must be a CMS_language object'); return false; } if (!$treatmentParameters["clientSpace"] instanceof CMS_moduleClientspace) { $this->raiseError('$treatmentParameters["clientSpace"] must be a CMS_moduleClientspace object'); return false; } if ($tag->getName() == 'row') { //replace {{pageID}} tag in all page content. return str_replace('{{pageID}}', $treatmentParameters["page"]->getID(), $tag->getInnerContent()); } else { //create the block data $block = $tag->getRepresentationInstance(); return $block->getData($treatmentParameters["language"], $treatmentParameters["page"], $treatmentParameters["clientSpace"], $treatedObject, $visualizationMode); } break; case MODULE_TREATMENT_CLIENTSPACE_TAGS: if (!$treatedObject instanceof CMS_pageTemplate) { $this->raiseError('$treatedObject must be a CMS_pageTemplate object'); return false; } if (!$treatmentParameters["page"] instanceof CMS_page) { $this->raiseError('$treatmentParameters["page"] must be a CMS_page object'); return false; } if (!$treatmentParameters["language"] instanceof CMS_language) { $this->raiseError('$treatmentParameters["language"] must be a CMS_language object'); return false; } $args = array("template" => $treatedObject->getID()); if ($visualizationMode == PAGE_VISUALMODE_CLIENTSPACES_FORM || $visualizationMode == PAGE_VISUALMODE_HTML_EDITION || $visualizationMode == PAGE_VISUALMODE_FORM) { $args["editedMode"] = true; } //load CS datas switch ($tag->getName()) { case 'atm-clientspace': default: $client_space = $tag->getRepresentationInstance($args); switch ($visualizationMode) { case PAGE_VISUALMODE_PRINT: $data = ""; $clientSpacesData = array(); $csTagID = $tag->getAttribute("id"); $printingCS = $treatedObject->getPrintingClientSpaces(); if (in_array($csTagID, $printingCS)) { $clientSpacesData[$csTagID] = $client_space->getData($treatmentParameters["language"], $treatmentParameters["page"], $visualizationMode, $treatedObject->hasPages()); } foreach ($printingCS as $cs) { if (isset($clientSpacesData[$cs])) { $data .= $clientSpacesData[$cs] . '<br />'; } } return $data; break; default: if (is_object($client_space)) { return $client_space->getData($treatmentParameters["language"], $treatmentParameters["page"], $visualizationMode, false); } else { return ''; } break; } break; } break; case MODULE_TREATMENT_LINXES_TAGS: switch ($tag->getName()) { case "atm-linx": //linx are visible only if target pages are published (public tree) $linx_args = array("page" => $treatedObject, "publicTree" => true); $linx = $tag->getRepresentationInstance($linx_args); return $linx->getOutput(true); break; } return ''; break; case MODULE_TREATMENT_PAGECONTENT_TAGS: if (!$treatedObject instanceof CMS_page) { $this->raiseError('$treatedObject must be a CMS_page object'); return false; } switch ($tag->getName()) { case "atm-main-url": return CMS_websitesCatalog::getMainURL(); break; case "atm-keywords": return '<meta name="keywords" content="' . SensitiveIO::sanitizeHTMLString($treatedObject->getKeywords($visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC)) . '" />'; break; case "atm-description": return '<meta name="description" content="' . SensitiveIO::sanitizeHTMLString($treatedObject->getDescription($visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC)) . '" />'; break; case "atm-last-update": $lastlog = CMS_log_catalog::getByResourceAction(MOD_STANDARD_CODENAME, $treatedObject->getID(), array(CMS_log::LOG_ACTION_RESOURCE_SUBMIT_DRAFT, CMS_log::LOG_ACTION_RESOURCE_DIRECT_VALIDATION), 1); if (!$lastlog || !is_object($lastlog[0])) { return ''; } $user = $lastlog[0]->getUser(); $date = $lastlog[0]->getDateTime(); $dateformat = $tag->getAttribute("format") ? $tag->getAttribute("format") : 'Y-m-d'; $replace = array('{{date}}' => date($dateformat, $date->getTimestamp()), '{{firstname}}' => $user->getFirstName(), '{{lastname}}' => $user->getLastName()); return str_replace(array_keys($replace), $replace, $tag->getInnerContent()); break; case "atm-print-link": if ($treatedObject->getPrintStatus()) { $template = $tag->getInnerContent(); if ($tag->getAttribute("keeprequest") == 'true') { return '<?php echo \'' . str_replace("{{href}}", $treatedObject->getURL(true) . '\'.($_SERVER["QUERY_STRING"] ? \'?\'.$_SERVER["QUERY_STRING"] : \'\').\'', str_replace("\\\\'", "\\'", str_replace("'", "\\'", $template))) . '\' ?>'; } else { return str_replace("{{href}}", $treatedObject->getURL(true), $template); } } return ''; break; case "atm-constant": $const = SensitiveIO::stripPHPTags(io::strtoupper($tag->getAttribute("name"))); if (defined($const)) { return constant($const); } return ''; break; case "head": $headCode = '<?php' . "\n" . '$atmHost = null;' . "\n" . '$atmPort = null;' . "\n" . 'if(isset($_SERVER["HTTP_HOST"])) {' . "\n" . ' $atmHost = @parse_url($_SERVER["HTTP_HOST"], PHP_URL_HOST) ? @parse_url($_SERVER["HTTP_HOST"], PHP_URL_HOST) : $_SERVER["HTTP_HOST"];' . "\n" . ' $atmPort = @parse_url($_SERVER[\'HTTP_HOST\'], PHP_URL_PORT) ? \':\'.@parse_url($_SERVER[\'HTTP_HOST\'], PHP_URL_PORT) : \'\';' . "\n" . '}' . "\n" . 'echo "\\t".\'<base href="//\'.$atmHost.$atmPort.PATH_REALROOT_WR.\'/" />\'."\\n";' . "\n" . ' ?>'; //Append base code return preg_replace('#<head([^>]*)>#', '<head\\1>' . "\n" . $headCode, $tag->getContent()); break; case "body": $statsCode = '<?php if (SYSTEM_DEBUG && STATS_DEBUG) {echo CMS_stats::view();} ?>'; //Append stats code return preg_replace('#</body>$#', $statsCode . "\n" . '</body>', $tag->getContent()); break; case "html": //Append DTD return '<?php if (defined(\'APPLICATION_XHTML_DTD\')) echo APPLICATION_XHTML_DTD."\\n"; ?>' . "\n" . $tag->getContent(); break; } return ''; break; case MODULE_TREATMENT_PAGEHEADER_TAGS: if (!$treatedObject instanceof CMS_page) { $this->raiseError('$treatedObject must be a CMS_page object'); return false; } switch ($tag->getName()) { case "atm-linx": if ($visualizationMode == PAGE_VISUALMODE_CLIENTSPACES_FORM || $visualizationMode == PAGE_VISUALMODE_FORM) { //direct linx are visible even if target pages are not published (edited tree) //all other linx are only visible if they are published (public tree) $linx_args = array("page" => $treatedObject, "publicTree" => !($tag->getAttribute('type') == 'direct' || !$tag->getAttribute('type'))); $linx = $tag->getRepresentationInstance($linx_args); $linx->setDebug(false); $linx->setLog(false); return $linx->getOutput(); } else { //for public and print visualmode, this treatment is done by MODULE_TREATMENT_LINXES_TAGS mode during page file linx treatment if ($visualizationMode != PAGE_VISUALMODE_HTML_PUBLIC && $visualizationMode != PAGE_VISUALMODE_PRINT) { //linx are visible only if target pages are published (public tree) $linx_args = array("page" => $treatedObject, "publicTree" => true); $linx = $tag->getRepresentationInstance($linx_args); return $linx->getOutput(); } } break; case "atm-js-tags": case "atm-css-tags": $usage = CMS_module::moduleUsage($treatedObject->getID(), $this->_codename); $tagFiles = $tag->getAttribute('files'); $tagFiles = array_map('trim', explode(',', $tagFiles)); //only if current page use a block of this module if ($tagFiles) { //save in global var the page ID who use this tag CMS_module::moduleUsage($treatedObject->getID(), $this->_codename, array($tag->getName() => true)); $return = ''; //overwrite previous modules return to append files of this module //save new modules files switch ($tag->getName()) { case "atm-js-tags": //get old files for this tag already needed by other modules $files = CMS_module::moduleUsage($treatedObject->getID(), "atm-js-tags"); $files = is_array($files) ? $files : array(); //append module js files $files = array_merge($files, $tagFiles); //append CMS_function.js file if (!isset($usage['js-files']) && file_exists(PATH_JS_FS . '/CMS_functions.js')) { $file = str_replace(PATH_REALROOT_FS . '/', '', PATH_JS_FS . '/CMS_functions.js'); $files = array_merge($files, array($file)); } //append swfobject for block flash if (is_array($usage) && isset($usage['blockflash']) && $usage['blockflash'] == true) { $files[] = 'swfobject'; } //save files CMS_module::moduleUsage($treatedObject->getID(), $tag->getName(), $files, true); break; case "atm-css-tags": //get old files for this tag already needed by other modules $files = CMS_module::moduleUsage($treatedObject->getID(), "atm-css-tags"); $files = is_array($files) ? $files : array(); $media = $tag->getAttribute('media') ? $tag->getAttribute('media') : 'all'; //append module css files if (!isset($files[$media])) { $files[$media] = array(); } $files[$media] = array_merge($files[$media], $tagFiles); //save files CMS_module::moduleUsage($treatedObject->getID(), "atm-css-tags", $files, true); break; } //Create return for all saved modules files switch ($tag->getName()) { case "atm-js-tags": //get old files for this tag already needed by other modules $files = CMS_module::moduleUsage($treatedObject->getID(), "atm-js-tags"); //add files from atm-js-add tag $filesAdd = CMS_module::moduleUsage($treatedObject->getID(), "atm-js-tags-add"); $filesAdd = is_array($filesAdd) ? $filesAdd : array(); $files = array_merge($files, $filesAdd); $return .= '<?php echo CMS_view::getJavascript(array(\'' . implode('\',\'', array_unique($files)) . '\')); ?>' . "\n"; break; case "atm-css-tags": $media = $tag->getAttribute('media') ? $tag->getAttribute('media') : 'all'; //get old files for this tag already needed by other modules $files = CMS_module::moduleUsage($treatedObject->getID(), "atm-css-tags"); //add files from atm-css-add tag $filesAdd = CMS_module::moduleUsage($treatedObject->getID(), "atm-css-tags-add"); $filesAdd = is_array($filesAdd) ? $filesAdd : array(); if (isset($files[$media])) { if (isset($filesAdd[$media])) { $files[$media] = array_merge($files[$media], $filesAdd[$media]); } $return .= '<?php echo CMS_view::getCSS(array(\'' . implode('\',\'', array_unique($files[$media])) . '\'), \'' . $media . '\'); ?>' . "\n"; } break; } return $return; } break; case "atm-meta-tags": $attributes = array(); //normalize values for attributes if ($tag->getAttributes()) { $attributes = $tag->getAttributes(); foreach ($attributes as $tagName => $value) { if ($attributes == '1' || $value == 'true') { $attributes[$tagName] = true; } elseif ($value == '0' || $value == 'false') { $attributes[$tagName] = false; } if ($attributes[$tagName] !== false && $attributes[$tagName] !== true) { unset($attributes[$tagName]); } } } $metaDatas = $treatedObject->getMetaTags($visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC, $attributes); $usage = CMS_module::moduleUsage($treatedObject->getID(), $this->_codename); //if page template already use atm-js-tags tag, no need to add JS again if (!is_array($usage) || !isset($usage['atm-js-tags'])) { $metaDatas .= ' <script type="text/javascript" src="' . PATH_REALROOT_WR . '/js/CMS_functions.js"></script>' . "\n"; //save JS handled CMS_module::moduleUsage($treatedObject->getID(), $this->_codename, array('js-files' => true)); } if ($visualizationMode == PAGE_VISUALMODE_FORM) { global $cms_user; $isValidator = is_object($cms_user) && $cms_user->hasPageClearance($treatedObject->getID(), CLEARANCE_PAGE_EDIT) && $cms_user->hasValidationClearance(MOD_STANDARD_CODENAME) ? 'true' : 'false'; //add needed javascripts $metaDatas .= '<script type="text/javascript">' . "\n" . 'var atmRowsDatas = {};' . "\n" . 'var atmBlocksDatas = {};' . "\n" . 'var atmCSDatas = {};' . "\n" . 'var atmIsValidator = ' . $isValidator . ';' . "\n" . 'var atmIsValidable = true;' . "\n" . 'var atmHasPreview = true;' . "\n" . 'var atmHasPreview = true;' . "\n" . 'var CKEDITOR_BASEPATH = \'' . PATH_MAIN_WR . '/ckeditor/\';' . "\n" . '</script>'; //append JS from current view instance $view = CMS_view::getInstance(); $metaDatas .= $view->getJavascript(); $metaDatas .= CMS_view::getCSS(array('edit')); } else { if ($visualizationMode == PAGE_VISUALMODE_CLIENTSPACES_FORM) { //add needed javascripts $metaDatas .= '<script type="text/javascript">' . "\n" . 'var atmRowsDatas = {};' . "\n" . 'var atmBlocksDatas = {};' . "\n" . 'var atmCSDatas = {};' . "\n" . 'var atmIsValidator = false;' . "\n" . 'var atmIsValidable = false;' . "\n" . 'var atmHasPreview = false;' . "\n" . 'var CKEDITOR_BASEPATH = \'' . PATH_MAIN_WR . '/ckeditor/\';' . "\n" . '</script>'; //append JS from current view instance $view = CMS_view::getInstance(); $metaDatas .= $view->getJavascript(); $metaDatas .= CMS_view::getCSS(array('edit')); } } //if page template already use atm-js-tags tag, no need to add JS again if (!is_array($usage) || !isset($usage['atm-js-tags'])) { //if this page use a row block of this module then add the header code to the page if (is_array($usage) && isset($usage['blockflash']) && $usage['blockflash'] == true) { $metaDatas .= '<script type="text/javascript" src="' . PATH_MAIN_WR . '/swfobject/swfobject.js"></script>' . "\n"; } } return $metaDatas; break; } return ''; break; case MODULE_TREATMENT_WYSIWYG_INNER_TAGS: if ($tag->getName() == 'atm-linx') { //linx from standard module $domdocument = new CMS_DOMDocument(); try { $domdocument->loadXML('<html>' . $tag->getContent() . '</html>'); } catch (DOMException $e) { $this->raiseError('Parse error for atm-linx : ' . $e->getMessage() . " :\n" . io::htmlspecialchars($tag->getContent())); return ''; } $nodespecs = $domdocument->getElementsByTagName('nodespec'); if ($nodespecs->length == 1) { $nodespec = $nodespecs->item(0); } $htmltemplates = $domdocument->getElementsByTagName('htmltemplate'); if ($htmltemplates->length == 1) { $htmltemplate = $htmltemplates->item(0); } $noselections = $domdocument->getElementsByTagName('noselection'); if ($noselections->length == 1) { $noselection = $noselections->item(0); } if ($nodespec && $htmltemplate) { //if ($paramsTags[0]->getName() == "nodespec" && $paramsTags[1]->getName() == "noselection" && $paramsTags[2]->getName() == "htmltemplate") { if (isset($noselection)) { // case noselection tag $pageID = $nodespec->getAttribute("value"); $link = CMS_DOMDocument::DOMElementToString($htmltemplate, true); $treatedLink = str_replace('href', 'noselection="true" href', str_replace('{{href}}', '{{' . $pageID . '}}', $link)); } else { $pageID = $nodespec->getAttribute("value"); $link = CMS_DOMDocument::DOMElementToString($htmltemplate, true); $treatedLink = str_replace('{{href}}', '{{' . $pageID . '}}', $link); } } } elseif ($tag->getName() == 'span') { //linx from other module $ids = explode('-', $tag->getAttribute('id')); $selectedPageID = (int) $ids[1]; $noselection = $ids[2]; //then create the code to paste for the current selected object if any if (sensitiveIO::isPositiveInteger($selectedPageID) && ($noselection == 'true' || $noselection == 'false')) { $pattern = "/(.*)<a([^>]*)'\\.CMS_tree.*, 'url'\\)\\.'(.*)\\<\\/a>(.*)<\\/span>/U"; if ($noselection == 'true') { $replacement = '<a noselection="true"\\2{{' . $selectedPageID . '}}\\3</a>'; } else { $replacement = '<a\\2{{' . $selectedPageID . '}}\\3</a>'; } $treatedLink = str_replace("\\'", "'", preg_replace($pattern, $replacement, $tag->getContent())); } } return $treatedLink; case MODULE_TREATMENT_WYSIWYG_OUTER_TAGS: //Anchor if (preg_match('/^#([a-zA-Z0-9._{}:-]*)$/i', $tag->getAttribute('href')) > 0) { //instanciate anchor tag $anchor = new CMS_XMLTag_anchor($tag->getName(), $tag->getAttributes(), $tag->getChildren(), $tag->getParameters()); return $anchor->compute(array('mode' => $treatmentMode, 'visualization' => $visualizationMode, 'object' => $treatedObject, 'parameters' => $treatmentParameters)); } elseif (preg_match('/^.*\\{\\{(\\d+)\\}\\}.*$/i', $tag->getAttribute('href')) > 0) { //internal links /* Pattern explanation : * * \<a([^>]*) : start with "<a" and any characters after except a ">". Content found into the "()" (first parameters of the link) is the first variable : "\\1" * {{(\d+)}} : some numbers only into "{{" and "}}". Content found into the "()" (the page number) is the second variable : "\\2" * (.*)\<\/a> : any characters after followed by "</a>". Content found into the "()" (last parameters of the link and link content) is the third variable : "\\3" * /U : PCRE_UNGREEDY stop to the first finded occurence. */ $pattern = "/<a([^>]*){{(\\d+)}}(.*)\\<\\/a>/Us"; if ($tag->getName() == 'a' && $treatmentParameters['module'] == MOD_STANDARD_CODENAME) { if ($tag->getAttribute('noselection') == 'true') { $replacement = "<atm-linx type=\"direct\"><selection><start><nodespec type=\"node\" value=\"\\2\"/></start></selection><noselection>" . $tag->getInnerContent() . "</noselection><display><htmltemplate><a\\1{{href}}\\3</a></htmltemplate></display></atm-linx>"; $treatedLink = preg_replace($pattern, $replacement, str_replace('noselection="true"', '', $tag->getContent())); } else { $replacement = "<atm-linx type=\"direct\"><selection><start><nodespec type=\"node\" value=\"\\2\"/></start></selection><display><htmltemplate><a\\1{{href}}\\3</a></htmltemplate></display></atm-linx>"; $treatedLink = preg_replace($pattern, $replacement, $tag->getContent()); } } elseif ($tag->getName() == 'a' && $treatmentParameters['module'] != MOD_STANDARD_CODENAME) { if ($tag->getAttribute('noselection') == 'true') { $replacement = '<span id="' . MOD_STANDARD_CODENAME . '-\\2-true"><?php if (CMS_tree::pageExistsForUser(\\2)) { echo \'<a\\1\'.CMS_tree::getPageValue(\\2, \'url\').\'\\3</a>\';} else { echo ' . var_export($tag->getInnerContent(), true) . ';} ?><!--{elements:' . base64_encode(serialize(array('module' => array(0 => MOD_STANDARD_CODENAME)))) . '}--></span>'; $treatedLink = preg_replace($pattern, $replacement, str_replace(array('noselection="true"', "'"), array('', "\\'"), $tag->getContent())); } else { $replacement = '<span id="' . MOD_STANDARD_CODENAME . '-\\2-false"><?php if (CMS_tree::pageExistsForUser(\\2)) { echo \'<a\\1\'.CMS_tree::getPageValue(\\2, \'url\').\'\\3</a>\';} ?><!--{elements:' . base64_encode(serialize(array('module' => array(0 => MOD_STANDARD_CODENAME)))) . '}--></span>'; $treatedLink = preg_replace($pattern, $replacement, str_replace("'", "\\'", $tag->getContent())); } } return $treatedLink; } break; } //in case of no tag treatment, simply return it return $tag->getContent(); }