/** * Access to a filename path * * @access public * @param mixed $language : CMS_language or language code * @param boolean $withPath If false, only returns the filename * @param string $dataLocation Where does the data lies ? See CMS_resource constants * @param integer $relativeTo Can be web root or filesystem relative, see base constants * @param boolean $withFilename Should the function return the filename too or only the path ? * @return string */ function getFilePath($language = false, $withPath = true, $relativeTo = PATH_RELATIVETO_WEBROOT, $withFilename = true) { if (!$this->_files) { $this->_retrieveLabels(); } if (!$language && is_object($this->_language)) { $language = $this->_language->getCode(); } elseif (is_a($language, 'CMS_language')) { $language = $language->getCode(); } if (!$language) { return ''; } if ($withPath) { switch ($relativeTo) { case PATH_RELATIVETO_WEBROOT: $path = PATH_MODULES_FILES_WR . "/" . $this->_moduleCodename . "/" . RESOURCE_DATA_LOCATION_PUBLIC; break; case PATH_RELATIVETO_FILESYSTEM: $path = PATH_MODULES_FILES_FS . "/" . $this->_moduleCodename . "/" . RESOURCE_DATA_LOCATION_PUBLIC; break; } if ($withFilename) { return $path . "/" . $this->_files[$language]; } else { return $path; } return false; } elseif (isset($this->_files[$language])) { return $this->_files[$language]; } else { return ''; } }
/** * Returns the html needed by the editor * * @return string * @access public */ function getHTML() { $value = $this->_initialContent; // Editor base path $sBasePath = PATH_MAIN_WR . '/fckeditor/'; $oFCKeditor = new FCKeditor($this->_formField); $oFCKeditor->BasePath = $sBasePath; $oFCKeditor->Config['AutoDetectLanguage'] = false; $oFCKeditor->Config['DefaultLanguage'] = $this->_language->getCode(); $oFCKeditor->Value = $value; if (is_array($this->_editorAttributes)) { while (list($k, $v) = @each($this->_editorAttributes)) { if ($v != '') { $oFCKeditor->{$k} = $v; } } } if (is_array($this->_editorConfigAttributes)) { while (list($k, $v) = @each($this->_editorConfigAttributes)) { if ($v != '') { $oFCKeditor->Config[$k] = $v; } } } return $oFCKeditor->Create(); }
/** * Writes the news into persistence (MySQL for now), along with base data. * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { //save data $closed = $this->_public === true ? 0 : 1; $sql_fields = "\n\t\t\towner_frm='" . $this->_ownerID . "',\n\t\t\tlanguage_frm='" . SensitiveIO::sanitizeSQLString($this->_language->getCode()) . "',\n\t\t\tname_frm='" . SensitiveIO::sanitizeSQLString($this->_name) . "',\n\t\t\tsource_frm='" . SensitiveIO::sanitizeSQLString($this->_source) . "',\n\t\t\tresponses_frm='" . SensitiveIO::sanitizeSQLString($this->_responses) . "',\n\t\t\tclosed_frm='" . $closed . "'"; if ($this->_formID) { $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tmod_cms_forms_formulars\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_frm='" . $this->_formID . "'\n\t\t\t"; } else { $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tmod_cms_forms_formulars\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields; } $q = new CMS_query($sql); if ($q->hasError()) { $this->raiseError("Failed to write"); return false; } elseif (!$this->_formID) { $this->_formID = $q->getLastInsertedID(); } //then create the 4 defaut actions for this form if hasn't any if (!$this->hasActions()) { //Form answer excedeed $alreadyFoldAction = new CMS_forms_action(); $alreadyFoldAction->setInteger("form", $this->_formID); $alreadyFoldAction->setInteger("type", CMS_forms_action::ACTION_ALREADY_FOLD); $alreadyFoldAction->setString("value", 'text'); $alreadyFoldAction->writeToPersistence(); //Save form results in DB $dbAction = new CMS_forms_action(); $dbAction->setInteger("form", $this->_formID); $dbAction->setInteger("type", CMS_forms_action::ACTION_DB); $dbAction->writeToPersistence(); //form OK $okAction = new CMS_forms_action(); $okAction->setInteger("form", $this->_formID); $okAction->setInteger("type", CMS_forms_action::ACTION_FORMOK); $okAction->setString("value", 'text'); $okAction->writeToPersistence(); //form NOK $nokAction = new CMS_forms_action(); $nokAction->setInteger("form", $this->_formID); $nokAction->setInteger("type", CMS_forms_action::ACTION_FORMNOK); $nokAction->setString("value", 'text'); $nokAction->writeToPersistence(); } return true; }
$comboLanguages = sensitiveIO::jsonEncode($comboLanguages); $datesFormat = array(array('format' => '', 'label' => '-'), array('format' => 'd/m/Y', 'label' => date('d/m/Y') . ' (d/m/Y)'), array('format' => 'm/d/Y', 'label' => date('m/d/Y') . ' (m/d/Y)'), array('format' => 'Y/m/d', 'label' => date('Y/m/d') . ' (Y/m/d)')); $datesFormat = sensitiveIO::jsonEncode($datesFormat); $modules = CMS_modulesCatalog::getAll(); $modulesDenied = $language->getModulesDenied(); $availableModules = $excludedModules = array(); foreach ($modules as $codename => $module) { if (in_array($codename, $modulesDenied)) { $excludedModules[] = array($codename, $module->getLabel($cms_language)); } else { $availableModules[] = array($codename, $module->getLabel($cms_language)); } } $availableModules = sensitiveIO::jsonEncode($availableModules); $excludedModules = sensitiveIO::jsonEncode($excludedModules); $selectLanguageDisabled = $language->getCode() ? 'true' : 'false'; $isAvailableForBackoffice = $language->isAvailableForBackoffice() ? 'true' : 'false'; $itemFields = "{\n\txtype:\t\t\t\t'combo',\n\tname:\t\t\t\t'selectedCode',\n\thiddenName:\t\t \t'selectedCode',\n\tforceSelection:\t\ttrue,\n\tfieldLabel:\t\t\t'<span class=\"atm-red\">*</span> {$cms_language->getJSMessage(MESSAGE_PAGE_LANGUAGE)}',\n\tmode:\t\t\t\t'local',\n\ttriggerAction:\t\t'all',\n\tvalueField:\t\t\t'code',\n\tdisplayField:\t\t'label',\n\tvalue:\t\t\t\t'{$language->getCode()}',\n\tanchor:\t\t\t\t'-20px',\n\tstore:\t\t\t\tnew Ext.data.JsonStore({\n\t\tfields:\t\t\t\t['code', 'label'],\n\t\tdata:\t\t\t\t{$comboLanguages}\n\t}),\n\tallowBlank:\t\t \tfalse,\n\tselectOnFocus:\t\ttrue,\n\teditable:\t\t\ttrue,\n\ttypeAhead:\t\t\ttrue,\n\tvalidateOnBlur:\t\tfalse,\n\tdisabled:\t\t\t{$selectLanguageDisabled}\n},{\n\txtype:\t\t\t\t'atmCombo',\n\tname:\t\t\t\t'dateformat',\n\thiddenName:\t\t \t'dateformat',\n\tforceSelection:\t\ttrue,\n\tfieldLabel:\t\t\t'<span class=\"atm-red\">*</span> {$cms_language->getJSMessage(MESSAGE_PAGE_DATE_FORMAT)}',\n\tmode:\t\t\t\t'local',\n\ttriggerAction:\t\t'all',\n\tvalueField:\t\t\t'format',\n\tdisplayField:\t\t'label',\n\tvalue:\t\t\t\t'{$language->getDateFormat()}',\n\tanchor:\t\t\t\t'-20px',\n\tstore:\t\t\t\tnew Ext.data.JsonStore({\n\t\tfields:\t\t\t\t['format', 'label'],\n\t\tdata:\t\t\t\t{$datesFormat}\n\t}),\n\tallowBlank:\t\t \tfalse,\n\tselectOnFocus:\t\ttrue,\n\teditable:\t\t\tfalse,\n\tvalidateOnBlur:\t\tfalse\n},{\n\txtype:\t\t\t'itemselector',\n\tname:\t\t\t'modulesDenied',\n\tfieldLabel:\t\t'<span class=\"atm-help\" ext:qtip=\"{$cms_language->getJSMessage(MESSAGE_PAGE_SELECT_MODULES)}\">{$cms_language->getJSMessage(MESSAGE_PAGE_EXCLUDED_MODULES)}</span>',\n\tdataFields:\t\t['code', 'label'],\n\ttoData:\t\t\t{$excludedModules},\n\tmsWidth:\t\t250,\n\tmsHeight:\t\t130,\n\theight:\t\t\t140,\n\tvalueField:\t\t'code',\n\tdisplayField:\t'label',\n\ttoLegend:\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_EXCLUDED)}',\n\tfromLegend:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_AVAILABLE)}',\n\tfromData:\t\t{$availableModules}\n},{\n\txtype: \t\t'checkbox', \n\tboxLabel: \t'{$cms_language->getJSMessage(MESSAGE_PAGE_LANGUE_AVAILABLE_FOR_ADMIN)}', \n\tinputValue:\t'1',\n\tchecked:\t{$isAvailableForBackoffice},\n\tname: \t\t'admin'\n},"; //remove last comma $itemFields = io::substr($itemFields, 0, -1); $itemsControlerURL = PATH_ADMIN_WR . '/languages-controler.php'; $jscontent = <<<END \tvar window = Ext.getCmp('{$winId}'); \t//set window title \twindow.setTitle('{$winLabel}'); \t//set help button on top of page \twindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({ \t\ttarget:\t\t window.tools['help'], \t\ttitle:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}',