3 * Base class for output stream; prints to stdout or buffer or wherever.
5 * Copyright © 2003, 2005, 2006 Brion Vibber <brion@pobox.com>
6 * https://www.mediawiki.org/
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
29 class DumpMultiWriter
{
34 function __construct( $sinks ) {
35 $this->sinks
= $sinks;
36 $this->count
= count( $sinks );
40 * @param string $string
42 function writeOpenStream( $string ) {
43 for ( $i = 0; $i < $this->count
; $i++
) {
44 $this->sinks
[$i]->writeOpenStream( $string );
49 * @param string $string
51 function writeCloseStream( $string ) {
52 for ( $i = 0; $i < $this->count
; $i++
) {
53 $this->sinks
[$i]->writeCloseStream( $string );
59 * @param string $string
61 function writeOpenPage( $page, $string ) {
62 for ( $i = 0; $i < $this->count
; $i++
) {
63 $this->sinks
[$i]->writeOpenPage( $page, $string );
68 * @param string $string
70 function writeClosePage( $string ) {
71 for ( $i = 0; $i < $this->count
; $i++
) {
72 $this->sinks
[$i]->writeClosePage( $string );
78 * @param string $string
80 function writeRevision( $rev, $string ) {
81 for ( $i = 0; $i < $this->count
; $i++
) {
82 $this->sinks
[$i]->writeRevision( $rev, $string );
87 * @param array $newnames
89 function closeRenameAndReopen( $newnames ) {
90 $this->closeAndRename( $newnames, true );
94 * @param array $newnames
97 function closeAndRename( $newnames, $open = false ) {
98 for ( $i = 0; $i < $this->count
; $i++
) {
99 $this->sinks
[$i]->closeAndRename( $newnames[$i], $open );
106 function getFilenames() {
108 for ( $i = 0; $i < $this->count
; $i++
) {
109 $filenames[] = $this->sinks
[$i]->getFilenames();