|
|
|
@ -540,7 +540,23 @@ class NetBiblio extends WebService
|
|
|
|
* This method is used by the website and the Android application to perform
|
|
|
|
* This method is used by the website and the Android application to perform
|
|
|
|
* book search.
|
|
|
|
* book search.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* TODO: describe various options for the parameters
|
|
|
|
* Search parameters :
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* ° queryText : the text to search for
|
|
|
|
|
|
|
|
* ° queryType : the field to search in, defaults to 'text'
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* ° genre : array of 'genreCode' to search for
|
|
|
|
|
|
|
|
* ° jeunesse : only display books for kids (must have format 'jeunesse' => array('filtrer' => 'filtrer')
|
|
|
|
|
|
|
|
* ° producerCode : filter by 'producerCode'
|
|
|
|
|
|
|
|
* ° reader : filter by 'reader'
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* ° count : number of results we want
|
|
|
|
|
|
|
|
* ° page : page to start at (0 is the first)
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Deprecated, but still in use on mobile apps :
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* ° category : synonym for 'genre' (see above)
|
|
|
|
|
|
|
|
* ° producer : synonym for 'producerCode' (see above)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param string $values JSON encoded object
|
|
|
|
* @param string $values JSON encoded object
|
|
|
|
* @return array
|
|
|
|
* @return array
|
|
|
|
@ -555,10 +571,16 @@ class NetBiblio extends WebService
|
|
|
|
throw new WebException("CallArg", "Argument must be valid JSON.", -42);
|
|
|
|
throw new WebException("CallArg", "Argument must be valid JSON.", -42);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// The iOS and Android applications still uses 'category' instead of 'genre'
|
|
|
|
// The iOS and Android applications still uses 'category' and 'producer'
|
|
|
|
if(isset($queryArray['category']) && is_array($queryArray['category'])) {
|
|
|
|
$compatibility = array(
|
|
|
|
$queryArray['genre'] = $queryArray['category'];
|
|
|
|
'category' => 'genre',
|
|
|
|
unset($queryArray['category']);
|
|
|
|
'producer' => 'producerCode'
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach($compatibility as $old => $new) {
|
|
|
|
|
|
|
|
if(isset($queryArray[$old])) {
|
|
|
|
|
|
|
|
$queryArray[$new] = $queryArray[$old];
|
|
|
|
|
|
|
|
unset($queryArray[$old]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$bs = new BookSearch();
|
|
|
|
$bs = new BookSearch();
|
|
|
|
@ -589,21 +611,18 @@ class NetBiblio extends WebService
|
|
|
|
$selectedGenres = array_filter($queryArray['genre'], function ($c) {
|
|
|
|
$selectedGenres = array_filter($queryArray['genre'], function ($c) {
|
|
|
|
return $c != '0';
|
|
|
|
return $c != '0';
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (count($selectedGenres) > 0) {
|
|
|
|
$bs->addOrQuery($selectedGenres, 'genreCode');
|
|
|
|
$selectedGenres = array_map(function ($c) {
|
|
|
|
|
|
|
|
return 'genreCode:'.\SolrUtils::escapeQueryChars($c);
|
|
|
|
|
|
|
|
}, $selectedGenres);
|
|
|
|
|
|
|
|
$bs->addQuery('('.implode(' OR ', $selectedGenres).')', null, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(isset($queryArray['jeunesse']) && $queryArray['jeunesse']['filtrer'] === 'filtrer') {
|
|
|
|
if(isset($queryArray['jeunesse']) && $queryArray['jeunesse']['filtrer'] === 'filtrer') {
|
|
|
|
$bs->addQuery(1, 'jeunesse');
|
|
|
|
$bs->addQuery(1, 'jeunesse');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// The following query filter is used by the mobile applications
|
|
|
|
$queries = array('producerCode', 'reader');
|
|
|
|
if(isset($queryArray['producer']) && strlen($queryArray['producer']) > 0) {
|
|
|
|
foreach($queries as $q) {
|
|
|
|
$bs->addQuery($queryArray['producer'], 'producerCode');
|
|
|
|
if(isset($queryArray[$q]) && strlen($queryArray[$q]) > 0) {
|
|
|
|
|
|
|
|
$bs->addQuery($queryArray[$q], $q);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$count = isset($queryArray['count']) ? (int) $queryArray['count'] : Configuration::get('solr.result_count');
|
|
|
|
$count = isset($queryArray['count']) ? (int) $queryArray['count'] : Configuration::get('solr.result_count');
|
|
|
|
|