diff --git a/.gitignore b/.gitignore index 8c12c70..54e8b97 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ sessions/* ignore kanban/ .pi-tasks +docs/framework_review.md diff --git a/conf/init.php b/conf/init.php index ed0dbc1..c65b349 100755 --- a/conf/init.php +++ b/conf/init.php @@ -52,7 +52,7 @@ spl_autoload_register(function ($class_name) { } $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) { $path[0] = $prefix . DIRECTORY_SEPARATOR . $class_name . '.interface.php'; diff --git a/lib/ImgSearch.class.php b/lib/ImgSearch.class.php index c1aaf46..9e9d44b 100755 --- a/lib/ImgSearch.class.php +++ b/lib/ImgSearch.class.php @@ -62,7 +62,7 @@ class ImgSearch { public function getImageData() { $clazz = ucfirst($this->engine); $search = new $clazz(); - $search->setQuery(urlencode($this->word)); + $search->setQuery($this->word); $search->setParam('start', $this->hitPosition); $search->setParam('size', $this->numberResults); diff --git a/resource/Brave.class.php b/resource/Brave.class.php index a55f164..74e727e 100644 --- a/resource/Brave.class.php +++ b/resource/Brave.class.php @@ -21,8 +21,20 @@ class Brave implements Search { public function setQuery($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)) { $request .= '&offset=' . $this->start; } @@ -38,11 +50,6 @@ class Brave implements Search { $this->$key = $value; } - public function getData() { - $return_array = $this->prepareData(); - return $return_array; - } - /** * Prepare a project wide universal array with results */