/** * Constructor EncryptDataWspObject * @param string $passphrase [default value: passphrase] * @param integer $private_key_bits [default value: 1024] * @param mixed $private_key_type [default value: OPENSSL_KEYTYPE_RSA] * @param boolean $encrypte_key [default value: true] */ function __construct($passphrase = 'passphrase', $private_key_bits = 1024, $private_key_type = OPENSSL_KEYTYPE_RSA, $encrypte_key = true) { if (!extension_loaded('openssl')) { throw new NewException("Please activate openssl php lib, to use " . get_class($this) . " object.", 0, getDebugBacktrace(1)); } $this->passphrase = url_rewrite_format($passphrase); $this->private_key_bits = $private_key_bits; $this->private_key_type = $private_key_type; $this->encrypte_key = $encrypte_key; }
/** * Method getAjaxRender * @access public * @return string javascript code to update initial html of object TreeViewItem (call with AJAX) * @since 1.0.35 */ public function getAjaxRender() { $html = ""; if ($this->object_change && !$this->is_new_object_after_init) { $treeview_object = $this->getTreeViewObject(); $treeview_object->generateTreeViewIds(); $old_value = $this->old_value; $old_value_id = $this->old_value; if (gettype($this->old_value) == "object") { if (in_array(get_class($this->old_value), $this->array_object_ok)) { if (get_class($this->old_value) == "Button") { $this->old_value->forceSpanTag(); } $old_value = $this->old_value->render($ajax_render); $old_value_id = $this->old_value->getValue(); } else { throw new NewException("Error TreeViewItem: value need to be a string, " . implode(", ", $array_object_ok), 0, getDebugBacktrace(1)); } } $value = $this->value; $value_id = $this->value; if (gettype($this->value) == "object") { if (in_array(get_class($this->value), $this->array_object_ok)) { if (get_class($this->value) == "Button") { $this->value->forceSpanTag(); } $value = $this->value->render($ajax_render); $value_id = $this->value->getValue(); } else { throw new NewException("Error TreeViewItem: value need to be a string, " . implode(", ", $array_object_ok), 0, getDebugBacktrace(1)); } } $id = $this->getId(); if ($old_value_id != $value_id) { $tmp_node_id = substr($id, strlen($id) - strlen($value_id), strlen($id)); $id = str_replace($tmp_node_id, strtolower(str_replace(" ", "_", str_replace("-", "_", url_rewrite_format($old_value_id)))), $id); } $html .= "\$('#" . $id . "_id').parent(\"span\").parent(\"li\").removeClass(\"closed\")"; if ($this->is_close) { $html .= ".addClass(\"closed\")"; } $html .= ";"; if ($value != $old_value) { $html .= "\$('#" . $id . "_id').html(\" " . str_replace("\n", "", str_replace("\r", "", str_replace('"', '\\"', addslashes($value)))) . "\");"; $html .= "\$('#" . $id . "_id').attr(\"id\", \"" . $this->getId() . "_id\");"; $html .= "\$('#" . $id . "').attr(\"id\", \"" . $this->getId() . "\");"; $html .= $this->generateHtmlChangeSubItemId($this, strlen($this->getId()), $id); } } return $html; }
function formalize_to_variable($txt) { $txt = url_rewrite_format($txt); return strtolower(str_replace("-", "_", $txt)); }
/** * 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)); } } } } }
public function createLabel($sender, $file, $label_name, $label_value) { $this->addObject(DialogBox::closeAll()); $label_name = strtoupper(str_replace("-", "_", url_rewrite_format($label_name))); $this->loadTranslation($sender, $file, "", $_GET['language']); $this->addDraggableTranslationEditor($label_name, $label_value); $this->save(null, $file); }