A search interface for data from the Politics of Patents case study (part of Copim WP6): this parses data from the archive of RTF files and provides additional data from the European Patent Office API. https://patents.copim.ac.uk
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

156 lines
3.9KB

  1. <?php
  2. # @name: search.php
  3. # @version: 0.1
  4. # @creation_date: 2021-09-30
  5. # @license: The MIT License <https://opensource.org/licenses/MIT>
  6. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  7. # @purpose: Searches the Solr index
  8. include '../solr.php';
  9. include '../text_functions.php';
  10. ?>
  11. <!DOCTYPE html>
  12. <html lang="en">
  13. <head>
  14. <title>Performing Patents Otherwise: Archival conversations with 320.000 clothing inventions</title>
  15. <meta charset="utf-8">
  16. <meta name="viewport" content="width=device-width, initial-scale=1">
  17. <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
  18. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
  19. <link rel="stylesheet" type="text/css" href="css/style.css">
  20. </head>
  21. <body>
  22. <div class="container">
  23. <div class="row p-3">
  24. <form action="search.php" method="POST">
  25. <?php
  26. if (!isset($_POST["searchopt"])) {
  27. $_POST["searchopt"] = 'all';
  28. }
  29. if (!isset($_POST["sort"])) {
  30. $_POST["sort"] = 'relevance';
  31. }
  32. ?>
  33. <input type="hidden" name="search" value="<?php echo $_POST["search"]?>">
  34. <input type="hidden" name="searchopt" value="<?php echo $_POST["searchopt"]?>">
  35. sort by:
  36. <select name="sort" id="sort" onchange="this.form.submit()">
  37. <option value="relevance" <?php if($_POST["sort"] == 'relevance') echo "selected"; ?>>relevance</option>
  38. <option value="year desc" <?php if($_POST["sort"] == 'year desc') echo "selected"; ?>>year descending</option>
  39. <option value="year asc" <?php if($_POST["sort"] == 'year asc') echo "selected"; ?>>year ascending</option>
  40. </select>
  41. <noscript>
  42. <input type="submit" class="btn btn-default" value="Set" />
  43. </noscript>
  44. </form>
  45. </div>
  46. <hr>
  47. <?php
  48. $search_results = solr_search($_POST["search"], $_POST["searchopt"], $_POST["sort"]);
  49. if(is_array($search_results)):
  50. foreach($search_results as $result):
  51. $result = highlight_search_terms($result, $_POST["search"]);
  52. ?>
  53. Application ID:
  54. <a href="id_search.php?id=<? echo $result['id']; ?>&core=<? echo $_POST['searchopt']; ?>">
  55. <?php
  56. echo $result['application_id'];
  57. ?>
  58. </a>
  59. <br><br>
  60. Year:
  61. <?php
  62. echo $result['year'];
  63. ?>
  64. <br><br>
  65. EPO publication:
  66. <a href=<?php echo $result['epo_publication_url']; ?>>
  67. <?php
  68. echo $result['epo_publication_url'];
  69. ?>
  70. </a>
  71. <br><br>
  72. IPC publication:
  73. <a href=<?php echo $result['ipc_publication_url']; ?>>
  74. <?php
  75. echo $result['ipc_publication_url'];
  76. ?>
  77. </a>
  78. <br><br>
  79. <?php
  80. if (isset($result['title'])):
  81. ?>
  82. Title:
  83. <?php
  84. echo $result['title'];
  85. ?>
  86. <br><br>
  87. <?
  88. endif;
  89. ?>
  90. <?php
  91. if (isset($result['abstract'])):
  92. ?>
  93. Abstract:
  94. <?php
  95. echo $result['abstract'];
  96. ?>
  97. <br><br>
  98. <?
  99. endif;
  100. ?>
  101. <hr>
  102. <?php
  103. endforeach;
  104. else:
  105. echo $search_results;
  106. endif;
  107. ?>
  108. </div>
  109. <script>
  110. const collection = document.getElementsByClassName("search_term");
  111. for (let i = 0; i < collection.length; i++) {
  112. let text = collection[i].textContent;
  113. upperText = text.toUpperCase();
  114. result = "<span style='color:orange'>" + upperText + "</span>";
  115. collection[i].innerHTML = result;
  116. }
  117. </script>
  118. </body>
  119. </html>