contest-question-table.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. if (!isset($can_reply)) {
  3. $can_reply = false;
  4. $reply_question = null;
  5. }
  6. ?>
  7. <div class="table-responsive shadow my-4">
  8. <table class="table table-bordered table-hover table-vertical-middle table-text-center">
  9. <thead>
  10. <tr>
  11. <th style="width:10em">提问者</th>
  12. <th style="width:7em">提问时间</th>
  13. <th>问题</th>
  14. </tr>
  15. </thead>
  16. <tbody>
  17. <?php if ($pag->isEmpty()): ?>
  18. <tr><td colspan="233"><?= UOJLocale::get('none') ?></td></tr>
  19. <?php else: foreach ($pag->get() as $question): ?>
  20. <tr>
  21. <td><?= getUserLink($question['username']) ?></td>
  22. <td class="small"><?= $question['post_time'] ?></td>
  23. <td style="text-align: left" class="question" data-qid="<?=$question['id']?>">
  24. <div class="question-content uoj-readmore"><?= HTML::escape($question['question']) ?></div>
  25. <?php if ($can_reply): ?>
  26. <div class="text-right">
  27. <button type="button" class="btn btn-primary btn-xs question-reply-button">编辑回复</button>
  28. </div>
  29. <?php endif ?>
  30. <hr class="top-buffer-sm bot-buffer-md" />
  31. <?php if ($question['answer'] === ''): ?>
  32. <div class="question-content"><strong class="text-muted">暂无回复</strong></div>
  33. <?php else: ?>
  34. <div class="question-content uoj-readmore"><strong class="text-danger">回复:</strong><span class="text-warning"><?= HTML::escape($question['answer']) ?></span></div>
  35. <?php endif ?>
  36. </td>
  37. </tr>
  38. <?php endforeach; endif ?>
  39. </tbody>
  40. </table>
  41. </div>
  42. <?= $pag->pagination() ?>
  43. <?php if ($reply_question): ?>
  44. <div id="div-reply" style="display:none" class="top-buffer-md bot-buffer-md">
  45. <?php $reply_question->printHTML() ?>
  46. </div>
  47. <script type="text/javascript">
  48. var onclick = function(p) {
  49. return function() {
  50. qid = parseInt($(p).data('qid'))
  51. q = '#div-reply';
  52. t = '#input-rid';
  53. r = '#input-rcontent';
  54. if ($(q).data('qid') != qid) {
  55. $(q).data('qid', qid);
  56. $(q).hide('fast', function() {
  57. $(this).appendTo(p).show('fast', function() {
  58. $(t).val(qid);
  59. $(r).val('').focus();
  60. });
  61. });
  62. } else if ($(q).css('display') != 'none') {
  63. $(q).appendTo(p).hide('fast');
  64. } else {
  65. $(q).appendTo(p).show('fast', function() {
  66. $(t).val(qid);
  67. $(r).val('').focus();
  68. });
  69. }
  70. };
  71. };
  72. $('.question').each(function() {
  73. $(this).find('.question-reply-button').click(onclick(this));
  74. });
  75. var onselectchange = function() {
  76. switch ($('#input-rtype').val()) {
  77. case 'private':
  78. case 'public':
  79. $('#input-rcontent').prop('readonly', false);
  80. break;
  81. default:
  82. $('#input-rcontent').val('').prop('readonly', true);
  83. break;
  84. }
  85. };
  86. $(document).ready(onselectchange);
  87. $('#input-rtype').on('change', onselectchange);
  88. </script>
  89. <?php endif ?>