search.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App;
  3. use App\Helpers\HtmlHelper;
  4. /**
  5. * @var array $results
  6. * @var string $term
  7. */
  8. $core = Core::getInstance();
  9. $user = $core->getUser();
  10. ?>
  11. <form class="mb-3" method="get">
  12. <label for="term" class="sr-only"><?=htmlspecialchars(__("Search Term"))?></label>
  13. <div class="input-group input-group-lg">
  14. <input class="form-control" type="search" name="term" id="term" value="<?=htmlspecialchars($term)?>" minlength="3" placeholder="<?=htmlspecialchars(__("Type search term"))?>" />
  15. <button type="submit" class="btn btn-primary">
  16. <i class="fa fa-fw fa-search"></i>
  17. </button>
  18. </div>
  19. </form>
  20. <?php
  21. if($term) {
  22. ?>
  23. <div class="row mb-3">
  24. <div class="col">
  25. <h3><?=htmlspecialchars(__("Search Results"))?></h3>
  26. </div>
  27. </div>
  28. <?php
  29. if(!$results) {
  30. HtmlHelper::renderInfoAlert(__("No search results to display."));
  31. }
  32. else {
  33. ?>
  34. <table class="table table-bordered table-hover mb-3">
  35. <thead>
  36. <tr>
  37. <th><?=htmlspecialchars(__("Type"))?></th>
  38. <th><?=htmlspecialchars(__("Result"))?></th>
  39. <th><?=htmlspecialchars(__("Match Reason"))?></th>
  40. </tr>
  41. </thead>
  42. <tbody>
  43. <?php
  44. foreach($results as $result) {
  45. ?>
  46. <tr>
  47. <td>
  48. <?=htmlspecialchars($result["type"])?>
  49. </td>
  50. <td>
  51. <a href="<?=htmlspecialchars($result["url"])?>"><?=htmlspecialchars($result["name"])?></a>
  52. </td>
  53. <td>
  54. <?=htmlspecialchars($result["match_reason"])?>
  55. </td>
  56. </tr>
  57. <?php
  58. }
  59. ?>
  60. </tbody>
  61. </table>
  62. <?php
  63. }
  64. }