2
// Author: Sebastian Voecking <sebastian.voecking@uni-muenster.de>
4
ADEI::RequireClass('KDBConstants', TRUE);
5
ADEI::RequireClass('KDBPhp', TRUE);
6
ADEI::RequireClass('KDBRunIdentifier', TRUE);
8
class KDBSearch extends SEARCHEngine
10
function __construct(REQUEST $req = NULL, $opts = FALSE)
12
parent::__construct($req, $opts);
13
$this->modules = array('runs' => _('Runs'));
14
$this->engine_search = array('runs');
17
function DetectModules($string)
19
$pos = strpos($string, ' ');
21
$word = substr($string, $pos);
27
$word = strtolower($word);
29
if ($word == 'run' or $word == 'runs') {
30
return array('runs' => TRUE);
37
function Search($search_string, $module, SEARCHFilter $filter = NULL,
40
$pattern = '=^(runs|run) ?(?<search>.*)=';
44
if (!preg_match($pattern, strtolower($search_string), $matches)) {
48
$runs = $kdb->SearchRuns($matches['search']);
49
$number = count($runs);
51
$results = new SEARCHResults($filter, $this, $module);
53
'title' => 'Result overview',
56
'kdb_search' => $matches['search'],
60
'certain' => ($number != 1));
62
$description = "1 run found";
65
$description = "$number runs found";
67
$item['description'] =
68
"<div class=\"description\">$description</div>";
69
$results->Append($item);
71
foreach ($runs as $run) {
74
new KDBRunIdentifier($run['system'], $run['number']);
75
$item['title'] = 'Run ' . $identifier->GetName();
76
$item['props'] = array(
77
'kdb_run' => $identifier->GetName(),
79
'kdb_search' => $matches['search'],
83
$description = "{$run['start']}, Duration: {$run['duration']}, ";
84
if ($run['subruns'] == 1) {
85
$description .= "1 subrun";
88
$description .= "{$run['subruns']} subruns";
90
$item['description'] =
91
"<div class=\"description\">$description</div>";
92
$item['certain'] = ($number == 1);
93
$results->Append($item);
b'\\ No newline at end of file'