| @@ -143,11 +143,12 @@ include '../text_functions.php'; | |||
| </div> | |||
| <script> | |||
| let text = "<?php echo $_POST["search"]; ?>"; | |||
| upperText = text.toUpperCase(); | |||
| result = "<span style='color:orange'>" + upperText + "</span>"; | |||
| const collection = document.getElementsByClassName("search_term"); | |||
| for (let i = 0; i < collection.length; i++) { | |||
| let text = collection[i].textContent; | |||
| console.log(collection[i]); | |||
| upperText = text.toUpperCase(); | |||
| result = "<span style='color:orange'>" + upperText + "</span>"; | |||
| collection[i].innerHTML = result; | |||
| } | |||
| </script> | |||
| @@ -2,6 +2,9 @@ | |||
| function solr_search($search, $core, $sort){ | |||
| // URL encode the search term | |||
| $search = urlencode($search); | |||
| if ($sort == 'relevance'){ | |||
| // Assemble a query string to send to Solr. This uses the Solr hostname from config.env. Solr's query syntax can be found at many sites including https://lucene.apache.org/solr/guide/6_6/the-standard-query-parser.html | |||
| $solrurl = 'http://' . $_ENV["SOLR_HOSTNAME"] . ':' . $_ENV["SOLR_PORT"] . '/solr/' . $core . '/select?q.op=OR&q=content%3A' . $search . '&wt=json'; | |||
| @@ -1,8 +1,11 @@ | |||
| <?php | |||
| function highlight_search_terms($array, $search_term){ | |||
| $replacement = "<span class='search_term'>$search_term</span>"; | |||
| $result = str_ireplace($search_term, $replacement, $array); | |||
| function highlight_search_terms($result, $search_term){ | |||
| $search_array = explode(" ", $search_term); | |||
| foreach ($search_array as $term) { | |||
| $replacement = "<span class='search_term'>$term</span>"; | |||
| $result = str_ireplace($term, $replacement, $result); | |||
| } | |||
| return $result; | |||
| } | |||