2
0

view_xref.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from .tool.func import *
  2. def view_xref_2(conn, name):
  3. curs = conn.cursor()
  4. if acl_check(name, 'render') == 1:
  5. return re_error('/ban')
  6. num = int(number_check(flask.request.args.get('num', '1')))
  7. sql_num = (num * 50 - 50) if num * 50 > 0 else 0
  8. xref_type = flask.request.args.get('change', '1')
  9. if xref_type == '1':
  10. div = '<a href="?change=2">(' + load_lang('link_in_this') + ')</a><hr class="main_hr">'
  11. else:
  12. div = '<a href="?change=1">(' + load_lang('normal') + ')</a><hr class="main_hr">'
  13. div += '<ul class="inside_ul">'
  14. sql_insert = ['link', 'title'] if xref_type == '1' else ['title', 'link']
  15. curs.execute(db_change("" + \
  16. "select distinct " + sql_insert[0] + ", type from back " + \
  17. "where " + sql_insert[1] + " = ? and not type = 'cat' and not type = 'no' and not type = 'nothing'" + \
  18. "order by type asc, title asc limit ?, 50" + \
  19. ""), [
  20. name,
  21. sql_num
  22. ])
  23. data_list = curs.fetchall()
  24. for data in data_list:
  25. div += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a>'
  26. if data[1]:
  27. div += ' (' + data[1] + ')'
  28. curs.execute(db_change("select title from back where title = ? and type = 'include'"), [data[0]])
  29. db_data = curs.fetchall()
  30. if db_data:
  31. div += ' <a id="inside" href="/xref/' + url_pas(data[0]) + '">(' + load_lang('backlink') + ')</a>'
  32. div += '</li>'
  33. div += '</ul>' + next_fix('/xref/' + url_pas(name) + '?change=' + xref_type + '&num=', num, data_list)
  34. return easy_minify(flask.render_template(skin_check(),
  35. imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('backlink') + ')', 0])],
  36. data = div,
  37. menu = [['w/' + url_pas(name), load_lang('return')], ['backlink_reset/' + url_pas(name), load_lang('reset_backlink')]]
  38. ))