public function do_html_object() { if ($this->db_table_data) { $this->div_container->set_attrib("class", "row k1lib-crudlexs-" . $this->css_class); $this->div_container->set_attrib("id", $this->object_id); $table_alias = \k1lib\db\security\db_table_aliases::encode($this->db_table->get_db_table_name()); $data_group = new \k1lib\html\div("k1lib-data-group"); $data_group->set_id("{$table_alias}-fields"); $data_group->append_to($this->div_container); $text_fields_div = new \k1lib\html\div("row"); $data_label = $this->get_labels_from_data(1); if (!empty($data_label)) { $this->remove_labels_from_data_filtered(); (new \k1lib\html\h3($data_label, "k1lib-data-group-title " . $this->css_class, "label-field-{$this->object_id}"))->append_to($data_group); } $labels = $this->db_table_data_filtered[0]; $values = $this->db_table_data_filtered[1]; $row = $data_group->append_div("row"); foreach ($values as $field => $value) { if (array_search($field, $this->fields_to_hide) !== FALSE) { continue; } if ($value !== 0 && $value !== NULL) { /** * ALL the TEXT field types are sendend to the last position to show nicely the HTML on it. */ $field_type = $this->db_table->get_field_config($field, 'type'); $field_alias = $this->db_table->get_field_config($field, 'alias'); if ($field_type == 'text') { $div_rows = $text_fields_div->append_div("large-12 column k1lib-data-item"); } else { $div_rows = $row->append_div($this->html_column_classes . " k1lib-data-item"); } if (!empty($field_alias)) { $div_rows->set_id("{$field_alias}-row"); } $label = $div_rows->append_div("k1lib-data-item-label")->set_value($labels[$field]); $value_div = $div_rows->append_div("k1lib-data-item-value")->set_value($value); if (!empty($field_alias)) { $div_rows->set_id("row-{$field_alias}"); $label->set_id("label-{$field_alias}"); if (method_exists($value, "set_id")) { $value->set_id("value-{$field_alias}"); } else { $value_div->set_id("value-{$field_alias}"); } } } } $text_fields_div->append_to($data_group); return $this->div_container; } else { return FALSE; } }
static function default_type(creating $crudlex_obj, $field) { $field_encrypted = $crudlex_obj->encrypt_field_name($field); if (!empty($crudlex_obj->db_table->get_field_config($field, 'refereced_table_name')) && self::$do_fk_search_tool && array_search($field, self::$fk_fields_to_skip) === FALSE) { $div_input_group = new \k1lib\html\div("input-group"); $input_tag = new \k1lib\html\input("text", $field_encrypted, NULL, "k1lib-input-insert input-group-field"); if (!empty($crudlex_obj->db_table->get_field_config($field, 'placeholder'))) { $input_tag->set_attrib("placeholder", $crudlex_obj->db_table->get_field_config($field, 'placeholder')); } else { $input_tag->set_attrib("placeholder", input_helper_strings::$input_fk_placeholder); } $input_tag->set_attrib("k1lib-data-group-" . $crudlex_obj->db_table->get_field_config($field, 'refereced_table_name'), TRUE); $input_tag->append_to($div_input_group); $div_input_group_button = new \k1lib\html\div("input-group-button"); $div_input_group_button->append_to($div_input_group); /** * FK TABLE EXTRACTOR */ $refereced_column_config = $crudlex_obj->db_table->get_field_config($field, 'refereced_column_config'); // while (!empty($refereced_column_config['refereced_column_config'])) { //// $refereced_column_config = $refereced_column_config['refereced_column_config']; // } $this_table = $crudlex_obj->db_table->get_db_table_name(); $this_table_alias = \k1lib\db\security\db_table_aliases::encode($this_table); $fk_table = $refereced_column_config['table']; $fk_table_alias = \k1lib\db\security\db_table_aliases::encode($fk_table); // $crudlex_obj->set_do_table_field_name_encrypt(); $static_values = $crudlex_obj->db_table->get_constant_fields(); $static_values_enconded = $crudlex_obj->encrypt_field_names($static_values); $search_button = new \k1lib\html\input("button", "search", "", "button fi-page-search fk-button"); $search_button->set_attrib("style", "font-family:foundation-icons"); $url_params = ["back-url" => $_SERVER['REQUEST_URI']]; $url_params = array_merge($static_values_enconded, $url_params); $url_to_search_fk_data = url::do_url(self::$url_to_search_fk_data . "{$fk_table_alias}/list/{$this_table_alias}/", $url_params); $search_button->set_attrib("onclick", "javascript:use_select_row_keys(this.form,'{$url_to_search_fk_data}')"); $search_button->append_to($div_input_group_button); $div_input_group->link_value_obj($input_tag); return $div_input_group; } elseif (strstr("date,date-past,date-future", $crudlex_obj->db_table->get_field_config($field, 'validation')) !== FALSE) { $div_input_group = new \k1lib\html\div("input-group"); $input_tag = new \k1lib\html\input("text", $field_encrypted, NULL, "k1lib-input-insert input-group-field datepicker"); $input_tag->set_attrib("placeholder", input_helper_strings::$input_date_placeholder); $input_tag->set_attrib("k1lib-data-datepickup", TRUE); $input_tag->append_to($div_input_group); $div_input_group_button = new \k1lib\html\div("input-group-button"); $div_input_group_button->append_to($div_input_group); $search_button = new \k1lib\html\a("#", "", "_self", "button fi-calendar"); $search_button->append_to($div_input_group_button); $div_input_group->link_value_obj($input_tag); return $div_input_group; } else { $input_tag = new \k1lib\html\input("text", $field_encrypted, NULL, "k1lib-input-insert"); $input_tag->set_attrib("placeholder", $crudlex_obj->db_table->get_field_config($field, 'placeholder')); return $input_tag; } }