|
@@ 317-344 (lines=28) @@
|
| 314 |
|
$purifier = new HTMLPurifier($config); |
| 315 |
|
|
| 316 |
|
$search_results = array(); |
| 317 |
|
foreach ($resultset as $document) { |
| 318 |
|
$search_results[$document->id] = array(); |
| 319 |
|
$snippet = ''; |
| 320 |
|
|
| 321 |
|
// highlighting results can be fetched by document id (the field defined as uniquekey in this schema) |
| 322 |
|
$highlightedDoc = $highlighting->getResult($document->id); |
| 323 |
|
|
| 324 |
|
if($highlightedDoc){ |
| 325 |
|
foreach($highlightedDoc as $field => $highlight) { |
| 326 |
|
$snippet = implode(' (...) ', $highlight); |
| 327 |
|
// get our highlight based on the wrapped tokens |
| 328 |
|
// note, this is to prevent partial html from breaking page layouts |
| 329 |
|
preg_match_all('/<span data-hl="elgg-solr">(.*?)<\/span>/', $snippet, $match); |
| 330 |
|
|
| 331 |
|
if ($match[1]) { |
| 332 |
|
$matches = array_unique($match[1]); |
| 333 |
|
foreach ($matches as $m) { |
| 334 |
|
$snippet = str_replace($m, $hl_prefix . $m . $hl_suffix, $snippet); |
| 335 |
|
} |
| 336 |
|
$snippet = $purifier->purify($snippet); |
| 337 |
|
} |
| 338 |
|
|
| 339 |
|
$search_results[$document->id][$field] = $snippet; |
| 340 |
|
} |
| 341 |
|
} |
| 342 |
|
|
| 343 |
|
$search_results[$document->id]['score'] = $document->score; |
| 344 |
|
} |
| 345 |
|
|
| 346 |
|
// get the entities |
| 347 |
|
$entities = array(); |
|
@@ 524-550 (lines=27) @@
|
| 521 |
|
$config = HTMLPurifier_Config::createDefault(); |
| 522 |
|
$purifier = new HTMLPurifier($config); |
| 523 |
|
|
| 524 |
|
foreach ($resultset as $document) { |
| 525 |
|
$search_results[$document->id] = array(); |
| 526 |
|
$snippet = ''; |
| 527 |
|
|
| 528 |
|
// highlighting results can be fetched by document id (the field defined as uniquekey in this schema) |
| 529 |
|
$highlightedDoc = $highlighting->getResult($document->id); |
| 530 |
|
|
| 531 |
|
if($highlightedDoc){ |
| 532 |
|
foreach($highlightedDoc as $field => $highlight) { |
| 533 |
|
$snippet = implode(' (...) ', $highlight); |
| 534 |
|
// get our highlight based on the wrapped tokens |
| 535 |
|
// note, this is to prevent partial html from breaking page layouts |
| 536 |
|
preg_match_all('/<span data-hl="elgg-solr">(.*?)<\/span>/', $snippet, $match); |
| 537 |
|
|
| 538 |
|
if ($match[1]) { |
| 539 |
|
$matches = array_unique($match[1]); |
| 540 |
|
foreach ($matches as $m) { |
| 541 |
|
$snippet = str_replace($m, $hl_prefix . $m . $hl_suffix, $snippet); |
| 542 |
|
} |
| 543 |
|
$snippet = $purifier->purify($snippet); |
| 544 |
|
} |
| 545 |
|
|
| 546 |
|
$search_results[$document->id][$field] = $snippet; |
| 547 |
|
} |
| 548 |
|
} |
| 549 |
|
$search_results[$document->id]['score'] = $document->score; |
| 550 |
|
} |
| 551 |
|
|
| 552 |
|
// get the entities |
| 553 |
|
$entities = array(); |
|
@@ 725-752 (lines=28) @@
|
| 722 |
|
$config = HTMLPurifier_Config::createDefault(); |
| 723 |
|
$purifier = new HTMLPurifier($config); |
| 724 |
|
|
| 725 |
|
foreach ($resultset as $document) { |
| 726 |
|
$search_results[$document->id] = array(); |
| 727 |
|
$snippet = ''; |
| 728 |
|
|
| 729 |
|
// highlighting results can be fetched by document id (the field defined as uniquekey in this schema) |
| 730 |
|
$highlightedDoc = $highlighting->getResult($document->id); |
| 731 |
|
|
| 732 |
|
if($highlightedDoc){ |
| 733 |
|
foreach($highlightedDoc as $field => $highlight) { |
| 734 |
|
$snippet = implode(' (...) ', $highlight); |
| 735 |
|
// get our highlight based on the wrapped tokens |
| 736 |
|
// note, this is to prevent partial html from breaking page layouts |
| 737 |
|
preg_match_all('/<span data-hl="elgg-solr">(.*?)<\/span>/', $snippet, $match); |
| 738 |
|
|
| 739 |
|
if ($match[1]) { |
| 740 |
|
$matches = array_unique($match[1]); |
| 741 |
|
foreach ($matches as $m) { |
| 742 |
|
$snippet = str_replace($m, $hl_prefix . $m . $hl_suffix, $snippet); |
| 743 |
|
} |
| 744 |
|
$snippet = $purifier->purify($snippet); |
| 745 |
|
} |
| 746 |
|
|
| 747 |
|
$search_results[$document->id][$field] = $snippet; |
| 748 |
|
} |
| 749 |
|
} |
| 750 |
|
|
| 751 |
|
$search_results[$document->id]['score'] = $document->score; |
| 752 |
|
} |
| 753 |
|
|
| 754 |
|
// get the entities |
| 755 |
|
$entities = array(); |