Brave request Fix. Path seperator fix.
This commit is contained in:
parent
d971512a31
commit
6a122e3bed
4 changed files with 16 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,3 +2,4 @@ sessions/*
|
||||||
ignore
|
ignore
|
||||||
kanban/
|
kanban/
|
||||||
.pi-tasks
|
.pi-tasks
|
||||||
|
docs/framework_review.md
|
||||||
|
|
|
||||||
|
|
@ -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';
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue