public static function register_footer($url, $relative = FALSE, $type = "auto") { trigger_error("Do not use me " . __METHOD__, E_USER_WARNING); self::is_enabled(true); if (!is_string($url)) { \trigger_error("The URL HAS to be a string", E_USER_ERROR); } if ($type == "auto") { $file_extension = \k1lib\common\get_file_extension($url); } else { $file_extension = $type; } if (!$file_extension) { return FALSE; } switch ($file_extension) { case 'js': $code = "<script src=\"%url%\"></script>"; break; case 'css': $code = "<link href=\"%url%\" rel=\"stylesheet\">"; break; default: \trigger_error("no extension detected on [{$url}] ", E_USER_ERROR); return FALSE; break; } if ($relative) { $code = str_replace("%url%", \k1lib\urlrewrite\url::do_url($url, [], FALSE), $code); } else { $code = str_replace("%url%", $url, $code); } return self::set_place_value("footer", $code); }
/** * @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; } }
/** * @param string $specific_board_to_init * @return \k1lib\html\div|boolean */ public function init_board($specific_board_to_init = NULL) { if ($this->security_no_rules_enable === FALSE) { if (isset($_GET['no-rules'])) { unset($_GET['no-rules']); } } if (empty($specific_board_to_init)) { $specific_board_to_init = $this->controller_board_url_value ? $this->controller_board_url_value : "no-url"; } switch ($specific_board_to_init) { case $this->board_create_url_name: $this->board_create_object = new board_create($this, $this->board_create_allowed_levels); $this->board_create_object->set_is_enabled($this->board_create_enabled); $this->board_create_object->set_board_name($this->board_create_name); $this->board_div_content = $this->board_create_object->board_content_div; break; case $this->board_read_url_name: $this->board_read_object = new board_read($this, $this->board_read_allowed_levels); $this->board_read_object->set_is_enabled($this->board_read_enabled); $this->board_read_object->set_board_name($this->board_read_name); $this->board_div_content = $this->board_read_object->board_content_div; if (!$this->board_list_enabled || !$this->get_board_list_allowed_for_current_user()) { $this->board_read_object->set_all_data_enable(FALSE); } if (!$this->board_update_enabled || !$this->get_board_update_allowed_for_current_user()) { $this->board_read_object->set_update_enable(FALSE); } if (!$this->board_delete_enabled || !$this->get_board_delete_allowed_for_current_user()) { $this->board_read_object->set_delete_enable(FALSE); } break; case $this->board_update_url_name: $this->board_update_object = new board_update($this, $this->board_update_allowed_levels); $this->board_update_object->set_is_enabled($this->board_update_enabled); $this->board_update_object->set_board_name($this->board_update_name); $this->board_div_content = $this->board_update_object->board_content_div; break; case $this->board_delete_url_name: $this->board_delete_object = new board_delete($this, $this->board_delete_allowed_levels); $this->board_delete_object->set_is_enabled($this->board_delete_enabled); $this->board_delete_object->set_board_name($this->board_delete_name); $this->board_div_content = $this->board_delete_object->board_content_div; break; case $this->board_list_url_name: $this->board_list_object = new board_list($this, $this->board_list_allowed_levels); $this->board_list_object->set_is_enabled($this->board_list_enabled); $this->board_list_object->set_board_name($this->board_list_name); $this->board_div_content = $this->board_list_object->board_content_div; if (!$this->board_create_enabled || !$this->get_board_create_allowed_for_current_user()) { $this->board_list_object->set_create_enable(FALSE); } break; case $this->board_search_url_name: $this->board_search_object = new board_search($this, $this->board_list_allowed_levels); $this->board_search_object->set_is_enabled($this->board_list_enabled); $this->board_search_object->set_board_name($this->board_search_url_name); $this->board_div_content = $this->board_search_object->board_content_div; break; default: $this->board_inited = FALSE; \k1lib\html\html_header_go(url::do_url($this->controller_root_dir . $this->get_board_list_url_name() . "/")); return FALSE; } $this->board_inited = TRUE; return $this->board_div_content; }
public function finish_board($do_redirect = TRUE, $custom_redirect = FALSE) { if ($this->sql_action_result !== NULL) { if ($custom_redirect === FALSE) { if (isset($_GET['back-url'])) { $url_to_go = urldecode($_GET['back-url']); } else { $get_params = ["auth-code" => "--authcode--"]; $url_to_go = url::do_url("{$this->controller_object->get_controller_root_dir()}{$this->controller_object->get_board_read_url_name()}/--rowkeys--/?", $get_params); } } else { $url_to_go = url::do_url($custom_redirect); } $this->update_object->post_update_redirect($url_to_go, $do_redirect); } }
/** * * @return \k1lib\html\div */ public function do_pagination() { $div_pagination = new \k1lib\html\div("k1lib-crudlexs-list-pagination clearfix", $this->get_object_id() . "-pagination"); $div_scroller = $div_pagination->append_div("float-left pagination-scroller"); $div_page_chooser = $div_pagination->append_div("float-left pagination-rows"); if ($this->db_table_data && self::$rows_per_page <= $this->total_rows) { $page_get_var_name = $this->get_object_id() . "-page"; $rows_get_var_name = $this->get_object_id() . "-rows"; $this_url = APP_URL . \k1lib\urlrewrite\url::get_this_url() . "#" . $this->get_object_id() . "-pagination"; if ($this->actual_page > 2) { $this->page_first = url::do_url($this_url, [$page_get_var_name => 1, $rows_get_var_name => self::$rows_per_page]); } else { $this->page_first = "#"; } if ($this->actual_page > 1) { $this->page_previous = url::do_url($this_url, [$page_get_var_name => $this->actual_page - 1, $rows_get_var_name => self::$rows_per_page]); } else { $this->page_previous = "#"; } if ($this->actual_page < $this->total_pages) { $this->page_next = url::do_url($this_url, [$page_get_var_name => $this->actual_page + 1, $rows_get_var_name => self::$rows_per_page]); } else { $this->page_next = "#"; } if ($this->actual_page <= $this->total_pages - 2) { $this->page_last = url::do_url($this_url, [$page_get_var_name => $this->total_pages, $rows_get_var_name => self::$rows_per_page]); } else { $this->page_last = "#"; } /** * HTML UL- LI construction */ $ul = new \k1lib\html\ul("pagination k1lib-crudlexs " . $this->get_object_id()); $ul->append_to($div_scroller); // First page LI $li = $ul->append_li(); // function append_a($href = NULL, $label = NULL, $target = NULL, $alt = NULL, $class = NULL, $id = NULL) { $a = $li->append_a($this->page_first, "‹‹", "_self", "k1lib-crudlexs-first-page"); if ($this->page_first == "#") { $a->set_attrib("class", "disabled"); } // Previuos page LI $li = $ul->append_li(""); $a = $li->append_a($this->page_previous, "‹", "_self", "k1lib-crudlexs-previous-page"); if ($this->page_previous == "#") { $a->set_attrib("class", "disabled"); } /** * Page GOTO selector */ $page_selector = new \k1lib\html\select("goto_page", "k1lib-crudlexs-page-goto", $this->get_object_id() . "-page-goto"); $page_selector->set_attrib("onChange", "use_select_option_to_url_go(this)"); for ($i = 1; $i <= $this->total_pages; $i++) { $option_url = url::do_url($this_url, [$page_get_var_name => $i, $rows_get_var_name => self::$rows_per_page]); $option = $page_selector->append_option($option_url, $i, $this->actual_page == $i ? TRUE : FALSE); } $ul->append_li()->append_child($page_selector); // Next page LI $li = $ul->append_li(""); $a = $li->append_a($this->page_next, "›", "_self", "k1lib-crudlexs-next-page"); if ($this->page_next == "#") { $a->set_attrib("class", "disabled"); } // Last page LI $li = $ul->append_li(""); $a = $li->append_a($this->page_last, "››", "_self", "k1lib-crudlexs-last-page"); if ($this->page_last == "#") { $a->set_attrib("class", "disabled"); } /** * PAGE ROWS selector */ $num_rows_selector = new \k1lib\html\select("goto_page", "k1lib-crudlexs-page-goto", $this->get_object_id() . "-page-rows-goto"); $num_rows_selector->set_attrib("onChange", "use_select_option_to_url_go(this)"); foreach (self::$rows_per_page_options as $num_rows) { if ($num_rows <= $this->total_rows) { $option_url = url::do_url($this_url, [$page_get_var_name => 1, $rows_get_var_name => $num_rows]); $option = $num_rows_selector->append_option($option_url, $num_rows, self::$rows_per_page == $num_rows ? TRUE : FALSE); } else { break; } } if ($this->total_rows <= self::$rows_limit_to_all) { $option_url = url::do_url($this_url, [$page_get_var_name => 1, $rows_get_var_name => $this->total_rows]); $option = $num_rows_selector->append_option($option_url, $this->total_rows, self::$rows_per_page == $this->total_rows ? TRUE : FALSE); } $label = new \k1lib\html\label("Show", $this->get_object_id() . "-page-rows-goto"); $label->set_attrib("style", "display:inline"); $label->append_to($div_page_chooser); $num_rows_selector->append_to($div_page_chooser); } return $div_pagination; }
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; } }
public function apply_link_on_field_filter($link_to_apply, $fields_to_change = null, $custom_field_value = null, $href_target = null) { if ($this->get_state()) { $this->link_on_field_filter_applied = true; $a_tag = new \k1lib\html\a(url::do_url($link_to_apply), "", $href_target); $a_tag->set_attrib("class", "k1lib-link-filter", TRUE); if (empty($fields_to_change)) { $fields_to_change = crudlexs_base::USE_KEY_FIELDS; } return $this->apply_html_tag_on_field_filter($a_tag, $fields_to_change, $custom_field_value); } else { return FALSE; } }
public function related_apply_link_read_field($field_links_array, $board_root, $board_read, $clear_url = FALSE) { if ($this->related_list->get_db_table_data()) { if ($clear_url) { $get_vars = []; } else { $get_vars = ["auth-code" => "--authcode--", "back-url" => $_SERVER['REQUEST_URI']]; } $link_row_url = url::do_url(APP_URL . $board_root . "/" . $board_read . "/--rowkeys--/", $get_vars); $this->related_list->apply_link_on_field_filter($link_row_url, $field_links_array); return TRUE; } else { return FALSE; } }