2
0

topic_close_list.py 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. from .tool.func import *
  2. def topic_close_list_2(conn, name):
  3. curs = conn.cursor()
  4. div = ''
  5. tool = flask.request.args.get('tool', '')
  6. plus = ''
  7. menu = [['topic/' + url_pas(name), load_lang('return')]]
  8. if tool == 'close':
  9. curs.execute(db_change("select sub from rd where title = ? and stop = 'O' order by sub asc"), [name])
  10. sub = load_lang('closed_discussion')
  11. elif tool == 'agree':
  12. curs.execute(db_change("select sub from rd where title = ? and agree = 'O' order by sub asc"), [name])
  13. sub = load_lang('agreed_discussion')
  14. else:
  15. sub = load_lang('discussion_list')
  16. menu = [['w/' + url_pas(name), load_lang('document')]]
  17. if acl_check(name, 'topic', sub) == 1:
  18. display = 'display: none;'
  19. else:
  20. display = ''
  21. curs.execute(db_change("select code from topic order by code + 0 desc limit 1"))
  22. t_data = curs.fetchall()
  23. if t_data:
  24. topic_num = str(int(t_data[0][0]) + 1)
  25. else:
  26. topic_num = '1'
  27. plus = '''
  28. <a href="/topic/''' + url_pas(name) + '?tool=close">(' + load_lang('closed_discussion') + ')</a> <a href="/topic/' + url_pas(name) + '?tool=agree">(' + load_lang('agreed_discussion') + ''')</a>
  29. <hr class=\"main_hr\">
  30. <form style="''' + display + '" method="post" action="/thread/' + topic_num + '''">
  31. <input placeholder="''' + load_lang('discussion_name') + '''" name="title">
  32. <hr class=\"main_hr\">
  33. <textarea rows="10" id="content" placeholder="''' + load_lang('content') + '''" name="content"></textarea>
  34. <hr class=\"main_hr\">
  35. ''' + captcha_get() + (ip_warring() if display == '' else '') + '''
  36. <input style="display: none;" name="topic" value="''' + name + '''">
  37. <button type="submit">''' + load_lang('send') + '''</button>
  38. <button id="preview" type="button" onclick="load_preview(\'''' + url_pas(name) + '\')">' + load_lang('preview') + '''</button>
  39. </form>
  40. <hr class=\"main_hr\">
  41. <div id="see_preview"></div>
  42. '''
  43. curs.execute(db_change("select sub from rd where title = ? order by date desc"), [name])
  44. t_num = 0
  45. for data in curs.fetchall():
  46. t_num += 1
  47. curs.execute(db_change("select code from topic where title = ? and sub = ? and id = '1'"), [name, data[0]])
  48. first_topic = curs.fetchall()
  49. if first_topic:
  50. it_p = 0
  51. if tool == '':
  52. curs.execute(db_change("select title from rd where title = ? and sub = ? and stop = 'O' order by sub asc"), [name, data[0]])
  53. if curs.fetchall():
  54. it_p = 1
  55. if it_p != 1:
  56. curs.execute(db_change("select id from topic where title = ? and sub = ? order by date desc limit 1"), [name, data[0]])
  57. t_data = curs.fetchall()
  58. div += '''
  59. <h2><a href="/thread/''' + first_topic[0][0] + '">' + str(t_num) + '. ' + data[0] + '''</a></h2>
  60. <div id="topic_pre_''' + str(t_num) + '''"></div>
  61. <div id="topic_back_pre_''' + str(t_num) + '''"></div>
  62. <script>
  63. topic_list_load(''' + first_topic[0][0] + ', 1, "topic_pre_' + str(t_num) + '''");
  64. if(''' + str(t_data[0][0]) + ''' !== 1) {
  65. topic_list_load(''' + first_topic[0][0] + ', ' + t_data[0][0] + ', "topic_back_pre_' + str(t_num) + '''");
  66. }
  67. </script>
  68. '''
  69. if div == '':
  70. plus = re.sub('^<br>', '', plus)
  71. return easy_minify(flask.render_template(skin_check(),
  72. imp = [name, wiki_set(), custom(), other2([' (' + sub + ')', 0])],
  73. data = div + plus,
  74. menu = menu
  75. ))