/** * Write to persistence and submit resource to validation process too. * * @access public * @return boolean true on success, false on failure */ function writeToPersistence() { if ($this->_public) { $this->raiseError("Object is public, read-only !"); return false; } if (!is_a($this->_form, 'CMS_forms_formular') || $this->_form->getID() <= 0) { $this->raiseError("No CMS_forms_formular found"); return false; } // Delete old relations $sql = "\n\t\t\tdelete\n\t\t\tfrom\n\t\t\t\tmod_cms_forms_categories\n\t\t\twhere\n\t\t\t\tform_fca='" . SensitiveIO::sanitizeSQLString($this->_form->getID()) . "'\n\t\t"; $qD = new CMS_query($sql); if ($qD->hasError()) { $this->raiseError("Error deleting previous relations"); return false; } // Insert if (sizeof($this->_categories)) { $err = 0; // Insert each label foreach ($this->_categories as $obj) { if (is_a($obj, 'CMS_moduleCategory')) { // Insert $sql = "\n\t\t\t\t\t\tinsert into\n\t\t\t\t\t\t\tmod_cms_forms_categories\n\t\t\t\t\t\tset\n\t\t\t\t\t\t\tform_fca='" . SensitiveIO::sanitizeSQLString($this->_form->getID()) . "',\n\t\t\t\t\t \t\tcategory_fca='" . SensitiveIO::sanitizeSQLString($obj->getID()) . "'\n\t\t\t\t\t"; $q = new CMS_query($sql); if ($q->hasError()) { $err++; $this->raiseError("Error inserting relation for cateogry : " . $obj->getID()); } } } return $err == 0 ? true : false; } return true; }
<input type="hidden" name="block" value="' . $blockId . '" /> <td class="admin"><input type="submit" class="admin_input_' . $td_class . '" value="' . $cms_language->getMessage(MESSAGE_PAGE_ACTION_UNSELECT, false, MOD_CMS_FORMS_CODENAME) . '" /></td> </form>'; } $content .= ' </tr> </table> </td> </tr> '; } $content .= ' </table>'; } //previsualization of a form if (sensitiveIO::isPositiveInteger($previz)) { $previzform = new CMS_forms_formular($previz); $content .= ' <br /><br /> <dialog-title type="admin_h2">' . $cms_language->getMessage(MESSAGE_PAGE_PREVIEW) . '</dialog-title><br /><br /> <table border="1" cellpadding="3" cellspacing="0"> <tr> <td class="admin"> ' . $previzform->getContent(CMS_forms_formular::REMOVE_FORM_SUBMIT) . ' </td> </tr> </table> '; } $dialog->setContent($content); $dialog->show();
color: #339900; } .retrait{ margin: 0 0 0 10px; } </style> </head> <body> <!--<script language="JavaScript" type="text/javascript">window.name = "cms_forms";</script>--> <?php // +----------------------------------------------------------------------+ // | Actions | // +----------------------------------------------------------------------+ switch ($step) { case 2: $form = new CMS_forms_formular($_POST["formId"]); //analyse the form from his xhtml code if (!$form->checkFormCode($_POST["formCode"])) { $errorMsg = 'DlgCMSFormsCopyError'; //then go to error window $step = 5; break; } $field = new CMS_forms_field('', $form->getID()); if (!is_object($field)) { $errorMsg = 'DlgCMSFormsFieldError'; //then go to error window $step = 5; break; } switch ($_POST["cms_action"]) {
/** * 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; } }
$cms_module = CMS_modulesCatalog::getByCodename(MOD_CMS_FORMS_CODENAME); if (!$cms_user->hasModuleClearance(MOD_CMS_FORMS_CODENAME, CLEARANCE_MODULE_EDIT)) { header("Location: " . PATH_ADMIN_SPECIAL_ENTRY_WR . "?cms_message_id=" . MESSAGE_PAGE_CLEARANCE_ERROR . "&" . session_name() . "=" . session_name()); exit; } if (!$_GET["form"] || !sensitiveIO::isPositiveInteger($_GET["form"])) { CMS_grandFather::raiseError("Formular export : Missing form ID parameter"); exit; } $replace = array('"' => '""', '\\r\\n' => '\\n'); function cleanvalue($value) { global $replace; return str_replace(array_keys($replace), $replace, $value); } $form = new CMS_forms_formular($_GET["form"]); //get array of form datas $formDatas = $form->getAllRecordDatas(false, $_GET["withDate"] ? true : false); //create array of fields names (for CSV header) $fields = $form->getFields(true); $fileFields = array(); if (sizeof($fields)) { if ($_GET["withDate"]) { $header[0] = '"Date"'; } foreach ($fields as $field) { if ($field->getAttribute('type') != 'submit') { //remove submit field $header[$field->getID()] = '"' . cleanvalue($field->getAttribute('label')) . '"'; } //check for file field in form
$item = new CMS_forms_formular($_POST["item"]); } // +----------------------------------------------------------------------+ // | Session management | // +----------------------------------------------------------------------+ // Language if ($_REQUEST["items_language"] != '') { CMS_session::setSessionVar("items_language", $_REQUEST["items_language"]); } elseif (CMS_session::getSessionVar("items_language") == '' || is_object(CMS_session::getSessionVar("items_language"))) { CMS_session::setSessionVar("items_language", $cms_module->getParameters("default_language")); } $items_language = new CMS_language(CMS_session::getSessionVar("items_language")); // +----------------------------------------------------------------------+ // | Actions | // +----------------------------------------------------------------------+ $item = new CMS_forms_formular($_POST["item"]); if (!$item->getID()) { $item->setAttribute('language', $items_language); //item need an ID $item->writeToPersistence(); } // All item relations with categories $item_relations = new CMS_forms_formularCategories($item); switch ($_POST["cms_action"]) { case "validate": //checks and assignments $cms_message = ""; $item->setDebug(false); //check mandatory fields if (!$_POST["name"]) { $cms_message .= $cms_language->getMessage(MESSAGE_FORM_ERROR_MANDATORY_FIELDS);
* Template CMS_forms_formular * * Represent a formular template for module cms_forms * * @package Automne * @subpackage cms_forms * @author Sébastien Pauchet <*****@*****.**> */ //force loading module cms_forms if (!class_exists('CMS_module_cms_forms')) { die('Cannot find cms_forms module ...'); } //set current page ID $mod_cms_forms["pageID"] = '{{pageID}}'; //Instanciate Form $form = new CMS_forms_formular($mod_cms_forms["formID"]); //Instanciate language $cms_language = $form->getLanguage(); //Instanciate field error Ids $cms_forms_error_ids = array(); //Form actions treatment if ($form->getID() && $form->isPublic()) { if (io::strtolower(APPLICATION_XHTML_DTD) != io::strtolower('<!DOCTYPE html>')) { echo '<a name="formAnchor' . $form->getID() . '"></a>'; } else { echo '<div id="formAnchor' . $form->getID() . '"></div>'; } //Create or append (from header) form required message if (isset($cms_forms_token[$form->getID()]) && $cms_forms_token[$form->getID()]) { $cms_forms_error_msg[$form->getID()] .= $cms_language->getMessage(CMS_forms_formular::MESSAGE_CMS_FORMS_TOKEN_EXPIRED, false, MOD_CMS_FORMS_CODENAME); }
color: #339900; } .retrait{ margin: 0 0 0 10px; } </style> </head> <body> <!--<script language="JavaScript" type="text/javascript">window.name = "cms_forms";</script>--> <?php // +----------------------------------------------------------------------+ // | Actions | // +----------------------------------------------------------------------+ switch ($step) { case 2: $form = new CMS_forms_formular($_POST["formId"]); //analyse the form from his xhtml code if (!$form->checkFormCode($_POST["formCode"])) { $errorMsg = 'DlgCMSFormsCopyError'; //then go to error window $step = 5; break; } if (!isset($_POST["fieldId"]) && isset($_POST["fieldName"])) { $fieldId = $form->getFieldByName($_POST["fieldName"]); } elseif (sensitiveIO::isPositiveInteger($_POST["fieldId"])) { $fieldId = $_POST["fieldId"]; } //get form fields $field = $form->getFieldById($fieldId); if (!is_object($field)) {
define("MESSAGE_PAGE_FIELD_RECEIVEDATA", 29); define("MESSAGE_PAGE_FIELD_FORM_OPEN", 44); define("MESSAGE_PAGE_FIELD_FORM_CLOSED", 45); define("MESSAGE_PAGE_FIELD_CATEGORY", 62); define("MESSAGE_PAGE_FIND_FORM", 63); define("MESSAGE_PAGE_WYSIWYG_ERROR", 84); //CHECKS if (!$cms_user->hasModuleClearance(MOD_CMS_FORMS_CODENAME, CLEARANCE_MODULE_EDIT)) { header("Location: " . PATH_ADMIN_SPECIAL_ENTRY_WR . "?cms_message_id=" . MESSAGE_PAGE_CLEARANCE_ERROR . "&" . session_name() . "=" . session_id()); exit; } $cms_module = CMS_modulesCatalog::getByCodename(MOD_CMS_FORMS_CODENAME); //get all user categories $user_categories = CMS_moduleCategories_catalog::getAllCategoriesAsArray($cms_user, $cms_module->getCodename(), $cms_language); //maintenance task : clean all empty forms CMS_forms_formular::cleanEmptyForms(); // Language if ($_REQUEST["items_language"] != '') { CMS_session::setSessionVar("items_language", $_REQUEST["items_language"]); } elseif (CMS_session::getSessionVar("items_language") == '' || is_object(CMS_session::getSessionVar("items_language"))) { CMS_session::setSessionVar("items_language", $cms_module->getParameters("default_language")); } $items_language = new CMS_language(CMS_session::getSessionVar("items_language")); // // Get default search options // // Get search options from posted datas if ($_POST["cms_action"] == 'search') { CMS_session::setSessionVar("items_ctg", $_POST["items_ctg"]); } // +----------------------------------------------------------------------+