4 * Registry of flags used with ParserOutput::setOutputFlag() within
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
28 namespace MediaWiki\Parser
;
31 * Registry of flags used with ParserOutput::{get,set}OutputFlag() within
34 * All flags used should be defined in this class.
36 * It is recommended that new flag names in core should begin with 'mw-'
37 * in order to prevent namespace conflicts with legacy flags.
39 * @package MediaWiki\Parser
41 class ParserOutputFlags
{
43 // These flags are currently stored as ParserOutput properties
46 * @var string No gallery on category page? (__NOGALLERY__).
47 * @see ParserOutput::getNoGallery()
48 * @see ParserOutput::setNoGallery()
50 public const NO_GALLERY
= 'mw-NoGallery';
53 * @var string Whether OOUI should be enabled.
54 * @see ParserOutput::getEnableOOUI()
55 * @see ParserOutput::setEnableOOUI()
57 public const ENABLE_OOUI
= 'mw-EnableOOUI';
60 * @var string Force index policy to be 'index'
61 * @see ParserOutput::getIndexPolicy()
62 * @see ParserOutput::setIndexPolicy()
64 public const INDEX_POLICY
= 'mw-IndexPolicy';
67 * @var string Force index policy to be 'noindex'
68 * @see ParserOutput::getIndexPolicy()
69 * @see ParserOutput::setIndexPolicy()
71 public const NO_INDEX_POLICY
= 'mw-NoIndexPolicy';
74 * @var string Show a new section link?
75 * @see ParserOutput::getNewSection()
76 * @see ParserOutput::setNewSection()
78 public const NEW_SECTION
= 'mw-NewSection';
81 * @var string Hide the new section link?
82 * @see ParserOutput::getHideNewSection()
83 * @see ParserOutput::setHideNewSection()
85 public const HIDE_NEW_SECTION
= 'mw-HideNewSection';
88 * @var string The prevent-clickjacking flag
89 * @see ParserOutput::getPreventClickjacking()
90 * @see ParserOutput::setPreventClickjacking()
92 public const PREVENT_CLICKJACKING
= 'mw-PreventClickjacking';
94 // These flags are stored in the ParserOutput::$mFlags array
97 * @var string Show the table of contents in the skin? This is
98 * a /suggestion/ based on whether the TOC is "large enough"
99 * and other factors, and is intended mostly for skins which
100 * want to match the behavior of the traditional inline ToC.
102 public const SHOW_TOC
= 'show-toc';
105 * @var string Suppress the table of contents in the skin?
106 * This reflects the use of the __NOTOC__ magic word in the
107 * article (possibly modified by __TOC__ or __FORCETOC__),
108 * and represents an explicit request from the author to
111 public const NO_TOC
= 'no-toc';
114 * @var string Suppress the section edit links?
115 * This reflects the ParserOptions::getSuppressSectionEditLinks()
116 * flag and affects the default value of `enableSectionEditLinks`
117 * in ParserOutput::getText().
119 public const NO_SECTION_EDIT_LINKS
= 'no-section-edit-links';
124 public const VARY_REVISION
= 'vary-revision';
127 * @var string Similar to VARY_REVISION, but used if we didn't
128 * guess the ID correctly. Informs the edit saving system that
129 * getting the canonical output after revision insertion requires
130 * a parse that used that exact revision ID.
132 public const VARY_REVISION_ID
= 'vary-revision-id';
135 * @var string Similar to VARY_REVISION, but used if we didn't
136 * guess the timestamp correctly. Informs the edit saving system
137 * that getting the canonical output after revision insertion
138 * requires a parse that used an actual revision timestamp.
140 public const VARY_REVISION_TIMESTAMP
= 'vary-revision-timestamp';
143 * @var string Similar to VARY_REVISION, but used if we didn't guess the
146 public const VARY_REVISION_SHA1
= 'vary-revision-sha1';
149 * @var string Similar to VARY_REVISION
151 public const VARY_REVISION_EXISTS
= 'vary-revision-exists';
154 * @var string Similar to VARY_REVISION, but used if we didn't guess the
155 * page id correctly. Informs the edit saving system that getting the
156 * canonical output after page insertion requires a parse that used that
159 public const VARY_PAGE_ID
= 'vary-page-id';
162 * @var string Similar to VARY_REVISION. Informs the edit saving
163 * system that getting the canonical output after revision
164 * insertion requires a parse that used the actual user ID.
166 public const VARY_USER
= 'vary-user';
169 * @var string Used to avoid extremely stale user signature timestamps
170 * (T84843). Set if the signature wikitext contains another '~~~~' or
173 public const USER_SIGNATURE
= 'user-signature';
176 * @var string Set when the parse is done in "preview mode", in which
177 * case various shortcuts are taken to work around the fact that the
178 * parsed text does not yet have an actual revision ID, revision time,
180 * @see ParserOptions::getIsPreview()
182 public const IS_PREVIEW
= 'is-preview';
184 public static function cases(): array {
189 self
::NO_INDEX_POLICY
,
191 self
::HIDE_NEW_SECTION
,
194 self
::NO_SECTION_EDIT_LINKS
,
195 self
::PREVENT_CLICKJACKING
,
197 self
::VARY_REVISION_ID
,
198 self
::VARY_REVISION_TIMESTAMP
,
199 self
::VARY_REVISION_SHA1
,
200 self
::VARY_REVISION_EXISTS
,
203 self
::USER_SIGNATURE
,