search.html.php 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php if (!defined('HTMLY')) die('HTMLy'); ?>
  2. <h2 class="post-index"><?php echo $heading ?></h2>
  3. <br>
  4. <?php $search_index = array(); if (!empty($posts)) { ?>
  5. <form method="POST" action="<?php echo site_url();?>admin/search/reindex">
  6. <p><?php echo i18n('unindexed_posts');?></p>
  7. <input type="submit" class="btn btn-primary" value="<?php echo i18n('add_search_index');?>">
  8. <br><br>
  9. <table class="table post-list">
  10. <thead>
  11. <tr class="head">
  12. <th><?php echo i18n('Title');?></th>
  13. <th><?php echo i18n('Published');?></th><?php if (config("views.counter") == "true"): ?>
  14. <th><?php echo i18n('Views');?></th><?php endif; ?>
  15. <th><?php echo i18n('Author');?></th>
  16. <th><?php echo i18n('Category');?></th>
  17. <th><?php echo i18n('Tags');?></th>
  18. </tr>
  19. </thead>
  20. <tbody>
  21. <?php foreach ($posts as $p): ?>
  22. <tr>
  23. <td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td>
  24. <td><?php echo format_date($p->date) ?></td>
  25. <?php if (config("views.counter") == "true"): ?>
  26. <td><?php echo $p->views ?></td><?php endif; ?>
  27. <td><a target="_blank" href="<?php echo $p->authorUrl ?>"><?php echo $p->author ?></a></td>
  28. <td><a href="<?php echo site_url() . 'admin/categories/' . $p->categorySlug; ?>"><?php echo $p->categoryTitle;?></a></td>
  29. <td><?php echo str_replace('rel="tag"', 'rel="tag" class="badge badge-light text-primary font-weight-normal"', $p->tag); ?></td>
  30. </tr>
  31. <?php $search_index[] = array($p->slug, $p->file);?>
  32. <?php endforeach; ?>
  33. </tbody>
  34. </table>
  35. <input type="submit" class="btn btn-primary" value="<?php echo i18n('add_search_index');?>">
  36. <br><br>
  37. <?php if (!empty($pagination['prev']) || !empty($pagination['next'])): ?>
  38. <br>
  39. <div class="pager">
  40. <ul class="pagination">
  41. <?php if (!empty($pagination['prev'])) { ?>
  42. <li class="newer page-item"><a class="page-link" href="?page=<?php echo $page - 1 ?>" rel="prev">&#8592; <?php echo i18n('Newer');?></a></li>
  43. <?php } else { ?>
  44. <li class="page-item disabled" ><span class="page-link">&#8592; <?php echo i18n('Newer');?></span></li>
  45. <?php } ?>
  46. <li class="page-number page-item disabled"><span class="page-link"><?php echo $pagination['pagenum'];?></span></li>
  47. <?php if (!empty($pagination['next'])) { ?>
  48. <li class="older page-item" ><a class="page-link" href="?page=<?php echo $page + 1 ?>" rel="next"><?php echo i18n('Older');?> &#8594;</a></li>
  49. <?php } else { ?>
  50. <li class="page-item disabled" ><span class="page-link"><?php echo i18n('Older');?> &#8594;</span></li>
  51. <?php } ?>
  52. </ul>
  53. </div>
  54. <?php endif; ?>
  55. <input type="hidden" name="search_index" value="<?php print_r(htmlspecialchars(json_encode($search_index)));?>">
  56. </form>
  57. <?php } else {?>
  58. <script>
  59. $(function() {
  60. var data = 'content/data/search.json';
  61. $("#clearButton").click(function(){
  62. $.ajax({
  63. type: 'POST',
  64. url: '<?php echo site_url();?>admin/search',
  65. dataType: 'json',
  66. data: {'json': data},
  67. success: function (response) {
  68. alert(response.message);
  69. location.reload();
  70. },
  71. });
  72. });
  73. });
  74. </script>
  75. <p><?php echo count(get_blog_posts()); ?> <?php echo i18n('indexed_posts');?></p>
  76. <p><button class="btn btn-primary" id="clearButton"><?php echo i18n('clear_search_index');?></button></p>
  77. <?php } ?>