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.

147 lines
3.6KB

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