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';
122 * @var string Wrap section contents to allow collapsing them?
123 * This reflects the ParserOptions::getCollapsibleSections()
126 public const COLLAPSIBLE_SECTIONS
= 'collapsible-sections';
131 public const VARY_REVISION
= 'vary-revision';
134 * @var string Similar to VARY_REVISION, but used if we didn't
135 * guess the ID correctly. Informs the edit saving system that
136 * getting the canonical output after revision insertion requires
137 * a parse that used that exact revision ID.
139 public const VARY_REVISION_ID
= 'vary-revision-id';
142 * @var string Similar to VARY_REVISION, but used if we didn't
143 * guess the timestamp correctly. Informs the edit saving system
144 * that getting the canonical output after revision insertion
145 * requires a parse that used an actual revision timestamp.
147 public const VARY_REVISION_TIMESTAMP
= 'vary-revision-timestamp';
150 * @var string Similar to VARY_REVISION, but used if we didn't guess the
153 public const VARY_REVISION_SHA1
= 'vary-revision-sha1';
156 * @var string Similar to VARY_REVISION
158 public const VARY_REVISION_EXISTS
= 'vary-revision-exists';
161 * @var string Similar to VARY_REVISION, but used if we didn't guess the
162 * page id correctly. Informs the edit saving system that getting the
163 * canonical output after page insertion requires a parse that used that
166 public const VARY_PAGE_ID
= 'vary-page-id';
169 * @var string Similar to VARY_REVISION. Informs the edit saving
170 * system that getting the canonical output after revision
171 * insertion requires a parse that used the actual user ID.
173 public const VARY_USER
= 'vary-user';
176 * @var string Used to avoid extremely stale user signature timestamps
177 * (T84843). Set if the signature wikitext contains another '~~~~' or
180 public const USER_SIGNATURE
= 'user-signature';
183 * @var string Set when the parse is done in "preview mode", in which
184 * case various shortcuts are taken to work around the fact that the
185 * parsed text does not yet have an actual revision ID, revision time,
187 * @see ParserOptions::getIsPreview()
189 public const IS_PREVIEW
= 'is-preview';
192 * @var string Set if this page contains content which could be
193 * asynchronous, even if the content was "ready" at the time of
194 * the parse. This ensures that when the page expires from the
195 * cache and the page is reparsed, RefreshLinksJob will also be
196 * re-run since the content could be different from the last
199 public const HAS_ASYNC_CONTENT
= 'has-async-content';
202 * @var string Set if this page contains asynchronous content which
203 * was not ready by the time the output was generated. At present
204 * this reduces the cache TTL. (T373256)
206 public const ASYNC_NOT_READY
= 'async-not-ready';
208 public static function cases(): array {
213 self
::NO_INDEX_POLICY
,
215 self
::HIDE_NEW_SECTION
,
218 self
::NO_SECTION_EDIT_LINKS
,
219 self
::COLLAPSIBLE_SECTIONS
,
220 self
::PREVENT_CLICKJACKING
,
222 self
::VARY_REVISION_ID
,
223 self
::VARY_REVISION_TIMESTAMP
,
224 self
::VARY_REVISION_SHA1
,
225 self
::VARY_REVISION_EXISTS
,
228 self
::USER_SIGNATURE
,
230 self
::HAS_ASYNC_CONTENT
,
231 self
::ASYNC_NOT_READY
,