public function onChangePasswd() { if ($this->edt_new_passwd->getValue() != "" && $this->edt_new_passwd->getValue() != "admin" && $this->edt_new_passwd->getValue() == $this->edt_confirm_passwd->getValue()) { if (changeWspUser("admin", $this->edt_old_passwd->getValue(), $this->edt_new_passwd->getValue(), "administrator")) { $this->addObject(DialogBox::closeAll()); $result_dialogbox = new DialogBox(__(CHANGE_PASSWD), __(CHANGE_PASSWD_CONGRATULATION)); } else { $result_dialogbox = new DialogBox(__(CHANGE_PASSWD), __(CHANGE_PASSWD_ERROR)); } } else { $result_dialogbox = new DialogBox(__(CHANGE_PASSWD), __(CHANGE_PASSWD_ERROR)); } $result_dialogbox->activateCloseButton(); $this->addObject($result_dialogbox); }
/** * Method render * @access public * @param boolean $ajax_render [default value: false] * @return string html code of object LiveValidation * @since 1.0.35 */ public function render($ajax_render = false) { if (!isset($this->object)) { throw new NewException("1 argument for " . get_class($this) . "::__construct() is mandatory", 0, getDebugBacktrace(1)); } if (get_class($this->object) == "Form") { return; } $html = $this->getJavascriptTagOpen(); if (get_class($this->object) == "Editor") { $id = $this->object->getHiddenId(); } else { $id = $this->object->getId(); } $html .= "\tLV_" . $id . " = new LiveValidation('" . $id . "'"; if ($this->onlyOnSubmit) { $html .= ", {onlyOnSubmit: true}"; } $html .= ");\n"; $html .= "\tLV_" . $id . $this->validate_js . ";\n"; if ($this->valid_init) { $html .= "\tLV_" . $id . ".validate();\n"; } if (method_exists($this->object, "getFormObject")) { $form_object = $this->object->getFormObject(); if ($form_object != null) { // search all button of the form $event_object_name = "Button_" . $form_object->getName(); $eventObject = $form_object->getPageObject()->getEventObjects($event_object_name); for ($i = 0; $i < sizeof($eventObject); $i++) { if (find($eventObject[$i]->getOnClickJs(), "/*LV_condition_zone*/", 0, 0) > 0) { $eventObject[$i]->onClickJs(str_replace("/*LV_validate_zone*/", "LV_" . $id . ".validate();/*LV_validate_zone*/", $eventObject[$i]->getOnClickJs())); $eventObject[$i]->onClickJs(str_replace("/*LV_condition_zone*/", "&&LiveValidationForm_" . $form_object->getName() . "_" . $id . "()/*LV_condition_zone*/", $eventObject[$i]->getOnClickJs())); } else { $html .= "\tlv_error_alert_id = '';\n\tlv_error_alert_field_name = '';\n\tlv_error_alert_msg = '';\n\tLV_ErrorAlert_" . $form_object->getName() . " = function() { "; $error_dialogbox_msg = new DialogBox(__(ERROR), __(LIVE_VALIDATION_FORMULAR_ERROR_MSG)); $error_dialogbox_msg->activateCloseButton("\$('#'+lv_error_alert_id).focus();"); $error_dialogbox_field = new DialogBox(__(ERROR), __(LIVE_VALIDATION_FORMULAR_FIELD_ERROR)); $error_dialogbox_field->activateCloseButton("\$('#'+lv_error_alert_id).focus();"); if (DEBUG) { $error_dialogbox = new DialogBox(__(ERROR), __(LIVE_VALIDATION_FORMULAR_ERROR_DEBUG)); } else { $error_dialogbox = new DialogBox(__(ERROR), __(LIVE_VALIDATION_FORMULAR_ERROR)); } $error_dialogbox->activateCloseButton(); $html .= "\tif (lv_error_alert_msg != '') {\n"; $html .= "\t\t" . $error_dialogbox_msg->render() . "\n"; $html .= "\t} else if (lv_error_alert_field_name != '') {\n"; $html .= "\t\t" . $error_dialogbox_field->render(); $html .= "\t} else {\n"; $html .= "\t\t" . $error_dialogbox->render() . "\n"; $html .= "\t}\n"; $html .= " };\n"; $eventObject[$i]->onClickJs("LV_" . $id . ".validate();/*LV_validate_zone*/if(LiveValidationForm_" . $form_object->getName() . "_" . $id . "()/*LV_condition_zone*/){" . $eventObject[$i]->getOnClickJs() . "}else{LV_ErrorAlert_" . $form_object->getName() . "();return false;}"); } } $html .= "\tLiveValidationForm_" . $form_object->getName() . "_" . $id . " = function() {\n"; $html .= "\t\tif (\$('#" . $id . "').attr('disabled')) {\n"; $html .= "\t\t\treturn true;\n"; $html .= "\t\t} else {\n"; $html .= "\t\t\tvar valid=(LV_" . $id . ".message!='Thankyou!'||LV_" . $id . ".message==null)?false:true;\n"; $html .= "\t\t\tif (valid) return true;\n"; $html .= "\t\t\tlv_error_alert_id = '" . $id . "';\n"; if ($this->field_name != "") { $html .= "\t\t\tlv_error_alert_field_name = '" . addslashes($this->field_name) . "';\n"; } else { $html .= "\t\t\tlv_error_alert_field_name = '';\n"; } if ($this->alert_msg != "") { $html .= "\t\t\tlv_error_alert_msg = '" . addslashes($this->alert_msg) . "';\n"; } else { $html .= "\t\t\tlv_error_alert_msg = '';\n"; } $html .= "\t\t\treturn false;\n"; $html .= "\t\t}\n"; $html .= "\t};\n"; } else { throw new NewException("To use LineValidation for object " . get_class($this->object) . " you must add him in a form (form object is null).", 0, getDebugBacktrace(1)); } } else { throw new NewException("LineValidation error: method getFormObject is missing for object " . get_class($this->object) . ".", 0, getDebugBacktrace(1)); } $html .= $this->getJavascriptTagClose(); $this->object_change = false; return $html; }
/** * Method getSynchronizeModelObject * @access public * @return mixed * @since 1.2.1 */ public function getSynchronizeModelObject() { $list_attribute = $this->database_object->getDbTableAttributes(); $key_attributes = $this->database_object->getDbTablePrimaryKeys(); $list_attribute_type = $this->database_object->getDbTableAttributesType(); $is_insert = !$this->database_model_object->isDbObject(); $error = false; foreach ($this->fields_array as $attribute => $field) { if ((!in_array($attribute, $key_attributes) || $is_insert) && in_array(get_class($field), $this->objects_ok_array)) { $value = $field->getValue(); $search_pos = array_search($attribute, $list_attribute); if ($search_pos !== false && $value != "") { settype($value, $list_attribute_type[$search_pos]); if ("" . $value != "" . $field->getValue() && get_class($field) != "CheckBox") { $error_dialog = new DialogBox(__(ERROR), "Can't convert " . $field->getValue() . " to " . $list_attribute_type[$search_pos]); $this->page_object->addObject($error_dialog->activateCloseButton()); $error = true; } } if ($value == "") { if (get_class($field) == "CheckBox") { $value = 0; } else { $value = null; } } $method = "set" . $this->getFormatValue($attribute); call_user_func_array(array($this->database_model_object, $method), array($value)); } } return $error ? false : $this->database_model_object; }
/** * Method getAjaxEventFunctionRender * @access protected * @return string * @since 1.0.35 */ protected function getAjaxEventFunctionRender() { $html = ""; $loading_obj = null; if (get_class($this) == "UploadFile") { $loading_obj = $this->getProgressBarObject(); if ($this->isSizeLimitJsCheckActivated() && $this->getFileSizeLimit() != -1) { $size_alert = new DialogBox(__(ERROR), __(UPLOAD_FILESIZE_LIMIT_ERROR_MSG, $this->getFileSizeLimitStr())); $size_alert->activateCloseButton()->setWidth(500); $size_alert->setDialogBoxLevel(rand(90000, 99999)); $html .= "var displaySizeErrorDialogBox" . get_class($this) . "_" . $this->getEventObjectName() . " = function(filename) {\n"; $html .= $size_alert->render(); $html .= "};\n"; } else { $html .= "var displaySizeErrorDialogBox" . get_class($this) . "_" . $this->getEventObjectName() . " = null;\n"; } if ($this->isMimeTypeJsCheckActivated() && sizeof($this->getAuthorizedMimeTypes()) > 0) { $mime_alert = new DialogBox(__(ERROR), __(UPLOAD_MIME_TYPES_ERROR_MSG, implode(", ", $this->getAuthorizedMimeTypes()))); $mime_alert->activateCloseButton()->setWidth(500); $mime_alert->setDialogBoxLevel(rand(90000, 99999)); $html .= "var displayMimeErrorDialogBox" . get_class($this) . "_" . $this->getEventObjectName() . " = function(filename, mime_type) {\n"; $html .= $mime_alert->render(); $html .= "};\n"; } else { $html .= "var displayMimeErrorDialogBox" . get_class($this) . "_" . $this->getEventObjectName() . " = null;\n"; } } if (gettype($this->ajax_wait_message) != "object") { $loading_img = new Picture("wsp/img/loading.gif", 32, 32); $loading_img->setId("wspAjaxEventLoadingPic" . get_class($this) . "_" . $this->getEventObjectName()); $loading_modalbox = new DialogBox(__(LOADING), new Object($this->ajax_wait_message, "<br/>", $loading_img, $loading_obj)); $loading_modalbox->setDialogBoxLevel(rand(90000, 99999))->modal(); } $error_alert = new DialogBox(__(ERROR), __(SUBMIT_ERROR)); $error_alert->activateCloseButton()->setWidth(500); $error_alert->setDialogBoxLevel(rand(90000, 99999)); $error_unknow_alert = new DialogBox(__(ERROR), __(SUBMIT_UNKNOW_ERROR)); $error_unknow_alert->activateCloseButton()->setWidth(400); $error_unknow_alert->setDialogBoxLevel(rand(90000, 99999)); $html .= "\tvar isRequestedAjaxEvent" . get_class($this) . "_" . $this->getEventObjectName() . " = false;\n"; $html .= "\tvar lastAjaxRequest" . get_class($this) . "_" . $this->getEventObjectName() . " = Array();\n"; $html .= "\tvar nbAjaxRequest" . get_class($this) . "_" . $this->getEventObjectName() . " = 0;\n"; if ($this->is_ajax_event) { $html .= "\tvar encryptedObjectValueArray" . get_class($this) . "_" . $this->getEventObjectName() . " = Array();\n"; } $html .= "\tcallAjax" . get_class($this) . "_" . $this->getEventObjectName() . "_event = function(callback_value, abort_last_request) {\n"; $html .= "\t\tif (isRequestedAjaxEvent" . get_class($this) . "_" . $this->getEventObjectName() . " && !abort_last_request) { return; }\n"; $html .= "\t\tisRequestedAjaxEvent" . get_class($this) . "_" . $this->getEventObjectName() . " = true;\n"; $html .= "\t\tnbAjaxRequest" . get_class($this) . "_" . $this->getEventObjectName() . "++;\n"; if (!$this->disable_ajax_wait_message) { if (gettype($this->ajax_wait_message) == "object") { $html .= "\t\t\$('#" . $this->ajax_wait_message->getId() . "').css('display', 'block');\n"; } else { $html .= "\t\t" . $loading_modalbox->render() . "\n"; } $html .= "\t\tsetTimeout(\"requestAjaxEvent" . get_class($this) . "_" . $this->getEventObjectName() . "(\\\"\" + callback_value + \"\\\", \" + abort_last_request + \");\", " . (gettype($this->ajax_wait_message) == "object" ? "1" : "1000") . ");\n"; } else { $html .= "\t\tsetTimeout(\"requestAjaxEvent" . get_class($this) . "_" . $this->getEventObjectName() . "(\\\"\" + callback_value + \"\\\", \" + abort_last_request + \");\", (abort_last_request?(lastAjaxRequest" . get_class($this) . "_" . $this->getEventObjectName() . ".length==0?1:200):1));\n"; } $html .= "\t};\n"; $html .= "\trequestAjaxEvent" . get_class($this) . "_" . $this->getEventObjectName() . " = function(callback_value, abort_last_request) {\n"; $html .= "\t\tnbAjaxRequest" . get_class($this) . "_" . $this->getEventObjectName() . "--;\n"; $html .= "\t\tif (abort_last_request) { for (var i=0; i < lastAjaxRequest" . get_class($this) . "_" . $this->getEventObjectName() . ".length; i++) { if (lastAjaxRequest" . get_class($this) . "_" . $this->getEventObjectName() . "[i]!=null) { lastAjaxRequest" . get_class($this) . "_" . $this->getEventObjectName() . "[i].abort(); lastAjaxRequest" . get_class($this) . "_" . $this->getEventObjectName() . "[i]=null; } } if (nbAjaxRequest" . get_class($this) . "_" . $this->getEventObjectName() . " > 0) { return; } }\n"; // encrypt formular if encrypt is active if ($this->form_object != null) { $html .= "\t\t" . $this->encryptObjectData($this->form_object, "isRequestedAjaxEvent" . get_class($this) . "_" . $this->getEventObjectName() . " = false;" . ($loading_modalbox == null ? "" : $loading_modalbox->close()->render())); } if (get_class($this) == "UploadFile") { $html .= "var upload_status = \$('#" . $this->getId() . "').upload('"; } else { $html .= "\t\tlastAjaxRequest" . get_class($this) . "_" . $this->getEventObjectName() . "[lastAjaxRequest" . get_class($this) . "_" . $this->getEventObjectName() . ".length] = \$.ajax({ type: '"; if ($this->form_object != null) { $html .= $this->form_object->getMethod(); } else { $html .= "POST"; } $html .= "', url: '"; } $html .= BASE_URL . LANGUAGE_URL . "/ajax/"; if ($this->form_object == null) { $html .= $this->getPage()->getPage() . ".html"; if (PARAMS_URL != "") { $pos = find(PARAMS_URL, "?", 0, $pos); if ($pos > 0) { $pos2 = strlen(PARAMS_URL); $html .= "?" . substr(PARAMS_URL, $pos, $pos2 - $pos); } } } else { if ($this->form_object->getAction() == "") { $html .= $this->form_object->getPageObject()->getPage() . ".html"; if (PARAMS_URL != "") { $pos = find(PARAMS_URL, "?", 0, $pos); if ($pos > 0) { $pos2 = strlen(PARAMS_URL); $html .= "?" . substr(PARAMS_URL, $pos, $pos2 - $pos); } } } else { $html .= $this->form_object->getAction(); } } $html .= "',\n"; if (get_class($this) == "UploadFile") { $html .= "\t\t\t\$('#Callback_" . $this->getEventObjectName() . "').serialize(),\n"; } else { if ($this->form_object != null) { $html .= "\t\t\tdata: "; if ($this->form_object->isEncrypted()) { $html .= "encrypt_data"; } else { $html .= "\$('#" . $this->form_object->getId() . "').serialize() + '&Callback_" . $this->getEventObjectName() . "=' + callback_value"; } $html .= ",\n"; } else { $html .= "\t\t\tdata: 'Callback_" . $this->getEventObjectName() . "=' + callback_value,\n"; } $html .= "\t\t\tdataType: 'json',\n"; $html .= "\t\t\tsuccess: "; } $html .= "function(ajax_event_response) {\n"; $html .= "\t\t\t\tisRequestedAjaxEvent" . get_class($this) . "_" . $this->getEventObjectName() . " = false;\n"; $html .= "\t\t\t\tif (ajax_event_response != \"\") {\n"; $html .= "\t\t\t\t\tvar dialogbox_is_change = false;\n"; if (isLocalDebug()) { $html .= "\t\t\t\t\tvar alert_local_eval_error = true;\n"; } $html .= "\t\t\t\t\tfor (var ajax_event_ind=0; ajax_event_ind < ajax_event_response.length; ajax_event_ind++) {\n"; if (!$this->disable_ajax_wait_message) { $html .= "\t\t\t\t\t\tif (ajax_event_response[ajax_event_ind] != null && ajax_event_response[ajax_event_ind].indexOf('wspDialogBox" . $modalbox_indice . "' + ' = ') != -1) {\n"; $html .= "\t\t\t\t\t\t\tdialogbox_is_change = true;\n"; $html .= "\t\t\t\t\t\t}\n"; } if (get_class($this) == "UploadFile") { $html .= "\t\t\t\t\t\tajax_event_response[ajax_event_ind] = myReplaceAll(myReplaceAll(ajax_event_response[ajax_event_ind], '{#wsp_lt}', '<'), '{#wsp_gt}', '>');\n"; } $html .= "\t\t\t\t\t\ttry {\n"; $html .= "\t\t\t\t\t\t\teval(ajax_event_response[ajax_event_ind]);\n"; $html .= "\t\t\t\t\t\t} catch (e) {\n"; $html .= "\t\t\t\t\t\t\tconsole.log('Js error: ' + e.message + '\\nCode: ' + ajax_event_response[ajax_event_ind]);\n"; // display ajax render error message when it's local or debug execution (useful to debug) if (isLocalDebug()) { $html .= "\t\t\t\t\t\t\tif (alert_local_eval_error) {\n"; $html .= "\t\t\t\t\t\t\t\talert('An error appeared during Ajax event, please check the console of your browser to see the error(s).');"; $html .= "\t\t\t\t\t\t\t\talert_local_eval_error = false;\n"; $html .= "\t\t\t\t\t\t\t}\n"; } $html .= "\t\t\t\t\t\t}\n"; $html .= "\t\t\t\t\t}\n"; if (!$this->disable_ajax_wait_message) { if (gettype($this->ajax_wait_message) == "object") { $html .= "\t\t\t\t\t\$('#" . $this->ajax_wait_message->getId() . "').css('display', 'none');\n"; } else { $html .= "\t\t\t\t\tif (!dialogbox_is_change) {\n"; $html .= "\t\t\t\t\t\t" . $loading_modalbox->close()->render(); $html .= "\t\t\t\t\t}\n"; } } $html .= "\t\t\t\t} else {\n"; if (gettype($this->ajax_wait_message) == "object") { $html .= "\t\t\t\t\t\$('#" . $this->ajax_wait_message->getId() . "').css('display', 'none');\n"; } else { $html .= "\t\t\t\t\t" . $loading_modalbox->close()->render(); } $html .= "\t\t\t\t\t" . $error_unknow_alert->render() . "\n"; $html .= "\t\t\t\t}\n"; $html .= "\t\t\t\t\$('#Callback_" . $this->getEventObjectName() . "').val('');\n"; if ($this->is_ajax_event) { $html .= "\t\t\t\trestoreEncryptedObject" . get_class($this) . "_" . $this->getEventObjectName() . "();\n"; } $html .= "\t\t\t},\n"; if (get_class($this) == "UploadFile") { $html .= "\t\t\t'json', \$('#wsp_object_wspAjaxEventLoadingObj" . get_class($this) . "_" . $this->getEventObjectName() . "'), \$('#wspAjaxEventLoadingPic" . get_class($this) . "_" . $this->getEventObjectName() . "'), displaySizeErrorDialogBox" . get_class($this) . "_" . $this->getEventObjectName() . ", '" . $this->getFileSizeLimit() . "', displayMimeErrorDialogBox" . get_class($this) . "_" . $this->getEventObjectName() . ", '" . implode(", ", $this->getAuthorizedMimeTypes()) . "');\n"; $html .= "\t\t\tisRequestedAjaxEvent" . get_class($this) . "_" . $this->getEventObjectName() . " = false;\n"; $html .= "\t\t\tif (upload_status === false) {\n"; if (gettype($this->ajax_wait_message) == "object") { $html .= "\t\t\t\t\t\$('#" . $this->ajax_wait_message->getId() . "').css('display', 'none');\n"; } else { $html .= "\t\t\t\t\t" . $loading_modalbox->close()->render() . "\n"; } $html .= "\t\t\t}\n"; } else { $html .= "\t\t\terror: function(transport) {\n"; $html .= "\t\t\t\tisRequestedAjaxEvent" . get_class($this) . "_" . $this->getEventObjectName() . " = false;\n"; $html .= "\t\t\t\tif (!abort_last_request || (abort_last_request && trim(transport.statusText) != 'abort')) {\n"; if (gettype($this->ajax_wait_message) == "object") { $html .= "\t\t\t\t\t\$('#" . $this->ajax_wait_message->getId() . "').css('display', 'none');\n"; } else { $html .= "\t\t\t\t\t" . $loading_modalbox->close()->render() . "\n"; } $html .= "\t\t\t\t\tif (trim(transport.responseText) == '') {\n"; $html .= "\t\t\t\t\t\t" . $error_unknow_alert->render(); $html .= "\t\t\t\t\t} else {\n"; $html .= "\t\t\t\t\t\t" . $error_alert->render(); $html .= "\t\t\t\t\t}\n"; $html .= "\t\t\t\t}\n"; $html .= "\t\t\t\t\$('#Callback_" . $this->getEventObjectName() . "').val('');\n"; if ($this->is_ajax_event) { $html .= "\t\t\t\trestoreEncryptedObject" . get_class($this) . "_" . $this->getEventObjectName() . "();\n"; } $html .= "\t\t\t}\n"; } if (get_class($this) != "UploadFile") { $html .= "\t\t});\n"; } $html .= "\t};\n"; if ($this->is_ajax_event) { $html .= "\trestoreEncryptedObject" . get_class($this) . "_" . $this->getEventObjectName() . " = function() {\n"; $html .= "\t\tfor (var i=0; i < encryptedObjectValueArray" . get_class($this) . "_" . $this->getEventObjectName() . ".length; i++) {\n"; $html .= "\t\t\t\$('#' + encryptedObjectValueArray" . get_class($this) . "_" . $this->getEventObjectName() . "[i][0]).val(encryptedObjectValueArray" . get_class($this) . "_" . $this->getEventObjectName() . "[i][1]);\n"; $html .= "\t\t}\n"; $html .= "\t};\n"; } return $html; }
/** * Method onChangeTableFromSqlDataView * @access public * @param mixed $sender * @since 1.1.6 */ public function onChangeTableFromSqlDataView($sender) { if ($this->id == "") { throw new NewException(get_class($this) . "->onChangeTableFromSqlDataView() error: you must define an id to the Table (" . get_class($this) . "->setId()) or you don't call this method for the good table", 0, getDebugBacktrace(1)); } if ($this->sql_data_view_object == null) { throw new NewException(get_class($this) . "->onChangeTableFromSqlDataView() error: you need to use the method loadFromSqlDataView before.", 0, getDebugBacktrace(1)); } if (gettype($sender) == "object") { if (get_class($sender) == "ComboBox") { $sender_id = $sender->getName(); } else { $sender_id = $sender->getId(); } } else { $sender_id = $sender; } $sender_table_id = substr($sender_id, 0, strlen($this->id)); if ($sender_table_id != $this->id) { throw new NewException(get_class($this) . "->onChangeTableFromSqlDataView() error: \$sender object is not link to this Table", 0, getDebugBacktrace(1)); } $sender_id = substr($sender_id, strlen($this->id) + 1, strlen($sender_id)); $sender_id_array = explode('_', $sender_id); $sender_type = $sender_id_array[0]; $input_ind = $sender_id_array[sizeof($sender_id_array) - 1]; $attribute_name = str_replace($sender_type . "_", "", $sender_id); $attribute_name = str_replace("_ind_" . $input_ind, "", $attribute_name); $list_attribute = $this->sql_data_view_object->getListAttributeArray(); $key_attributes = $this->sql_data_view_object->getPrimaryKeysAttributes(); $list_attribute_type = $this->sql_data_view_object->getListAttributeTypeArray(); $it = $this->data_row_iterator_object; if ($sender_type == "input" && $attribute_name != "" && !in_array($list_attribute[$i], $key_attributes)) { if (isset($this->from_sql_data_view_data_row_array[$input_ind])) { $row = $this->from_sql_data_view_data_row_array[$input_ind]; $value = $sender->getValue(); $search_pos = array_search($attribute_name, $list_attribute); if ($search_pos !== false) { settype($value, $list_attribute_type[$search_pos]); } if ($value == "") { if (get_class($sender) == "CheckBox") { $value = 0; } else { $value = null; } } try { // get property db_attribute $is_db_attribute = false; if (isset($this->from_sql_data_view_properties[$attribute_name]["db_attribute"])) { $db_attribute = $this->from_sql_data_view_properties[$attribute_name]["db_attribute"]; $row->setValue($db_attribute, $value); $is_db_attribute = true; } else { $row->setValue($attribute_name, $value); } DataBase::getInstance()->beginTransaction(); $it->save(); DataBase::getInstance()->commitTransaction(); $object_id = "wsp_object_" . $this->id . "_" . $attribute_name . "_input_obj_" . $input_ind; $object_text_id = "wsp_object_" . $this->id . "_" . $attribute_name . "_obj_" . $input_ind; $row_obj = $this->getPage()->getObjectId($object_text_id); $row_obj->emptyObject(); if ($is_db_attribute) { $this->from_sql_data_view_reload_pic->onClickJs("\$('#" . $object_id . "').html('<img src=\\'" . $this->getPage()->getCDNServerURL() . "wsp/img/loading.gif\\' height=\\'16\\' width=\\'16\\'/>');"); $row_obj->add($this->from_sql_data_view_reload_pic, " "); } else { $edit_pic = new Picture("wsp/img/edit_16x16.png", 16, 16); $row_obj->add($edit_pic, " "); } if (get_class($sender) == "ComboBox") { $row_obj->add($value === null ? " " : $sender->getText()); } else { if (get_class($sender) == "Calendar") { $row_obj->add($value === null ? " " : $sender->getValueStr()); } else { $row_obj->add($value === null ? " " : $value); } } $this->getPage()->addObject(new JavaScript("\$('#" . $object_text_id . "').css('display', 'inline');\$('#" . $object_id . "').hide();" . ($this->from_sql_data_view_add_button != null ? "\$('#" . $this->from_sql_data_view_add_button->getId() . "').button({ disabled: false });" : "")), false, true); } catch (Exception $e) { $error_msg = $e->getMessage(); if (($pos = find($error_msg, ": ")) > 0) { $error_msg = ucfirst(substr($error_msg, $pos, strlen($error_msg))); } $this->getPage()->addObject(new DialogBox(__(ERROR), $error_msg)); } } } else { if ($sender_type == "btnadd" && $attribute_name == "") { $error = false; $objects_ok_array = array("TextBox", "ComboBox", "CheckBox", "Calendar", "TextArea", "Editor"); $auto_increment_id = $this->sql_data_view_object->getDbTableObject()->getDbTableAutoIncrement(); $reload_pics_array = array(); $already_add_by_db_attribute = array(); $ind = $it->getRowsNum(); $row = $it->insert(); for ($i = 0; $i < sizeof($list_attribute); $i++) { $object_id = $this->id . "_input_" . $list_attribute[$i] . "_ind_"; $input_obj = $this->getPage()->getObjectId($object_id); if (!in_array($list_attribute[$i], $already_add_by_db_attribute)) { if ((!in_array($list_attribute[$i], $key_attributes) || in_array($list_attribute[$i], $key_attributes) && $list_attribute[$i] != null && $list_attribute[$i] != $auto_increment_id) && in_array(get_class($input_obj), $objects_ok_array)) { $value = $input_obj->getValue(); $search_pos = array_search($list_attribute[$i], $list_attribute); if ($search_pos !== false && $value != "") { settype($value, $list_attribute_type[$search_pos]); if ("" . $value != "" . $input_obj->getValue() && get_class($input_obj) != "CheckBox") { $error_dialog = new DialogBox(__(ERROR), "Can't convert " . $input_obj->getValue() . " to " . $list_attribute_type[$search_pos]); $this->getPage()->addObject($error_dialog->activateCloseButton()); $error = true; } } if ($value == "") { if (get_class($input_obj) == "CheckBox") { $value = 0; } else { $value = null; } } if (!$error) { // get property db_attribute if (isset($this->from_sql_data_view_properties[$list_attribute[$i]]["db_attribute"]) || in_array($list_attribute[$i], $key_attributes)) { if (in_array($list_attribute[$i], $key_attributes)) { $db_attribute = $list_attribute[$i]; } else { $db_attribute = $this->from_sql_data_view_properties[$list_attribute[$i]]["db_attribute"]; } $row->setValue($db_attribute, $value); $already_add_by_db_attribute[] = $db_attribute; if (!in_array($list_attribute[$i], $key_attributes)) { $row->enableSqlLoadMode(); $reload_pic = clone $this->from_sql_data_view_reload_pic; $reload_pic->setTag($list_attribute[$i]); $reload_pics_array[] = $reload_pic; $row->setValue($list_attribute[$i], new Object($reload_pic, $value)); $row->disableSqlLoadMode(); } } else { $row->setValue($list_attribute[$i], $value); } } } else { // get property db_attribute if (isset($this->from_sql_data_view_properties[$list_attribute[$i]]["db_attribute"])) { $db_attribute = $this->from_sql_data_view_properties[$list_attribute[$i]]["db_attribute"]; $row->setValue($db_attribute, null); $already_add_by_db_attribute[] = $db_attribute; $row->enableSqlLoadMode(); $row->setValue($list_attribute[$i], null); $row->disableSqlLoadMode(); } else { $row->setValue($list_attribute[$i], null); } } } } if (!$error) { DataBase::getInstance()->beginTransaction(); $it->save(); if ($auto_increment_id != null && $auto_increment_id != "") { $row->setValue($auto_increment_id, DataBase::getInstance()->getLastInsertId()); } DataBase::getInstance()->commitTransaction(); $key_str = ""; if (sizeof($key_attributes) == 0) { $key_str = $ind; } else { for ($i = 0; $i < sizeof($key_attributes); $i++) { if ($i > 0) { $key_str .= "-"; } $key_str .= $row->getValue($key_attributes[$i]); } $key_str = strtolower(url_rewrite_format($key_str)); } for ($i = 0; $i < sizeof($reload_pics_array); $i++) { $reload_pics_array[$i]->onClickJs("\$('#wsp_object_" . $this->id . "_" . $reload_pics_array[$i]->getTag() . "_input_obj_" . $key_str . "').html('<img src=\\'" . $this->getPage()->getCDNServerURL() . "wsp/img/loading.gif\\' height=\\'16\\' width=\\'16\\'/>');"); } $this->addRowLoadFromSqlDataView($row, $list_attribute, $list_attribute_type, $key_attributes, $key_str); } } else { if ($sender_type == "btndel" && $attribute_name == "") { if (isset($this->from_sql_data_view_data_row_array[$input_ind])) { $rowToDelete = $this->from_sql_data_view_data_row_array[$input_ind]; $this->deleteRow($this->id . "_row_" . $input_ind); try { $rowToDelete->delete(); DataBase::getInstance()->beginTransaction(); $it->save(); DataBase::getInstance()->commitTransaction(); } catch (Exception $e) { $error_msg = $e->getMessage(); if (($pos = find($error_msg, ": ")) > 0) { $error_msg = ucfirst(substr($error_msg, $pos, strlen($error_msg))); } $error_msg = explode(" - Query:", $error_msg); $error_msg = $error_msg[0]; $error_msg = explode("(", $error_msg); $error_msg = $error_msg[0]; $this->getPage()->addObject(new DialogBox(__(ERROR), $error_msg)); } } } else { if ($sender_type == "btnreload" && $attribute_name == "") { /*if (isset($this->from_sql_data_view_data_row_array[$input_ind])) { $row = $this->from_sql_data_view_data_row_array[$input_ind]; $this->deleteRow($this->id."_row_".$input_ind); $this->addRowLoadFromSqlDataView($row, $list_attribute, $list_attribute_type, $key_attributes, $input_ind); }*/ $this->setAjaxRefreshAllTable(); } else { throw new NewException(get_class($this) . "->onChangeTableFromSqlDataView() error: \$sender type (" . $sender_type . ") is not valid", 0, getDebugBacktrace(1)); } } } } }
/** * Method sendMail * @access public * @since 1.0.59 */ public function sendMail() { if (!$this->captcha->check()) { $this->captcha->forceObjectChange(); $dialog = new DialogBox(__(ERROR), __(ERROR_CAPTCHA)); $this->page_object->addObject($dialog->activateCloseButton()); } else { try { $message = __(CONTACTFORM_NAME) . ": " . utf8encode($this->getContactName()) . "<br/>" . __(CONTACTFORM_EMAIL) . ": " . $this->getContactEmail() . "<br/>" . __(CONTACTFORM_SUBJECT) . ": " . utf8encode($this->getContactSubject()) . "<br/><br/>" . __(CONTACTFORM_MESSAGE) . ": <br/>" . utf8encode($this->getContactMessage()); $mail = new SmtpMail($this->mail_to, __($this->mail_to_name), __(SITE_NAME) . " : " . utf8encode($this->getContactSubject()), $message, $this->getContactEmail(), utf8encode($this->getContactName())); if (!$mail->Send()) { $dialog = new DialogBox(__(CONTACTFORM_MAIL) . " " . __(ERROR), $mail->getErrorInfo()); $this->page_object->addObject($dialog->activateCloseButton()); } else { if ($this->send_wait_mail) { if ($this->send_wait_mail_message == "") { $this->send_wait_mail_message = __(CONTACTFORM_SEND_WAIT_MAIL_MESSAGE, $this->getContactName(), __(SITE_NAME), $this->mail_to_name); } $wait_mail = new SmtpMail($this->getContactEmail(), utf8encode($this->getContactName()), __(SITE_NAME), utf8encode($this->send_wait_mail_message), $this->mail_to, utf8encode($this->mail_to_name)); $wait_mail->Send(); } $dialog = new DialogBox(__(CONTACTFORM_MAIL), __(CONTACTFORM_MAIL_SENT)); $this->page_object->addObject($dialog->activateCloseButton()); $this->page_object->forceObjectsDefaultValues(); } } catch (Exception $ex) { $dialog = new DialogBox(__(ERROR), __(ERROR) . ": " . $ex->getMessage()); $this->page_object->addObject($dialog->activateCloseButton()); } } }
/** * Method saveFormFromSqlDataView * @access private * @param mixed $insert * @param mixed $update * @return boolean * @since 1.2.0 */ private function saveFormFromSqlDataView($insert, $update) { if ($this->sql_data_view_object == null) { throw new NewException(get_class($this) . "->saveFormFromSqlDataView() error: you need to use the method loadFromSqlDataView before.", 0, getDebugBacktrace(1)); } $list_attribute = $this->sql_data_view_object->getListAttributeArray(); $key_attributes = $this->sql_data_view_object->getPrimaryKeysAttributes(); $list_attribute_type = $this->sql_data_view_object->getListAttributeTypeArray(); $it = $this->data_row_iterator_object; $error = false; $objects_ok_array = array("TextBox", "ComboBox", "CheckBox", "Calendar", "TextArea", "Editor"); $auto_increment_id = $this->sql_data_view_object->getDbTableObject()->getDbTableAutoIncrement(); $already_add_by_db_attribute = array(); if ($insert) { $row = $it->insert(); } else { if ($update) { if ($this->data_row_object == null) { return false; } $row = $this->data_row_object; } } for ($i = 0; $i < sizeof($list_attribute); $i++) { if ($update && $auto_increment_id != null && $auto_increment_id == $list_attribute[$i]) { continue; } $object_id = $this->id . "_input_" . $list_attribute[$i] . "_ind_"; $input_obj = $this->getPage()->getObjectId($object_id); if (!in_array($list_attribute[$i], $already_add_by_db_attribute)) { if ((!in_array($list_attribute[$i], $key_attributes) || in_array($list_attribute[$i], $key_attributes) && $list_attribute[$i] != null && $list_attribute[$i] != $auto_increment_id) && in_array(get_class($input_obj), $objects_ok_array)) { $value = $input_obj->getValue(); $search_pos = array_search($list_attribute[$i], $list_attribute); if ($search_pos !== false && $value != "") { settype($value, $list_attribute_type[$search_pos]); if ("" . $value != "" . $input_obj->getValue() && get_class($input_obj) != "CheckBox") { $error_dialog = new DialogBox(__(ERROR), "Can't convert " . $input_obj->getValue() . " to " . $list_attribute_type[$search_pos]); $this->getPage()->addObject($error_dialog->activateCloseButton()); $error = true; } } if ($value == "") { if (get_class($input_obj) == "CheckBox") { $value = 0; } else { $value = null; } } if (!$error) { // get property db_attribute if (isset($this->from_sql_data_view_properties[$list_attribute[$i]]["db_attribute"]) || in_array($list_attribute[$i], $key_attributes)) { if (in_array($list_attribute[$i], $key_attributes)) { $db_attribute = $list_attribute[$i]; } else { $db_attribute = $this->from_sql_data_view_properties[$list_attribute[$i]]["db_attribute"]; } $row->setValue($db_attribute, $value); $already_add_by_db_attribute[] = $db_attribute; if (!in_array($list_attribute[$i], $key_attributes)) { $row->enableSqlLoadMode(); $row->setValue($list_attribute[$i], $value); $row->disableSqlLoadMode(); } } else { $row->setValue($list_attribute[$i], $value); } } } else { if ($insert) { // get property db_attribute if (isset($this->from_sql_data_view_properties[$list_attribute[$i]]["db_attribute"])) { $db_attribute = $this->from_sql_data_view_properties[$list_attribute[$i]]["db_attribute"]; $row->setValue($db_attribute, null); $already_add_by_db_attribute[] = $db_attribute; $row->enableSqlLoadMode(); $row->setValue($list_attribute[$i], null); $row->disableSqlLoadMode(); } else { $row->setValue($list_attribute[$i], null); } } } } } if (!$error) { DataBase::getInstance()->beginTransaction(); $it->save(); if ($insert && $auto_increment_id != null && $auto_increment_id != "") { $row->setValue($auto_increment_id, DataBase::getInstance()->getLastInsertId()); } DataBase::getInstance()->commitTransaction(); // Refresh form $this->from_sql_data_view_refresh = true; $this->loadFromSqlDataView($this->sql_data_view_object, $this->from_sql_data_view_properties); $this->from_sql_data_view_refresh = false; return true; } else { return false; } }
private function generateTableClass($database, $table) { $class_name = $this->getFormatValue($table); $is_primary = false; $is_unique_key = false; $const = ""; $attr = ""; $attr_type = ""; $attr_key = ""; $attr_unique_key = ""; $db_key_identifier = "PRI"; $auto_increment_var = ""; $query = "SHOW COLUMNS FROM `" . $database . "`.`" . $table . "`"; $result = $this->dbInstance->prepareStatement($query); while ($row = $result->fetch_array()) { $wsp_field = "FIELD_" . str_replace("-", "_", strtoupper($row['Field'])); $const .= "\tconst " . $wsp_field . " = \"" . $row['Field'] . "\";\n"; if ($attr != "") { $attr .= ", "; } $attr .= $class_name . "DbTable::" . $wsp_field; if ($attr_type != "") { $attr_type .= ", "; } $attr_type .= "\"" . $this->convertFieldTypeToWspType($row['Type']) . "\""; if ($row['Key'] == "PRI") { if ($attr_key != "") { $attr_key .= ", "; } $attr_key .= $class_name . "DbTable::" . $wsp_field; $is_primary = true; } else { if ($row['Key'] == "MUL") { if ($attr_unique_key != "") { $attr_unique_key .= ", "; } $attr_unique_key .= $class_name . "DbTable::" . $wsp_field; $is_unique_key = true; } } if ($row['Extra'] == "auto_increment") { $auto_increment_var = $row['Field']; } } if (!$is_primary && $is_unique_key) { $attr_key = $attr_unique_key; $db_key_identifier = "MUL"; } if (!$is_primary && !$is_unique_key) { $dialog = new DialogBox(__(PRIMARY_KEY), __(NO_PRIMARY_KEY, $database, $table)); $dialog->activateCloseButton(); $this->addObject($dialog); return false; } $attr_foreign_key = ""; $query = "SELECT column_name, referenced_table_schema, referenced_table_name, referenced_column_name\n\t\t\t\t\tFROM INFORMATION_SCHEMA.key_column_usage \n\t\t\t\t\tWHERE referenced_table_schema = '" . $database . "' \n\t\t\t\t\t AND table_name = '" . $table . "'\n\t\t\t\t\t AND referenced_table_name IS NOT NULL \n\t\t\t\t\tORDER BY table_name, column_name"; $stmt = $this->dbInstance->prepareStatement($query); $row = DataBase::getInstance()->stmtBindAssoc($stmt, $row); while ($stmt->fetch()) { if ($attr_foreign_key != "") { $attr_foreign_key .= ", "; } $attr_foreign_key .= "'" . $row['column_name'] . "' => array('table' => '`" . $row['referenced_table_schema'] . "`.`" . $row['referenced_table_name'] . "`', 'column' => '`" . $row['referenced_column_name'] . "`')"; } $attr_foreign_key = "array(" . $attr_foreign_key . ")"; $data = "<?php\nclass " . $class_name . "DbTable extends DbTableObject {\n\t/**#@-*/\n" . $const . "\n\t\n\tconst SCHEMA_NAME = \"" . $database . "\";\n\tconst TABLE_NAME = \"" . $table . "\";\n\t/**#@-*/\n\t\n\tfunction __construct() {\n\t\tparent::__construct();\n\t\t\n\t\t\$this->setDbSchemaName(" . $class_name . "DbTable::SCHEMA_NAME);\n\t\t\$this->setDbTableName(" . $class_name . "DbTable::TABLE_NAME);\n\t\t\$this->setDbTableAttributes(array(" . $attr . "));\n\t\t\$this->setDbTableAttributesType(array(" . $attr_type . "));\n\t\t\$this->setDbTablePrimaryKeys(array(" . $attr_key . "));\n\t\t\$this->setDbTableAutoIncrement(" . ($auto_increment_var == "" ? "''" : $class_name . "DbTable::FIELD_" . str_replace("-", "_", strtoupper($auto_increment_var))) . ");\n\t\t\$this->setDbTableForeignKeys(" . $attr_foreign_key . ");\n\t}\n}\n?>"; $file = new File(dirname(__FILE__) . "/../../../wsp/class/database_object/" . $class_name . "DbTable.class.php", false, true); $file->write($data); $file->close(); return $db_key_identifier; }
public function configureSmtp() { $data_config_file = "<?php\n"; $data_config_file .= "define(\"SMTP_HOST\", \"" . $this->edtHost->getValue() . "\"); \t// gmail : ssl://smtp.gmail.com\n"; $data_config_file .= "define(\"SMTP_PORT\", " . $this->edtPort->getValue() . "); \t\t\t\t\t\t// default : 25, gmail : 465\n\n"; $data_config_file .= "define(\"SMTP_NAME\", \"" . $this->edtName->getValue() . "\"); // Webmaster name\n"; $data_config_file .= "define(\"SMTP_MAIL\", \"" . $this->edtMail->getValue() . "\"); // Webmaster user (link with SMTP)\n\n"; $data_config_file .= "define(\"SMTP_AUTH\", " . $this->cmbAuth->getValue() . "); // true or false, gmail : true\n"; $data_config_file .= "define(\"SMTP_USER\", \"" . $this->edtUser->getValue() . "\"); // gmail : yourmail@gmail.com\n"; $data_config_file .= "define(\"SMTP_PASS\", \"" . $this->edtPassword->getValue() . "\"); // gmail : yourpassword\n"; $data_config_file .= "?>"; $config_file = new File(dirname(__FILE__) . "/../../../wsp/config/config_smtp.inc.php", false, true); if ($config_file->write($data_config_file)) { $config_ok = true; } $config_file->close(); if ($config_ok) { $result_dialogbox = new DialogBox(__(CONFIG_FILE), __(CONFIG_FILE_OK)); } else { $result_dialogbox = new DialogBox(__(CONFIG_FILE), __(CONFIG_FILE_NOT_OK)); } $result_dialogbox->activateCloseButton(); $this->addObject($result_dialogbox); }
public function configureCss($sender) { $data_config_file = ""; $data_config_file .= "<?php\n"; $data_config_file .= "define(\"DEFINE_STYLE_BCK_BODY\", \"" . str_replace("\"", "\\\"", $this->background_body->getValue()) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_BCK_BODY_PIC\", \"" . str_replace("\"", "\\\"", $this->bck_body_pic->getValue()) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_BCK_BODY_PIC_REPEAT\", \"" . str_replace("\"", "\\\"", $this->bck_body_pic_repeat->getValue()) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_BCK_BODY_PIC_POSITION\", \"" . trim(str_replace("\"", "\\\"", $this->bck_body_pic_position->getValue()) . " " . str_replace("\"", "\\\"", $this->bck_body_pic_position_more->getValue())) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_BODY\", \"" . str_replace("\"", "\\\"", $this->color_body->getValue()) . "\");\n"; $data_config_file .= "\n"; $data_config_file .= "define(\"DEFINE_STYLE_LINK_COLOR\", \"" . str_replace("\"", "\\\"", $this->link_color->getValue()) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_LINK_HOVER_COLOR\", \"" . str_replace("\"", "\\\"", $this->link_hover_color->getValue()) . "\");\n"; $data_config_file .= "\n"; $data_config_file .= "define(\"NB_DEFINE_STYLE_BCK\", " . str_replace("\"", "\\\"", $this->nb_define_style_bck->getValue()) . "); \n"; $data_config_file .= "\n"; for ($i = 1; $i <= $this->nb_define_style_bck->getValue(); $i++) { if ($this->current_style_display->getValue() == $i) { $data_config_file .= "define(\"DEFINE_STYLE_BCK_" . $i . "_HEADER\", \"" . str_replace("\"", "\\\"", $this->background_1_header->getValue()) . "\"); // If DEFINE_STYLE_BCK_PICTURE_1 is defined, DEFINE_STYLE_BCK_1_HEADER not use for Box object\n"; $data_config_file .= "define(\"DEFINE_STYLE_BCK_PICTURE_" . $i . "\", \"" . str_replace("\"", "\\\"", $this->background_picture_1->getValue()) . "\"); // ex : ../wsp/img/round_bgd/round_bgd.png (please use the default file wsp/img/round_bgd/round_bgd.png to create your own background)\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_" . $i . "_HEADER\", \"" . str_replace("\"", "\\\"", $this->color_1_header->getValue()) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_BCK_" . $i . "\", \"" . str_replace("\"", "\\\"", $this->background_1->getValue()) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_" . $i . "\", \"" . str_replace("\"", "\\\"", $this->color_1->getValue()) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_" . $i . "_LINK\", \"" . str_replace("\"", "\\\"", $this->style1_color_link->getValue()) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_" . $i . "_LINK_HOVER\", \"" . str_replace("\"", "\\\"", $this->style1_color_link_hover->getValue()) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_BORDER_TABLE_" . $i . "\", \"" . str_replace("\"", "\\\"", $this->border_table_1->getValue()) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_" . $i . "_HEADER_LINK\", \"" . str_replace("\"", "\\\"", $this->style1_header_link->getValue()) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_" . $i . "_HEADER_LINK_HOVER\", \"" . str_replace("\"", "\\\"", $this->style1_header_link_hover->getValue()) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_GRADIENT_" . $i . "\", " . ($this->style_gradient->isChecked() ? "true" : "false") . ");\n"; $data_config_file .= "define(\"DEFINE_STYLE_OMBRE_COLOR_" . $i . "\", \"" . str_replace("\"", "\\\"", $this->color_shadow->getValue()) . "\");\n"; } else { $data_config_file .= "define(\"DEFINE_STYLE_BCK_" . $i . "_HEADER\", \"" . (defined("DEFINE_STYLE_BCK_" . $i . "_HEADER") ? constant("DEFINE_STYLE_BCK_" . $i . "_HEADER") : "#000000") . "\"); // If DEFINE_STYLE_BCK_PICTURE_1 is defined, DEFINE_STYLE_BCK_1_HEADER not use for Box object\n"; $data_config_file .= "define(\"DEFINE_STYLE_BCK_PICTURE_" . $i . "\", \"" . (defined("DEFINE_STYLE_BCK_PICTURE_" . $i) ? constant("DEFINE_STYLE_BCK_PICTURE_" . $i) : "") . "\"); // ex : ../wsp/img/round_bgd/round_bgd.png (please use the default file wsp/img/round_bgd/round_bgd.png to create your own background)\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_" . $i . "_HEADER\", \"" . (defined("DEFINE_STYLE_COLOR_" . $i . "_HEADER") ? constant("DEFINE_STYLE_COLOR_" . $i . "_HEADER") : "#BFBFBF") . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_BCK_" . $i . "\", \"" . (defined("DEFINE_STYLE_BCK_" . $i) ? constant("DEFINE_STYLE_BCK_" . $i) : "#FFFFFF") . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_" . $i . "\", \"" . (defined("DEFINE_STYLE_COLOR_" . $i) ? constant("DEFINE_STYLE_COLOR_" . $i) : "#000000") . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_" . $i . "_LINK\", \"" . (defined("DEFINE_STYLE_COLOR_" . $i . "_LINK") ? constant("DEFINE_STYLE_COLOR_" . $i . "_LINK") : "#4D4D4D") . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_" . $i . "_LINK_HOVER\", \"" . (defined("") ? constant("") : "") . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_BORDER_TABLE_" . $i . "\", \"" . (defined("DEFINE_STYLE_BORDER_TABLE_" . $i) ? constant("DEFINE_STYLE_BORDER_TABLE_" . $i) : "#000000") . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_" . $i . "_HEADER_LINK\", \"" . (defined("DEFINE_STYLE_COLOR_" . $i . "_HEADER_LINK") ? constant("DEFINE_STYLE_COLOR_" . $i . "_HEADER_LINK") : "#C2C2C2") . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_" . $i . "_HEADER_LINK_HOVER\", \"" . (defined("DEFINE_STYLE_COLOR_" . $i . "_HEADER_LINK_HOVER") ? constant("DEFINE_STYLE_COLOR_" . $i . "_HEADER_LINK_HOVER") : "") . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_GRADIENT_" . $i . "\", " . (defined("DEFINE_STYLE_GRADIENT_" . $i) ? constant("DEFINE_STYLE_GRADIENT_" . $i) ? "true" : "false" : "false") . ");\n"; $data_config_file .= "define(\"DEFINE_STYLE_OMBRE_COLOR_" . $i . "\", \"" . (defined("DEFINE_STYLE_OMBRE_COLOR_" . $i) ? constant("DEFINE_STYLE_OMBRE_COLOR_" . $i) : "#000000") . "\");\n"; } $data_config_file .= "\n"; } $data_config_file .= "define(\"DEFINE_STYLE_JQUERY\", \"" . str_replace("\"", "\\\"", $this->style_jquery->getValue()) . "\");\t// ex: redmond, smoothness, start, flick\n"; $data_config_file .= "\t\t\t\t\t\t\t\t\t// complete list : http://www.socialblogr.com/2010/08/how-to-change-jquiery-ui-themes.html\n"; $data_config_file .= "\n"; $data_config_file .= "// Define the default font\n"; $data_config_file .= "define(\"DEFINE_STYLE_FONT\", \"" . str_replace("\"", "\\\"", $this->style_font->getValue()) . "\"); \t// You can use default font (Arial, Times New Roman, Verdana) and Google font (http://code.google.com/webfonts)\n"; $data_config_file .= "\t\t\t\t\t\t\t\t// List of google web font : Cantarell, Cardo, Crimson Text, Droid Sans, Droid Sans Mono, Droid Serif, IM Fell, Inconsolata, Josefin Sans Std Light, Lobster, Molengo, Nobile, OFL Sorts Mill Goudy TT, Old Standard TT, Reenie Beanie, Tangerine, Vollkorn, Yanone Kaffeesatz.\n"; $data_config_file .= "define(\"DEFINE_STYLE_FONT_SIZE\", \"" . str_replace("\"", "\\\"", $this->style_font_size->getValue()) . "pt\"); // ex: 12pt, 10pt (defautl), 8pt\n"; $data_config_file .= "define(\"DEFINE_STYLE_FONT_SERIF\", \"" . str_replace("\"", "\\\"", $this->style_font_serif->getValue()) . "\"); // ex: serif, sans serif (default), monospace\n"; $data_config_file .= "\n"; $data_config_file .= "define(\"DEFINE_STYLE_COLOR_UPLOAD_PROGRESS_BAR\", \"" . str_replace("\"", "\\\"", $this->style_upload_progress_bar->getValue()) . "\");\n"; $data_config_file .= "define(\"DEFINE_STYLE_BACKCOLOR_SCROLL_TO_TOP\", \"" . str_replace("\"", "\\\"", $this->style_scroll_to_top->getValue()) . "\");\n"; $data_config_file .= "?>\n"; $config_file = new File(dirname(__FILE__) . "/../../../wsp/config/config_css.inc.php", false, true); if ($config_file->write($data_config_file)) { $config_ok = true; } $config_file->close(); if ($config_ok) { $result_dialogbox = new DialogBox(__(CONFIG_FILE), __(CONFIG_FILE_OK)); } else { $result_dialogbox = new DialogBox(__(CONFIG_FILE), __(CONFIG_FILE_NOT_OK)); } $result_dialogbox->activateCloseButton(); $this->addObject($result_dialogbox); }
function create_label_translation($constantValue) { $translate_file = $_GET['p'] . ".inc.php"; // Check if translation needs to be writed in all.inc.php $trace_array = explode("\n", getDebugBacktrace(2)); if (isset($trace_array[1])) { $trace_array[1] = str_replace("\\", "/", $trace_array[1]); if (find($trace_array[1], "wsp/includes/utils_label.inc.php") > 0) { // call function __() $trace = isset($trace_array[4]) ? $trace_array[4] : ""; } else { // call function translate() $trace = isset($trace_array[1]) ? $trace_array[1] : ""; } $trace = str_replace("\\", "/", $trace); if (($pos = find($trace, SITE_DIRECTORY)) > 0) { $trace_file = substr($trace, $pos, strlen($trace)); $page_label = str_replace("/pages/", "", substr($trace_file, 0, strlen($trace_file) - 4)); if ($page_label != $_GET['p']) { $translate_file = "all.inc.php"; } } } // Create new label in each languages $creation_message = ""; $base_dir = dirname(__FILE__) . "/../.."; $array_lang_dir = scandir($base_dir . "/lang"); for ($i = 0; $i < sizeof($array_lang_dir); $i++) { if (is_dir($base_dir . "/lang/" . $array_lang_dir[$i]) && $array_lang_dir[$i] != "" && $array_lang_dir[$i] != "." && $array_lang_dir[$i] != ".." && $array_lang_dir[$i] != ".svn" && strlen($array_lang_dir[$i]) == 2) { $lang_file_path = str_replace("\\", "/", realpath($base_dir . "/lang/" . $array_lang_dir[$i])) . "/" . $translate_file; // Read File $lang_file_content = ""; if (file_exists($lang_file_path)) { $lang_file = new File($lang_file_path); $lang_file_content = $lang_file->read(); $lang_file->close(); } // Check if the label doesn't already exists for this language if (!label_exists($lang_file_content, $constantValue)) { // Create new label if ($lang_file_content == "") { $lang_file_content = "<?php\n"; } $lang_file_content = str_replace("\r", "", $lang_file_content); $lang_file_content = str_replace_last("?>", "", $lang_file_content); $lang_file_content .= "\tdefine('" . addslashes($constantValue) . "', '" . addslashes($constantValue) . "'); // TODO: Label needs to be translated\n"; $lang_file_content .= "?>"; // Write File if ($GLOBALS['WSP_AUTO_CREATE_CONSTANT']) { $lang_file = new File($lang_file_path, false, true); if ($lang_file->write($lang_file_content) !== false) { $creation_message .= "Information: Constant <font color='blue'>" . $constantValue . "</font> automatically <font color='green'>CREATED</font> in the file " . $lang_file_path . ".<br/>"; } $lang_file->close(); } // Check if this label doesn't exists in other language for the current page if ($translate_file == "all.inc.php") { $page_lang_file_path = str_replace("\\", "/", realpath($base_dir . "/lang/" . $array_lang_dir[$i])) . "/" . $_GET['p'] . ".inc.php"; if (file_exists($page_lang_file_path)) { $lang_file = new File($page_lang_file_path); $lang_file_content = $lang_file->read(); $lang_file->close(); if (!label_exists($lang_file_content, $constantValue)) { $label_found = false; if (find($lang_file_content, "define(\"" . $constantValue . "\"") > 0) { $lang_file_content = str_replace_first("define(\"" . $constantValue . "\"", "// TODO: Remove label (now in all.inc.php) -> define(\"" . $constantValue . "\"", $lang_file_content); $label_found = true; } else { if (find($lang_file_content, "define('" . $constantValue . "'") > 0) { $lang_file_content = str_replace_first("define('" . $constantValue . "'", "// TODO: Remove label (now in all.inc.php) -> define('" . $constantValue . "'", $lang_file_content); $label_found = true; } } // Write File if ($label_found && $GLOBALS['WSP_AUTO_CREATE_CONSTANT']) { $lang_file = new File($page_lang_file_path, false, true); if ($lang_file->write($lang_file_content) !== false) { $creation_message .= "Information: Constant <font color='blue'>" . $constantValue . "</font> automatically <font color='red'>COMMENT</font> in the file " . $page_lang_file_path . ".<br/>"; } $lang_file->close(); } } } } } } } if ($creation_message != "") { // Simulate the new label is loaded define($constantValue, $constantValue); // Inform the developer by DialogBox if ($GLOBALS['__AJAX_LOAD_PAGE__'] == false || $GLOBALS['__AJAX_LOAD_PAGE__'] == true && find($_GET['mime'], "html") > 0) { $dialog = new DialogBox("Alert translation", $creation_message); $dialog->activateCloseButton()->setWidth(600); Page::getInstance($_GET['p'])->addObject($dialog); } // Inform the developer by mail if (defined('SEND_ERROR_BY_MAIL') && SEND_ERROR_BY_MAIL == true && !isLocalDebug()) { try { $mail = new SmtpMail(SEND_ERROR_BY_MAIL_TO, __(SEND_ERROR_BY_MAIL_TO), "New label on " . __(SITE_NAME) . " !!!", $creation_message, SMTP_MAIL, __(SMTP_NAME)); $mail->setPriority(SmtpMail::PRIORITY_HIGH); $mail->send(); } catch (Exception $e) { } } } }
public function changeSiteName($sender) { $dialog = new DialogBox(__(WARNING), __(WARNING_SITE_NAME_DISONNCET)); $this->addObject($dialog->activateCloseButton()); }