/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/stream/streamfilter.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
 
 
3
class STREAMFilter extends STREAMHandler implements STREAMSequenceInterface, STREAMWriterInterface {
 
4
 var $joiner;
 
5
 var $count;
 
6
 
 
7
 function __construct(FILTER $object, STREAMHandler $next = NULL, $flags = 0) {
 
8
    parent::__construct($object, $next, $flags);
 
9
 
 
10
    $this->joiner = $this->object->IsJoiner();
 
11
 }
 
12
 
 
13
 function Connect(STREAMHandler $next) {
 
14
    $this->object->SetOutput($next);
 
15
 
 
16
    return parent::Connect($next);
 
17
 }
 
18
 
 
19
 
 
20
 function SequenceStart(&$args = NUL) {
 
21
    if ($this->joiner) {
 
22
        $new_args = $args;
 
23
        $new_args['expected_blocks'] = 1;
 
24
        parent::SequenceStart($new_args);
 
25
        
 
26
        if ($this->saved_next)
 
27
            $this->object->SetOutput($this->next);
 
28
 
 
29
        parent::Start($args);
 
30
 
 
31
        $this->count = 0;
 
32
        $this->object->Open($args);
 
33
    } else {
 
34
        parent::SequenceStart($args);
 
35
 
 
36
        if ($this->saved_next)
 
37
            $this->object->SetOutput($this->next);
 
38
    }
 
39
 }
 
40
 
 
41
 function Start(&$args = NULL) {
 
42
    if ($this->joiner) {
 
43
        if ($this->count) {
 
44
            $new_args = $args;
 
45
            $new_args['block_number'] = $this->count;
 
46
            unset($args);
 
47
            $args = &$new_args;
 
48
        }
 
49
        $this->count++;
 
50
    } else {
 
51
        parent::Start($args);
 
52
        $this->object->Open($args);
 
53
    }
 
54
 
 
55
    $this->object->BlockStart($args);
 
56
 }
 
57
 
 
58
 function End() {
 
59
    $this->object->BlockEnd($this->next);
 
60
 
 
61
    if (!$this->joiner) {
 
62
        $this->object->Close($this->next);
 
63
        parent::End();
 
64
    }
 
65
 }
 
66
 
 
67
 function SequenceEnd() {
 
68
    if ($this->joiner) {
 
69
        $this->object->Close($this->next);
 
70
        parent::End();
 
71
    }
 
72
 
 
73
    if ($this->saved_next)
 
74
        $this->object->SetOutput($this->saved_next);
 
75
        
 
76
    parent::SequenceEnd();
 
77
 }
 
78
 
 
79
 function WriteData(&$data, $flags=false) {
 
80
    $this->object->WriteData($data, $flags);
 
81
    if (!$this->object->filewriter) $this->object->StreamData($this->next);
 
82
 }
 
83
 
 
84
 function RequestFilemode() {
 
85
    $this->filemode = $this->object->RequestFilemode();
 
86
    return $this->filemode;
 
87
 }
 
88
 
 
89
}
 
90
 
 
91
?>
 
 
b'\\ No newline at end of file'