view_list_recent_discuss.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package route
  2. import (
  3. "database/sql"
  4. "opennamu/route/tool"
  5. )
  6. func Get_ui_recent_discuss(db *sql.DB, config tool.Config, data_all [][]string) string {
  7. auth_name := tool.Get_user_auth(db, config.IP)
  8. auth_info := tool.Get_auth_group_info(db, auth_name)
  9. data_html := ""
  10. for_count := 1
  11. for _, in_data := range data_all {
  12. // for_count_str := strconv.Itoa(for_count)
  13. for_count += 1
  14. left := `<a href="/thread/` + in_data[3] + `">` + tool.HTML_escape(in_data[1]) + `</a> `
  15. left += `<a href="/w/` + tool.Url_parser(in_data[0]) + `">(` + tool.HTML_escape(in_data[0]) + `)</a> `
  16. if _, ok := auth_info["hidel"]; ok {
  17. left = `<label><input type="checkbox"> ` + left + `</label>`
  18. }
  19. right := ``
  20. switch in_data[4] {
  21. case "O":
  22. right += tool.Get_language(db, "closed", true) + " | "
  23. case "S":
  24. right += tool.Get_language(db, "stop", true) + " | "
  25. }
  26. if in_data[8] != "" {
  27. right += tool.Get_language(db, "agreed_discussion", true) + " | "
  28. }
  29. right += `<a href="/thread/` + in_data[3] + `#` + in_data[7] + `">#` + in_data[7] + `</a> | `
  30. right += in_data[6] + " | " + in_data[2]
  31. data_html += tool.Get_list_ui(left, right, "", "")
  32. }
  33. return data_html
  34. }
  35. func View_list_recent_discuss(config tool.Config, limit string, num string, set_type string) string {
  36. db := tool.DB_connect()
  37. defer tool.DB_close(db)
  38. data_html := ""
  39. sub := ""
  40. menu_option := [][]string{
  41. { "normal", tool.Get_language(db, "normal", true) },
  42. { "close", tool.Get_language(db, "close_discussion", true) },
  43. { "open", tool.Get_language(db, "open_discussion", true) },
  44. }
  45. for _, option := range menu_option {
  46. data_html += `<a href="/recent_discuss/1/` + option[0] + `">(` + option[1] + `)</a> `
  47. if option[0] == set_type {
  48. sub = "(" + option[1] + ")"
  49. }
  50. }
  51. data_html += "<hr class=\"main_hr\">"
  52. api_data := Api_list_recent_discuss(config, limit, num, set_type)
  53. api_data_list := api_data["data"].([][]string)
  54. data_html += Get_ui_recent_discuss(db, config, api_data_list)
  55. data_html += tool.Get_page_control(
  56. db,
  57. tool.Str_to_int(num),
  58. len(api_data_list),
  59. tool.Str_to_int(limit),
  60. "/recent_discuss/{}/" + set_type,
  61. )
  62. out := tool.Get_template(
  63. db,
  64. config,
  65. tool.Get_language(db, "recent_discussion", true),
  66. data_html,
  67. []any{ sub },
  68. [][]any{},
  69. map[string]string{},
  70. )
  71. return out
  72. }