Ejemplo n.º 1
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;
 }