/** * @return \k1lib\html\div|boolean */ public function start_board() { if (!parent::start_board()) { return FALSE; } if ($this->list_object->get_state()) { /** * BACK */ if ($this->back_enable && isset($_GET['back-url'])) { $back_url = \k1lib\urlrewrite\get_back_url(); $back_link = \k1lib\html\get_link_button($back_url, board_read_strings::$button_back); $back_link->append_to($this->button_div_tag); } /** * NEW BUTTON */ $related_url_keys_text = url::get_url_level_value_by_name("related_url_keys_text"); if (empty($related_url_keys_text)) { $related_url_keys_text = ""; $new_link = \k1lib\html\get_link_button(url::do_url("../{$this->controller_object->get_board_create_url_name()}/" . $related_url_keys_text), board_list_strings::$button_new); } else { $related_url_keys_text .= "/"; $new_link = \k1lib\html\get_link_button(url::do_url("../../{$this->controller_object->get_board_create_url_name()}/" . $related_url_keys_text), board_list_strings::$button_new); } if ($this->create_enable) { // $new_link = \k1lib\html\get_link_button(url::do_url("../{$this->controller_object->get_board_create_url_name()}/" . $related_url_keys_text), board_list_strings::$button_new); // $new_link = \k1lib\html\get_link_button("../{$this->controller_object->get_board_create_url_name()}/?back-url={$this_url}", board_list_strings::$button_new); $new_link->append_to($this->button_div_tag); } /** * Search */ if ($this->search_enable) { $search_iframe = new \k1lib\html\iframe(url::do_url($this->controller_object->get_controller_root_dir() . "search/?just-controller=1&caller-url=" . urlencode($_SERVER['REQUEST_URI'])), 'utility-iframe', "search-iframe"); // $this->board_content_div->append_child_tail($search_iframe); DOM::html()->body()->append_child_tail($search_iframe); // $search_iframe->append_to($this->board_content_div); $search_buttom = new \k1lib\html\a(NULL, " " . board_list_strings::$button_search, "_self"); $search_buttom->set_id("search-button"); $search_buttom->set_attrib("class", "button fi-page-search"); $search_buttom->append_to($this->button_div_tag); if (isset($_POST) && isset($_POST['from-search']) && urldecode($_POST['from-search']) == $_SERVER['REQUEST_URI']) { // if ($this->) /** * decrypt post field names */ $incomming_search_data = \k1lib\forms\check_all_incomming_vars($_POST); if ($this->list_object->get_do_table_field_name_encrypt()) { $search_data = $this->list_object->decrypt_field_names($incomming_search_data); } else { $search_data = $incomming_search_data; } $this->controller_object->db_table->set_query_filter($search_data); $search_post = \k1lib\common\serialize_var($_POST, urlencode($_SERVER['REQUEST_URI'])); /** * Clear search */ $clear_search_buttom = new \k1lib\html\a(url::do_url($_SERVER['REQUEST_URI']), board_list_strings::$button_search_cancel, "_self"); $search_buttom->set_value(" " . board_list_strings::$button_search_modify); $clear_search_buttom->set_attrib("class", "button warning"); $clear_search_buttom->append_to($this->button_div_tag); } else { $search_post = \k1lib\common\unset_serialize_var(urlencode($_SERVER['REQUEST_URI'])); } } $this->data_loaded = $this->list_object->load_db_table_data($this->show_rule_to_apply); return $this->board_content_div; } else { DOM_notification::queue_mesasage(board_base_strings::$error_mysql_table_not_opened, "alert", $this->notifications_div_id); DOM_notification::queue_title(board_base_strings::$error_mysql); $this->list_object->make_invalid(); $this->is_enabled = FALSE; return FALSE; } }
/** * @return \k1lib\html\div */ public function do_html_object() { if (!empty($this->db_table_data_filtered)) { $this->div_container->set_attrib("class", "k1lib-crudlexs-create"); /** * DIV content */ $this->div_container->set_attrib("class", "k1lib-form-generator " . $this->html_form_column_classes, TRUE); $this->div_container->set_attrib("style", "margin:0 auto;", TRUE); /** * FORM time !! */ $html_form = new \k1lib\html\form(); $html_form->append_to($this->div_container); if ($this->enable_foundation_form_check) { $html_form->set_attrib("data-abide", TRUE); } $form_header = $html_form->append_div("k1lib-form-header row"); $form_body = $html_form->append_div("k1lib-form-body row"); $form_footer = $html_form->append_div("k1lib-form-footer row"); $form_footer->set_attrib("style", "margin-top:0.9em;"); $form_buttons = $html_form->append_div("k1lib-form-buttons row"); /** * Hidden input */ $hidden_input = new \k1lib\html\input("hidden", "k1magic", "123123"); $hidden_input->append_to($html_form); // FORM LAYOUT // <div class="row"> $row_number = 0; foreach ($this->db_table_data_filtered[1] as $field => $value) { $row_number++; $row = new \k1lib\html\foundation\label_value_row($this->db_table_data_filtered[0][$field], $value, $row_number); $row->append_to($form_body); } /** * BUTTONS */ if ($this->show_cancel_button) { $cancel_button = \k1lib\html\get_link_button($this->back_url, creating_strings::$button_cancel, "small"); } $submit_button = new \k1lib\html\input("submit", "k1send", creating_strings::$button_submit, "small button fi-check success"); $buttons_div = new \k1lib\html\foundation\label_value_row(NULL, "{$cancel_button} {$submit_button}"); $buttons_div->append_to($form_buttons); $buttons_div->col(1)->remove_childs(); $buttons_div->col(2)->set_class("text-center", TRUE); /** * Prepare output */ return $this->div_container; } else { return FALSE; } }
/** * @return \k1lib\html\div|boolean */ public function exec_board() { if (!$this->is_enabled) { return FALSE; } if ($this->update_object->get_state() && !empty($this->row_keys_text)) { if ($this->data_loaded) { if ($this->update_object->get_post_data_catched()) { $this->update_object->put_post_data_on_table_data(); if (!$this->skip_form_action) { if ($this->update_object->do_post_data_validation()) { $this->sql_action_result = $this->update_object->do_update(); } else { DOM_notification::queue_mesasage(board_update_strings::$error_form, "alert", $this->notifications_div_id); DOM_notification::queue_title(board_base_strings::$alert_board); } } } if ($this->apply_label_filter) { $this->update_object->apply_label_filter(); } $this->update_object->insert_inputs_on_data_row(); /** * DELETE BUTTON */ if ($this->controller_object->get_board_delete_enabled()) { $delete_url = $this->controller_object->get_controller_root_dir() . "{$this->controller_object->get_board_delete_url_name()}/{$this->row_keys_text}/"; if (\k1lib\urlrewrite\get_back_url(TRUE)) { $get_vars = ["auth-code" => md5(session_plain::get_user_hash() . $this->row_keys_text), "back-url" => \k1lib\urlrewrite\get_back_url(TRUE)]; } else { $get_vars = ["auth-code" => md5(session_plain::get_user_hash() . $this->row_keys_text)]; } $delete_link = \k1lib\html\get_link_button(url::do_url($delete_url, $get_vars), board_read_strings::$button_delete, "small"); $delete_link->append_to($this->button_div_tag); } $update_content_div = $this->update_object->do_html_object(); $update_content_div->append_to($this->board_content_div); return $this->board_content_div; } else { DOM_notification::queue_mesasage(board_base_strings::$error_mysql_table_no_data, "alert", $this->notifications_div_id, board_base_strings::$error_mysql); $this->update_object->make_invalid(); $this->is_enabled = FALSE; return FALSE; } } }
/** * * @param \k1lib\crudlexs\class_db_table $db_table * @param array $field_links_array * @param string $title * @param string $board_root * @param string $board_create * @param string $board_read * @param boolean $show_create * @return \k1lib\html\div|boolean */ public function create_related_list(class_db_table $db_table, $field_links_array, $title, $board_root, $board_create, $board_read, $board_list, $use_back_url = FALSE, $clear_url = FALSE) { $table_alias = \k1lib\db\security\db_table_aliases::encode($db_table->get_db_table_name()); $detail_div = new \k1lib\html\div(); $this->related_list = $this->do_related_list($db_table, $field_links_array, $board_root, $board_read); if (!empty($this->related_list)) { $current_row_keys_text = $this->read_object->get_row_keys_text(); $current_row_keys_text_auth_code = md5(\k1lib\K1MAGIC::get_value() . $current_row_keys_text); $detail_div->set_class("k1lib-related-data-list {$table_alias}"); $related_title = $detail_div->append_h4($title, "{$table_alias}"); $detail_div->append_div("related-messaje"); if ($data_loaded) { $get_vars = ["auth-code" => $current_row_keys_text_auth_code, "back-url" => $_SERVER['REQUEST_URI']]; $all_data_url = url::do_url(APP_URL . $board_root . "/" . $board_list . "/{$current_row_keys_text}/", $get_vars, FALSE); $this->related_html_object_show_all_data = \k1lib\html\get_link_button($all_data_url, board_read_strings::$button_all_data, "tiny"); if ($this->related_show_all_data) { $related_title->set_value($this->related_html_object_show_all_data, TRUE); } } if ($use_back_url) { $get_vars = ["auth-code" => $current_row_keys_text_auth_code, "back-url" => $_SERVER['REQUEST_URI']]; $create_url = url::do_url(APP_URL . $board_root . "/" . $board_create . "/{$current_row_keys_text}/", $get_vars, TRUE); } else { $get_vars = ["auth-code" => $current_row_keys_text_auth_code]; $create_url = url::do_url(APP_URL . $board_root . "/" . $board_create . "/{$current_row_keys_text}/", $get_vars, TRUE, ['back-url'], FALSE); } $this->related_html_object_show_new = \k1lib\html\get_link_button($create_url, board_list_strings::$button_new, "tiny"); if ($this->related_show_new) { $related_title->set_value($this->related_html_object_show_new, TRUE); } $this->related_list->do_html_object()->append_to($detail_div); $this->related_html_table_object = $this->related_list->get_html_table(); if ($db_table->get_total_rows() > $this->related_rows_to_show) { $this->related_list->do_pagination()->append_to($detail_div); $this->related_list->do_row_stats()->append_to($detail_div); } listing::$rows_per_page = $actual_rows_per_page; } // TODO: NONSENSE line ! // $this->set_related_show_new(TRUE); return $detail_div; }