Ejemplo n.º 1
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_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;
             }
             switch ($tag->getName()) {
                 case "atm-clientspace":
                     $args = array("template" => $treatedObject->getID());
                     if ($visualizationMode == PAGE_VISUALMODE_CLIENTSPACES_FORM || $visualizationMode == PAGE_VISUALMODE_HTML_EDITION || $visualizationMode == PAGE_VISUALMODE_FORM) {
                         $args["editedMode"] = true;
                     }
                     $cs = $tag->getRepresentationInstance($args);
                     if (is_object($cs)) {
                         $html = $cs->getData($treatmentParameters["language"], $treatmentParameters["page"], $visualizationMode, false);
                     } else {
                         //call generic module clientspace content
                         $cs = new CMS_moduleClientspace($tag->getAttributes());
                         $html = $cs->getClientspaceData($this->_codename, $treatmentParameters["language"], $treatmentParameters["page"], $visualizationMode);
                     }
                     if ($visualizationMode != PAGE_VISUALMODE_PRINT) {
                         //save in global var the page ID who need this module so we can add the header code later.
                         CMS_module::moduleUsage($treatmentParameters["page"]->getID(), $this->_codename, array('block' => true));
                     }
                     break;
                 case 'block':
                     $attributes = $tag->getAttributes();
                     if (!isset($attributes['id'])) {
                         $this->raiseError('Missing attribute id in block tag');
                         return false;
                     }
                     //create the block data
                     $block = $tag->getRepresentationInstance();
                     //instanciate fake row
                     $row = new CMS_row(0, $attributes['id']);
                     //instanciate fake clientspace
                     $cs = new CMS_moduleClientspace($tag->getAttributes());
                     //if block exists, use it
                     if ($block) {
                         $return = $block->getData($treatmentParameters["language"], $treatmentParameters["page"], $cs, $row, $visualizationMode);
                         if ($return) {
                             //save in global var the page ID who need this module so we can add the header code later.
                             CMS_module::moduleUsage($treatmentParameters["page"]->getID(), $this->_codename, array('block' => true));
                         }
                         return $return;
                     } else {
                         //else call module clientspace content
                         $cs = new CMS_moduleClientspace($tag->getAttributes());
                         $return = $cs->getClientspaceData($this->_codename, new CMS_date(), $treatmentParameters["page"], $visualizationMode);
                         if ($visualizationMode != PAGE_VISUALMODE_PRINT && $return) {
                             //save in global var the page ID who need this module so we can add the header code later.
                             CMS_module::moduleUsage($treatmentParameters["page"]->getID(), $this->_codename, array('block' => true));
                         }
                         return $return;
                     }
                     break;
             }
             return $html;
             break;
         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;
             }
             $attributes = $tag->getAttributes();
             //create the block data
             $block = $tag->getRepresentationInstance();
             //if block exists, use it
             if ($block) {
                 $return = $block->getData($treatmentParameters["language"], $treatmentParameters["page"], $treatmentParameters["clientSpace"], $treatedObject, $visualizationMode);
                 if ($return) {
                     //save in global var the page ID who need this module so we can add the header code later.
                     CMS_module::moduleUsage($treatmentParameters["page"]->getID(), $this->_codename, array('block' => true));
                 }
                 return $return;
             } else {
                 //else call module clientspace content
                 $cs = new CMS_moduleClientspace($tag->getAttributes());
                 $return = $cs->getClientspaceData($this->_codename, new CMS_date(), $treatmentParameters["page"], $visualizationMode);
                 if ($visualizationMode != PAGE_VISUALMODE_PRINT && $return) {
                     //save in global var the page ID who need this module so we can add the header code later.
                     CMS_module::moduleUsage($treatmentParameters["page"]->getID(), $this->_codename, array('block' => true));
                 }
                 return $return;
             }
             break;
         case MODULE_TREATMENT_PAGEHEADER_TAGS:
             switch ($tag->getName()) {
                 case "atm-js-tags":
                 case "atm-css-tags":
                     $usage = CMS_module::moduleUsage($treatedObject->getID(), $this->_codename);
                     $return = '';
                     //overwrite previous modules return to append files of this module
                     //only if current page use a block of this module
                     if (isset($usage['block'])) {
                         //save in global var the page ID who use this tag
                         CMS_module::moduleUsage($treatedObject->getID(), $this->_codename, array($tag->getName() => true));
                         //save new modules files
                         switch ($tag->getName()) {
                             case "atm-js-tags":
                                 if (!isset($usage['js-files'])) {
                                     //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, $this->getJSFiles($treatedObject->getID()));
                                     //save files
                                     CMS_module::moduleUsage($treatedObject->getID(), $tag->getName(), $files, true);
                                     //save JS handled
                                     CMS_module::moduleUsage($treatedObject->getID(), $this->_codename, array('js-files' => true));
                                 }
                                 break;
                             case "atm-css-tags":
                                 $media = $tag->getAttribute('media') ? $tag->getAttribute('media') : 'all';
                                 if (!isset($usage['css-media'][$media])) {
                                     $return = '';
                                     //overwrite previous modules return to append files of this module
                                     //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();
                                     //append module css files
                                     $moduleCSSFiles = $this->getCSSFiles($treatedObject->getID());
                                     foreach ($moduleCSSFiles as $filesMedia => $mediaFiles) {
                                         if (!isset($files[$filesMedia])) {
                                             $files[$filesMedia] = array();
                                         }
                                         $files[$filesMedia] = array_merge($files[$filesMedia], $moduleCSSFiles[$filesMedia]);
                                     }
                                     //save files
                                     CMS_module::moduleUsage($treatedObject->getID(), "atm-css-tags", $files, true);
                                     //save media handled
                                     CMS_module::moduleUsage($treatedObject->getID(), $this->_codename, array('css-media' => array($media => 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':
                     //if this page use a row of this module then add the css file if exists to the page
                     $usage = CMS_module::moduleUsage($treatedObject->getID(), $this->_codename);
                     if (isset($usage['block'])) {
                         //append module css files
                         $moduleCSSFiles = $this->getCSSFiles($treatedObject->getID());
                         foreach ($moduleCSSFiles as $media => $mediaFiles) {
                             if (!isset($usage['css-media'][$media])) {
                                 $tagContent .= "\n" . '	<!-- load the style of ' . $this->_codename . ' module for media ' . $media . ' -->' . "\n";
                                 foreach ($moduleCSSFiles[$media] as $cssfile) {
                                     $tagContent .= '	<link rel="stylesheet" type="text/css" href="' . $cssfile . '" media="' . $media . '" />' . "\n";
                                 }
                                 //save media handled
                                 CMS_module::moduleUsage($treatedObject->getID(), $this->_codename, array('css-media' => array($media => true)));
                             }
                         }
                         if (!isset($usage['atm-js-tags'])) {
                             $jsFiles = $this->getJSFiles($treatedObject->getID());
                             if ($jsFiles) {
                                 $tagContent .= "\n" . '	<!-- load js file of ' . $this->_codename . ' module -->' . "\n";
                                 foreach ($jsFiles as $jsfile) {
                                     $tagContent .= '	<script type="text/javascript" src="' . $jsfile . '"></script>' . "\n";
                                 }
                             }
                             //save JS handled
                             CMS_module::moduleUsage($treatedObject->getID(), $this->_codename, array('js-files' => true));
                         }
                     }
                     return $tagContent;
                     break;
             }
             break;
     }
     return $tagContent;
 }
Ejemplo n.º 2
0
 /**
  * Return the module code for the specified treatment mode, visualization mode and object.
  * 
  * @param mixed $modulesCode the previous modules codes (usually string)
  * @param integer $treatmentMode The current treatment mode (see constants on top of this file 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 module code to add
  * @access public
  */
 function getModuleCode($modulesCode, $treatmentMode, $visualizationMode, &$treatedObject, $treatmentParameters)
 {
     switch ($treatmentMode) {
         case MODULE_TREATMENT_EDITOR_CODE:
             if ($treatmentParameters["editor"] == "fckeditor") {
                 $languages = implode(',', array_keys(CMS_languagesCatalog::getAllLanguages(MOD_CMS_FORMS_CODENAME)));
                 //This is an exception of the method, because here we return an array, see admin/fckeditor/fckconfig.php for the detail
                 // add cms_form wizard
                 $modulesCode["modulesDeclaration"][] = "FCKConfig.Plugins.Add( 'cms_forms', '" . $languages . "' );";
                 // create specific cms_form toolbar
                 $modulesCode["ToolbarSets"][] = "FCKConfig.ToolbarSets['cms_forms'] = [\n\t\t\t\t\t\t\t\t['Source','-','Preview'],//['Source','DocProps','-','Save','NewPage','Preview','-','Templates'],\n\t\t\t\t\t\t\t\t['Cut','Copy','Paste','PasteText','PasteWord','-','Print'], //'SpellCheck'],\n\t\t\t\t\t\t\t\t['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],\n\t\t\t\t\t\t\t\t['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],\n\t\t\t\t\t\t\t\t['OrderedList','UnorderedList','-','Outdent','Indent'],\n\t\t\t\t\t\t\t\t['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],\n\t\t\t\t\t\t\t\t['Link','Unlink','Anchor'],\n\t\t\t\t\t\t\t\t['Table','Rule','SpecialChar'],//['Image','Flash','Table','Rule','Smiley','SpecialChar','UniversalKey'],\n\t\t\t\t\t\t\t\t['Style','FontFormat','FontSize'],//['Style','FontFormat','FontName','FontSize'],\n\t\t\t\t\t\t\t\t['TextColor','BGColor'],//\n\t\t\t\t\t\t\t\t//'/',\n\t\t\t\t\t\t\t\t['cms_forms']//,'Checkbox','Radio','TextField','Textarea','Select','Button','HiddenField']\n\t\t\t\t\t\t\t];";
                 return $modulesCode;
             } else {
                 return $modulesCode;
             }
             break;
         case MODULE_TREATMENT_PAGECONTENT_HEADER_CODE:
             //if this page use a row of this module then add the header code to the page (see CMS_block_cms_forms::getData for GLOBAL var creation)
             if ($visualizationMode != PAGE_VISUALMODE_HTML_PUBLIC_INDEXABLE && isset($treatedObject) && isset($GLOBALS[MOD_CMS_FORMS_CODENAME]["pageUseModule"][$treatedObject->getID()])) {
                 //call clientspace header content
                 $cs = new CMS_moduleClientspace(array("module" => MOD_CMS_FORMS_CODENAME, "id" => "cms_forms_header", "type" => "header", "usedforms" => $GLOBALS[MOD_CMS_FORMS_CODENAME]["pageUseModule"][$treatedObject->getID()]));
                 $modulesCode[MOD_CMS_FORMS_CODENAME] = $cs->getClientspaceData(MOD_CMS_FORMS_CODENAME, new CMS_date(), $treatedObject, $visualizationMode);
                 return $modulesCode;
             } else {
                 return $modulesCode;
             }
             break;
         case MODULE_TREATMENT_ROWS_EDITION_LABELS:
             $modulesCode[MOD_CMS_FORMS_CODENAME] = $treatmentParameters["language"]->getMessage(MESSAGE_MOD_CMS_FORMS_ROWS_EXPLANATION, false, MOD_CMS_FORMS_CODENAME);
             return $modulesCode;
             break;
         case MODULE_TREATMENT_TEMPLATES_EDITION_LABELS:
             $modulesCode[MOD_CMS_FORMS_CODENAME] = $treatmentParameters["language"]->getMessage(MESSAGE_MOD_CMS_FORMS_TEMPLATE_EXPLANATION, false, MOD_CMS_FORMS_CODENAME);
             return $modulesCode;
             break;
     }
     return $modulesCode;
 }
Ejemplo n.º 3
0
 /**
  * Gets the data in HTML mode.
  *
  * @param CMS_language &$language The language of the administration frontend
  * @param CMS_page &$page The page which contains the client space
  * @param CMS_clientSpace &$clientSpace The client space which contains the row
  * @param CMS_row &$row The row which contains the block
  * @param integer $visualizationMode The visualization mode used
  * @return string the HTML data
  * @access public
  */
 function getData(&$language, &$page, &$clientSpace, &$row, $visualizationMode)
 {
     parent::getData($language, $page, $clientSpace, $row, $visualizationMode);
     //get the data
     switch ($visualizationMode) {
         case PAGE_VISUALMODE_HTML_PUBLIC:
         case PAGE_VISUALMODE_PRINT:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_USERSPACE, true);
             break;
         case PAGE_VISUALMODE_HTML_EDITED:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_USERSPACE, false);
             break;
         case PAGE_VISUALMODE_HTML_EDITION:
         case PAGE_VISUALMODE_FORM:
         case PAGE_VISUALMODE_CLIENTSPACES_FORM:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_EDITION, false);
             break;
     }
     //build the HTML
     switch ($visualizationMode) {
         case PAGE_VISUALMODE_HTML_PUBLIC:
         case PAGE_VISUALMODE_PRINT:
             if (isset($data["value"]['formID']) && sensitiveIO::IsPositiveInteger($data["value"]['formID'])) {
                 //call cms_forms clientspace content
                 $cs = new CMS_moduleClientspace(array("module" => MOD_CMS_FORMS_CODENAME, "id" => "cms_forms", "type" => "formular", "formID" => $data["value"]['formID']));
                 $html = $cs->getClientspaceData(MOD_CMS_FORMS_CODENAME, new CMS_date(), $page, $visualizationMode);
                 if ($visualizationMode != PAGE_VISUALMODE_PRINT) {
                     //save in global var the page ID who need this module so we can add the header module code later.
                     $GLOBALS[MOD_CMS_FORMS_CODENAME]["pageUseModule"][$this->_pageID][] = $data["value"]['formID'];
                 }
                 return str_replace("{{data}}", $html, $this->_definition);
             }
             break;
         case PAGE_VISUALMODE_HTML_EDITED:
         case PAGE_VISUALMODE_HTML_EDITION:
             if ($data && isset($data["value"]['formID']) && sensitiveIO::IsPositiveInteger($data["value"]['formID'])) {
                 //call cms_forms clientspace content
                 $cs = new CMS_moduleClientspace(array("module" => MOD_CMS_FORMS_CODENAME, "id" => "cms_forms", "type" => "formular", "formID" => $data["value"]['formID']));
                 //$html = $cs->getClientspaceData(MOD_CMS_FORMS_CODENAME, new CMS_date(), $page, $visualizationMode);
                 $form = new CMS_forms_formular($data["value"]['formID']);
                 $html = $form->getContent(CMS_forms_formular::REMOVE_FORM_SUBMIT);
                 return str_replace("{{data}}", $html, $this->_definition);
             }
             break;
         case PAGE_VISUALMODE_FORM:
             if ($data && isset($data["value"]['formID']) && sensitiveIO::IsPositiveInteger($data["value"]['formID'])) {
                 $form = new CMS_forms_formular($data["value"]['formID']);
                 $html = $form->getContent(CMS_forms_formular::REMOVE_FORM_SUBMIT);
             } else {
                 $html = '<img src="' . PATH_MODULES_FILES_WR . '/' . MOD_CMS_FORMS_CODENAME . '/demo.gif" alt="X" title="X" />';
             }
             $form_data = str_replace("{{data}}", $html, $this->_definition);
             $this->_hasContent = $data && isset($data["value"]['formID']) ? true : false;
             $this->_editable = true;
             global $cms_user;
             $module = CMS_modulesCatalog::getByCodename(MOD_CMS_FORMS_CODENAME);
             $this->_administrable = $module->hasAdmin() && $cms_user->hasModuleClearance(MOD_CMS_FORMS_CODENAME, CLEARANCE_MODULE_EDIT);
             return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             break;
         case PAGE_VISUALMODE_CLIENTSPACES_FORM:
             $this->_hasContent = $this->_editable = $this->_administrable = false;
             $html = '<img src="' . PATH_MODULES_FILES_WR . '/' . MOD_CMS_FORMS_CODENAME . '/demo.gif" alt="X" title="X" />';
             $form_data = str_replace("{{data}}", $html, $this->_definition);
             return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             break;
     }
 }