/adei/ui

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/ui

« back to all changes in this revision

Viewing changes to classes/stream/filter.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
abstract class FILTER extends VIRTUALStreamReaderWriter implements STREAMObjectInterface {
 
4
 var $info;
 
5
 var $output;
 
6
 
 
7
 var $joiner = false;
 
8
 var $content_type = "application/binary";
 
9
 var $extension = false;
 
10
 var $specials = false;
 
11
 
 
12
 var $blockmode;
 
13
 
 
14
 var $filewriter = false;
 
15
 var $filereader = false;
 
16
 var $tmpfile;
 
17
 
 
18
 var $filemode = false;
 
19
 
 
20
 function __construct(&$info = NULL, STREAMWriterInterface $output = NULL) {
 
21
    $this->info = &$info;
 
22
 
 
23
    if (isset($info['joiner'])) 
 
24
        $this->joiner = $info['joiner'];
 
25
 
 
26
    if (isset($info['content_type'])) 
 
27
        $this->content_type = $info['content_type'];
 
28
 
 
29
    if (isset($info['extension'])) 
 
30
        $this->extension = $info['extension'];
 
31
 
 
32
    $this->output = $output;
 
33
 }
 
34
 
 
35
 function SetOutput(STREAMWriterInterface $output = NULL) {
 
36
    $this->output = $output;
 
37
 }
 
38
 
 
39
 function Open(&$args = NULL) {
 
40
    if ($this->filewriter) {
 
41
        if (($args)&&($args['tmpfile'])) $this->tmpfile = $args['tmpfile'];
 
42
        else $this->tmpfile = GetTmpFile("adei_appfilter_", $this->GetExtension());
 
43
    }
 
44
 }
 
45
 
 
46
 
 
47
 function Close(STREAMWriterInterface $h = NULL) {
 
48
    if ($this->filewriter) {
 
49
        if ($this->output) $h = $this->output;
 
50
 
 
51
        if ($this->filemode) {
 
52
            if ($h) $h->WriteData($this->tmpfile);
 
53
            else throw new ADEIException(translate("The STREAM should be supplied to the FILTER while operating in the filemode"));
 
54
        } else {
 
55
            if ($h) $h->WriteFile($this->tmpfile);
 
56
            return file_get_contents($this->tmpfile);
 
57
        }
 
58
        unlink($this->tmpfile);
 
59
    }
 
60
 }
 
61
 
 
62
 function BlockStart(&$args = NULL) {
 
63
 }
 
64
 
 
65
 function BlockEnd(STREAMWriterInterface $h = NULL) {
 
66
 }
 
67
 
 
68
 
 
69
 function ReadData($limit = 0) {
 
70
    if ($this->filewriter)
 
71
        return "";
 
72
    else
 
73
        throw new ADEIException(translate("The ReadData function is not implemented within FILTER class"));
 
74
 }
 
75
 
 
76
 function EOS() {
 
77
    if ($this->filewriter)
 
78
        return false;
 
79
    else
 
80
        throw new ADEIException(translate("The EOS function is not implemented within FILTER class"));
 
81
 } 
 
82
 
 
83
 function GetSpecials() {
 
84
    return $this->specials;
 
85
 }
 
86
 
 
87
 function GetContentType() {
 
88
    return $this->content_type;
 
89
 }
 
90
 
 
91
 function GetExtension() {
 
92
    return $this->extension;
 
93
 }
 
94
 
 
95
 function IsJoiner() {
 
96
    return $this->joiner;
 
97
 }
 
98
 
 
99
 function RequestFilemode() {
 
100
    if ($this->filewriter) {
 
101
        $this->filemode = true;
 
102
        return true;
 
103
    }
 
104
    return false;
 
105
 }
 
106
 
 
107
}
 
108
 
 
109
require("iofilter.php");
 
110
require("appfilter.php");
 
111
require("zipfilter.php");
 
112
 
 
113
?>
 
 
b'\\ No newline at end of file'