/dev/trunk

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

« back to all changes in this revision

Viewing changes to classes/datahandler.php

  • Committer: Suren A. Chilingaryan
  • Date: 2008-04-02 10:23:22 UTC
  • Revision ID: csa@dside.dyndns.org-20080402102322-okib92sicg2dx3o3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
interface DATAHandlerInterface {
 
3
    public function SequenceStart($flags = 0);
 
4
    public function GroupStart($title, $subseconds = false, $flags = 0);
 
5
    public function GroupEnd($flags = 0);
 
6
    public function SequenceEnd($flags = 0);
 
7
 
 
8
    public function Start($flags = 0);
 
9
    public function HeaderStart($flags = 0);
 
10
    public function TimeHeader($flags = 0);
 
11
    public function DataHeader(&$header, $i, $flags = 0);
 
12
    public function HeaderEnd($flags = 0);
 
13
    public function VectorStart($flags = 0);
 
14
    public function TimeValue(&$time, $flags = 0);
 
15
    public function DataValue(&$value, $i, $flags = 0);
 
16
    public function VectorEnd($flags = 0);
 
17
    public function End($flags = 0);
 
18
 
 
19
    public function GetContentType();
 
20
    public function GetExtension();
 
21
}
 
22
 
 
23
 
 
24
abstract class DATAHandler implements DATAHandlerInterface {
 
25
 var $h;
 
26
 var $output;
 
27
 var $info;
 
28
 
 
29
 var $content_type = false;
 
30
 var $extension = false;
 
31
 
 
32
 var $subseconds;
 
33
 var $tz, $saved_tz;
 
34
 
 
35
 var $multigroup = false;
 
36
 var $filewriter = false;
 
37
 var $filemode = false;
 
38
 
 
39
 function __construct(&$opts, STREAMWriterInterface $h = NULL) {
 
40
    $this->output = $h;
 
41
    $this->info = &$opts;
 
42
 
 
43
    if (isset($opts['content_type'])) 
 
44
        $this->content_type = $opts['content_type'];
 
45
    if (isset($opts['extension'])) 
 
46
        $this->extension = $opts['extension'];
 
47
 
 
48
    if ($opts) {
 
49
        $this->tz = $opts['timezone'];
 
50
    }
 
51
 
 
52
    if (!$this->tz) $this->tz = "UTC";
 
53
 }
 
54
 
 
55
 function SetOutput(STREAMWriterInterface $h) {
 
56
    $this->output = $h;
 
57
 }
 
58
 
 
59
 function SequenceStart($flags = 0) {
 
60
    if ($this->output) $this->h = $this->output;
 
61
    else {
 
62
        $this->h = new IO();
 
63
        $this->h->Open();
 
64
    }
 
65
 
 
66
    $this->saved_tz = date_default_timezone_get ();
 
67
    date_default_timezone_set($this->tz);
 
68
 }
 
69
 
 
70
 function GroupStart($title, $subseconds = false, $flags = 0) {
 
71
    $this->subseconds = $subseconds;
 
72
 }
 
73
 
 
74
 function GroupEnd($flags = 0) {
 
75
 }
 
76
 
 
77
 function SequenceEnd($flags = 0) {
 
78
    date_default_timezone_set($this->saved_tz);
 
79
 
 
80
    if (!$this->output) {
 
81
        $this->h->Close();
 
82
        unset($this->h);
 
83
    }
 
84
 }
 
85
 
 
86
 
 
87
 function Start($flags = 0) {
 
88
 } 
 
89
 function HeaderStart($flags = 0) {
 
90
 }
 
91
 function TimeHeader($flags = 0) {
 
92
 }
 
93
 function DataHeader(&$header, $i, $flags = 0) {
 
94
 }
 
95
 function HeaderEnd($flags = 0) {
 
96
 }
 
97
 function VectorStart($flags = 0) {
 
98
 }
 
99
 function VectorEnd($flags = 0) {
 
100
 }
 
101
 function End($flags = 0) {
 
102
 }
 
103
 
 
104
 function GetContentType() {
 
105
    return $this->content_type;
 
106
 }
 
107
 function GetExtension() {
 
108
    return $this->extension;
 
109
 }
 
110
 
 
111
 function RequestFilemode() {
 
112
    if ($this->filewriter)
 
113
        $this->filemode = true;
 
114
    else
 
115
        throw new ADEIException(translate("Filemode is not supported by the handler"));
 
116
 
 
117
    return true;
 
118
 }
 
119
 
 
120
}
 
121
 
 
122
require("handlers/csv.php");
 
123
?>
 
 
b'\\ No newline at end of file'