summaryrefslogtreecommitdiff
path: root/includes/changetags/ChangeTagsList.php
blob: dd8bab98788892b9625b0daa212b702fef559d62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 * @file
 * @ingroup Change tagging
 */

/**
 * Generic list for change tagging.
 */
abstract class ChangeTagsList extends RevisionListBase {
	function __construct( IContextSource $context, Title $title, array $ids ) {
		parent::__construct( $context, $title );
		$this->ids = $ids;
	}

	/**
	 * Creates a ChangeTags*List of the requested type.
	 *
	 * @param string $typeName 'revision' or 'logentry'
	 * @param IContextSource $context
	 * @param Title $title
	 * @param array $ids
	 * @return ChangeTagsList An instance of the requested subclass
	 * @throws Exception If you give an unknown $typeName
	 */
	public static function factory( $typeName, IContextSource $context,
		Title $title, array $ids ) {

		switch ( $typeName ) {
			case 'revision':
				$className = 'ChangeTagsRevisionList';
				break;
			case 'logentry':
				$className = 'ChangeTagsLogList';
				break;
			default:
				throw new Exception( "Class $className requested, but does not exist" );
		}
		return new $className( $context, $title, $ids );
	}

	/**
	 * Reload the list data from the master DB.
	 */
	function reloadFromMaster() {
		$dbw = wfGetDB( DB_MASTER );
		$this->res = $this->doQuery( $dbw );
	}

	/**
	 * Add/remove change tags from all the items in the list.
	 *
	 * @param array $tagsToAdd
	 * @param array $tagsToRemove
	 * @param array $params
	 * @param string $reason
	 * @param User $user
	 * @return Status
	 */
	abstract function updateChangeTagsOnAll( $tagsToAdd, $tagsToRemove, $params,
		$reason, $user );
}