Пример #1
0
 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;
     }
 }
Пример #2
0
 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;
     }
 }
Пример #3
0
 /**
  * 
  * @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;
 }
Пример #4
0
 /**
  * 
  * @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;
 }