예제 #1
0
 /**
  * Constructor
  * 
  * @param string $codename, the codename of the module to export datas
  * @return void
  */
 function __construct($codename)
 {
     if (!in_array($codename, CMS_modulesCatalog::getAllCodenames())) {
         $this->raiseError('Unknown module : ' . $codename);
         return false;
     }
     $this->_module = $codename;
     //only polymod for now, but can be switched by modules later
     $this->_hasExport = CMS_modulesCatalog::isPolymod($this->_module);
     if ($this->_hasExport) {
         $this->_defaultParameters = array('objects', 'categories', 'rows', 'css', 'js', 'img');
         $this->_availableParameters = array('objects' => self::MESSAGE_PARAM_OBJECTS, 'categories' => self::MESSAGE_PARAM_CATEGORIES, 'rows' => self::MESSAGE_PARAM_ROWS, 'css' => self::MESSAGE_PARAM_CSS, 'js' => self::MESSAGE_PARAM_JS, 'img' => self::MESSAGE_PARAM_IMG);
     }
 }
예제 #2
0
         $content = $codeTopaste;
     } else {
         $selectedContent = $selectedContent ? $selectedContent : ' ';
         $content = $selectedContent;
     }
     break;
 case 'setRowParameters':
     $tpl = sensitiveIO::request('template', 'sensitiveIO::isPositiveInteger');
     $rowId = sensitiveIO::request('rowType', 'sensitiveIO::isPositiveInteger');
     $rowTag = sensitiveIO::request('rowTag');
     $cs = sensitiveIO::request('cs');
     $currentPage = sensitiveIO::request('page', 'sensitiveIO::isPositiveInteger', CMS_session::getPageID());
     $blockId = sensitiveIO::request('block');
     $blockClass = sensitiveIO::request('blockClass');
     $value = sensitiveIO::request('value', 'is_array');
     $codename = sensitiveIO::request('module', CMS_modulesCatalog::getAllCodenames());
     $cms_page = CMS_tree::getPageByID($currentPage);
     //RIGHTS CHECK
     if (!is_object($cms_page) || $cms_page->hasError() || !$cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_EDIT) || !$cms_user->hasModuleClearance(MOD_STANDARD_CODENAME, CLEARANCE_MODULE_EDIT)) {
         CMS_grandFather::raiseError('Insufficient rights on page ' . $cms_page->getID());
         break;
     }
     //CHECKS user has module clearance
     if (!$cms_user->hasModuleClearance($codename, CLEARANCE_MODULE_EDIT)) {
         CMS_grandFather::raiseError('Error, user has no rights on module : ' . $codename);
         break;
     }
     //ARGUMENTS CHECK
     if (!$cs || !$rowTag || !$rowId || !$blockId) {
         CMS_grandFather::raiseError('Data missing ...');
         break;
 /**
  * Compute an atm-cache-reference tag
  *
  * @param array $tag : the reference atm-cache-reference tag to compute
  * @return void
  * @access private
  */
 protected function _cacheReference($tag)
 {
     $codenames = CMS_modulesCatalog::getAllCodenames();
     //check tags requirements
     if (!$this->checkTagRequirements($tag, array('element' => '(' . implode($codenames, '|') . '|users)'))) {
         return;
     }
     if (in_array($tag['attributes']['element'], $codenames)) {
         $this->_elements['module'][] = $tag['attributes']['element'];
     } else {
         $this->_elements['resource'][] = $tag['attributes']['element'];
     }
     return '';
 }
예제 #4
0
 /**
  * Import module from given array datas
  *
  * @param array $data The module datas to import
  * @param array $params The import parameters.
  *		array(
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 static function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     $return = true;
     foreach ($data as $moduleDatas) {
         if (!isset($moduleDatas['codename'])) {
             $infos .= 'Missing codename ...' . "\n";
             return false;
         }
         //check if module exists
         $codenames = CMS_modulesCatalog::getAllCodenames();
         //instanciate module
         $importType = '';
         if (isset($codenames[$moduleDatas['codename']])) {
             if (!isset($params['update']) || $params['update'] == true) {
                 $module = CMS_modulesCatalog::getByCodename($moduleDatas['codename']);
                 $infos .= 'Get Module ' . $module->getLabel($cms_language) . ' for update...' . "\n";
                 $importType = ' (Update)';
             } else {
                 $infos .= 'Module already exists and parameter does not allow to update it ...' . "\n";
                 return false;
             }
         } else {
             if (!isset($params['create']) || $params['create'] == true) {
                 $infos .= 'Create new module for imported datas...' . "\n";
                 $importType = ' (Creation)';
                 if (isset($moduleDatas['polymod']) && $moduleDatas['polymod']) {
                     $module = new CMS_polymod();
                 } else {
                     $module = new CMS_module();
                 }
             } else {
                 $infos .= 'Module does not exists and parameter does not allow to create it ...' . "\n";
                 return false;
             }
         }
         if ($module->fromArray($moduleDatas, $params, $cms_language, $idsRelation, $infos)) {
             $return &= true;
             $infos .= 'Module "' . $module->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
         } else {
             $return = false;
             $infos .= 'Error during import of module ' . $moduleDatas['codename'] . $importType . "\n";
         }
     }
     return $return;
 }
예제 #5
0
 */
// *******************************************************************************
// **   IMAGE FILE HANDLER. THIS PHP CODE IS NEEDED TO DOWNLOAD IMAGES          **
// *******************************************************************************
//disactive HTML compression
define("ENABLE_HTML_COMPRESSION", false);
//only cms_rc needed in this case : no extra loading
define('APPLICATION_USER_TYPE', 'file');
require_once dirname(__FILE__) . '/cms_rc.php';
$replace = array('..' => '', '\\' => '', '/' => '');
//Get image vars
$image = io::get('image');
$location = io::get('location') && isset($_SERVER["HTTP_REFERER"]) && strpos($_SERVER["HTTP_REFERER"], "automne/admin") !== false ? io::get('location') : RESOURCE_DATA_LOCATION_PUBLIC;
$location = in_array($location, array(RESOURCE_DATA_LOCATION_EDITED, RESOURCE_DATA_LOCATION_EDITION, RESOURCE_DATA_LOCATION_PUBLIC)) ? $location : '';
$module = io::get('module') ? io::get('module') : 'standard';
$module = in_array($module, CMS_modulesCatalog::getAllCodenames()) ? $module : '';
$x = io::get('x', 'io::isPositiveInteger');
$y = io::get('y', 'io::isPositiveInteger');
$crop = io::get('crop') && $x && $y ? true : false;
if ($image != io::htmlspecialchars(str_replace(array_keys($replace), $replace, $image))) {
    $image = '';
}
//missing datas : send 404
if (!$image || !$module || !$location) {
    //send 404 headers
    header('HTTP/1.x 404 Not Found', true, 404);
    //send image 404
    if (file_exists(PATH_REALROOT_FS . '/img/404.png')) {
        CMS_file::downloadFile(PATH_REALROOT_FS . '/img/404.png');
        exit;
    }
예제 #6
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_PAGECONTENT_HEADER_CODE:
                //if this page use a row of this module then add the header code to the page
                if ($usage = CMS_module::moduleUsage($treatedObject->getID(), $this->_codename)) {
                    if (isset($usage['headCallback'])) {
                        $modulesCode[$this->_codename] = '';
                        foreach ($usage['headCallback'] as $headCallback) {
                            //add header codes
                            if (isset($headCallback['tagsCallback'])) {
                                foreach ($headCallback['tagsCallback'] as $key => $headcode) {
                                    if (isset($headcode['code'])) {
                                        $modulesCode[$this->_codename] .= '<?php' . "\n" . $headCallback['headcode'] . "\n" . $headcode['code'] . "\n" . '?>';
                                    }
                                }
                            }
                            //add forms header if needed
                            if (isset($headCallback['form']) && $headCallback['form']) {
                                $modulesCode[$this->_codename] .= '<?php CMS_poly_definition_functions::formActions(' . var_export($headCallback['form'], true) . ', \'' . $treatedObject->getID() . '\', \'' . $headCallback['language'] . '\', ' . ($visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC || $visualizationMode == PAGE_VISUALMODE_PRINT || $visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC_INDEXABLE ? 'true' : 'false') . ', $polymodFormsError, $polymodFormsItems); ?>';
                            }
                            //add forms callback if needed
                            if (isset($headCallback['formsCallback']) && is_array($headCallback['formsCallback']) && isset($headCallback['headcode'])) {
                                foreach ($headCallback['formsCallback'] as $formName => $formCallback) {
                                    foreach ($formCallback as $formFieldID => $callback) {
                                        if (io::isPositiveInteger($formFieldID)) {
                                            $modulesCode[$this->_codename] .= '<?php' . "\n" . '//callback function to check field ' . $formFieldID . ' for atm-form ' . $formName . "\n" . 'function form_' . $formName . '_' . $formFieldID . '($formName, $fieldID, &$item_' . $formName . '_' . $formFieldID . ') {' . "\n" . '		global $cms_user;' . "\n" . '		global $public_search;' . "\n" . '		global $cms_language;' . "\n" . '       $object[$item_' . $formName . '_' . $formFieldID . '->getObjectID()] = $item_' . $formName . '_' . $formFieldID . ';' . "\n" . '       ' . $headCallback['headcode'] . "\n" . '       ' . $callback . "\n" . '       return false;' . "\n" . '}' . "\n" . '?>';
                                        } elseif ($formFieldID == 'form') {
                                            $modulesCode[$this->_codename] .= '<?php' . "\n" . '//callback function for atm-form ' . $formName . "\n" . 'function form_' . $formName . '($formName, &$item_' . $formName . ') {' . "\n" . '		global $cms_user;' . "\n" . '		global $public_search;' . "\n" . '		global $cms_language;' . "\n" . '       $object[$item_' . $formName . '->getObjectID()] = $item_' . $formName . ';' . "\n" . '       ' . $headCallback['headcode'] . "\n" . '       ' . $callback . "\n" . '       return true;' . "\n" . '}' . "\n" . '?>';
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return $modulesCode;
                break;
            case MODULE_TREATMENT_ROWS_EDITION_LABELS:
                $modulesCode[$this->_codename] = '';
                //if user has rights on module
                if ($treatmentParameters["user"]->hasModuleClearance($this->_codename, CLEARANCE_MODULE_EDIT)) {
                    if (!isset($treatmentParameters['request'])) {
                        //add form to choose object to display
                        $modulesCode[$this->_codename] = '
							<h1>' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_ROW_TAGS_CHOOSE, false, MOD_POLYMOD_CODENAME) . '<select onchange="Ext.get(\'help' . $this->_codename . '\').getUpdater().update({url: \'' . PATH_ADMIN_WR . '/help-detail.php\',params: {module: \'' . $this->_codename . '\',object: this.value, mode:' . MODULE_TREATMENT_ROWS_EDITION_LABELS . '}});">
								<option value="">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_CHOOSE) . '</option>
								<optgroup label="' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_ROW_TAGS_EXPLANATION, false, MOD_POLYMOD_CODENAME) . '">
									<option value="block">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_BLOCK_TAGS, false, MOD_POLYMOD_CODENAME) . '</option>
									<option value="search">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_SEARCH_TAGS, false, MOD_POLYMOD_CODENAME) . '</option>
									<option value="working">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_WORKING_TAGS) . '</option>
									<option value="working-polymod">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_WORKING_POLYMOD_TAGS, false, MOD_POLYMOD_CODENAME) . '</option>
									<option value="vars">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_BLOCK_GENERAL_VARS) . '</option>
									<option value="forms">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_BLOCK_FORMS, false, MOD_POLYMOD_CODENAME) . '</option>
								</optgroup>
								<optgroup label="' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_ROW_OBJECTS_VARS_EXPLANATION, false, MOD_POLYMOD_CODENAME) . '">';
                        $modulesCode[$this->_codename] .= CMS_poly_module_structure::viewObjectInfosList($this->_codename, $treatmentParameters["language"], @$treatmentParameters['request'][$this->_codename . 'object']);
                        $modulesCode[$this->_codename] .= '
								</optgroup>';
                        $modulesCode[$this->_codename] .= '
							</select></h1>
							<div id="help' . $this->_codename . '"></div>
						';
                    }
                    //then display chosen object infos
                    if (isset($treatmentParameters['request'][$this->_codename]) && isset($treatmentParameters['request'][$this->_codename . 'object'])) {
                        switch ($treatmentParameters['request'][$this->_codename . 'object']) {
                            case 'block':
                                $moduleLanguages = CMS_languagesCatalog::getAllLanguages($this->_codename);
                                foreach ($moduleLanguages as $moduleLanguage) {
                                    $moduleLanguagesCodes[] = $moduleLanguage->getCode();
                                }
                                $modulesCode[$this->_codename] .= $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_BLOCK_TAGS_EXPLANATION, array($this->_codename, implode(', ', $moduleLanguagesCodes)), MOD_POLYMOD_CODENAME);
                                break;
                            case 'search':
                                $modulesCode[$this->_codename] .= $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_SEARCH_TAGS_EXPLANATION, false, MOD_POLYMOD_CODENAME);
                                break;
                            case 'working':
                                $modulesCode[$this->_codename] .= $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_WORKING_TAGS_EXPLANATION);
                                break;
                            case 'working-polymod':
                                $modulesCode[$this->_codename] .= $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_WORKING_POLYMOD_TAGS_EXPLANATION, array(implode(', ', CMS_modulesCatalog::getAllCodenames())), MOD_POLYMOD_CODENAME);
                                break;
                            case 'vars':
                                $modulesCode[$this->_codename] .= $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_BLOCK_GENERAL_VARS_EXPLANATION, array($treatmentParameters["language"]->getDateFormatMask(), $treatmentParameters["language"]->getDateFormatMask(), $treatmentParameters["language"]->getDateFormatMask()));
                                break;
                            case 'forms':
                                $modulesCode[$this->_codename] .= $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_BLOCK_FORMS_EXPLANATION, false, MOD_POLYMOD_CODENAME);
                                break;
                            default:
                                //object info
                                $modulesCode[$this->_codename] .= CMS_poly_module_structure::viewObjectRowInfos($this->_codename, $treatmentParameters["language"], $treatmentParameters['request'][$this->_codename . 'object']);
                                break;
                        }
                    }
                }
                return $modulesCode;
                break;
            case MODULE_TREATMENT_EDITOR_CODE:
                if ($treatmentParameters["editor"] == "fckeditor" && $treatmentParameters["user"]->hasModuleClearance($this->_codename, CLEARANCE_MODULE_EDIT)) {
                    if (!isset($modulesCode["Default"]['polymod'])) {
                        $pluginDefinitions = CMS_poly_object_catalog::getAllPluginDefinitionsForObject();
                        if (is_array($pluginDefinitions) && $pluginDefinitions) {
                            $languages = implode(',', array_keys(CMS_languagesCatalog::getAllLanguages()));
                            //This is an exception of the method, because here we return an array, see admin/fckeditor/fckconfig.php for the detail
                            $modulesCode["Default"]['polymod'] = "'polymod'";
                            $modulesCode["modulesDeclaration"]['polymod'] = "FCKConfig.Plugins.Add( 'polymod', '" . $languages . "' );";
                        }
                    }
                    $plugins = array();
                    //get all objects for module
                    $moduleObjects = CMS_poly_object_catalog::getObjectsForModule($this->_codename);
                    foreach ($moduleObjects as $object) {
                        $fields = CMS_poly_object_catalog::getFieldsDefinition($object->getID());
                        foreach ($fields as $field) {
                            $fieldObject = $field->getTypeObject(true);
                            if (method_exists($fieldObject, 'getUsedPlugins')) {
                                $plugins = array_merge($plugins, $fieldObject->getUsedPlugins());
                            }
                        }
                    }
                    $plugins = array_unique($plugins);
                    // create specific polymod toolbar
                    $modulesCode["ToolbarSets"][] = "FCKConfig.ToolbarSets[\"" . $this->_codename . "\"] = [\n\t\t\t\t\t\t\t\t['Source','Undo','Redo'],\n\t\t\t\t\t\t\t\t['Cut','Copy','Paste','PasteText','PasteWord'],\n\t\t\t\t\t\t\t\t['OrderedList','UnorderedList','-','Outdent','Indent'],\n\t\t\t\t\t\t\t\t['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],\n\t\t\t\t\t\t\t\t['Link','Unlink','Anchor'" . ($plugins ? ',' . implode(",", $plugins) : '') . "],\n\t\t\t\t\t\t\t\t['Table','Rule','SpecialChar']\n\t\t\t\t\t\t\t];";
                }
                return $modulesCode;
                break;
            case MODULE_TREATMENT_EDITOR_PLUGINS:
                if ($treatmentParameters["editor"] == "fckeditor" && $treatmentParameters["user"]->hasModuleClearance($this->_codename, CLEARANCE_MODULE_EDIT)) {
                    if (!isset($modulesCode['polymod'])) {
                        $modulesCode['polymod'] = '';
                        $pluginDefinitions = CMS_poly_object_catalog::getAllPluginDefinitionsForObject();
                        if (is_array($pluginDefinitions) && $pluginDefinitions) {
                            foreach ($pluginDefinitions as $pluginDefinition) {
                                $modulesCode['polymod'] .= $modulesCode['polymod'] ? ', ' : '';
                                $modulesCode['polymod'] .= $pluginDefinition->getLabel($treatmentParameters["user"]->getLanguage());
                            }
                        }
                    }
                }
                break;
            case MODULE_TREATMENT_AFTER_VALIDATION_TREATMENT:
                //if object is a polyobject and module is the current object's module
                if ($treatedObject instanceof CMS_poly_object && $this->_codename == CMS_poly_object_catalog::getModuleCodenameForObject($treatedObject->getID())) {
                    //send notification of the validation result to polyobject
                    $treatedObject->afterValidation($treatmentParameters['result']);
                }
                break;
            case MODULE_TREATMENT_ALERTS:
                //only if user has validation clearances
                if ($treatmentParameters['user']->hasValidationClearance($this->_codename)) {
                    $modulesCode[$this->_codename] = array(ALERT_LEVEL_VALIDATION => array('label' => self::MESSAGE_ALERT_LEVEL_VALIDATION, 'description' => self::MESSAGE_ALERT_LEVEL_VALIDATION_DESCRIPTION));
                }
                return $modulesCode;
                break;
        }
        return $modulesCode;
    }