}
echo '<br />';
require "tabs.php";
require "sql.php";
/// printing the entries
$entriesshown = 0;
$currentpivot = '';
$paging = NULL;
if ($allentries) {
    //Decide if we must show the ALL link in the pagebar
    $specialtext = '';
    if ($glossary->showall) {
        $specialtext = get_string("allentries", "glossary");
    }
    //Build paging bar
    $paging = glossary_get_paging_bar($count, $page, $entriesbypage, "view.php?id={$id}&amp;mode={$mode}&amp;hook=" . urlencode($hook) . "&amp;sortkey={$sortkey}&amp;sortorder={$sortorder}&amp;fullsearch={$fullsearch}&amp;", 9999, 10, '&nbsp;&nbsp;', $specialtext, -1);
    echo '<div class="paging">';
    echo $paging;
    echo '</div>';
    //load ratings
    require_once $CFG->dirroot . '/rating/lib.php';
    if ($glossary->assessed != RATING_AGGREGATE_NONE) {
        $ratingoptions = new stdClass();
        $ratingoptions->context = $context;
        $ratingoptions->component = 'mod_glossary';
        $ratingoptions->ratingarea = 'entry';
        $ratingoptions->items = $allentries;
        $ratingoptions->aggregate = $glossary->assessed;
        //the aggregation method
        $ratingoptions->scaleid = $glossary->scale;
        $ratingoptions->userid = $USER->id;
$query = trim(strip_tags($query));
// Launch the SQL quey.
$bookresults = search($query, $course, $bookids, $start, $countentries);
$coursefield = '<input type="hidden" name="courseid" value="' . $course->id . '"/>';
$pagefield = '<input type="hidden" name="page" value="0"/>';
$searchbox = '<input type="text" name="bsquery" size="20" maxlength="255" value="' . s($query) . '"/>';
$submitbutton = '<input type="submit" name="submit" value="' . $searchbooks . '"/>';
$content = $coursefield . $pagefield . $searchbox . $submitbutton;
$form = '<form method="get" action="' . $CFG->wwwroot . '/blocks/search_books/search_books.php" name="form" id="form">' . $content . '</form>';
echo '<div style="margin-left: auto; margin-right: auto; width: 100%; text-align: center">' . $form . '</div>';
// Process $bookresults, if present.
$startindex = $start;
$endindex = $start + count($bookresults);
$countresults = $countentries;
// Print results page tip.
$page_bar = glossary_get_paging_bar($countresults, $page, BOOKMAXRESULTSPERPAGE, "search_books.php?bsquery=" . urlencode(stripslashes($query)) . "&amp;courseid={$course->id}&amp;");
// //Iterate over results.
// if (!empty($bookresults)) {
// // Print header
// echo '<p style="text-align: right">'.$strresults.' <b>'.($startindex+1).'</b> - <b>'.$endindex.'</b> '.$ofabout.'<b> '.$countresults.' </b>'.$for.'<b> "'.s($query).'"</b></p>';
// echo $page_bar;
// // Prepare each entry (hilight, footer...)
// echo '<ul>';
// foreach ($bookresults as $entry) {
// $book = $DB->get_record('book', array('id' => $entry->bookid));
// $cm = get_coursemodule_from_instance("book", $book->id, $course->id);
// //To show where each entry belongs to
// $result = "<li><a href=\"$CFG->wwwroot/mod/book/view.php?id=$cm->id\">".format_string($book->name,true)."</a>&nbsp;&raquo;&nbsp;<a href=\"$CFG->wwwroot/mod/book/view.php?id=$cm->id&amp;chapterid=$entry->id\">".format_string($entry->title,true)."</a></li>";
// echo $result;
// }
// echo '</ul>';