]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/changetags/ChangeTagsList.php
MediaWiki 1.30.2-scripts2
[autoinstallsdev/mediawiki.git] / includes / changetags / ChangeTagsList.php
1 <?php
2 /**
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16  * http://www.gnu.org/copyleft/gpl.html
17  *
18  * @file
19  * @ingroup Change tagging
20  */
21
22 /**
23  * Generic list for change tagging.
24  */
25 abstract class ChangeTagsList extends RevisionListBase {
26         function __construct( IContextSource $context, Title $title, array $ids ) {
27                 parent::__construct( $context, $title );
28                 $this->ids = $ids;
29         }
30
31         /**
32          * Creates a ChangeTags*List of the requested type.
33          *
34          * @param string $typeName 'revision' or 'logentry'
35          * @param IContextSource $context
36          * @param Title $title
37          * @param array $ids
38          * @return ChangeTagsList An instance of the requested subclass
39          * @throws Exception If you give an unknown $typeName
40          */
41         public static function factory( $typeName, IContextSource $context,
42                 Title $title, array $ids
43         ) {
44                 switch ( $typeName ) {
45                         case 'revision':
46                                 $className = 'ChangeTagsRevisionList';
47                                 break;
48                         case 'logentry':
49                                 $className = 'ChangeTagsLogList';
50                                 break;
51                         default:
52                                 throw new Exception( "Class $typeName requested, but does not exist" );
53                 }
54
55                 return new $className( $context, $title, $ids );
56         }
57
58         /**
59          * Reload the list data from the master DB.
60          */
61         function reloadFromMaster() {
62                 $dbw = wfGetDB( DB_MASTER );
63                 $this->res = $this->doQuery( $dbw );
64         }
65
66         /**
67          * Add/remove change tags from all the items in the list.
68          *
69          * @param array $tagsToAdd
70          * @param array $tagsToRemove
71          * @param array $params
72          * @param string $reason
73          * @param User $user
74          * @return Status
75          */
76         abstract function updateChangeTagsOnAll( $tagsToAdd, $tagsToRemove, $params,
77                 $reason, $user );
78 }