Merge "Update docs/hooks.txt for ShowSearchHitTitle"
[mediawiki.git] / includes / export / DumpFilter.php
blob5c27658af561f451f2a7ab768c658cd8842e9d40
1 <?php
2 /**
3 * Dump output filter class.
4 * This just does output filtering and streaming; XML formatting is done
5 * higher up, so be careful in what you do.
7 * Copyright © 2003, 2005, 2006 Brion Vibber <brion@pobox.com>
8 * https://www.mediawiki.org/
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * http://www.gnu.org/copyleft/gpl.html
25 * @file
28 /**
29 * @ingroup Dump
31 class DumpFilter {
32 /**
33 * @var DumpOutput
34 * FIXME will need to be made protected whenever legacy code
35 * is updated.
37 public $sink;
39 /**
40 * @var bool
42 protected $sendingThisPage;
44 /**
45 * @param DumpOutput $sink
47 function __construct( &$sink ) {
48 $this->sink =& $sink;
51 /**
52 * @param string $string
54 function writeOpenStream( $string ) {
55 $this->sink->writeOpenStream( $string );
58 /**
59 * @param string $string
61 function writeCloseStream( $string ) {
62 $this->sink->writeCloseStream( $string );
65 /**
66 * @param object $page
67 * @param string $string
69 function writeOpenPage( $page, $string ) {
70 $this->sendingThisPage = $this->pass( $page, $string );
71 if ( $this->sendingThisPage ) {
72 $this->sink->writeOpenPage( $page, $string );
76 /**
77 * @param string $string
79 function writeClosePage( $string ) {
80 if ( $this->sendingThisPage ) {
81 $this->sink->writeClosePage( $string );
82 $this->sendingThisPage = false;
86 /**
87 * @param object $rev
88 * @param string $string
90 function writeRevision( $rev, $string ) {
91 if ( $this->sendingThisPage ) {
92 $this->sink->writeRevision( $rev, $string );
96 /**
97 * @param object $rev
98 * @param string $string
100 function writeLogItem( $rev, $string ) {
101 $this->sink->writeRevision( $rev, $string );
105 * @param string $newname
107 function closeRenameAndReopen( $newname ) {
108 $this->sink->closeRenameAndReopen( $newname );
112 * @param string $newname
113 * @param bool $open
115 function closeAndRename( $newname, $open = false ) {
116 $this->sink->closeAndRename( $newname, $open );
120 * @return array
122 function getFilenames() {
123 return $this->sink->getFilenames();
127 * Override for page-based filter types.
128 * @param object $page
129 * @return bool
131 function pass( $page ) {
132 return true;