/adei/ui

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/ui
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
require("../adei.php");

header("Content-type: application/json");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

try {
    $req = new REQUEST();
    if ($req->CheckData()) {

	$req = $req->CreateDataRequest();

	$draw = $req->CreatePlotter();
	$draw->Create();
	$file = $draw->Save();
	$scale = $draw->GetScaleInfo();
    } else {
	$draw = $req->CreateImageHelper();
	$draw->Create();
	$file = $draw->Save();
	$no_data = true;
    }
} catch(ADEIException $e) {
    $error = $e->getInfo();

    if (($draw)&&(($e->getCode() == ADEIException::NO_DATA)||($e->getCode() == ADEIException::NO_CACHE))) {
	if (($e->getCode() == ADEIException::NO_CACHE)&&($req->IsVirtual())) {
	    $error = "----------------";
	}
	
	try {
	    $no_data = true;
	    $draw->CreateMessage("Error", $error);
	    $file = $draw->Save();
	    $error = false;
	} catch (ADEIException $ex) {
	    $no_data = false;
	    $ex->logInfo(NULL, $draw);
	}
    } else {
	$e->logInfo(NULL, $draw?$draw:$req);	
    }
}

if ($error) {
    echo json_encode(array("error" => $error));
} else {
    if ($draw) {
	if ($no_data) {
	    echo json_encode(array(
		"module" => "graph",
		"nodata" => true,
		"draw" => 1,
		"image" => $file
	    ));
	} else {
	    echo json_encode(array_merge(array(
		"error" => 0,
		"module" => "graph",
		"draw" => 1,
		"image" => $file
	    ), $scale));
	}
    } else {
	echo json_encode(array(
	    "error" => 0
	));
    }
}


?>