/adei/trunk

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

« back to all changes in this revision

Viewing changes to services/search.php

  • Committer: Suren A. Chilingaryan
  • Date: 2009-01-30 23:56:42 UTC
  • Revision ID: csa@dside.dyndns.org-20090130235642-gw9n5v9y7w23dmmd
Further search improvements, support for custom properties (config)

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
try {
9
9
    $req = new REQUEST();
 
10
 
 
11
    $xslt = $req->GetProp('xslt');
 
12
 
10
13
    $search = $req->CreateSearcher();
11
14
    $results = $search->Search();    
 
15
    if ($results) $res = $results->GetResults();
 
16
    else $res = false;
12
17
    
13
 
    $res = $results->GetResults();
14
18
    if (!$res) $res = array();
15
19
//    if (!$res) throw new ADEIException(translate("Nothing is found"));
16
20
    
28
32
    $out = fopen("php://output", "w");
29
33
}
30
34
 
31
 
if (!$out) {
32
 
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
33
 
    echo "<result><Error>$error</Error></result>";
34
 
    return;
35
 
}
36
 
 
37
 
 
38
 
 
39
 
fwrite($out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
40
 
fwrite($out, "<result>");
41
 
if ($error) fwrite($out, "<Error>$error</Error>");
42
 
else {
 
35
 
 
36
if ($out) {
 
37
  fwrite($out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
 
38
  fwrite($out, "<result>");
 
39
  if ($error) {
 
40
    fwrite($out, "<Error>$error</Error>");
 
41
    $error = false;
 
42
  } else {
43
43
    foreach ($res as &$mod) {
44
44
        if ($mod['title']) {
45
45
            $title = xml_escape($mod['title']);
52
52
            fwrite($out, $mod['description']);
53
53
            fwrite($out, "</description>");
54
54
        }
55
 
        fwrite($out, "<results>");
56
 
        foreach ($mod['results'] as &$r) {
57
 
            $rreq = new REQUEST($r['props']);
58
 
            $props = xml_escape($rreq->GetQueryString());
59
 
            if ($r['title']) {
60
 
                $title = xml_escape($r['title']);
61
 
            } else {
62
 
                $title = preg_replace("/&amp;/", ",", $props);
63
 
            }
 
55
        if ($mod['results']) {
 
56
                fwrite($out, "<results>");
 
57
                foreach ($mod['results'] as &$r) {
 
58
                    $rreq = new REQUEST($r['props']);
 
59
                    $props = xml_escape($rreq->GetQueryString());
 
60
                    if ($r['title']) {
 
61
                        $title = xml_escape($r['title']);
 
62
                    } else {
 
63
                        $title = preg_replace("/&amp;/", ",", $props);
 
64
                    }
64
65
 
65
 
            $extra = "";
66
 
            if ($r['certain']) $extra=" certain=\"1\"";
67
 
            
68
 
            fwrite($out, "<Value  title=\"$title\" props=\"$props\"$extra>");
69
 
            if ($r['description']) {
70
 
                fwrite($out, "<description>");
71
 
                fwrite($out, $r['description']);
72
 
                fwrite($out, "</description>");
73
 
            }
74
 
            fwrite($out, "</Value>");
 
66
                    $extra = "";
 
67
                    if ($r['certain']) $extra=" certain=\"1\"";
 
68
                
 
69
                    fwrite($out, "<Value  title=\"$title\" props=\"$props\"$extra>");
 
70
                    if ($r['description']) {
 
71
                        fwrite($out, "<description>");
 
72
                        fwrite($out, $r['description']);
 
73
                        fwrite($out, "</description>");
 
74
                    }
 
75
                    fwrite($out, "</Value>");
 
76
                }
 
77
                fwrite($out, "</results>");
 
78
        } else if ($mod['content']) {
 
79
                fwrite($out, "<Content>");
 
80
                fwrite($out, $mod['content']);
 
81
                fwrite($out, "</Content>");
75
82
        }
76
 
        fwrite($out, "</results></module>");
77
 
    }
78
 
}
79
 
fwrite ($out, "</result>");
 
83
        fwrite($out, "</module>");
 
84
    }
 
85
  }
 
86
  fwrite ($out, "</result>");
 
87
}
 
88
 
 
89
if (($xslt)&&(!$error)) {
 
90
    try {
 
91
        echo $ADEI->TransformXML($xslt, $temp_file);
 
92
    } catch (ADEIException $ex) {
 
93
        $ex->logInfo(NULL, $reader?$reader:$req);
 
94
        $error = $ADEI->EscapeForXML($ex->getInfo());
 
95
    }
 
96
    @unlink($temp_file);
 
97
}
 
98
 
 
99
if ($error) {
 
100
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 
101
    echo "<result><Error>$error</Error></result>";
 
102
}
 
103
 
80
104
?>
 
 
b'\\ No newline at end of file'