public function post_update_redirect($url_to_go = "../../", $do_redirect = TRUE) { if (!empty($this->update_perfomed)) { /** * Merge the ROW KEYS with all the possible keys on the POST array */ $merged_key_array = array_merge($this->db_table_data_keys[1], \k1lib\sql\get_keys_array_from_row_data($this->post_incoming_array, $this->db_table->get_db_table_config())); $row_key_text = \k1lib\sql\table_keys_to_text($merged_key_array, $this->db_table->get_db_table_config()); if (!empty($url_to_go)) { $this->set_auth_code($row_key_text); $this->set_auth_code_personal($row_key_text); $url_to_go = str_replace("--rowkeys--", $row_key_text, $url_to_go); $url_to_go = str_replace("--authcode--", $this->get_auth_code(), $url_to_go); } if ($do_redirect) { \k1lib\html\html_header_go($url_to_go); exit; return TRUE; } else { return $url_to_go; } } else { return ""; } }
public function post_insert_redirect($url_to_go = "../", $do_redirect = TRUE) { if ($this->inserted && $this->inserted_result !== FALSE) { $new_keys_text = \k1lib\sql\table_keys_to_text($this->get_inserted_keys(), $this->db_table->get_db_table_config()); if (!empty($url_to_go)) { $this->set_auth_code($new_keys_text); $this->set_auth_code_personal($new_keys_text); $url_to_go = str_replace("--rowkeys--", $new_keys_text, $url_to_go); $url_to_go = str_replace("--authcode--", $this->get_auth_code(), $url_to_go); } if ($do_redirect) { if ($new_keys_text) { \k1lib\html\html_header_go($url_to_go); exit; } else { \k1lib\html\html_header_go("../"); exit; } return TRUE; } else { return $url_to_go; } } else { return ""; } }
public function apply_html_tag_on_field_filter(\k1lib\html\tag $tag_object, $fields_to_change = crudlexs_base::USE_KEY_FIELDS, $custom_field_value = null) { if ($this->get_state()) { if (empty($this->db_table_data) || !is_array($this->db_table_data)) { trigger_error(__METHOD__ . " " . object_base_strings::$error_no_table_data, E_USER_NOTICE); return FALSE; } else { if ($fields_to_change == crudlexs_base::USE_KEY_FIELDS) { $fields_to_change = \k1lib\sql\get_db_table_keys_array($this->db_table->get_db_table_config()); } elseif ($fields_to_change == crudlexs_base::USE_ALL_FIELDS) { $fields_to_change = $this->db_table_data[0]; } elseif ($fields_to_change == crudlexs_base::USE_LABEL_FIELDS) { $fields_to_change = \k1lib\sql\get_db_table_label_fields($this->db_table->get_db_table_config()); if (empty($fields_to_change)) { $fields_to_change = \k1lib\sql\get_db_table_keys_array($this->db_table->get_db_table_config()); } } elseif (empty($fields_to_change)) { $fields_to_change = $this->db_table_data[0]; } else { if (!is_array($fields_to_change) && is_string($fields_to_change)) { $fields_to_change = array($fields_to_change); } } $table_constant_fields = $this->db_table->get_constant_fields(); foreach ($fields_to_change as $field_to_change) { foreach ($this->db_table_data_filtered as $index => $row_data) { if ($index === 0) { continue; } if (!array_key_exists($field_to_change, $row_data)) { trigger_error(__METHOD__ . "The field to change ({$field_to_change}) do no exist ", E_USER_NOTICE); continue; } else { // Let's clone the $tag_object to reuse it properly $tag_object_original = clone $tag_object; $custom_field_value_original = $custom_field_value; if ($this->skip_blanks_on_filters && empty($row_data[$field_to_change])) { continue; } $tag_object->set_value($row_data[$field_to_change]); if (is_object($tag_object)) { $a_tags = []; $tag_value = null; if (get_class($tag_object) == "k1lib\\html\\a") { $tag_href = $tag_object->get_attribute("href"); $tag_value = $tag_object->get_value(); } elseif (get_class($tag_object) == "k1lib\\html\\img") { $tag_href = $tag_object->get_attribute("src"); $tag_value = $tag_object->get_attribute("alt"); } else { // Let's try to get an A object from this object searching for it $a_tags = $tag_object->get_elements_by_tag("a"); if (count($a_tags) === 1) { $tag_href = $a_tags[0]->get_attribute("href"); $tag_value = $a_tags[0]->get_value(); } else { // TODO: CHECK THIS! - WTF line // $tag_href = $tag_object->get_value(); $tag_href = NULL; } } if (!empty($this->db_table_data_keys) && !empty($tag_href)) { if (is_array($custom_field_value)) { foreach ($custom_field_value as $key => $field_value) { if (isset($row_data[$field_value])) { $custom_field_value[$key] = $this->db_table_data[$index][$field_value]; } if (isset($table_constant_fields[$field_value])) { $custom_field_value[$key] = $table_constant_fields[$field_value]; } } $custom_field_value = implode("--", $custom_field_value); } $key_array_text = \k1lib\sql\table_keys_to_text($this->db_table_data_keys[$index], $this->db_table->get_db_table_config()); $auth_code = md5(\k1lib\K1MAGIC::get_value() . $key_array_text); /** * HREF STR_REPLACE */ $tag_href = str_replace("--rowkeys--", $key_array_text, $tag_href); $tag_href = str_replace("--fieldvalue--", $row_data[$field_to_change], $tag_href); // TODO: Why did I needed this ? WFT Line $actual_custom_field_value = str_replace("--fieldvalue--", $row_data[$field_to_change], $custom_field_value); $tag_href = str_replace("--customfieldvalue--", $actual_custom_field_value, $tag_href); $tag_href = str_replace("--authcode--", $auth_code, $tag_href); $tag_href = str_replace("--fieldauthcode--", md5(\k1lib\K1MAGIC::get_value() . ($actual_custom_field_value ? $actual_custom_field_value : $row_data[$field_to_change])), $tag_href); /** * VALUE STR_REPLACE */ $tag_value = str_replace("--rowkeys--", $key_array_text, $tag_value); $tag_value = str_replace("--fieldvalue--", $row_data[$field_to_change], $tag_value); $tag_value = str_replace("--customfieldvalue--", $actual_custom_field_value, $tag_value); $tag_value = str_replace("--authcode--", $auth_code, $tag_value); $tag_value = str_replace("--fieldauthcode--", md5(\k1lib\K1MAGIC::get_value() . ($actual_custom_field_value ? $actual_custom_field_value : $row_data[$field_to_change])), $tag_value); if (get_class($tag_object) == "k1lib\\html\\a") { $tag_object->set_attrib("href", $tag_href); $tag_object->set_value($tag_value); } if (get_class($tag_object) == "k1lib\\html\\img") { $tag_object->set_attrib("src", $tag_href); } // get-elements-by-tags fix foreach ($a_tags as $a_tag) { $a_tag->set_attrib("href", $tag_href); $a_tag->set_value($tag_value); } } } else { trigger_error("Not a HTML_TAG Object", E_USER_WARNING); } $this->db_table_data_filtered[$index][$field_to_change] = $tag_object; // Clean it... $tag_object unset($tag_object); // Let's clone the original to re use it $tag_object = clone $tag_object_original; $custom_field_value = $custom_field_value_original; } } } return TRUE; } } else { return FALSE; } }