diff --git a/lib/doofinder_management_api.php b/lib/doofinder_management_api.php index efb02ff..9cae594 100644 --- a/lib/doofinder_management_api.php +++ b/lib/doofinder_management_api.php @@ -374,7 +374,7 @@ function __construct($searchEngine, $dType){ $this->searchEngine = $searchEngine; } - function rewind() { + private function fetchResults(){ $apiResults = $this->searchEngine->getScrolledItemsPage($this->dType); $this->total = $apiResults['total']; $this->resultsPage = $apiResults['results']; @@ -382,6 +382,10 @@ function rewind() { $this->currentItem = each($this->resultsPage); } + function rewind() { + $this->fetchResults(); + } + function valid(){ print "\nValid? ".$this->position.", ".$this->total; return $this->position < $this->total; @@ -399,9 +403,7 @@ function next(){ ++$this->position; $this->currentItem = each($this->resultsPage); if(!$this->currentItem and $this->position < $this->total){ - $this->resultsPage = $this->searchEngine->getScrolledItemsPage( - $this->dType, $this->scrollId - )['results']; + $this->fetchResults(); $this->currentItem = each($this->resultsPage); } }