/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php 
require("adei.php");

header("Content-Type: text/html; charset=UTF-8");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

?>
<html>
<head>
 <style type="text/css">
    .header {
    }
    .header a {
	padding: 5px;
	margin-bottom: 2px;
	color: #000055;
	background: #F0F0F0;
	font-weight: bold;
	border: 1px solid #C0C0C0;
	text-decoration: none;
    }
    .header a:hover {
	border: 1px #007000 solid; 
	background: #FDD;
    }
 </style>
</head>
<body>
<?


function GetQueryString(REQUEST $sreq) {
    global $ADEI_SETUP;
    
    $req = $sreq->GetQueryString();
    
    if ($req) $req .= "&";
    else $req = "";
	
    $req .= "setup=" . $ADEI_SETUP;

    return $req;
}

function data_link(&$req, $grname, $format, $from, $to) {
    global $FORMATS;
    
    $props = array();
    $props["experiment"] = "$from-$to";
    $props["window"] = "0";
    $props["format"] = $format;    

    if ($FORMATS[$format]["title"]) $title = $FORMATS[$format]["title"];
    else $title = $format;
    if ($FORMATS[$format]["extension"]) $ext = $FORMATS[$format]["extension"];
    else $ext = $format;

    
//    $props["filename"] =  preg_replace("/[^\w\d]/", "_", $grname) . "__" . round($from) . "_" . round($to) . "." . $ext;
    
#    if (isset($_GET['setup'])) $props["setup"] = $_GET['setup'];
    $query = $req->GetQueryString($props);
    
    echo "<a href=\"services/getdata.php?$query\">" . $title . "</a>";
}

if (isset($_GET['period'])) {
    $period = $_GET['period'] * 3600;
} else {
    $period = 86400;
}


try {
    $req = new SOURCERequest();
} catch (ADEIException $e) {
    $req = new REQUEST();
    $nodata = 1;
}


$list = $req->GetSources(REQUEST::LIST_ALL);
?><div class="header"><?
foreach ($list as $sreq) {
    ?><a href="download.php?<?echo GetQueryString($sreq);?>"><?echo $sreq->props['db_server'];?>.<?echo $sreq->props['db_name'];?></a> <?
}
?><a href="csvmerge.php">Merge Groups</a></div><?
if ($nodata) exit;


?><h3>Server: <?echo $req->props['db_server'];?>, DataBase: <?echo $req->props['db_name'];?></h3><?


//$props = array("db_server"=>"katrin", "db_name"=>"HS");
$reader = $req->CreateReader();
$groups = $reader->GetGroupList(REQUEST::NEED_INFO);

$list = $req->GetGroups();
foreach ($list as $gid => $greq) {
    $group = $groups[$gid];
    ?><div style="background-color: grey">
	<h3><?echo $group["name"];?></h3>
	<?echo $group["comment"];?>
	<br/><br/>
	<?
	$first = $group["first"];
	$last = $group["last"];
	
	$first = floor($first);
	$last = ceil($last);

	$first_day = $first - ($first % $period);
	if ($last%$period) $last_day = $last + $period - ($last % $period);
	else $last_day = $last - ($last % $period);


	for ($i=$first_day; $i<$last_day; $i += $period) {
	    echo date("d.m.Y", $i) . "(";

	    $first_flag = 1;
	    
	    foreach ($EXPORT_FORMATS as $format => $fattr) {
		if ($first_flag) $first_flag = 0;
		else  echo ", ";
		
		data_link($greq, $group["name"], $format, ($i>$first)?$i:$first, (($i + $period)>$last)?$last:($i + $period));
	    }
	    echo ") ";
	}
	

	echo "Everything (";
        $first_flag = 1;

	foreach ($EXPORT_FORMATS as $format => $fname) {
	    if ($first_flag) $first_flag = 0;
	    else  echo ", ";
		
	    data_link($greq, $group["name"], $format, $first, $last);
	}
	echo ") ";
    ?></div><br/><br/><?
}


?>
(*) the GMT days are used
</body></html>