Esempio n. 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;
     }
 }
Esempio n. 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;
     }
 }
Esempio n. 3
0
 public function do_orderby_headers()
 {
     $this->set_do_table_field_name_encrypt();
     $headers =& $this->db_table_data_filtered[0];
     foreach ($headers as $field => $label) {
         $field_encrypted = $this->encrypt_field_name($field);
         $table_alias = \k1lib\db\security\db_table_aliases::encode($this->db_table->get_db_table_name());
         $sort_by_name = $table_alias . '-sort-by';
         $sort_mode_name = $table_alias . '-sort-mode';
         $sort_mode = 'ASC';
         $class_sort_mode = '';
         $class_active = ' non-ordering';
         if (isset($_GET[$sort_by_name]) && $_GET[$sort_by_name] == $field_encrypted) {
             $class_active = ' ordering';
             if (isset($_GET[$sort_mode_name]) && $_GET[$sort_mode_name] == 'ASC') {
                 $sort_mode = 'DESC';
                 $class_sort_mode = 'fi-arrow-down';
             } else {
                 $class_sort_mode = 'fi-arrow-up';
             }
         }
         $sort_url = url::do_url($_SERVER['REQUEST_URI'], [$sort_by_name => $field_encrypted, $sort_mode_name => $sort_mode]);
         $a = new \k1lib\html\a($sort_url, " {$label}", NULL, $class_sort_mode . $class_active);
         $headers[$field] = $a;
     }
 }
Esempio n. 4
0
 /**
  * @param \k1lib\crudlexs\class_db_table $db_table
  * @param array $field_links_array
  * @param string $board_root
  * @param string $board_read
  * @param boolean $clear_url
  * @return \k1lib\crudlexs\listing|boolean
  */
 public function do_related_list(class_db_table $db_table, $field_links_array, $board_root, $board_read, $clear_url = FALSE)
 {
     $table_alias = \k1lib\db\security\db_table_aliases::encode($db_table->get_db_table_name());
     if ($this->is_enabled && $this->read_object->is_valid()) {
         /**
          * Clients list
          */
         if ($db_table->get_state()) {
             if ($this->related_use_rows_key_text) {
                 $current_row_keys_array = $this->read_object->get_row_keys_array();
                 $db_table->set_field_constants($current_row_keys_array);
                 $db_table->set_query_filter($current_row_keys_array, TRUE, $this->related_do_clean_array_on_query_filter);
             }
             /**
              * LIST OBJECT must be created here to know if ther is data or not to show
              * all data button.
              */
             $this->related_list = new \k1lib\crudlexs\listing($db_table, FALSE);
             $this->related_list->set_rows_per_page($this->related_rows_to_show);
             $data_loaded = $this->related_list->load_db_table_data($this->related_use_show_rule);
             if ($data_loaded) {
                 if ($this->related_apply_filters) {
                     $this->related_apply_filters();
                     $this->related_apply_link_read_field($field_links_array, $board_root, $board_read, $clear_url);
                 }
             }
             return $this->related_list;
         } else {
             trigger_error("DB Table couldn't be opened : " . $db_table->get_db_table_name(), E_USER_NOTICE);
             return FALSE;
         }
     } else {
         return FALSE;
     }
 }