/openshift/adei

To get this branch, use:
bzr branch http://darksoft.org/webbzr/openshift/adei

« back to all changes in this revision

Viewing changes to setups/katrin/classes/search/kdbsearch.php

  • Committer: Suren A. Chilingaryan
  • Date: 2012-02-07 22:44:15 UTC
  • Revision ID: csa@dside.dyndns.org-20120207224415-sy360wa1ammhd1ph
Use localization subsystem, updated Katrin configs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
// Author: Sebastian Voecking <sebastian.voecking@uni-muenster.de>
3
 
 
4
 
ADEI::RequireClass('KDBConstants', TRUE);
5
 
ADEI::RequireClass('KDBPhp', TRUE);
6
 
ADEI::RequireClass('KDBRunIdentifier', TRUE);
7
 
 
8
 
class KDBSearch extends SEARCHEngine
9
 
{
10
 
    function __construct(REQUEST $req = NULL, $opts = FALSE)
11
 
    {
12
 
        parent::__construct($req, $opts);
13
 
        $this->modules = array('runs' => _('Runs'));
14
 
        $this->engine_search = array('runs');
15
 
    }
16
 
 
17
 
    function DetectModules($string)
18
 
    {
19
 
        $pos = strpos($string, ' ');
20
 
        if ($pos !== FALSE) {
21
 
            $word = substr($string, $pos);
22
 
        }
23
 
        else {
24
 
            $word = $string;
25
 
        }
26
 
 
27
 
        $word = strtolower($word);
28
 
 
29
 
        if ($word == 'run' or $word == 'runs') {
30
 
            return array('runs' => TRUE);
31
 
        }
32
 
        else {
33
 
            return FALSE;
34
 
        }
35
 
    }
36
 
 
37
 
    function Search($search_string, $module, SEARCHFilter $filter = NULL,
38
 
                    $opts = FALSE)
39
 
    {
40
 
        $pattern = '=^(runs|run) ?(?<search>.*)=';
41
 
 
42
 
        $kdb = new KDBPhp();
43
 
 
44
 
        if (!preg_match($pattern, strtolower($search_string), $matches)) {
45
 
            return FALSE;
46
 
        }
47
 
 
48
 
        $runs = $kdb->SearchRuns($matches['search']);
49
 
        $number = count($runs);
50
 
        
51
 
        $results = new SEARCHResults($filter, $this, $module);
52
 
        $item = array(
53
 
            'title' => 'Result overview',
54
 
            'props' => array(
55
 
                'kdb_run' => '',
56
 
                'kdb_search' => $matches['search'],
57
 
                'kdb_page' => 1,
58
 
                'module' => 'katrin',
59
 
                'kdb_date' => ''),
60
 
            'certain' => ($number != 1));
61
 
        if ($number == 1) {
62
 
            $description = "1 run found";
63
 
        }
64
 
        else {
65
 
            $description = "$number runs found";
66
 
        }
67
 
        $item['description'] =
68
 
            "<div class=\"description\">$description</div>";
69
 
        $results->Append($item);
70
 
        
71
 
        foreach ($runs as $run) {
72
 
            $item = array();
73
 
            $identifier =
74
 
                new KDBRunIdentifier($run['system'], $run['number']);
75
 
            $item['title'] = 'Run ' . $identifier->GetName();
76
 
            $item['props'] = array(
77
 
                'kdb_run' => $identifier->GetName(),
78
 
                'kdb_subruns' => 0,
79
 
                'kdb_search' => $matches['search'],
80
 
                'kdb_page' => 1,
81
 
                'module' => 'katrin',
82
 
                'kdb_date' => '');
83
 
            $description = "{$run['start']}, Duration: {$run['duration']}, ";
84
 
            if ($run['subruns'] == 1) {
85
 
                $description .= "1 subrun";
86
 
            }
87
 
            else {
88
 
                $description .= "{$run['subruns']} subruns";
89
 
            }
90
 
            $item['description'] =
91
 
                "<div class=\"description\">$description</div>";
92
 
            $item['certain'] = ($number == 1);
93
 
            $results->Append($item);
94
 
        }
95
 
 
96
 
        return $results;
97
 
    }
98
 
}
99
 
 
100
 
?>
 
 
b'\\ No newline at end of file'