diff --git a/NetBiblio.php b/NetBiblio.php index 2b74541..2c2293b 100644 --- a/NetBiblio.php +++ b/NetBiblio.php @@ -317,7 +317,7 @@ class NetBiblio extends WebService // add fields for mobile apps compatibility $b['date'] = date('Y.m.d', strtotime($b['availabilityDate'])); - $b['readBy'] = $b['reader']; + $b['readBy'] = isset($b['reader']) ? $b['reader'] : null; $b['code3'] = $b['producerCode']; $b['code3Long'] = $b['producer']; $b['typeMedia1'] = $b['mediaType']; @@ -394,7 +394,8 @@ class NetBiblio extends WebService $bs = new BookSearch(); $bs->addSortField('random_'.$seed); - return $this->AddBookData($bs->getResults(0, $number)); + $results = $bs->getResults(0, $number); + return $this->AddBookData($results['books']); } public function Search($query, $start, $limit) @@ -525,19 +526,12 @@ class NetBiblio extends WebService } $s->addSortField('availabilityDate'); - try { - $results = $s->getResults(0, $itemsByGroup); - } catch(\SolrClientException $e) { - throw new WebException ("SolrError", $e->getMessage(), -710); - } - - $ids = array_map(function($r) { return $r['id']; }, $results['response']['docs']); - $books = AudioBook::findBy('NoticeID', $ids, true); - $books = $this->AddBookData($books); + $results = $s->getResults(0, $itemsByGroup); + $books = $this->AddBookData($results['books']); $data = array(); foreach($books as $b) { - $data[$b['type']][] = $b; + $data[$b['genre']][] = $b; } return $data; }