]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojox/data/tests/stores/snap_pipeline.php
add Dojo 1.1.1
[eow] / static / dojo-release-1.1.1 / dojox / data / tests / stores / snap_pipeline.php
1 <?php
2
3 $field_names = array('"empno"', '"ename"', '"job"', '"hiredate"', '"sal"', '"comm"', '"deptno"');
4
5 $rows = array(array("7369", '"SMITH,CLERK"', "7902", '"1993-06-13"', "800.00", "0.00", "20"),
6               array("7499", '"ALLEN,SALESMAN"', "7698", '"1998-08-15"', "1600.00", "300.00", "30"),
7               array("7521", '"WARD,SALESMAN"', "7698", '"1996-03-26"', "1250.00", "500.00", "30"),
8               array("7566", '"JONES,MANAGER"', "7839", '"1995-10-31"', "2975.00", '""', "20"),
9               array("7698", '"BLAKE,MANAGER"', "7839", '"1992-06-11"', "2850.00", '""', "30"),
10               array("7782", '"CLARK,MANAGER"', "7839", '"1993-05-14"', "2450.00", '""', "10"),
11               array("7788", '"SCOTT,ANALYST"', "7566", '"1996-03-05"', "3000.00", '""', "20"),
12               array("7839", '"KING,PRESIDENT"', '"1990-06-09"', "5000", "1100.0", '""', "0.00", "10"),
13               array("7844", '"TURNER,SALESMAN"', "7698", '"1995-06-04"', "1500.00", '""', "0.00", "30"),
14               array("7876", '"ADAMS,CLERK"', "7788", '"1999-06-04"', "1100.00", '""', "20"),
15               array("7900", '"JAMES,CLERK"', "7698", '"2000-06-23"', "950.00", '""', "30"),
16               array("7934", '"MILLER,CLERK"', "7782", '"2000-01-21"', "1300.00", '""', "10"),
17               array("7902", '"FORD,ANALYST"', "7566", '"1997-12-05"', "3000.00", '""', "20"),
18               array("7654", '"MARTIN,SALESMAN"', "7698", '"1998-12-05"', "1250.00", "1400.00", "30"));
19
20 $prefix = $_GET["sn_stream_header"];
21
22 if($_GET["sn_count"]) {
23     if($_GET["sn_count"] == "records"){
24         echo $prefix . "([[" . count($rows) . "]])";
25     } else {
26         header("HTTP/1.1 400 Bad Request");
27         echo "sn.count parameter, if present, must be set to 'records'.";
28         exit(0);
29     }
30 } else {
31     if($_GET["sn_start"]) {
32         $start = $_GET["sn_start"];
33     } else {
34         $start = 1;
35     }
36
37     if($_GET["sn_limit"]) {
38         $limit = $_GET["sn_limit"];
39     } else {
40         $limit = count($rows);
41     }
42
43     if(!is_numeric($start) || !is_numeric($limit)) {
44         header("HTTP/1.1 400 Bad Request");
45         echo "sn.start or sn.limit specified a non-integer value";
46         exit(0);
47     }
48
49     $start -= 1;
50
51     if($start < 0 || $start >= count($rows) || $limit < 0) {
52         header("HTTP/1.1 400 Bad Request");
53         echo "sn.start and/or sn.limit out of range";
54         exit(0);
55     }
56
57     $slice = array_slice($rows, $start, $limit);
58
59     header("Content-type: application/javascript");
60     echo $prefix . "([";
61
62     $out_rows = array("[" . join(", ", $field_names) . "]");
63     foreach($slice as $r) {
64         $out_rows[] = "[" . join(", ", $r) . "]";
65     }
66     
67     echo join(", ", $out_rows);
68     echo "])";
69  }
70
71 ?>
72