コード例 #1
0
        print "<div>{$selects} queries ({$results->dbstart} rows used, {$results->dbrows} read), average {$average} s</div><ul>";
        if ($results->success) {
            foreach ($results->results as $result) {
                if ($result->title === '') {
                    $result->title = '(Blank line title)';
                }
                print '<li><div style="background:#eee">' . str_replace('highlight>', 'strong>', $result->title) . '</div><div>' . str_replace('highlight>', 'strong>', $result->summary) . ' [<a href="' . htmlspecialchars($result->url) . '">View</a>]</div></li>';
            }
        } else {
            print '<li>Query failed: <strong>' . $results->problemword . '</strong></li>';
        }
        print '</ul>';
    }
}
$sh = new ousearch_search('"the time"');
$sh->set_plugin('test/test2');
$tests = array(new ousearch_search('a and'), new ousearch_search('23dfbsdg3456 and'), new ousearch_search('and 23dfbsdg3456'), new ousearch_search('virulent attack'), new ousearch_search('regiment moved'), new ousearch_search('adjutant galloping'), new ousearch_search('adjutant galloping -Napoleon'), new ousearch_search('adjutant galloping -"where Napoleon was standing"'), new ousearch_search('about an hour'), new ousearch_search('"about an hour"'), new ousearch_search('about french hour were an'), new ousearch_search('and'), new ousearch_search('"a and"'), new ousearch_search('"and maidens"'), new ousearch_search('"the time"'), $sh);
//$tests=array(new ousearch_search('"a and"'));
$results = array();
foreach ($tests as $test) {
    $blankresult = new StdClass();
    $blankresult->time = 0.0;
    $blankresult->count = 0;
    $results[] = $blankresult;
}
// Test loop
define('OUSEARCH_TESTLOOPS', 3);
print '<h1>Running tests ' . OUSEARCH_TESTLOOPS . ' times</h1>';
flush();
for ($i = 0; $i < OUSEARCH_TESTLOOPS; $i++) {
    $last = $i === OUSEARCH_TESTLOOPS - 1 ? true : false;
コード例 #2
0
$navigation = build_navigation($extranavigation);
print_header_simple(get_string('searchresults'), "", $navigation);
$querytext = stripslashes(required_param('query', PARAM_RAW));
$query = new ousearch_search($querytext);
if (strpos($plugin, 'mod/') === 0) {
    $modname = substr($plugin, 4);
} else {
    $modname = null;
}
$query->set_visible_modules_in_course($COURSE, $modname);
// Restrict them to the groups they belong to
if (!isset($USER->groupmember[$courseid])) {
    $query->set_group_ids(array());
} else {
    $query->set_group_ids($USER->groupmember[$courseid]);
}
// Add exceptions where they can see other groups
$query->set_group_exceptions(ousearch_get_group_exceptions($courseid));
$query->set_user_id($USER->id);
$query->set_plugin($plugin);
ousearch_display_results($query, 'search.php?course=' . $courseid . '&plugin=' . $plugin);
//Print advanced search link
if ($plugin == 'mod/forumng') {
    $querytext = rawurlencode($querytext);
    $options = "course={$courseid}&amp;query={$querytext}";
    $url = $CFG->wwwroot . '/mod/forumng/advancedsearch.php?' . $options;
    $strlink = get_string('moresearchoptions', 'forumng');
    print "<div class='advanced-search-link'>\n            <a href=\"{$url}\">{$strlink}</a></div>";
}
// Footer
print_footer();
コード例 #3
0
 $urloptions .= $daterangefrom ? '&datefrom=' . $daterangefrom : '';
 $urloptions .= $daterangeto ? '&dateto=' . $daterangeto : '';
 if (!$allforums) {
     // Display group selector if required
     groups_print_activity_menu($cm, $url . $urloptions);
     $groupid = forum::get_activity_group($cm, true);
     $forum->require_view($groupid, 0, true);
     print '<br/><br/>';
 }
 $editform->display();
 // Searching for free text with or without filtering author and date range
 if ($query) {
     $result = new ousearch_search(stripslashes($query));
     // Search all forums
     if ($allforums) {
         $result->set_plugin('mod/forumng');
         $result->set_course_id($courseid);
         $result->set_visible_modules_in_course($COURSE);
         // Restrict them to the groups they belong to
         if (!isset($USER->groupmember[$courseid])) {
             $result->set_group_ids(array());
         } else {
             $result->set_group_ids($USER->groupmember[$courseid]);
         }
         // Add exceptions where they can see other groups
         $result->set_group_exceptions(ousearch_get_group_exceptions($courseid));
         $result->set_user_id($USER->id);
     } else {
         // Search this forum
         $result->set_coursemodule($forum->get_course_module(true));
         if ($groupid && $groupid != forum::NO_GROUPS) {