Brave request Fix. Path seperator fix.

This commit is contained in:
Fabian de Boer 2026-07-17 12:34:37 +02:00
commit 6a122e3bed
4 changed files with 16 additions and 8 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ sessions/*
ignore ignore
kanban/ kanban/
.pi-tasks .pi-tasks
docs/framework_review.md

View file

@ -52,7 +52,7 @@ spl_autoload_register(function ($class_name) {
} }
$include_path = get_include_path(); $include_path = get_include_path();
$include_path_tokens = explode(':', $include_path); $include_path_tokens = explode(PATH_SEPARATOR, $include_path);
foreach ($include_path_tokens as $prefix) { foreach ($include_path_tokens as $prefix) {
$path[0] = $prefix . DIRECTORY_SEPARATOR . $class_name . '.interface.php'; $path[0] = $prefix . DIRECTORY_SEPARATOR . $class_name . '.interface.php';

View file

@ -62,7 +62,7 @@ class ImgSearch {
public function getImageData() { public function getImageData() {
$clazz = ucfirst($this->engine); $clazz = ucfirst($this->engine);
$search = new $clazz(); $search = new $clazz();
$search->setQuery(urlencode($this->word)); $search->setQuery($this->word);
$search->setParam('start', $this->hitPosition); $search->setParam('start', $this->hitPosition);
$search->setParam('size', $this->numberResults); $search->setParam('size', $this->numberResults);

View file

@ -21,8 +21,20 @@ class Brave implements Search {
public function setQuery($word) { public function setQuery($word) {
$this->word = $word; $this->word = $word;
}
$request = $this->q_prefix . urlencode($word); public function getData() {
$this->buildRequest();
$return_array = $this->prepareData();
return $return_array;
}
/**
* Build the request URL and cURL handle after all setParam() calls have been made.
* This ensures start/offset and size are available when constructing the URL.
*/
private function buildRequest() {
$request = $this->q_prefix . urlencode($this->word);
if (isset($this->start)) { if (isset($this->start)) {
$request .= '&offset=' . $this->start; $request .= '&offset=' . $this->start;
} }
@ -38,11 +50,6 @@ class Brave implements Search {
$this->$key = $value; $this->$key = $value;
} }
public function getData() {
$return_array = $this->prepareData();
return $return_array;
}
/** /**
* Prepare a project wide universal array with results * Prepare a project wide universal array with results
*/ */