示例#1
0
 /**
  * Compute the tag
  *
  * @return string the PHP / HTML content computed
  * @access private
  */
 protected function _compute()
 {
     if ($this->_parameters['context'] == CMS_XMLTag::HTML_CONTEXT) {
         if (!isset($this->_computeParams['visualization']) || !isset($this->_computeParams['object']) || !$this->_computeParams['object'] instanceof CMS_page) {
             return '';
         }
         return SensitiveIO::sanitizeHTMLString($this->_computeParams['object']->getTitle($this->_computeParams['visualization'] == PAGE_VISUALMODE_HTML_PUBLIC));
     } else {
         return '$content .= CMS_tree::getPageValue($parameters[\'pageID\'], \'title\', (isset($public_search) ? $public_search : false));';
     }
 }
 /**
  * Data access method : set the validation type label
  *
  * @param string $label the label of the internal type
  * @return boolean true on success to set it, false otherwise.
  * @access public
  */
 function setValidationTypeLabel($label)
 {
     $this->_validationTypeLabel = SensitiveIO::sanitizeHTMLString($label);
     return true;
 }
示例#3
0
    /**
     * Get soap values
     *
     * @param integer $fieldID The field ID
     * @param object $language The CMS_language to deal with
     *
     * @return string $xml XML definition
     * @access public
     */
    function getSoapValues($fieldID, $language)
    {
        $xml = '';
        $xmlFields = '';
        //get Object definition
        $objectDef = $this->getObjectDefinition();
        //get module codename
        $moduleCodename = $objectDef->getValue('module');
        foreach (array_keys($this->_objectValues) as $subFieldID) {
            $xmlFields .= $this->_objectValues[$subFieldID]->getSoapValues($subFieldID, $language);
        }
        $resource = '';
        switch ($this->_objectResourceStatus) {
            case 2:
                //secondary
                $resource = '<resource type="2" name="secondary"/>';
                break;
            case 1:
                //primary
                $dateStart = $this->getPublicationDateStart();
                $dateEnd = $this->getPublicationDateEnd();
                $resource = '<resource type="1" name="primary">
					<pubdatestart>' . $dateStart->getDBValue() . '</pubdatestart>
					<pubdateend>' . $dateEnd->getDBValue() . '</pubdateend>
				</resource>';
                break;
            case 0:
                //none
            //none
            default:
                $resource = '<resource type="0" name="none"/>';
                break;
        }
        $xml .= '<object module="' . SensitiveIO::sanitizeHTMLString($moduleCodename) . '" type="' . $objectDef->getID() . '" id="' . $this->getID() . '" label="' . SensitiveIO::sanitizeHTMLString($this->getLabel()) . '">
			' . $resource . '
			' . $xmlFields . '
		</object>';
        return $xml;
    }
示例#4
0
//sort($getRoot);
//remove double
$getRoot = array_unique($getRoot);
if ($heading) {
    $content .= '<div class="admin">' . urldecode($heading) . '</div><br />';
}
//then display all Trees (queried Root and other user sections)
$content .= '<table border="0" cellpadding="2" cellspacing="0">';
foreach ($getRoot as $aRootID) {
    if ($pages[$aRootID]) {
        $treeRoot = $pages[$aRootID];
    } else {
        $treeRoot = CMS_tree::getPageByID($aRootID);
        $pages[$aRootID] = $treeRoot;
    }
    $pl = SensitiveIO::sanitizeHTMLString($pageLink);
    $pl = str_replace(chr(167) . chr(167), "?", $pl);
    $pl = str_replace(chr(167), "&amp;", $pl);
    $lineage = is_array($lineages[$aRootID]) ? $lineages[$aRootID] : CMS_tree::getLineage($cms_root->getID(), $treeRoot->getID(), false);
    $grand_grand_father = CMS_tree::getAncestor($treeRoot, '3', false);
    $grand_father = CMS_tree::getAncestor($treeRoot, '2', false);
    $father = CMS_tree::getAncestor($treeRoot, '1', false);
    if ($grand_grand_father && $cms_user->hasPageClearance($grand_grand_father->getID(), CLEARANCE_PAGE_VIEW)) {
        $brothers = CMS_tree::getSiblings($grand_grand_father, '0');
    } elseif ($grand_father && $cms_user->hasPageClearance($grand_father->getID(), CLEARANCE_PAGE_VIEW)) {
        $brothers = array($grand_father);
    } elseif ($father && $cms_user->hasPageClearance($father->getID(), CLEARANCE_PAGE_VIEW)) {
        $brothers = array($father);
    } else {
        $brothers = array($treeRoot);
    }
示例#5
0
 protected function _createCategoriesTree($categories, $itemPattern, $templatePattern, $selectedPattern, $maxlevel = 0, $selectedIDs = array())
 {
     global $cms_language;
     static $level;
     $level++;
     $return = "";
     //get all level categories object
     $categoriesObjects = array();
     $subCats = array();
     foreach ($categories as $catID => $subCategories) {
         $category = CMS_moduleCategories_catalog::getByID($catID);
         $categoriesObjects[$category->getAttribute('order')] = $category;
         $subCats[$catID] = $subCategories;
     }
     //sort categories by order
     ksort($categoriesObjects);
     ///then display it
     foreach ($categoriesObjects as $category) {
         $catID = $category->getID();
         $subCategories = $subCats[$catID];
         $subcats = '';
         if (is_array($subCategories) && $subCategories && (!$maxlevel || $level < $maxlevel)) {
             //recurse on subcategories
             $subcats = $this->_createCategoriesTree($subCategories, $itemPattern, $templatePattern, $selectedPattern, $maxlevel, $selectedIDs);
         }
         $iconPathFS = $category->getIconPath(true, PATH_RELATIVETO_FILESYSTEM, true);
         if ($iconPathFS && file_exists($iconPathFS)) {
             $iconPathWR = CMS_websitesCatalog::getCurrentDomain() . $category->getIconPath(true, PATH_RELATIVETO_WEBROOT, true);
             $icon = '<img src="' . $iconPathWR . '" alt="" title="' . SensitiveIO::sanitizeHTMLString($category->getLabel($cms_language)) . '" />';
         } else {
             $icon = '';
         }
         $replace = array('{id}' => $catID, '{label}' => $category->getLabel($cms_language), '{description}' => $category->getDescription($cms_language), '{sublevel}' => $subcats, '{lvl}' => $level, '{icon}' => $icon);
         if ($selectedIDs && in_array($catID, $selectedIDs)) {
             $return .= str_replace(array_keys($replace), $replace, $selectedPattern);
         } else {
             $return .= str_replace(array_keys($replace), $replace, $itemPattern);
         }
     }
     $return = str_replace('{sublevel}', $return, $templatePattern);
     $level--;
     return $return;
 }
示例#6
0
        } else {
            $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
        }
    } else {
        $cms_message = $cms_language->getMessage(MESSAGE_CLEARANCE_INSUFFICIENT);
    }
}
if ($cms_user) {
    $title = '<span class="admin">' . $cms_language->getMessage(MESSAGE_HELLO) . ' <strong>' . $cms_user->getFirstName() . ' ' . $cms_user->getLastName() . '</strong></span>';
}
$dialog = new CMS_dialog();
if ($cms_message) {
    $dialog->setActionMessage($cms_message);
} else {
    if (isset($_GET["cms_message"])) {
        $dialog->setActionMessage(SensitiveIO::sanitizeHTMLString($_GET["cms_message"]));
    }
}
$dialog->reloadTree();
$content = '
<table border="0" cellpadding="2" cellspacing="0" class="admin_clientSpace">
<tr>
	<td class="admin" width="100%" align="center">&nbsp;' . $title . '&nbsp;</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
	<td class="admin" width="100%" align="center">
<br />
<br />
<br />
示例#7
0
    /**
     * Return the needed form field tag for current object field
     *
     * @param array $values : parameters values array(parameterName => parameterValue) in :
     *     id : the form field id to set
     * @param multidimentionnal array $tags : xml2Array content of atm-function tag
     * @return string : the form field HTML tag
     * @access public
     */
    function getInput($fieldID, $language, $inputParams)
    {
        //hidden field : use parent method
        if (isset($inputParams['hidden']) && ($inputParams['hidden'] == 'true' || $inputParams['hidden'] == 1)) {
            return parent::getInput($fieldID, $language, $inputParams);
        }
        if (isset($inputParams['prefix'])) {
            $prefixName = $inputParams['prefix'];
            unset($inputParams['prefix']);
        } else {
            $prefixName = '';
        }
        $params = $this->getParamsValues();
        //serialize all htmlparameters
        $htmlParameters = $this->serializeHTMLParameters($inputParams);
        $html = '';
        //create fieldname
        $fieldName = $prefixName . $this->_field->getID() . '_0';
        //append field id to html field parameters (if not already exists)
        $htmlParameters .= !isset($inputParams['id']) ? ' id="' . $prefixName . $this->_field->getID() . '_0"' : '';
        //create field value
        $value = $this->_subfieldValues[0]->getValue() ? $this->_subfieldValues[0]->getValue() : '';
        //then create field HTML
        $html .= $html ? '<br />' : '';
        $html .= '<input ' . $htmlParameters . ' type="text" name="' . $fieldName . '" value="' . $value . '" />' . "\n";
        //build tree link
        $grand_root = CMS_tree::getRoot();
        $href = PATH_ADMIN_SPECIAL_TREE_WR;
        $href .= '?root=' . $grand_root->getID();
        $windowTitle = SensitiveIO::sanitizeHTMLString($language->getMessage(self::MESSAGE_PAGE_TREEH1));
        $href .= '&amp;heading=' . $windowTitle;
        $href .= '&amp;encodedOnClick=' . base64_encode("window.opener.document.getElementById('" . $fieldName . "').value = '%s';self.close();");
        $href .= '&encodedPageLink=' . base64_encode('false');
        $html .= '&nbsp;<a href="' . $href . '" class="admin" target="_blank"><img title="' . $windowTitle . '" alt="' . $windowTitle . '" src="' . PATH_ADMIN_IMAGES_WR . '/picto-arbo.gif" border="0" align="absmiddle" /></a>
			';
        if (POLYMOD_DEBUG) {
            $html .= ' <span class="admin_text_alert">(Field : ' . $this->_field->getID() . ' - SubField : 0)</span>';
        }
        //append html hidden field which store field name
        if ($html) {
            $html .= '<input type="hidden" name="polymodFields[' . $this->_field->getID() . ']" value="' . $this->_field->getID() . '" />';
        }
        return $html;
    }
 /**
  * Get user by ID
  * 
  * @access public
  * @param integer $userId The user ID
  * @return string XML definition object
  */
 static function soapGetUser($userId = 0)
 {
     $xml = '';
     $user = SensitiveIO::isPositiveInteger($userId) ? CMS_profile_usersCatalog::getByID($userId) : new CMS_profile_user();
     $user = CMS_profile_usersCatalog::getByID($userId);
     if ($user && !$user->hasError() && $user->isActive()) {
         $contactData = $user->getContactData();
         $language = $user->getLanguage();
         // Groups
         $xmlGroups = '<groups>';
         $userGroupsIds = CMS_profile_usersGroupsCatalog::getGroupsOfUser($user, false, true);
         if ($userGroupsIds) {
             foreach ($userGroupsIds as $userGroup) {
                 $xmlGroups .= '<group id="' . $userGroup->getGroupId() . '">
                     <label><![CDATA[' . $userGroup->getLabel() . ']]></label>
                     <description><![CDATA[' . $userGroup->getDescription() . ']]></description>
                 </group>';
             }
         } else {
             $xmlGroups .= '<group id=""></group>';
         }
         $xmlGroups .= '</groups>';
         // User
         $xml .= '<user>
             <firstName><![CDATA[' . $user->getFirstName() . ']]></firstName>
             <lastName><![CDATA[' . $user->getLastName() . ']]></lastName>
             <login><![CDATA[' . $user->getLogin() . ']]></login>
             <active><![CDATA[' . $user->isActive() . ']]></active>
             <deleted><![CDATA[' . $user->isDeleted() . ']]></deleted>
             <language label="' . SensitiveIO::sanitizeHTMLString($language->getLabel()) . '"><![CDATA[' . $language->getCode() . ']]></language>
             <contactData>
                 <email><![CDATA[' . $contactData->getEmail() . ']]></email>
                 <service><![CDATA[' . $contactData->getService() . ']]></service>
                 <jobTitle><![CDATA[' . $contactData->getJobTitle() . ']]></jobTitle>
                 <addressField1><![CDATA[' . $contactData->getAddressField1() . ']]></addressField1>
                 <addressField2><![CDATA[' . $contactData->getAddressField1() . ']]></addressField2>
                 <addressField3><![CDATA[' . $contactData->getAddressField1() . ']]></addressField3>
                 <zip><![CDATA[' . $contactData->getZip() . ']]></zip>
                 <city><![CDATA[' . $contactData->getCity() . ']]></city>
                 <state><![CDATA[' . $contactData->getState() . ']]></state>
                 <country><![CDATA[' . $contactData->getCountry() . ']]></country>
                 <phone><![CDATA[' . $contactData->getPhone() . ']]></phone>
                 <cellphone><![CDATA[' . $contactData->getCellPhone() . ']]></cellphone>
                 <fax><![CDATA[' . $contactData->getFax() . ']]></fax>
             </contactData>' . $xmlGroups . '</user>';
     }
     return $xml;
 }
 /**
  * Return a variable value of a given name and check it for a given dataType
  *
  * @param string $varType : the variable type to get between var, request, session
  * @param string $name : the variable name to get
  * @param string $dataType : the type of value to check
  * @param mixed $varValue : the var value (optionnal to avoid global problems if vars are declared in previous PHP codes)
  * @return mixed : the variable value
  * @access public
  * @static
  */
 static function getVarContent($varType, $name, $dataType, $varValue = '')
 {
     if (!$name || !$dataType) {
         return false;
     }
     switch ($varType) {
         case 'request':
             if ($dataType == 'string') {
                 $dataType = 'safestring';
                 //Force safestring to avoid XSS
             }
             $varContent = isset($_REQUEST[$name]) ? $_REQUEST[$name] : null;
             break;
         case 'session':
             $varContent = isset($_SESSION[$name]) ? $_SESSION[$name] : null;
             break;
         case 'var':
             global ${$name};
             $varContent = isset(${$name}) && ${$name} !== null ? ${$name} : $varValue;
             break;
         case 'constant':
             $varContent = defined($name) ? constant($name) : null;
             break;
         case 'server':
             $varContent = isset($_SERVER[$name]) ? $_SERVER[$name] : null;
             break;
         default:
             CMS_grandFather::raiseError('Unknown var type to get : ' . $varType);
             return false;
             break;
     }
     //pr('Vartype : '.$varType.' - Name : '.$name.' - Datatype : '.$dataType.' - Content : '.$varContent);
     switch ($dataType) {
         case 'int':
             return (int) $varContent;
             break;
         case 'date':
         case 'datetime':
         case 'localisedDate':
             if ($varContent) {
                 global $cms_language;
                 $date = new CMS_date();
                 $date->setDebug(false);
                 $date->setFormat($cms_language->getDateFormat());
                 $date->setLocalizedDate($varContent);
                 if ($date->hasError()) {
                     return '';
                 }
                 switch ($dataType) {
                     case 'date':
                         return $date->getDBValue(true);
                         break;
                     case 'datetime':
                         return $date->getDBValue(false);
                         break;
                     case 'localisedDate':
                         return $date->getLocalizedDate();
                         break;
                 }
             } else {
                 return '';
             }
             break;
         case 'string':
         case 'unsafestring':
             return (string) $varContent;
             break;
         case 'safestring':
             //safestring return string without any XSS vector
             return SensitiveIO::sanitizeHTMLString((string) $varContent);
             break;
         case 'array':
             if (is_array($varContent)) {
                 return $varContent;
             } else {
                 return array();
                 //false
             }
             break;
         case 'bool':
         case 'boolean':
             if ($varContent === 'true') {
                 return true;
             } elseif ($varContent === 'false') {
                 return false;
             } else {
                 return (bool) $varContent;
             }
             break;
         case 'email':
             if (sensitiveIO::IsValidEmail($varContent)) {
                 return $varContent;
             }
             break;
         default:
             CMS_grandFather::raiseError('Unknown data type to get : ' . $dataType);
             return '';
             break;
     }
     return '';
 }
示例#10
0
    /**
     * Writes message
     *
     * @return void
     * @access private
     */
    protected function _showMessage()
    {
        if ($this->_actionMessage) {
            return '
				<table border="0" width="100%">
				<tr>
					<td align="left">
						<pre class="admin_text_alert">' . SensitiveIO::sanitizeHTMLString($this->_actionMessage) . '</pre>
					</td>
				</tr>
				</table>
				<br />
			';
        }
    }
         $users = array();
         foreach ($elements as $element) {
             $usr = CMS_profile_usersCatalog::getByID($element[0]);
             if (is_a($usr, 'CMS_profile_user') && !$usr->hasError()) {
                 $users[] = $usr;
             }
         }
         foreach ($languages as $language) {
             $subjects[$language->getCode()] = $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_REFUSE_SUBJECT);
             $bodies[$language->getCode()] = $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_REFUSE_BODY, $args);
         }
         break;
     case VALIDATION_OPTION_TRANSFER:
         if ($transferUser) {
             //send an email to the transferred validator
             $args = array($cms_user->getFullName(), $validation->getValidationLabel() . " (ID : " . $validation->getResourceID() . ")", $mod->getLabel($cms_language), SensitiveIO::sanitizeHTMLString($comment));
             $users = array(CMS_profile_usersCatalog::getByID($transferUser));
             foreach ($languages as $language) {
                 $subjects[$language->getCode()] = $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_TRANSFER_SUBJECT);
                 $bodies[$language->getCode()] = $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_TRANSFER_BODY, $args);
             }
         }
         break;
 }
 $group_email = new CMS_emailsCatalog();
 $group_email->setUserMessages($users, $bodies, $subjects, ALERT_LEVEL_VALIDATION, $validation->getModuleCodename());
 $group_email->sendMessages();
 //check if resource still exists
 $resUpdated = $validation->getResource();
 $deleted = true;
 if ($resUpdated && is_object($resUpdated)) {
示例#12
0
 /**
  * Set a string of the object
  *
  * @param string $stringName The string name to set
  * @param string $stringValue The string value to set
  * @return boolean true on success, false on failure
  * @access public
  */
 function setString($stringName, $stringValue)
 {
     if (in_array($this->_tableData[$stringName][0], $this->_classString)) {
         //here you can verifiy string data
         switch ($this->_tableData[$stringName][0]) {
             case "email":
                 //null case
                 if (is_null($stringValue)) {
                     $this->_tableData[$stringName][1] = null;
                     break;
                 }
                 if (!SensitiveIO::isValidEmail($stringValue)) {
                     $this->raiseError("Try to set an uncorrect email format :" . $stringValue);
                     return false;
                 }
                 break;
             case "string":
                 $stringValue = SensitiveIO::sanitizeHTMLString($stringValue);
                 break;
             case "html":
                 //$stringValue = $stringValue;
                 break;
             default:
                 $this->raiseError("Unknown string or not a string dataType :" . $stringName);
                 return false;
                 break;
         }
         $this->_tableData[$stringName][1] = $stringValue;
         return true;
     } else {
         $this->raiseError("Unknown string or not a string dataType :" . $stringName);
         return false;
     }
 }
示例#13
0
 /**
  * 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();
 }