Debian Codegraph @

includes/parser/ParserOutputFlags.php

raw symbols SCIP
1 <?php
2
3 /**
4 * Registry of flags used with ParserOutput::setOutputFlag() within
5 * MediaWiki core.
6 *
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.
11 *
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.
16 *
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
21 *
22 * @since 1.38
23 *
24 * @file
25 * @ingroup Parser
26 */
27
28 namespace MediaWiki\Parser;
29
30 /**
31 * Registry of flags used with ParserOutput::{get,set}OutputFlag() within
32 * MediaWiki core.
33 *
34 * All flags used should be defined in this class.
35 *
36 * It is recommended that new flag names in core should begin with 'mw-'
37 * in order to prevent namespace conflicts with legacy flags.
38 *
39 * Note that in order to provide forward compatibility with "new" flag
40 * values, any additions to ParserOutputFlags should be backported to
41 * all currently-active release branches before those flags are written
42 * into the parser cache.
43 *
44 * @package MediaWiki\Parser
45 * @since 1.38
46 */
47 class ParserOutputFlags {
48
49 // See note above about backporting any new flags added to this
50 // enumeration.
51
52 /**
53 * @var string Disable magic gallery on category page (__NOGALLERY__).
54 *
55 * This is used to selectively disable the auto-magic thumbnail
56 * gallery on thumbnail pages.
57 *
58 * @see MainConfigSchema::CategoryMagicGallery
59 * @since 1.38
60 */
61 public const NO_GALLERY = 'mw-NoGallery';
62
63 /**
64 * @var string Whether OOUI should be enabled. If set, OOUI is enabled in
65 * any OutputPage instance the ParserOutput containing this flag
66 * is added to.
67 * @since 1.38
68 */
69 public const ENABLE_OOUI = 'mw-EnableOOUI';
70
71 /**
72 * @var string Force index policy to be 'index'.
73 * @see ParserOutput::getIndexPolicy()
74 * @see ParserOutput::setIndexPolicy()
75 * @since 1.38
76 */
77 public const INDEX_POLICY = 'mw-IndexPolicy';
78
79 /**
80 * @var string Force index policy to be 'noindex'.
81 * @see ParserOutput::getIndexPolicy()
82 * @see ParserOutput::setIndexPolicy()
83 * @since 1.38
84 */
85 public const NO_INDEX_POLICY = 'mw-NoIndexPolicy';
86
87 /**
88 * @var string Show a new section link?
89 * @since 1.38
90 */
91 public const NEW_SECTION = 'mw-NewSection';
92
93 /**
94 * @var string Hide the new section link?
95 * @since 1.38
96 */
97 public const HIDE_NEW_SECTION = 'mw-HideNewSection';
98
99 /**
100 * @var string The prevent-clickjacking flag.
101 *
102 * If true, we emit an `X-Frame-Options` header appropriate for
103 * edit pages. The exact header value is controlled by
104 * `$wgEditPageFrameOptions`. This controls if anti-clickjacking
105 * / frame-breaking headers will be sent. This flag is set by
106 * default for special pages. For other pages where a
107 * CSRF-protect form is displayed (for example where edit actions
108 * are possible), you need to set this flag.
109 *
110 * @since 1.38
111 */
112 public const PREVENT_CLICKJACKING = 'mw-PreventClickjacking';
113
114 /**
115 * @var string Show the table of contents in the skin?
116 *
117 * This is a /suggestion/ based on whether the TOC is "large
118 * enough" and other factors, and is intended mostly for skins
119 * which want to match the behavior of the traditional inline ToC.
120 * @since 1.39
121 */
122 public const SHOW_TOC = 'show-toc';
123
124 /**
125 * @var string Suppress the table of contents in the skin?
126 *
127 * This reflects the use of the `__NOTOC__` magic word in the
128 * article (possibly modified by `__TOC__` or `__FORCETOC__`), and
129 * represents an explicit request from the author to hide the TOC.
130 * @since 1.41
131 */
132 public const NO_TOC = 'no-toc';
133
134 /**
135 * @var string Suppress the section edit links?
136 *
137 * This reflects the `ParserOptions::getSuppressSectionEditLinks()`
138 * flag and affects the default value of `enableSectionEditLinks`
139 * in `ParserOutput::getText()`.
140 * @since 1.42
141 */
142 public const NO_SECTION_EDIT_LINKS = 'no-section-edit-links';
143
144 /**
145 * @var string Wrap section contents to allow collapsing them?
146 *
147 * This reflects the ParserOptions::getCollapsibleSections()
148 * flag.
149 * @since 1.43
150 */
151 public const COLLAPSIBLE_SECTIONS = 'collapsible-sections';
152
153 // See RenderedRevision::outputVariesOnRevisionMetadata for the
154 // VARY_* flags.
155
156 /**
157 * @var string Informs the edit saving system that the canonical output for
158 * this page may change after revision insertion; for instance
159 * if it uses some properties of the page itself (like categories)
160 * which will not be updated until the RefreshLinksJob is run after
161 * the revision is saved.
162 * @since 1.38
163 */
164 public const VARY_REVISION = 'vary-revision';
165
166 /**
167 * @var string Similar to VARY_REVISION, but used if we didn't
168 * guess the ID correctly. Informs the edit saving system that
169 * getting the canonical output after revision insertion requires
170 * a parse that used that exact revision ID, for instance if the
171 * page used {{REVISIONID}} to fetch its own revision ID.
172 * @since 1.38
173 */
174 public const VARY_REVISION_ID = 'vary-revision-id';
175
176 /**
177 * @var string Similar to VARY_REVISION_ID, but used if we didn't
178 * guess the timestamp correctly. Informs the edit saving system
179 * that getting the canonical output after revision insertion
180 * requires a parse that used an actual revision timestamp.
181 * @since 1.38
182 */
183 public const VARY_REVISION_TIMESTAMP = 'vary-revision-timestamp';
184
185 /**
186 * @var string Similar to VARY_REVISION, but used if we didn't guess the
187 * content correctly. For example, a self-transclusion will
188 * set this flag, since the lookup of the transcluded content
189 * (itself) will be stale until the new revision of this page
190 * is actually stored in the DB.
191 * @since 1.38
192 */
193 public const VARY_REVISION_SHA1 = 'vary-revision-sha1';
194
195 /**
196 * @var string Similar to VARY_REVISION, but used if the output will change
197 * once this page exists in the database.
198 * @since 1.38
199 */
200 public const VARY_REVISION_EXISTS = 'vary-revision-exists';
201
202 /**
203 * @var string Similar to VARY_REVISION, but used if we didn't guess the
204 * page id correctly. Informs the edit saving system that getting the
205 * canonical output after page insertion requires a parse that used that
206 * exact page id.
207 * @since 1.38
208 */
209 public const VARY_PAGE_ID = 'vary-page-id';
210
211 /**
212 * @var string Similar to VARY_REVISION. Informs the edit saving
213 * system that getting the canonical output after revision
214 * insertion requires a parse that used the actual user ID.
215 * @since 1.38
216 */
217 public const VARY_USER = 'vary-user';
218
219 /**
220 * @var string Used to avoid extremely stale user signature timestamps
221 * (T84843). Set if the signature wikitext contains another '~~~~' or
222 * similar (T230652).
223 * @since 1.38
224 */
225 public const USER_SIGNATURE = 'user-signature';
226
227 /**
228 * @var string Set when the parse is done in "preview mode".
229 *
230 * When the parse is done in "previous mode" various shortcuts are
231 * taken to work around the fact that the parsed text does not yet
232 * have an actual revision ID, revision time, etc.
233 * @see ParserOptions::getIsPreview()
234 * @since 1.42
235 */
236 public const IS_PREVIEW = 'is-preview';
237
238 /**
239 * @var string Set when the parse was done with parsoid; clear if the
240 * parse was done with the legacy parser (or unknown).
241 *
242 * @see ParserOptions::getUseParsoid()
243 * @since 1.45
244 */
245 public const USE_PARSOID = 'use-parsoid';
246
247 /**
248 * @var string Set if this page contains content which could be
249 * asynchronous, even if the content was "ready" at the time of
250 * the parse.
251 *
252 * This ensures that when the page expires from the
253 * cache and the page is reparsed, RefreshLinksJob will also be
254 * re-run since the content could be different from the last
255 * parse. (T373256)
256 * @since 1.44
257 */
258 public const HAS_ASYNC_CONTENT = 'has-async-content';
259
260 /**
261 * @var string Set if this page contains asynchronous content which
262 * was not ready by the time the output was generated.
263 *
264 * At present this reduces the cache TTL. (T373256)
265 * @since 1.44
266 */
267 public const ASYNC_NOT_READY = 'async-not-ready';
268
269 /**
270 * @var string Set if this page is unsafe for selective update.
271 *
272 * Generally this means a resource limit was reached, and so this
273 * page does not contain a full representation of the input wikitext.
274 * An update might resolve the excess resource use, but it wouldn't
275 * be able to replace the content that was lost when the limit
276 * was reached. (Duplicate or conflicting definitions constitute
277 * another form of "resource limit", since uniqueness limits us to
278 * only one of a given item.)
279 *
280 * Triggering other error conditions or the use of other unsafe features
281 * may also set this flag.
282 * @since 1.46
283 */
284 public const PREVENT_SELECTIVE_UPDATE = 'prevent-selective-update';
285
286 /**
287 * @var string Set if this page contains header placeholders (T200915).
288 * @since 1.46
289 */
290 public const HAS_SLOT_HEADERS = 'has-slot-headers';
291
292 public static function cases(): array {
293 return [
294 self::NO_GALLERY,
295 self::ENABLE_OOUI,
296 self::INDEX_POLICY,
297 self::NO_INDEX_POLICY,
298 self::NEW_SECTION,
299 self::HIDE_NEW_SECTION,
300 self::SHOW_TOC,
301 self::NO_TOC,
302 self::NO_SECTION_EDIT_LINKS,
303 self::COLLAPSIBLE_SECTIONS,
304 self::PREVENT_CLICKJACKING,
305 self::VARY_REVISION,
306 self::VARY_REVISION_ID,
307 self::VARY_REVISION_TIMESTAMP,
308 self::VARY_REVISION_SHA1,
309 self::VARY_REVISION_EXISTS,
310 self::VARY_PAGE_ID,
311 self::VARY_USER,
312 self::USER_SIGNATURE,
313 self::IS_PREVIEW,
314 self::USE_PARSOID,
315 self::HAS_ASYNC_CONTENT,
316 self::ASYNC_NOT_READY,
317 self::PREVENT_SELECTIVE_UPDATE,
318 self::HAS_SLOT_HEADERS,
319 ];
320 }
321 }