Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
 
4
/**
5
 * Write to several writers
6
 *
7
 * PHP versions 4 and 5
8
 *
9
 * This library is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU Lesser General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2.1 of the License, or (at your option) any later version.
13
 *
14
 * This library is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 * Lesser General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public
20
 * License along with this library; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
22
 *
23
 * @category   File Formats
24
 * @package    File_Archive
25
 * @author     Vincent Lascaux <vincentlascaux@php.net>
26
 * @copyright  1997-2005 The PHP Group
27
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL
28
 * @version    CVS: $Id: Multi.php,v 1.10 2005/06/05 18:19:33 vincentlascaux Exp $
29
 * @link       http://pear.php.net/package/File_Archive
30
 */
31
 
32
require_once "File/Archive/Writer.php";
33
 
34
/**
35
 * Write to several writers
36
 */
37
class File_Archive_Writer_Multi extends File_Archive_Writer
38
{
39
    /**
40
     * @var File_Archive_Writer_Writer Data will be copied to these two writers
41
     * @access private
42
     */
43
    var $writers;
44
 
45
    function addWriter(&$writer)
46
    {
47
        $this->writers[] =& $writer;
48
    }
49
 
50
    /**
51
     * @see File_Archive_Writer::newFile()
52
     */
53
    function newFile($filename, $stat = array(), $mime = "application/octet-stream")
54
    {
55
        $globalError = null;
56
        foreach($this->writers as $key => $foo) {
57
            $error = $this->writers[$key]->newFile($filename, $stat, $mime);
58
            if (PEAR::isError($error)) {
59
                $globalError = $error;
60
            }
61
        }
62
        if (PEAR::isError($globalError)) {
63
            return $globalError;
64
        }
65
    }
66
    /**
67
     * @see File_Archive_Writer::newFileNeedsMIME()
68
     */
69
    function newFileNeedsMIME()
70
    {
71
        foreach($this->writers as $key => $foo) {
72
            if ($this->writers[$key]->newFileNeedsMIME()) {
73
                return true;
74
            }
75
        }
76
        return false;
77
    }
78
 
79
    /**
80
     * @see File_Archive_Writer::writeData()
81
     */
82
    function writeData($data)
83
    {
84
        $globalError = null;
85
        foreach($this->writers as $key => $foo) {
86
            $error = $this->writers[$key]->writeData($data);
87
            if (PEAR::isError($error)) {
88
                $globalError = $error;
89
            }
90
        }
91
        if (PEAR::isError($globalError)) {
92
            return $globalError;
93
        }
94
    }
95
 
96
    /**
97
     * @see File_Archive_Writer::writeFile()
98
     */
99
    function writeFile($filename)
100
    {
101
        $globalError = null;
102
        foreach($this->writers as $key => $foo) {
103
            $error = $this->writers[$key]->writeFile($filename);
104
            if (PEAR::isError($error)) {
105
                $globalError = $error;
106
            }
107
        }
108
        if (PEAR::isError($globalError)) {
109
            return $globalError;
110
        }
111
    }
112
 
113
    /**
114
     * @see File_Archive_Writer::close()
115
     */
116
    function close()
117
    {
118
        $globalError = null;
119
        foreach($this->writers as $key => $foo) {
120
            $error = $this->writers[$key]->close();
121
            if (PEAR::isError($error)) {
122
                $globalError = $error;
123
            }
124
        }
125
        if (PEAR::isError($globalError)) {
126
            return $globalError;
127
        }
128
    }
129
}
130
?>