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
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
3.7KB

  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. <input type="hidden" name="search" value="<?php echo $_POST["search"]?>">
  26. <input type="hidden" name="searchopt" value="<?php echo $_POST["searchopt"]?>">
  27. sort by:
  28. <select name="sort" id="sort" onchange="this.form.submit()">
  29. <option value="relevance" <?php if($_POST["sort"] == 'relevance') echo "selected"; ?>>relevance</option>
  30. <option value="year desc" <?php if($_POST["sort"] == 'year desc') echo "selected"; ?>>year descending</option>
  31. <option value="year asc" <?php if($_POST["sort"] == 'year asc') echo "selected"; ?>>year ascending</option>
  32. </select>
  33. <noscript>
  34. <input type="submit" class="btn btn-default" value="Set" />
  35. </noscript>
  36. </form>
  37. </div>
  38. <hr>
  39. <?php
  40. $search_results = solr_search($_POST["search"], $_POST["searchopt"], $_POST["sort"]);
  41. if(is_array($search_results)):
  42. foreach($search_results as $result):
  43. $result = highlight_search_terms($result, $_POST["search"]);
  44. ?>
  45. Application ID:
  46. <a href="id_search.php?id=<? echo $result['id']; ?>&core=<? echo $_POST['searchopt']; ?>">
  47. <?php
  48. echo $result['application_id'];
  49. ?>
  50. </a>
  51. <br><br>
  52. Year:
  53. <?php
  54. echo $result['year'];
  55. ?>
  56. <br><br>
  57. EPO publication:
  58. <a href=<?php echo $result['epo_publication_url']; ?>>
  59. <?php
  60. echo $result['epo_publication_url'];
  61. ?>
  62. </a>
  63. <br><br>
  64. IPC publication:
  65. <a href=<?php echo $result['ipc_publication_url']; ?>>
  66. <?php
  67. echo $result['ipc_publication_url'];
  68. ?>
  69. </a>
  70. <br><br>
  71. <?php
  72. if (isset($result['title'])):
  73. ?>
  74. Title:
  75. <?php
  76. echo $result['title'];
  77. ?>
  78. <br><br>
  79. <?
  80. endif;
  81. ?>
  82. <?php
  83. if (isset($result['abstract'])):
  84. ?>
  85. Abstract:
  86. <?php
  87. echo $result['abstract'];
  88. ?>
  89. <br><br>
  90. <?
  91. endif;
  92. ?>
  93. <hr>
  94. <?php
  95. endforeach;
  96. else:
  97. echo $search_results;
  98. endif;
  99. ?>
  100. </div>
  101. <script>
  102. let text = "<?php echo $_POST["search"]; ?>";
  103. upperText = text.toUpperCase();
  104. result = "<span style='color:orange'>" + upperText + "</span>";
  105. const collection = document.getElementsByClassName("search_term");
  106. for (let i = 0; i < collection.length; i++) {
  107. collection[i].innerHTML = result;
  108. }
  109. </script>
  110. </body>
  111. </html>