Пример #1
0
        displayErrorBeforeForm('Could not decode search request');
    }
}
$_SESSION['lastSearchRequest'] = $searchRequest;
//Main form logic: When the user first enters the page, display form defaulted to
//show the search results with default object selected on a previous page, otherwise
// just display the blank form.
if (isset($_POST['searchSubmit']) && isset($searchRequest)) {
    require_once 'header.php';
    displaySearchForm($searchRequest);
    print updateUrlScript($searchRequest);
    $searchTimeStart = microtime(true);
    $records = search($searchRequest);
    $searchTimeEnd = microtime(true);
    $searchTimeElapsed = $searchTimeEnd - $searchTimeStart;
    displaySearchResult($records, $searchTimeElapsed);
    include_once 'footer.php';
} else {
    require_once 'header.php';
    displaySearchForm($searchRequest);
    include_once 'footer.php';
}
//Show the main SOSL search form with default search or last submitted search and export action (screen or CSV)
function displaySearchForm($searchRequest)
{
    registerShortcut("Ctrl+Alt+W", "addReturningObjectRow(document.getElementById('numReturningObjects').value++);" . "toggleFieldDisabled();");
    print "<script>\n";
    print "var searchable_objects = new Array();\n";
    foreach (describeGlobal("searchable") as $obj) {
        print "searchable_objects[\"{$obj}\"]=\"{$obj}\";\n";
    }
Пример #2
0
    $ageRangeLow = trim($ageRangeLow);
    $q2 = "SELECT subjects.lastName, subjects.firstName, subjects.dob, sessions.* FROM subjects, sessions WHERE sessions.subjectID = subjects.id ";
    if ($subjectName != "") {
        $subjectName = strtolower(trim($subjectName));
        $subjectName = str_replace('*', '%', $subjectName);
        $q2 .= "AND (subjects.lastName LIKE ('%{$subjectName}%') OR subjects.firstName LIKE ('%{$subjectName}%')) ";
    }
    if (is_numeric($ageRangeLow)) {
        $q2 .= "AND (DATE_ADD(subjects.dob, INTERVAL " . $ageRangeLow . " YEAR) <= sessions.start) ";
    }
    if (is_numeric($ageRangeHigh)) {
        $q2 .= "AND (DATE_ADD(subjects.dob, INTERVAL " . $ageRangeHigh . " YEAR) >= sessions.start) ";
    }
    if ($subjectNotes != "") {
        $subjectNotes = strtolower(trim($subjectNotes));
        $subjectNotes = str_replace('*', '%', $subjectNotes);
        $q2 .= "AND (subjects.notes LIKE ('%{$subjectNotes}%')) ";
    }
    $q2 .= "ORDER by sessions.id";
    if (!($res = mysql_query($q2, $db))) {
        print "\n<p>ERROR " . mysql_error($db);
        exit;
    }
    $totalNumRows = mysql_num_rows($res);
    if ($totalNumRows > 0) {
        displaySearchResult($res, $int_cur_position);
    } else {
        echo "<center><h2>No result found. Try again.</h2></center>\n";
    }
}
writeFooter("basic");
    $keyword = strtolower(trim($keyword));
    // Can use IN BOOLEAN MODE only when we upgrade to mySQL 4.0.1 (done as of 12/03)
    if ($fld == 'all fields') {
        $q1 = "SELECT * FROM {$tbl} WHERE MATCH {$fullTextString[$tbl]} AGAINST ('{$keyword}' IN BOOLEAN MODE) ";
    } else {
        //echo "*".$fld."*".$q. "*".$tbl."^";
        $keyword = str_replace('*', '%', $keyword);
        $q1 = "SELECT * FROM {$tbl} WHERE {$fld} LIKE ('%{$keyword}%') ";
    }
    if ($sortBy == "") {
        $sortBy = "id";
    }
    /*  if(in_array($sortBy, $sbjArray))
        $sortByOrder = "subjects.".$sortBy;
      else
        $sortByOrder = "sessions.".$sortBy;	*/
    $q1 .= "ORDER by {$tbl}." . $sortBy . " " . $sortDir;
    if (!($res = mysql_query($q1, $db))) {
        print "\n<p>ERROR " . mysql_error($db);
        exit;
    }
    $totalNumRows = mysql_num_rows($res);
    $displaySummaryStr = '<a href="' . selfURL() . '?displaySummary=<DS>&sortDir=' . $sortDir . '&sortBy=' . $sortBy . '&tbl=' . $tbl . '&fld=' . $fld . '&keyword=' . $keyword . '&generalSearch=1' . '">Click here to see a <DSS> version</a>';
    $sortbyStr = '<a href="' . selfURL() . '?displaySummary=' . $displaySummary . '&sortDir=<DIR2>&sortBy=<ID>&tbl=' . $tbl . '&fld=' . $fld . '&keyword=' . $keyword . '&generalSearch=1' . '"><ID2><DIR></a>';
    if ($totalNumRows > 0) {
        displaySearchResult($db, $tbl, $res, $int_cur_position, $displaySummaryStr, $displaySummary, $sortbyStr, $sortBy, $sortDir);
    } else {
        echo "<center><h2>No result found. Try again.</h2></center>\n";
    }
}
writeFooter("basic");