Bump and prep 1.34.1
[lhc/web/wiklou.git] / includes / Revision / FallbackSlotRoleHandler.php
1 <?php
2 /**
3 * This file is part of MediaWiki.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 namespace MediaWiki\Revision;
24
25 use MediaWiki\Linker\LinkTarget;
26
27 /**
28 * A SlotRoleHandler for providing basic functionality for undefined slot roles.
29 *
30 * This class is intended to be used when encountering slots with a role that used to be defined
31 * by an extension, but no longer is backed by hany specific handler, since the extension in
32 * question has been uninstalled. It may also be used for pages imported from another wiki.
33 *
34 * @since 1.33
35 */
36 class FallbackSlotRoleHandler extends SlotRoleHandler {
37
38 public function __construct( $role ) {
39 // treat unknown content as plain text
40 parent::__construct( $role, CONTENT_MODEL_TEXT );
41 }
42
43 /**
44 * @param LinkTarget $page
45 *
46 * @return bool Always false, to prevent undefined slots from being used in new revisions.
47 */
48 public function isAllowedOn( LinkTarget $page ) {
49 return false;
50 }
51
52 /**
53 * @param string $model
54 * @param LinkTarget $page
55 *
56 * @return bool Always false, to prevent undefined slots from being used for
57 * arbitrary content.
58 */
59 public function isAllowedModel( $model, LinkTarget $page ) {
60 return false;
61 }
62
63 public function getOutputLayoutHints() {
64 // TODO: should be return [ 'display' => 'none'] here, causing undefined slots
65 // to be hidden? We'd still need some place to surface the content of such
66 // slots, see T209923.
67
68 return parent::getOutputLayoutHints(); // TODO: Change the autogenerated stub
69 }
70
71 }