Change the search to look into tags and series (in addition to book title and author).

re #34, #47, #78
This commit is contained in:
Sébastien Lucas 2013-09-27 17:13:31 +02:00
parent acea490e00
commit 3943205b58
3 changed files with 30 additions and 10 deletions

View file

@ -664,18 +664,26 @@ class PageRecentBooks extends Page
class PageQueryResult extends Page
{
const SCOPE_TAG = "tag";
const SCOPE_SERIES = "series";
const SCOPE_AUTHOR = "author";
const SCOPE_BOOK = "book";
public function InitializeContent ()
{
global $config;
$this->title = str_format (localize ("search.result"), $this->query);
$currentPage = getURLParam ("current", NULL);
$scope = getURLParam ("scope");
$crit = "%" . $this->query . "%";
$bad = "QQQQQ";
// Special case when we are doing a search and no database is selected
if (is_array ($config['calibre_directory']) && is_null (GetUrlParam (DB))) {
$i = 0;
foreach ($config['calibre_directory'] as $key => $value) {
Base::clearDb ();
list ($array, $totalNumber) = Book::getBooksByQuery ($this->query, $this->n, $i);
list ($array, $totalNumber) = Book::getBooksByQuery (array ($crit, $crit, $crit, $crit), $this->n, $i);
array_push ($this->entryArray, new Entry ($key, DB . ":query:{$i}",
str_format (localize ("bookword", count($array)), count($array)), "text",
array ( new LinkNavigation ("?" . DB . "={$i}&page=9&query=" . $this->query))));
@ -683,14 +691,23 @@ class PageQueryResult extends Page
}
return;
}
switch ($currentPage) {
case Base::PAGE_ALL_AUTHORS :
case Base::PAGE_AUTHORS_FIRST_LETTER :
switch ($scope) {
case self::SCOPE_AUTHOR :
$this->entryArray = Author::getAuthorsByStartingLetter ('%' . $this->query);
break;
case self::SCOPE_TAG :
$this->entryArray = Tag::getAllTagsByQuery ($this->query);
break;
case self::SCOPE_SERIES :
$this->entryArray = Serie::getAllSeriesByQuery ($this->query);
break;
case self::SCOPE_BOOK :
list ($this->entryArray, $this->totalNumber) = Book::getBooksByQuery (
array ($bad, $bad, $bad, $crit), $this->n);
break;
default:
list ($this->entryArray, $this->totalNumber) = Book::getBooksByQuery ($this->query, $this->n);
list ($this->entryArray, $this->totalNumber) = Book::getBooksByQuery (
array ($crit, $crit, $crit, $crit), $this->n);
}
}
}