Skip to content

Commit

Permalink
fix: solr accents (#232)
Browse files Browse the repository at this point in the history
* fix: remove double encoding

* fix: exclude from search
  • Loading branch information
64knl authored Apr 18, 2024
1 parent 5bfa71c commit 7df472e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private function legacyConveryBitToJSon($menuitem)
'allowChangeParent' => (bool) (intval($menuitem->attr) & $ATTR_CHANGEPARENT),
'allowDeleteChildren' => ! (intval($menuitem->attr) & $ATTR_NODELETECHILD),
'allowEnabled' => ! (intval($menuitem->attr) & $ATTR_NOENABLE),
'exludeFromSearch' => (bool) $excludeFromSearch,
'excludeFromSearch' => (bool) $excludeFromSearch,
];
$menuitem->properties = ($newProperties);
$menuitem->menu = (bool) (intval($menuitem->attr) & $ATTR_NODELETECHILD);
Expand Down
7 changes: 4 additions & 3 deletions src/Models/Indexes/SolrItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct($solr, $q, $collate = false, private int $highlightL
$this->error = isset($solr->error) ? $solr->error : null;
}

public function isValid()
public function isValid(): bool
{
return $this->header && $this->header->status == 0;
}
Expand Down Expand Up @@ -183,21 +183,22 @@ public function predictions()
return $queries;
}

public function spellcheckList()
public function spellcheckList(): array
{
$items = [];
$query = $this->q;

if (isset($this->spellcheck)) {
foreach ($this->spellcheck->suggestions as $suggestion) {

if (isset($suggestion->startOffset)) {
$suggest = substr($query, 0, $suggestion->startOffset).'<em>'.$suggestion->suggestion[0].'</em>'.substr($query, $suggestion->endOffset);
$suggestTerm = preg_replace('/^([a-zA-Z])+(_[a-zA-Z]{2})?:/', '', $suggest); // remove search field if necessary

$suggest_url = substr($query, 0, $suggestion->startOffset).$suggestion->suggestion[0].substr($query, $suggestion->endOffset);
$suggest_url = preg_replace('/^([a-zA-Z])+(_[a-zA-Z]{2})?:/', '', $suggest_url); // remove search field if necessary

$items[] = (object) ['link' => '?q='.rawurlencode(urldecode($suggest_url)), 'text' => urldecode($suggestTerm)];
$items[] = (object) ['link' => '?q='.rawurlencode(urldecode($suggest_url)), 'text' => $suggestTerm];
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Indexer/IndexBuilderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private function indexChildPages($parentId)

continue;
}
if (isset($page->properties->exludeFromSearch) && $page->properties->exludeFromSearch == true) {
if (isset($page->properties->excludeFromSearch) && $page->properties->excludeFromSearch == true) {
$this->writeDebug(" skipping, page not searchable\n");

continue;
Expand Down

0 comments on commit 7df472e

Please sign in to comment.