Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ParserOutputFlags | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| values | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Registry of flags used with ParserOutput::setOutputFlag() within |
| 5 | * MediaWiki core. |
| 6 | * |
| 7 | * @license GPL-2.0-or-later |
| 8 | * @since 1.38 |
| 9 | * |
| 10 | * @file |
| 11 | * @ingroup Parser |
| 12 | */ |
| 13 | |
| 14 | namespace MediaWiki\Parser; |
| 15 | |
| 16 | /** |
| 17 | * Registry of flags used with ParserOutput::{get,set}OutputFlag() within |
| 18 | * MediaWiki core. |
| 19 | * |
| 20 | * All flags used should be defined in this class. |
| 21 | * |
| 22 | * It is recommended that new flag names in core should begin with 'mw-' |
| 23 | * in order to prevent namespace conflicts with legacy flags. |
| 24 | * |
| 25 | * @package MediaWiki\Parser |
| 26 | * @since 1.38 |
| 27 | */ |
| 28 | enum ParserOutputFlags: string { |
| 29 | |
| 30 | // These flags are currently stored as ParserOutput properties |
| 31 | |
| 32 | /** |
| 33 | * Disable magic gallery on category page (__NOGALLERY__). |
| 34 | * |
| 35 | * This is used to selectively disable the auto-magic thumbnail |
| 36 | * gallery on thumbnail pages. |
| 37 | * |
| 38 | * @see MainConfigSchema::CategoryMagicGallery |
| 39 | * @see ParserOutput::getNoGallery() |
| 40 | * @see ParserOutput::setNoGallery() |
| 41 | * @since 1.38 |
| 42 | */ |
| 43 | case NO_GALLERY = 'mw-NoGallery'; |
| 44 | |
| 45 | /** |
| 46 | * Whether OOUI should be enabled. |
| 47 | * @see ParserOutput::getEnableOOUI() |
| 48 | * @see ParserOutput::setEnableOOUI() |
| 49 | * @since 1.38 |
| 50 | */ |
| 51 | case ENABLE_OOUI = 'mw-EnableOOUI'; |
| 52 | |
| 53 | /** |
| 54 | * Force index policy to be 'index'. |
| 55 | * @see ParserOutput::getIndexPolicy() |
| 56 | * @see ParserOutput::setIndexPolicy() |
| 57 | * @since 1.38 |
| 58 | */ |
| 59 | case INDEX_POLICY = 'mw-IndexPolicy'; |
| 60 | |
| 61 | /** |
| 62 | * Force index policy to be 'noindex'. |
| 63 | * @see ParserOutput::getIndexPolicy() |
| 64 | * @see ParserOutput::setIndexPolicy() |
| 65 | * @since 1.38 |
| 66 | */ |
| 67 | case NO_INDEX_POLICY = 'mw-NoIndexPolicy'; |
| 68 | |
| 69 | /** |
| 70 | * Show a new section link? |
| 71 | * @see ParserOutput::getNewSection() |
| 72 | * @see ParserOutput::setNewSection() |
| 73 | * @since 1.38 |
| 74 | */ |
| 75 | case NEW_SECTION = 'mw-NewSection'; |
| 76 | |
| 77 | /** |
| 78 | * Hide the new section link? |
| 79 | * @see ParserOutput::getHideNewSection() |
| 80 | * @see ParserOutput::setHideNewSection() |
| 81 | * @since 1.38 |
| 82 | */ |
| 83 | case HIDE_NEW_SECTION = 'mw-HideNewSection'; |
| 84 | |
| 85 | /** |
| 86 | * The prevent-clickjacking flag. |
| 87 | * If true, we emit X-Frame-Options: DENY. |
| 88 | * This controls if anti-clickjacking / frame-breaking headers will |
| 89 | * be sent. This should be done for pages where edit actions are possible. |
| 90 | * @see ParserOutput::getPreventClickjacking() |
| 91 | * @see ParserOutput::setPreventClickjacking() |
| 92 | * @since 1.38 |
| 93 | */ |
| 94 | case PREVENT_CLICKJACKING = 'mw-PreventClickjacking'; |
| 95 | |
| 96 | // These flags are stored in the ParserOutput::$mFlags array |
| 97 | |
| 98 | /** |
| 99 | * Show the table of contents in the skin? |
| 100 | * |
| 101 | * This is a /suggestion/ based on whether the TOC is "large |
| 102 | * enough" and other factors, and is intended mostly for skins |
| 103 | * which want to match the behavior of the traditional inline ToC. |
| 104 | * @since 1.39 |
| 105 | */ |
| 106 | case SHOW_TOC = 'show-toc'; |
| 107 | |
| 108 | /** |
| 109 | * Suppress the table of contents in the skin? |
| 110 | * |
| 111 | * This reflects the use of the `__NOTOC__` magic word in the |
| 112 | * article (possibly modified by `__TOC__` or `__FORCETOC__`), and |
| 113 | * represents an explicit request from the author to hide the TOC. |
| 114 | * @since 1.41 |
| 115 | */ |
| 116 | case NO_TOC = 'no-toc'; |
| 117 | |
| 118 | /** |
| 119 | * Suppress the section edit links? |
| 120 | * |
| 121 | * This reflects the `ParserOptions::getSuppressSectionEditLinks()` |
| 122 | * flag and affects the default value of `enableSectionEditLinks` |
| 123 | * in `ParserOutput::getText()`. |
| 124 | * @since 1.42 |
| 125 | */ |
| 126 | case NO_SECTION_EDIT_LINKS = 'no-section-edit-links'; |
| 127 | |
| 128 | /** |
| 129 | * Wrap section contents to allow collapsing them? |
| 130 | * |
| 131 | * This reflects the ParserOptions::getCollapsibleSections() |
| 132 | * flag. |
| 133 | * @since 1.43 |
| 134 | */ |
| 135 | case COLLAPSIBLE_SECTIONS = 'collapsible-sections'; |
| 136 | |
| 137 | // See RenderedRevision::outputVariesOnRevisionMetadata for the |
| 138 | // following flags. |
| 139 | |
| 140 | /** |
| 141 | * Informs the edit saving system that the canonical output for |
| 142 | * this page may change after revision insertion; for instance |
| 143 | * if it uses some properties of the page itself (like categories) |
| 144 | * which will not be updated until the RefreshLinksJob is run after |
| 145 | * the revision is saved. |
| 146 | * @since 1.38 |
| 147 | */ |
| 148 | case VARY_REVISION = 'vary-revision'; |
| 149 | |
| 150 | /** |
| 151 | * Similar to VARY_REVISION, but used if we didn't |
| 152 | * guess the ID correctly. Informs the edit saving system that |
| 153 | * getting the canonical output after revision insertion requires |
| 154 | * a parse that used that exact revision ID, for instance if the |
| 155 | * page used {{REVISIONID}} to fetch its own revision ID. |
| 156 | * @since 1.38 |
| 157 | */ |
| 158 | case VARY_REVISION_ID = 'vary-revision-id'; |
| 159 | |
| 160 | /** |
| 161 | * Similar to VARY_REVISION_ID, but used if we didn't |
| 162 | * guess the timestamp correctly. Informs the edit saving system |
| 163 | * that getting the canonical output after revision insertion |
| 164 | * requires a parse that used an actual revision timestamp. |
| 165 | * @since 1.38 |
| 166 | */ |
| 167 | case VARY_REVISION_TIMESTAMP = 'vary-revision-timestamp'; |
| 168 | |
| 169 | /** |
| 170 | * Similar to VARY_REVISION, but used if we didn't guess the |
| 171 | * content correctly. For example, a self-transclusion will |
| 172 | * set this flag, since the lookup of the transcluded content |
| 173 | * (itself) will be stale until the new revision of this page |
| 174 | * is actually stored in the DB. |
| 175 | * @since 1.38 |
| 176 | */ |
| 177 | case VARY_REVISION_SHA1 = 'vary-revision-sha1'; |
| 178 | |
| 179 | /** |
| 180 | * Similar to VARY_REVISION, but used if the output will change |
| 181 | * once this page exists in the database. |
| 182 | * @since 1.38 |
| 183 | */ |
| 184 | case VARY_REVISION_EXISTS = 'vary-revision-exists'; |
| 185 | |
| 186 | /** |
| 187 | * Similar to VARY_REVISION, but used if we didn't guess the |
| 188 | * page id correctly. Informs the edit saving system that getting the |
| 189 | * canonical output after page insertion requires a parse that used that |
| 190 | * exact page id. |
| 191 | * @since 1.38 |
| 192 | */ |
| 193 | case VARY_PAGE_ID = 'vary-page-id'; |
| 194 | |
| 195 | /** |
| 196 | * Similar to VARY_REVISION. Informs the edit saving |
| 197 | * system that getting the canonical output after revision |
| 198 | * insertion requires a parse that used the actual user ID. |
| 199 | * @since 1.38 |
| 200 | */ |
| 201 | case VARY_USER = 'vary-user'; |
| 202 | |
| 203 | /** |
| 204 | * Used to avoid extremely stale user signature timestamps |
| 205 | * (T84843). Set if the signature wikitext contains another '~~~~' or |
| 206 | * similar (T230652). |
| 207 | * @since 1.38 |
| 208 | */ |
| 209 | case USER_SIGNATURE = 'user-signature'; |
| 210 | |
| 211 | /** |
| 212 | * Set when the parse is done in "preview mode". |
| 213 | * |
| 214 | * When the parse is done in "previous mode" various shortcuts are |
| 215 | * taken to work around the fact that the parsed text does not yet |
| 216 | * have an actual revision ID, revision time, etc. |
| 217 | * @see ParserOptions::getIsPreview() |
| 218 | * @since 1.42 |
| 219 | */ |
| 220 | case IS_PREVIEW = 'is-preview'; |
| 221 | |
| 222 | /** |
| 223 | * Set when the parse was done with parsoid; clear if the |
| 224 | * parse was done with the legacy parser (or unknown). |
| 225 | * |
| 226 | * @see ParserOptions::getUseParsoid() |
| 227 | * @since 1.45 |
| 228 | */ |
| 229 | case USE_PARSOID = 'use-parsoid'; |
| 230 | |
| 231 | /** |
| 232 | * Set if this page contains content which could be |
| 233 | * asynchronous, even if the content was "ready" at the time of |
| 234 | * the parse. |
| 235 | * |
| 236 | * This ensures that when the page expires from the |
| 237 | * cache and the page is reparsed, RefreshLinksJob will also be |
| 238 | * re-run since the content could be different from the last |
| 239 | * parse. (T373256) |
| 240 | * @since 1.44 |
| 241 | */ |
| 242 | case HAS_ASYNC_CONTENT = 'has-async-content'; |
| 243 | |
| 244 | /** |
| 245 | * Set if this page contains asynchronous content which |
| 246 | * was not ready by the time the output was generated. |
| 247 | * |
| 248 | * At present this reduces the cache TTL. (T373256) |
| 249 | * @since 1.44 |
| 250 | */ |
| 251 | case ASYNC_NOT_READY = 'async-not-ready'; |
| 252 | |
| 253 | /** |
| 254 | * Return the ParserOutputFlags, as an array of string flag values. |
| 255 | * @return list<string> |
| 256 | */ |
| 257 | public static function values(): array { |
| 258 | return array_column( self::cases(), 'value' ); |
| 259 | } |
| 260 | } |