public function load_db_table_data($blank_data = FALSE) { $return_data = parent::load_db_table_data($blank_data); $url_action = url::set_url_rewrite_var(url::get_url_level_count(), "url_action", FALSE); $url_action_on_encoded_field = url::set_url_rewrite_var(url::get_url_level_count(), "url_action_on_encoded_field", FALSE); $url_action_on_field = $this->decrypt_field_name($url_action_on_encoded_field); if ($url_action == "unlink-uploaded-file") { \k1lib\forms\file_uploads::unlink_uploaded_file($this->db_table_data[1][$url_action_on_field]); $this->db_table_data[1][$url_action_on_field] = NULL; $this->db_table->update_data($this->db_table_data[1], $this->db_table_data_keys[1]); \k1lib\html\html_header_go(\k1lib\urlrewrite\get_back_url()); } return $return_data; }
/** * @return \k1lib\html\div|boolean */ public function exec_board() { if (!$this->is_enabled) { return FALSE; } /** * HTML DB TABLE */ if ($this->data_loaded) { if ($this->apply_label_filter) { $this->list_object->apply_label_filter(); } if ($this->apply_field_label_filter) { $this->list_object->apply_field_label_filter(); } if (\k1lib\forms\file_uploads::is_enabled()) { $this->list_object->apply_file_uploads_filter(); } // IF NOT previous link applied this will try to apply ONLY on keys if are present on show-list filter if (!$this->list_object->get_link_on_field_filter_applied()) { $get_vars = ["auth-code" => "--authcode--", "back-url" => $_SERVER['REQUEST_URI']]; $this->list_object->apply_link_on_field_filter(url::do_url("../{$this->controller_object->get_board_read_url_name()}/--rowkeys--/", $get_vars), crudlexs_base::USE_KEY_FIELDS); } // Show stats BEFORE if ($this->stats_enable && ($this->where_to_show_stats == self::SHOW_BEFORE_TABLE || $this->where_to_show_stats == self::SHOW_BEFORE_AND_AFTER_TABLE)) { $this->list_object->do_pagination()->append_to($this->board_content_div); $this->list_object->do_row_stats()->append_to($this->board_content_div); } /** * HTML OBJECT */ $list_content_div = $this->list_object->do_html_object(); $list_content_div->append_to($this->board_content_div); // Show stats AFTER if ($this->stats_enable && ($this->where_to_show_stats == self::SHOW_AFTER_TABLE || $this->where_to_show_stats == self::SHOW_BEFORE_AND_AFTER_TABLE)) { $this->list_object->do_row_stats()->append_to($this->board_content_div); $this->list_object->do_pagination()->append_to($this->board_content_div); } return $this->board_content_div; } else { $this->list_object->do_html_object()->append_to($this->board_content_div); return $this->board_content_div; } }
public function apply_file_uploads_filter() { 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_WARNING); return FALSE; } else { $table_config_array = $this->db_table->get_db_table_config(); $file_upload_fields = []; foreach ($table_config_array as $field => $options) { if ($options['validation'] == 'file-upload') { $file_upload_fields[$field] = $options['file-type']; } } if (!empty($file_upload_fields)) { foreach ($file_upload_fields as $field => $file_type) { switch ($file_type) { case "image": // $div_container = new \k1lib\html\div(); $img_tag = new \k1lib\html\img(file_uploads::get_uploads_url() . "--fieldvalue--"); $img_tag->set_attrib("class", "k1lib-data-img", TRUE); // $delete_file_link = new \k1lib\html\a("./unlink-uploaded-file/", "remove this file"); // $div_container->append_child($img_tag); // $div_container->append_child($delete_file_link); return $this->apply_html_tag_on_field_filter($img_tag, array_keys($file_upload_fields)); default: $link_tag = new \k1lib\html\a(url::do_url(file_uploads::get_uploads_url() . "--fieldvalue--"), "--fieldvalue--", "_blank"); $link_tag->set_attrib("class", "k1lib-data-link", TRUE); return $this->apply_html_tag_on_field_filter($link_tag, array_keys($file_upload_fields)); } } } } } else { return FALSE; } }
function form_file_upload_handle($file_data, $field_config) { /** * File validations with DB Table Config directives */ $file_max_size = $field_config['file-max-size'] + 0; $file_type = $field_config['file-type']; if (strstr($file_data['type'], $file_type) === FALSE) { return "The file type is {$file_data['type']} not {$file_type}"; } if ($file_data['size'] > $file_max_size) { return "Size is bigger than " . $file_max_size / 1024 . "k"; } /** * ALL ok? then place the file and let it go... let it goooo! (my daughter Allison fault! <3 ) */ if (file_uploads::place_upload_file($file_data['tmp_name'], $file_data['name'])) { return TRUE; } else { return file_uploads::get_last_error(); } // $file_location = file_uploads::get_uploaded_file_path($file_data['name']); // $file_location_url = file_uploads::get_uploaded_file_url($file_data['name']); }
public function related_apply_filters() { if ($this->related_list->get_db_table_data()) { $this->related_list->apply_label_filter(); $this->related_list->apply_field_label_filter(); if (\k1lib\forms\file_uploads::is_enabled()) { // $this->related_list->set $this->related_list->apply_file_uploads_filter(); } return TRUE; } else { return FALSE; } }