Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / export / DumpMultiWriter.php
blob940ee383cc93d53371ce9aa0c18b782352d36cdf
1 <?php
2 /**
3 * Base class for output stream; prints to stdout or buffer or wherever.
5 * Copyright © 2003, 2005, 2006 Brooke Vibber <bvibber@wikimedia.org>
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
23 * @file
26 /**
27 * @ingroup Dump
29 class DumpMultiWriter {
30 /** @var array */
31 private $sinks;
32 /** @var int */
33 private $count;
35 /**
36 * @param array $sinks
38 public function __construct( $sinks ) {
39 $this->sinks = $sinks;
40 $this->count = count( $sinks );
43 /**
44 * @param string $string
46 public function writeOpenStream( $string ) {
47 for ( $i = 0; $i < $this->count; $i++ ) {
48 $this->sinks[$i]->writeOpenStream( $string );
52 /**
53 * @param string $string
55 public function writeCloseStream( $string ) {
56 for ( $i = 0; $i < $this->count; $i++ ) {
57 $this->sinks[$i]->writeCloseStream( $string );
61 /**
62 * @param stdClass $page
63 * @param string $string
65 public function writeOpenPage( $page, $string ) {
66 for ( $i = 0; $i < $this->count; $i++ ) {
67 $this->sinks[$i]->writeOpenPage( $page, $string );
71 /**
72 * @param string $string
74 public function writeClosePage( $string ) {
75 for ( $i = 0; $i < $this->count; $i++ ) {
76 $this->sinks[$i]->writeClosePage( $string );
80 /**
81 * @param stdClass $rev
82 * @param string $string
84 public function writeRevision( $rev, $string ) {
85 for ( $i = 0; $i < $this->count; $i++ ) {
86 $this->sinks[$i]->writeRevision( $rev, $string );
90 /**
91 * @param array $newnames
93 public function closeRenameAndReopen( $newnames ) {
94 $this->closeAndRename( $newnames, true );
97 /**
98 * @param array $newnames
99 * @param bool $open
101 public function closeAndRename( $newnames, $open = false ) {
102 for ( $i = 0; $i < $this->count; $i++ ) {
103 $this->sinks[$i]->closeAndRename( $newnames[$i], $open );
108 * @return array
110 public function getFilenames() {
111 $filenames = [];
112 for ( $i = 0; $i < $this->count; $i++ ) {
113 $filenames[] = $this->sinks[$i]->getFilenames();
115 return $filenames;