/** * Write to disk the linx file, i.e. the content for the specified page. * Doesn't translates the atm-linx tags. * Also writes the "print" linx file * * @return boolean true on success, false on failure to write the content to this file. * @access private */ function writeLinxFile() { $defaultLanguage = CMS_languagesCatalog::getDefaultLanguage(); //get public page content (without linxes process) $pageContent = $this->getContent($defaultLanguage, PAGE_VISUALMODE_HTML_PUBLIC); //then write the page linx file $linxFile = new CMS_file($this->getLinxFilePath()); $linxFile->setContent($pageContent); if (!$linxFile->writeToPersistence()) { $this->raiseError("Can't write linx file : " . $this->getLinxFilePath()); return false; } //writes the "print" linx file if any if (USE_PRINT_PAGES && $this->_template->getPrintingClientSpaces()) { //get print page content (without linxes process) $printPageContent = $this->getContent($defaultLanguage, PAGE_VISUALMODE_PRINT); //then write the print page linx file $linxFile = new CMS_file($this->getLinxFilePath() . ".print", CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE); $linxFile->setContent($printPageContent); if (!$linxFile->writeToPersistence()) { $this->raiseError("Can't write print linx file : " . $this->getLinxFilePath() . ".print"); return false; } } return true; }
// +----------------------------------------------------------------------+ // // $Id: index.php,v 1.12 2010/03/08 16:41:18 sebastien Exp $ /** * PHP page : index * Manages the login and logout of users. Creates the context and put it into $_SESSION. * * @package Automne * @subpackage admin * @author Sébastien Pauchet <*****@*****.**> */ require_once dirname(__FILE__) . '/../../cms_rc_admin.php'; define("MESSAGE_PAGE_TITLE", 51); define("MESSAGE_PAGE_LOADING", 1321); //load language object $language = CMS_languagesCatalog::getDefaultLanguage(true); //load interface instance $view = CMS_view::getInstance(); //set main and ext CSS $view->addCSSFile('ext'); $view->addCSSFile('main'); $view->addCSSFile('codemirror'); if (SYSTEM_DEBUG) { $view->addCSSFile('debug'); } //set needed JS files if (SYSTEM_DEBUG) { $jsfiles = array('ext', 'debug', 'codemirror', 'main'); } else { $jsfiles = array('ext', 'codemirror', 'main'); }
/** * Constructor * * @access public * @param integer $id * @param boolean $public if only public data to retrieve * @param CMS_profile_user $cms_user */ function __construct($id, $cms_user = false) { if ($id) { if (!SensitiveIO::isPositiveInteger($id)) { $this->raiseError("Id is not a positive integer"); return; } $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_cms_forms_formulars\n\t\t\t\twhere\n\t\t\t\t\tid_frm='" . $id . "'\n\t\t\t"; $q = new CMS_query($sql); if ($q->getNumRows()) { $data = $q->getArray(); $this->_formID = $id; $this->_name = $data["name_frm"]; $this->_source = $data["source_frm"]; $this->_public = $data["closed_frm"] > 0 ? false : true; // Form creator $this->_ownerID = (int) $data["owner_frm"]; $this->_language = new CMS_language($data["language_frm"]); $this->_responses = (int) $data["responses_frm"]; } else { $this->raiseError("Unknown ID :" . $id); } } else { $this->_public = true; if (is_a($cms_user, 'CMS_profile_user')) { $this->_ownerID = $cms_user->getID(); } $this->_language = CMS_languagesCatalog::getDefaultLanguage(); } }
/** * get an object field * * @param integer $fieldID : the field to get * @return mixed : the object field * @access public */ function objectValues($fieldID) { if (!isset($this->_objectValues[$fieldID])) { global $cms_language; $language = $cms_language ? $cms_language : CMS_languagesCatalog::getDefaultLanguage(); $objectDef = $this->getObjectDefinition(); $this->raiseError('Object field with ID ' . $fieldID . ' does not exists as a field of object ' . $objectDef->getObjectLabel($language)); return $this; } return $this->_objectValues[$fieldID]; }
/** * Get object as an array structure used for export * * @param array $params The export parameters. * array( * categories => false|true : export module categories (default : true) * rows => false|true : export module rows (default : true) * css => false|true : export module JS (default : true) * js => false|true : export module CSS (default : true) * ) * @param array $files The reference to the found files used by object * @return array : the object array structure * @access public */ public function asArray($params = array(), &$files) { if (!is_array($files)) { $files = array(); } $aModule = array('codename' => $this->_codename, 'polymod' => false, 'labels' => CMS_language::getMessages(1, $this->_codename), 'parameters' => $this->getParameters(false, true)); $defaultLanguage = CMS_languagesCatalog::getDefaultLanguage(); if (in_array('categories', $params)) { global $cms_user; if (APPLICATION_ENFORCES_ACCESS_CONTROL != false && isset($cms_user)) { $categories = $this->getModuleCategories(array('language' => $defaultLanguage, 'root' => 0, 'cms_user' => $cms_user)); } else { $categories = $this->getModuleCategories(array('language' => $defaultLanguage, 'root' => 0)); } foreach ($categories as $category) { $aModule['categories'][] = $category->asArray($params, $files); } } if (in_array('rows', $params)) { $modulesRows = CMS_rowsCatalog::getByModules(array($this->_codename)); if ($this->_codename != MOD_STANDARD_CODENAME) { $modulesStandardRows = CMS_rowsCatalog::getByModules(array($this->_codename, MOD_STANDARD_CODENAME)); foreach ($modulesStandardRows as $id => $row) { $modulesRows[$id] = $row; } } foreach ($modulesRows as $row) { $aModule['rows'][] = $row->asArray($params, $files); } } if (in_array('js', $params)) { $jsFiles = $this->getJSFiles('', true); $aModule['js'] = array(); if ($jsFiles) { foreach ($jsFiles as $key => $jsFile) { $jsFiles[$key] = '/' . $jsFile; } $aModule['js'] = $jsFiles; $files = array_merge($files, $jsFiles); } } if (in_array('css', $params)) { $cssFiles = $this->getCSSFiles('', true); $aModule['css'] = array(); if ($cssFiles) { foreach ($cssFiles as $media => $cssMediaFiles) { if ($cssMediaFiles) { foreach ($cssMediaFiles as $key => $cssFile) { $cssMediaFiles[$key] = '/' . $cssFile; } $files = array_merge($files, $cssMediaFiles); $aModule['css'] = array_merge($aModule['css'], $cssMediaFiles); } } } } if (in_array('img', $params)) { $imgFiles = array(); $aModule['css'] = array(); if (is_dir(PATH_REALROOT_FS . '/img/modules/' . $this->getCodename())) { $imgFiles = glob(PATH_REALROOT_FS . '/img/modules/' . $this->getCodename() . '/*.*', GLOB_NOSORT); } if ($imgFiles && is_array($imgFiles)) { foreach ($imgFiles as $key => $imgFile) { $imgFiles[$key] = str_replace(PATH_REALROOT_FS, '', $imgFile); } $aModule['img'] = $imgFiles; $files = array_merge($files, $imgFiles); } } return $aModule; }
/** * get an object field * * @param integer $fieldID : the field to get. If empty, return an array of all objects values * @return mixed : the object field or an array of the object fields * @access public */ function objectValues($fieldID = '') { if (!$fieldID) { return $this->_objectValues; } else { if (!isset($this->_objectValues[$fieldID])) { global $cms_language; $language = $cms_language ? $cms_language : CMS_languagesCatalog::getDefaultLanguage(); $this->raiseError('Object field with ID ' . $fieldID . ' does not exists as a field of object ' . $this->getFieldLabel($language) . ' (' . $this->_objectID . ') - ' . io::getCallInfos(3)); //return dummy object field (correct bug 536) return new CMS_poly_object($this->_objectID); } return $this->_objectValues[$fieldID]; } }
/** * Destroy the module * * @return void * @access public */ function destroy() { global $cms_user; // Check module exists and is polymod if (!$this->isDestroyable()) { return false; } // CHECK USED ROWS $rowsIds = CMS_rowsCatalog::getByModules(array($this->_codename), false, false); //delete all module rows foreach ($rowsIds as $rowId) { $row = CMS_rowsCatalog::getByID($rowId); if (is_object($row)) { $row->destroy(); } } // TREAT CATEGORIES $attrs = array("module" => $this->_codename, "language" => CMS_languagesCatalog::getDefaultLanguage(), "level" => -1, "root" => -1, "cms_user" => $cms_user, "clearanceLevel" => CLEARANCE_MODULE_EDIT, "strict" => false); $cats = CMS_moduleCategories_catalog::getAll($attrs); if ($cats) { foreach ($cats as $cat) { // Destroy category $cat->destroy(); } } // TREAT MODULE & VALIDATIONS RIGHTS $sql = "\n\t\t\tselect \n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\tprofiles\n\t\t\twhere\n\t\t\t\tmoduleClearancesStack_pr like '" . io::sanitizeSQLString($this->_codename) . ",%'\n\t\t\t\t or moduleClearancesStack_pr like '%;" . io::sanitizeSQLString($this->_codename) . ",%'\n\t\t "; $q = new CMS_query($sql); if ($q->getNumRows()) { while ($r = $q->getArray()) { $stack = new CMS_stack(); $stack->setTextDefinition($r['moduleClearancesStack_pr']); $stack->delAllWithOneKey($this->_codename); $qInsert = new CMS_query("update profiles set moduleClearancesStack_pr='" . io::sanitizeSQLString($stack->getTextDefinition()) . "' where id_pr='" . $r['id_pr'] . "'"); } } $sql = "\n\t\t\tselect \n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\tprofiles\n\t\t\twhere\n\t\t\t\tvalidationClearancesStack_pr like '" . io::sanitizeSQLString($this->_codename) . ";%'\n\t\t\t\t or validationClearancesStack_pr like '%;" . io::sanitizeSQLString($this->_codename) . ";%'\n\t\t\t\t or validationClearancesStack_pr = '" . io::sanitizeSQLString($this->_codename) . "'\n\t\t\t"; $q = new CMS_query($sql); if ($q->getNumRows()) { while ($r = $q->getArray()) { $stack = new CMS_stack(); $stack->setTextDefinition($r['validationClearancesStack_pr']); $stack->delAllWithOneKey($this->_codename); $qInsert = new CMS_query("update profiles set validationClearancesStack_pr='" . io::sanitizeSQLString($stack->getTextDefinition()) . "' where id_pr='" . $r['id_pr'] . "'"); } } //remove module files if (CMS_file::deltreeSimulation(PATH_MODULES_FILES_FS . '/' . $this->_codename, true)) { CMS_file::deltree(PATH_MODULES_FILES_FS . '/' . $this->_codename, true); } //remove JS and CSS if (is_dir(PATH_JS_FS . '/modules/' . $this->_codename) && CMS_file::deltreeSimulation(PATH_JS_FS . '/modules/' . $this->_codename, true)) { CMS_file::deltree(PATH_JS_FS . '/modules/' . $this->_codename, true); } if (is_dir(PATH_CSS_FS . '/modules/' . $this->_codename) && CMS_file::deltreeSimulation(PATH_CSS_FS . '/modules/' . $this->_codename, true)) { CMS_file::deltree(PATH_CSS_FS . '/modules/' . $this->_codename, true); } $cssFiles = $this->getCSSFiles('', true); foreach ($cssFiles as $mediaCssFiles) { foreach ($mediaCssFiles as $cssFile) { CMS_file::deleteFile(PATH_REALROOT_FS . '/' . $cssFile); } } //Clear polymod cache //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $this->_codename)); CMS_cache::clearTypeCache('polymod'); // Destroy module return parent::destroy(); }
<fieldset> <legend>Inclure une description</legend> <textarea style="width:100%;height:150px;" name="desc">' . io::htmlspecialchars(io::post('desc')) . '</textarea> </fieldset><br /><br /> <input type="submit" class="admin_input_submit" value="' . $cms_language->getMessage(MESSAGE_PAGE_EXPORT_MODULE) . '" /> </form>'; switch (io::post('action')) { case 'export': if (io::post('desc')) { $options['description'] = io::post('desc'); } //set export parameters $export->setParameters($options); //force default language loading to overwrite user language because datas is more accurate in default language $oldLanguage = $cms_language->getCode(); $cms_language = CMS_languagesCatalog::getDefaultLanguage(false); //export datas $exportDatas = $export->export($format); //reload user language $cms_language = CMS_languagesCatalog::getByCode($oldLanguage); switch ($format) { case 'php': $content .= ' <br /><a name="exportDatas"></a> <fieldset> <legend>' . $cms_language->getMessage(MESSAGE_PAGE_EXPORTED_DATAS) . '</legend> <textarea style="width:100%;height:300px;">' . htmlspecialchars(var_export($exportDatas, true)) . '</textarea> </fielset>'; break; case 'xml': $content .= '