Skip to content

Commit

Permalink
added a hook for custom functions
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsekaean committed Dec 1, 2019
1 parent 7f685a4 commit 9b8fb43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 45 deletions.
47 changes: 3 additions & 44 deletions src/Model/SearchDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ public function makeSearchContent()
$contents = strip_tags($html);
}


$this->Title = $origin->getTitle();
if ($this->Origin()->hasMethod('updateSearchContents')) {
$this->Origin()->updateSearchContents($contents);
}
if ($contents) {
$contents = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $contents);
$this->Content = $contents;
Expand All @@ -134,49 +136,6 @@ public function makeSearchContent()
SSViewer::set_themes($oldThemes);
}
return implode($output);


/*
$searchLink = $origin->getGenerateSearchLink();
try {
$client = new Client();
$res = $client->request('GET', $searchLink);
if ($res->getStatusCode() == 200) {
$body = $res->getBody();
$x_path = $origin->config()->get('search_x_path');
if (!$x_path) {
$x_path = self::config()->get('search_x_path');
}
if ($x_path) {
$domDoc = new \DOMDocument();
@$domDoc->loadHTML($body);
$finder = new \DOMXPath($domDoc);
$nodes = $finder->query("//*[contains(@class, '$x_path')]");
$nodeValues = [];
if ($nodes->length) {
foreach ($nodes as $node) {
$nodeValues[] = $node->nodeValue;
}
}
$contents = implode("\n\n", $nodeValues);
} else {
$contents = strip_tags($body);
}
$this->Title = $origin->getTitle();
if ($contents) {
$this->Content = $contents;
}
$this->write();
}
} catch(\Exception $e) {}
*/


}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/ORM/Connect/MySQLDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ public function searchEngine(
$objects = array();

foreach ($records as $record) {
$objects[] = DataList::create($record['ClassName'])->byID($record['ID']);
$object = DataList::create($record['ClassName'])->byID($record['ID']);
if ($object->canView()) {
$objects[] = $object;
}
}

$list = new PaginatedList(new ArrayList($objects));
Expand Down

0 comments on commit 9b8fb43

Please sign in to comment.