Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like OutputPage often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use OutputPage, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 43 | class OutputPage extends ContextSource { |
||
| 44 | /** @var array Should be private. Used with addMeta() which adds "<meta>" */ |
||
| 45 | protected $mMetatags = []; |
||
| 46 | |||
| 47 | /** @var array */ |
||
| 48 | protected $mLinktags = []; |
||
| 49 | |||
| 50 | /** @var bool */ |
||
| 51 | protected $mCanonicalUrl = false; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @var array Additional stylesheets. Looks like this is for extensions. |
||
| 55 | * Might be replaced by ResourceLoader. |
||
| 56 | */ |
||
| 57 | protected $mExtStyles = []; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @var string Should be private - has getter and setter. Contains |
||
| 61 | * the HTML title */ |
||
| 62 | public $mPagetitle = ''; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var string Contains all of the "<body>" content. Should be private we |
||
| 66 | * got set/get accessors and the append() method. |
||
| 67 | */ |
||
| 68 | public $mBodytext = ''; |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Holds the debug lines that will be output as comments in page source if |
||
| 72 | * $wgDebugComments is enabled. See also $wgShowDebug. |
||
| 73 | * @deprecated since 1.20; use MWDebug class instead. |
||
| 74 | */ |
||
| 75 | public $mDebugtext = ''; |
||
| 76 | |||
| 77 | /** @var string Stores contents of "<title>" tag */ |
||
| 78 | private $mHTMLtitle = ''; |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @var bool Is the displayed content related to the source of the |
||
| 82 | * corresponding wiki article. |
||
| 83 | */ |
||
| 84 | private $mIsarticle = false; |
||
| 85 | |||
| 86 | /** @var bool Stores "article flag" toggle. */ |
||
| 87 | private $mIsArticleRelated = true; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @var bool We have to set isPrintable(). Some pages should |
||
| 91 | * never be printed (ex: redirections). |
||
| 92 | */ |
||
| 93 | private $mPrintable = false; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @var array Contains the page subtitle. Special pages usually have some |
||
| 97 | * links here. Don't confuse with site subtitle added by skins. |
||
| 98 | */ |
||
| 99 | private $mSubtitle = []; |
||
| 100 | |||
| 101 | /** @var string */ |
||
| 102 | public $mRedirect = ''; |
||
| 103 | |||
| 104 | /** @var int */ |
||
| 105 | protected $mStatusCode; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @var string Used for sending cache control. |
||
| 109 | * The whole caching system should probably be moved into its own class. |
||
| 110 | */ |
||
| 111 | protected $mLastModified = ''; |
||
| 112 | |||
| 113 | /** @var array */ |
||
| 114 | protected $mCategoryLinks = []; |
||
| 115 | |||
| 116 | /** @var array */ |
||
| 117 | protected $mCategories = []; |
||
| 118 | |||
| 119 | /** @var array */ |
||
| 120 | protected $mIndicators = []; |
||
| 121 | |||
| 122 | /** @var array Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page') */ |
||
| 123 | private $mLanguageLinks = []; |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Used for JavaScript (predates ResourceLoader) |
||
| 127 | * @todo We should split JS / CSS. |
||
| 128 | * mScripts content is inserted as is in "<head>" by Skin. This might |
||
| 129 | * contain either a link to a stylesheet or inline CSS. |
||
| 130 | */ |
||
| 131 | private $mScripts = ''; |
||
| 132 | |||
| 133 | /** @var string Inline CSS styles. Use addInlineStyle() sparingly */ |
||
| 134 | protected $mInlineStyles = ''; |
||
| 135 | |||
| 136 | /** |
||
| 137 | * @var string Used by skin template. |
||
| 138 | * Example: $tpl->set( 'displaytitle', $out->mPageLinkTitle ); |
||
| 139 | */ |
||
| 140 | public $mPageLinkTitle = ''; |
||
| 141 | |||
| 142 | /** @var array Array of elements in "<head>". Parser might add its own headers! */ |
||
| 143 | protected $mHeadItems = []; |
||
| 144 | |||
| 145 | /** @var array */ |
||
| 146 | protected $mModules = []; |
||
| 147 | |||
| 148 | /** @var array */ |
||
| 149 | protected $mModuleScripts = []; |
||
| 150 | |||
| 151 | /** @var array */ |
||
| 152 | protected $mModuleStyles = []; |
||
| 153 | |||
| 154 | /** @var ResourceLoader */ |
||
| 155 | protected $mResourceLoader; |
||
| 156 | |||
| 157 | /** @var ResourceLoaderClientHtml */ |
||
| 158 | private $rlClient; |
||
| 159 | |||
| 160 | /** @var ResourceLoaderContext */ |
||
| 161 | private $rlClientContext; |
||
| 162 | |||
| 163 | /** @var string */ |
||
| 164 | private $rlUserModuleState; |
||
| 165 | |||
| 166 | /** @var array */ |
||
| 167 | protected $mJsConfigVars = []; |
||
| 168 | |||
| 169 | /** @var array */ |
||
| 170 | protected $mTemplateIds = []; |
||
| 171 | |||
| 172 | /** @var array */ |
||
| 173 | protected $mImageTimeKeys = []; |
||
| 174 | |||
| 175 | /** @var string */ |
||
| 176 | public $mRedirectCode = ''; |
||
| 177 | |||
| 178 | protected $mFeedLinksAppendQuery = null; |
||
| 179 | |||
| 180 | /** @var array |
||
| 181 | * What level of 'untrustworthiness' is allowed in CSS/JS modules loaded on this page? |
||
| 182 | * @see ResourceLoaderModule::$origin |
||
| 183 | * ResourceLoaderModule::ORIGIN_ALL is assumed unless overridden; |
||
| 184 | */ |
||
| 185 | protected $mAllowedModules = [ |
||
| 186 | ResourceLoaderModule::TYPE_COMBINED => ResourceLoaderModule::ORIGIN_ALL, |
||
| 187 | ]; |
||
| 188 | |||
| 189 | /** @var bool Whether output is disabled. If this is true, the 'output' method will do nothing. */ |
||
| 190 | protected $mDoNothing = false; |
||
| 191 | |||
| 192 | // Parser related. |
||
| 193 | |||
| 194 | /** @var int */ |
||
| 195 | protected $mContainsNewMagic = 0; |
||
| 196 | |||
| 197 | /** |
||
| 198 | * lazy initialised, use parserOptions() |
||
| 199 | * @var ParserOptions |
||
| 200 | */ |
||
| 201 | protected $mParserOptions = null; |
||
| 202 | |||
| 203 | /** |
||
| 204 | * Handles the Atom / RSS links. |
||
| 205 | * We probably only support Atom in 2011. |
||
| 206 | * @see $wgAdvertisedFeedTypes |
||
| 207 | */ |
||
| 208 | private $mFeedLinks = []; |
||
| 209 | |||
| 210 | // Gwicke work on squid caching? Roughly from 2003. |
||
| 211 | protected $mEnableClientCache = true; |
||
| 212 | |||
| 213 | /** @var bool Flag if output should only contain the body of the article. */ |
||
| 214 | private $mArticleBodyOnly = false; |
||
| 215 | |||
| 216 | /** @var bool */ |
||
| 217 | protected $mNewSectionLink = false; |
||
| 218 | |||
| 219 | /** @var bool */ |
||
| 220 | protected $mHideNewSectionLink = false; |
||
| 221 | |||
| 222 | /** |
||
| 223 | * @var bool Comes from the parser. This was probably made to load CSS/JS |
||
| 224 | * only if we had "<gallery>". Used directly in CategoryPage.php. |
||
| 225 | * Looks like ResourceLoader can replace this. |
||
| 226 | */ |
||
| 227 | public $mNoGallery = false; |
||
| 228 | |||
| 229 | /** @var string */ |
||
| 230 | private $mPageTitleActionText = ''; |
||
| 231 | |||
| 232 | /** @var int Cache stuff. Looks like mEnableClientCache */ |
||
| 233 | protected $mCdnMaxage = 0; |
||
| 234 | /** @var int Upper limit on mCdnMaxage */ |
||
| 235 | protected $mCdnMaxageLimit = INF; |
||
| 236 | |||
| 237 | /** |
||
| 238 | * @var bool Controls if anti-clickjacking / frame-breaking headers will |
||
| 239 | * be sent. This should be done for pages where edit actions are possible. |
||
| 240 | * Setters: $this->preventClickjacking() and $this->allowClickjacking(). |
||
| 241 | */ |
||
| 242 | protected $mPreventClickjacking = true; |
||
| 243 | |||
| 244 | /** @var int To include the variable {{REVISIONID}} */ |
||
| 245 | private $mRevisionId = null; |
||
| 246 | |||
| 247 | /** @var string */ |
||
| 248 | private $mRevisionTimestamp = null; |
||
| 249 | |||
| 250 | /** @var array */ |
||
| 251 | protected $mFileVersion = null; |
||
| 252 | |||
| 253 | /** |
||
| 254 | * @var array An array of stylesheet filenames (relative from skins path), |
||
| 255 | * with options for CSS media, IE conditions, and RTL/LTR direction. |
||
| 256 | * For internal use; add settings in the skin via $this->addStyle() |
||
| 257 | * |
||
| 258 | * Style again! This seems like a code duplication since we already have |
||
| 259 | * mStyles. This is what makes Open Source amazing. |
||
| 260 | */ |
||
| 261 | protected $styles = []; |
||
| 262 | |||
| 263 | private $mIndexPolicy = 'index'; |
||
| 264 | private $mFollowPolicy = 'follow'; |
||
| 265 | private $mVaryHeader = [ |
||
| 266 | 'Accept-Encoding' => [ 'match=gzip' ], |
||
| 267 | ]; |
||
| 268 | |||
| 269 | /** |
||
| 270 | * If the current page was reached through a redirect, $mRedirectedFrom contains the Title |
||
| 271 | * of the redirect. |
||
| 272 | * |
||
| 273 | * @var Title |
||
| 274 | */ |
||
| 275 | private $mRedirectedFrom = null; |
||
| 276 | |||
| 277 | /** |
||
| 278 | * Additional key => value data |
||
| 279 | */ |
||
| 280 | private $mProperties = []; |
||
| 281 | |||
| 282 | /** |
||
| 283 | * @var string|null ResourceLoader target for load.php links. If null, will be omitted |
||
| 284 | */ |
||
| 285 | private $mTarget = null; |
||
| 286 | |||
| 287 | /** |
||
| 288 | * @var bool Whether parser output should contain table of contents |
||
| 289 | */ |
||
| 290 | private $mEnableTOC = true; |
||
| 291 | |||
| 292 | /** |
||
| 293 | * @var bool Whether parser output should contain section edit links |
||
| 294 | */ |
||
| 295 | private $mEnableSectionEditLinks = true; |
||
| 296 | |||
| 297 | /** |
||
| 298 | * @var string|null The URL to send in a <link> element with rel=copyright |
||
| 299 | */ |
||
| 300 | private $copyrightUrl; |
||
| 301 | |||
| 302 | /** @var array Profiling data */ |
||
| 303 | private $limitReportData = []; |
||
| 304 | |||
| 305 | /** |
||
| 306 | * Constructor for OutputPage. This should not be called directly. |
||
| 307 | * Instead a new RequestContext should be created and it will implicitly create |
||
| 308 | * a OutputPage tied to that context. |
||
| 309 | * @param IContextSource|null $context |
||
| 310 | */ |
||
| 311 | function __construct( IContextSource $context = null ) { |
||
| 319 | |||
| 320 | /** |
||
| 321 | * Redirect to $url rather than displaying the normal page |
||
| 322 | * |
||
| 323 | * @param string $url URL |
||
| 324 | * @param string $responsecode HTTP status code |
||
| 325 | */ |
||
| 326 | public function redirect( $url, $responsecode = '302' ) { |
||
| 331 | |||
| 332 | /** |
||
| 333 | * Get the URL to redirect to, or an empty string if not redirect URL set |
||
| 334 | * |
||
| 335 | * @return string |
||
| 336 | */ |
||
| 337 | public function getRedirect() { |
||
| 340 | |||
| 341 | /** |
||
| 342 | * Set the copyright URL to send with the output. |
||
| 343 | * Empty string to omit, null to reset. |
||
| 344 | * |
||
| 345 | * @since 1.26 |
||
| 346 | * |
||
| 347 | * @param string|null $url |
||
| 348 | */ |
||
| 349 | public function setCopyrightUrl( $url ) { |
||
| 352 | |||
| 353 | /** |
||
| 354 | * Set the HTTP status code to send with the output. |
||
| 355 | * |
||
| 356 | * @param int $statusCode |
||
| 357 | */ |
||
| 358 | public function setStatusCode( $statusCode ) { |
||
| 361 | |||
| 362 | /** |
||
| 363 | * Add a new "<meta>" tag |
||
| 364 | * To add an http-equiv meta tag, precede the name with "http:" |
||
| 365 | * |
||
| 366 | * @param string $name Tag name |
||
| 367 | * @param string $val Tag value |
||
| 368 | */ |
||
| 369 | function addMeta( $name, $val ) { |
||
| 372 | |||
| 373 | /** |
||
| 374 | * Returns the current <meta> tags |
||
| 375 | * |
||
| 376 | * @since 1.25 |
||
| 377 | * @return array |
||
| 378 | */ |
||
| 379 | public function getMetaTags() { |
||
| 382 | |||
| 383 | /** |
||
| 384 | * Add a new \<link\> tag to the page header. |
||
| 385 | * |
||
| 386 | * Note: use setCanonicalUrl() for rel=canonical. |
||
| 387 | * |
||
| 388 | * @param array $linkarr Associative array of attributes. |
||
| 389 | */ |
||
| 390 | function addLink( array $linkarr ) { |
||
| 393 | |||
| 394 | /** |
||
| 395 | * Returns the current <link> tags |
||
| 396 | * |
||
| 397 | * @since 1.25 |
||
| 398 | * @return array |
||
| 399 | */ |
||
| 400 | public function getLinkTags() { |
||
| 403 | |||
| 404 | /** |
||
| 405 | * Add a new \<link\> with "rel" attribute set to "meta" |
||
| 406 | * |
||
| 407 | * @param array $linkarr Associative array mapping attribute names to their |
||
| 408 | * values, both keys and values will be escaped, and the |
||
| 409 | * "rel" attribute will be automatically added |
||
| 410 | */ |
||
| 411 | function addMetadataLink( array $linkarr ) { |
||
| 415 | |||
| 416 | /** |
||
| 417 | * Set the URL to be used for the <link rel=canonical>. This should be used |
||
| 418 | * in preference to addLink(), to avoid duplicate link tags. |
||
| 419 | * @param string $url |
||
| 420 | */ |
||
| 421 | function setCanonicalUrl( $url ) { |
||
| 424 | |||
| 425 | /** |
||
| 426 | * Returns the URL to be used for the <link rel=canonical> if |
||
| 427 | * one is set. |
||
| 428 | * |
||
| 429 | * @since 1.25 |
||
| 430 | * @return bool|string |
||
| 431 | */ |
||
| 432 | public function getCanonicalUrl() { |
||
| 435 | |||
| 436 | /** |
||
| 437 | * Get the value of the "rel" attribute for metadata links |
||
| 438 | * |
||
| 439 | * @return string |
||
| 440 | */ |
||
| 441 | public function getMetadataAttribute() { |
||
| 451 | |||
| 452 | /** |
||
| 453 | * Add raw HTML to the list of scripts (including \<script\> tag, etc.) |
||
| 454 | * Internal use only. Use OutputPage::addModules() or OutputPage::addJsConfigVars() |
||
| 455 | * if possible. |
||
| 456 | * |
||
| 457 | * @param string $script Raw HTML |
||
| 458 | */ |
||
| 459 | function addScript( $script ) { |
||
| 462 | |||
| 463 | /** |
||
| 464 | * Register and add a stylesheet from an extension directory. |
||
| 465 | * |
||
| 466 | * @deprecated since 1.27 use addModuleStyles() or addStyle() instead |
||
| 467 | * @param string $url Path to sheet. Provide either a full url (beginning |
||
| 468 | * with 'http', etc) or a relative path from the document root |
||
| 469 | * (beginning with '/'). Otherwise it behaves identically to |
||
| 470 | * addStyle() and draws from the /skins folder. |
||
| 471 | */ |
||
| 472 | public function addExtensionStyle( $url ) { |
||
| 476 | |||
| 477 | /** |
||
| 478 | * Get all styles added by extensions |
||
| 479 | * |
||
| 480 | * @deprecated since 1.27 |
||
| 481 | * @return array |
||
| 482 | */ |
||
| 483 | function getExtStyle() { |
||
| 487 | |||
| 488 | /** |
||
| 489 | * Add a JavaScript file out of skins/common, or a given relative path. |
||
| 490 | * Internal use only. Use OutputPage::addModules() if possible. |
||
| 491 | * |
||
| 492 | * @param string $file Filename in skins/common or complete on-server path |
||
| 493 | * (/foo/bar.js) |
||
| 494 | * @param string $version Style version of the file. Defaults to $wgStyleVersion |
||
| 495 | */ |
||
| 496 | public function addScriptFile( $file, $version = null ) { |
||
| 508 | |||
| 509 | /** |
||
| 510 | * Add a self-contained script tag with the given contents |
||
| 511 | * Internal use only. Use OutputPage::addModules() if possible. |
||
| 512 | * |
||
| 513 | * @param string $script JavaScript text, no script tags |
||
| 514 | */ |
||
| 515 | public function addInlineScript( $script ) { |
||
| 518 | |||
| 519 | /** |
||
| 520 | * Filter an array of modules to remove insufficiently trustworthy members, and modules |
||
| 521 | * which are no longer registered (eg a page is cached before an extension is disabled) |
||
| 522 | * @param array $modules |
||
| 523 | * @param string|null $position If not null, only return modules with this position |
||
| 524 | * @param string $type |
||
| 525 | * @return array |
||
| 526 | */ |
||
| 527 | protected function filterModules( array $modules, $position = null, |
||
| 544 | |||
| 545 | /** |
||
| 546 | * Get the list of modules to include on this page |
||
| 547 | * |
||
| 548 | * @param bool $filter Whether to filter out insufficiently trustworthy modules |
||
| 549 | * @param string|null $position If not null, only return modules with this position |
||
| 550 | * @param string $param |
||
| 551 | * @return array Array of module names |
||
| 552 | */ |
||
| 553 | public function getModules( $filter = false, $position = null, $param = 'mModules', |
||
| 561 | |||
| 562 | /** |
||
| 563 | * Add one or more modules recognized by ResourceLoader. Modules added |
||
| 564 | * through this function will be loaded by ResourceLoader when the |
||
| 565 | * page loads. |
||
| 566 | * |
||
| 567 | * @param string|array $modules Module name (string) or array of module names |
||
| 568 | */ |
||
| 569 | public function addModules( $modules ) { |
||
| 572 | |||
| 573 | /** |
||
| 574 | * Get the list of module JS to include on this page |
||
| 575 | * |
||
| 576 | * @param bool $filter |
||
| 577 | * @param string|null $position |
||
| 578 | * @return array Array of module names |
||
| 579 | */ |
||
| 580 | public function getModuleScripts( $filter = false, $position = null ) { |
||
| 585 | |||
| 586 | /** |
||
| 587 | * Add only JS of one or more modules recognized by ResourceLoader. Module |
||
| 588 | * scripts added through this function will be loaded by ResourceLoader when |
||
| 589 | * the page loads. |
||
| 590 | * |
||
| 591 | * @param string|array $modules Module name (string) or array of module names |
||
| 592 | */ |
||
| 593 | public function addModuleScripts( $modules ) { |
||
| 596 | |||
| 597 | /** |
||
| 598 | * Get the list of module CSS to include on this page |
||
| 599 | * |
||
| 600 | * @param bool $filter |
||
| 601 | * @param string|null $position |
||
| 602 | * @return array Array of module names |
||
| 603 | */ |
||
| 604 | public function getModuleStyles( $filter = false, $position = null ) { |
||
| 609 | |||
| 610 | /** |
||
| 611 | * Add only CSS of one or more modules recognized by ResourceLoader. |
||
| 612 | * |
||
| 613 | * Module styles added through this function will be added using standard link CSS |
||
| 614 | * tags, rather than as a combined Javascript and CSS package. Thus, they will |
||
| 615 | * load when JavaScript is disabled (unless CSS also happens to be disabled). |
||
| 616 | * |
||
| 617 | * @param string|array $modules Module name (string) or array of module names |
||
| 618 | */ |
||
| 619 | public function addModuleStyles( $modules ) { |
||
| 622 | |||
| 623 | /** |
||
| 624 | * @return null|string ResourceLoader target |
||
| 625 | */ |
||
| 626 | public function getTarget() { |
||
| 629 | |||
| 630 | /** |
||
| 631 | * Sets ResourceLoader target for load.php links. If null, will be omitted |
||
| 632 | * |
||
| 633 | * @param string|null $target |
||
| 634 | */ |
||
| 635 | public function setTarget( $target ) { |
||
| 638 | |||
| 639 | /** |
||
| 640 | * Get an array of head items |
||
| 641 | * |
||
| 642 | * @return array |
||
| 643 | */ |
||
| 644 | function getHeadItemsArray() { |
||
| 647 | |||
| 648 | /** |
||
| 649 | * Add or replace a head item to the output |
||
| 650 | * |
||
| 651 | * Whenever possible, use more specific options like ResourceLoader modules, |
||
| 652 | * OutputPage::addLink(), OutputPage::addMetaLink() and OutputPage::addFeedLink() |
||
| 653 | * Fallback options for those are: OutputPage::addStyle, OutputPage::addScript(), |
||
| 654 | * OutputPage::addInlineScript() and OutputPage::addInlineStyle() |
||
| 655 | * This would be your very LAST fallback. |
||
| 656 | * |
||
| 657 | * @param string $name Item name |
||
| 658 | * @param string $value Raw HTML |
||
| 659 | */ |
||
| 660 | public function addHeadItem( $name, $value ) { |
||
| 663 | |||
| 664 | /** |
||
| 665 | * Add one or more head items to the output |
||
| 666 | * |
||
| 667 | * @since 1.28 |
||
| 668 | * @param string|string[] $value Raw HTML |
||
| 669 | */ |
||
| 670 | public function addHeadItems( $values ) { |
||
| 673 | |||
| 674 | /** |
||
| 675 | * Check if the header item $name is already set |
||
| 676 | * |
||
| 677 | * @param string $name Item name |
||
| 678 | * @return bool |
||
| 679 | */ |
||
| 680 | public function hasHeadItem( $name ) { |
||
| 683 | |||
| 684 | /** |
||
| 685 | * @deprecated since 1.28 Obsolete - wgUseETag experiment was removed. |
||
| 686 | * @param string $tag |
||
| 687 | */ |
||
| 688 | public function setETag( $tag ) { |
||
| 690 | |||
| 691 | /** |
||
| 692 | * Set whether the output should only contain the body of the article, |
||
| 693 | * without any skin, sidebar, etc. |
||
| 694 | * Used e.g. when calling with "action=render". |
||
| 695 | * |
||
| 696 | * @param bool $only Whether to output only the body of the article |
||
| 697 | */ |
||
| 698 | public function setArticleBodyOnly( $only ) { |
||
| 701 | |||
| 702 | /** |
||
| 703 | * Return whether the output will contain only the body of the article |
||
| 704 | * |
||
| 705 | * @return bool |
||
| 706 | */ |
||
| 707 | public function getArticleBodyOnly() { |
||
| 710 | |||
| 711 | /** |
||
| 712 | * Set an additional output property |
||
| 713 | * @since 1.21 |
||
| 714 | * |
||
| 715 | * @param string $name |
||
| 716 | * @param mixed $value |
||
| 717 | */ |
||
| 718 | public function setProperty( $name, $value ) { |
||
| 721 | |||
| 722 | /** |
||
| 723 | * Get an additional output property |
||
| 724 | * @since 1.21 |
||
| 725 | * |
||
| 726 | * @param string $name |
||
| 727 | * @return mixed Property value or null if not found |
||
| 728 | */ |
||
| 729 | public function getProperty( $name ) { |
||
| 736 | |||
| 737 | /** |
||
| 738 | * checkLastModified tells the client to use the client-cached page if |
||
| 739 | * possible. If successful, the OutputPage is disabled so that |
||
| 740 | * any future call to OutputPage->output() have no effect. |
||
| 741 | * |
||
| 742 | * Side effect: sets mLastModified for Last-Modified header |
||
| 743 | * |
||
| 744 | * @param string $timestamp |
||
| 745 | * |
||
| 746 | * @return bool True if cache-ok headers was sent. |
||
| 747 | */ |
||
| 748 | public function checkLastModified( $timestamp ) { |
||
| 828 | |||
| 829 | /** |
||
| 830 | * Override the last modified timestamp |
||
| 831 | * |
||
| 832 | * @param string $timestamp New timestamp, in a format readable by |
||
| 833 | * wfTimestamp() |
||
| 834 | */ |
||
| 835 | public function setLastModified( $timestamp ) { |
||
| 838 | |||
| 839 | /** |
||
| 840 | * Set the robot policy for the page: <http://www.robotstxt.org/meta.html> |
||
| 841 | * |
||
| 842 | * @param string $policy The literal string to output as the contents of |
||
| 843 | * the meta tag. Will be parsed according to the spec and output in |
||
| 844 | * standardized form. |
||
| 845 | * @return null |
||
| 846 | */ |
||
| 847 | public function setRobotPolicy( $policy ) { |
||
| 857 | |||
| 858 | /** |
||
| 859 | * Set the index policy for the page, but leave the follow policy un- |
||
| 860 | * touched. |
||
| 861 | * |
||
| 862 | * @param string $policy Either 'index' or 'noindex'. |
||
| 863 | * @return null |
||
| 864 | */ |
||
| 865 | public function setIndexPolicy( $policy ) { |
||
| 871 | |||
| 872 | /** |
||
| 873 | * Set the follow policy for the page, but leave the index policy un- |
||
| 874 | * touched. |
||
| 875 | * |
||
| 876 | * @param string $policy Either 'follow' or 'nofollow'. |
||
| 877 | * @return null |
||
| 878 | */ |
||
| 879 | public function setFollowPolicy( $policy ) { |
||
| 885 | |||
| 886 | /** |
||
| 887 | * Set the new value of the "action text", this will be added to the |
||
| 888 | * "HTML title", separated from it with " - ". |
||
| 889 | * |
||
| 890 | * @param string $text New value of the "action text" |
||
| 891 | */ |
||
| 892 | public function setPageTitleActionText( $text ) { |
||
| 895 | |||
| 896 | /** |
||
| 897 | * Get the value of the "action text" |
||
| 898 | * |
||
| 899 | * @return string |
||
| 900 | */ |
||
| 901 | public function getPageTitleActionText() { |
||
| 904 | |||
| 905 | /** |
||
| 906 | * "HTML title" means the contents of "<title>". |
||
| 907 | * It is stored as plain, unescaped text and will be run through htmlspecialchars in the skin file. |
||
| 908 | * |
||
| 909 | * @param string|Message $name |
||
| 910 | */ |
||
| 911 | public function setHTMLTitle( $name ) { |
||
| 918 | |||
| 919 | /** |
||
| 920 | * Return the "HTML title", i.e. the content of the "<title>" tag. |
||
| 921 | * |
||
| 922 | * @return string |
||
| 923 | */ |
||
| 924 | public function getHTMLTitle() { |
||
| 927 | |||
| 928 | /** |
||
| 929 | * Set $mRedirectedFrom, the Title of the page which redirected us to the current page. |
||
| 930 | * |
||
| 931 | * @param Title $t |
||
| 932 | */ |
||
| 933 | public function setRedirectedFrom( $t ) { |
||
| 936 | |||
| 937 | /** |
||
| 938 | * "Page title" means the contents of \<h1\>. It is stored as a valid HTML |
||
| 939 | * fragment. This function allows good tags like \<sup\> in the \<h1\> tag, |
||
| 940 | * but not bad tags like \<script\>. This function automatically sets |
||
| 941 | * \<title\> to the same content as \<h1\> but with all tags removed. Bad |
||
| 942 | * tags that were escaped in \<h1\> will still be escaped in \<title\>, and |
||
| 943 | * good tags like \<i\> will be dropped entirely. |
||
| 944 | * |
||
| 945 | * @param string|Message $name |
||
| 946 | */ |
||
| 947 | public function setPageTitle( $name ) { |
||
| 963 | |||
| 964 | /** |
||
| 965 | * Return the "page title", i.e. the content of the \<h1\> tag. |
||
| 966 | * |
||
| 967 | * @return string |
||
| 968 | */ |
||
| 969 | public function getPageTitle() { |
||
| 972 | |||
| 973 | /** |
||
| 974 | * Set the Title object to use |
||
| 975 | * |
||
| 976 | * @param Title $t |
||
| 977 | */ |
||
| 978 | public function setTitle( Title $t ) { |
||
| 981 | |||
| 982 | /** |
||
| 983 | * Replace the subtitle with $str |
||
| 984 | * |
||
| 985 | * @param string|Message $str New value of the subtitle. String should be safe HTML. |
||
| 986 | */ |
||
| 987 | public function setSubtitle( $str ) { |
||
| 991 | |||
| 992 | /** |
||
| 993 | * Add $str to the subtitle |
||
| 994 | * |
||
| 995 | * @param string|Message $str String or Message to add to the subtitle. String should be safe HTML. |
||
| 996 | */ |
||
| 997 | public function addSubtitle( $str ) { |
||
| 1004 | |||
| 1005 | /** |
||
| 1006 | * Build message object for a subtitle containing a backlink to a page |
||
| 1007 | * |
||
| 1008 | * @param Title $title Title to link to |
||
| 1009 | * @param array $query Array of additional parameters to include in the link |
||
| 1010 | * @return Message |
||
| 1011 | * @since 1.25 |
||
| 1012 | */ |
||
| 1013 | public static function buildBacklinkSubtitle( Title $title, $query = [] ) { |
||
| 1020 | |||
| 1021 | /** |
||
| 1022 | * Add a subtitle containing a backlink to a page |
||
| 1023 | * |
||
| 1024 | * @param Title $title Title to link to |
||
| 1025 | * @param array $query Array of additional parameters to include in the link |
||
| 1026 | */ |
||
| 1027 | public function addBacklinkSubtitle( Title $title, $query = [] ) { |
||
| 1030 | |||
| 1031 | /** |
||
| 1032 | * Clear the subtitles |
||
| 1033 | */ |
||
| 1034 | public function clearSubtitle() { |
||
| 1037 | |||
| 1038 | /** |
||
| 1039 | * Get the subtitle |
||
| 1040 | * |
||
| 1041 | * @return string |
||
| 1042 | */ |
||
| 1043 | public function getSubtitle() { |
||
| 1046 | |||
| 1047 | /** |
||
| 1048 | * Set the page as printable, i.e. it'll be displayed with all |
||
| 1049 | * print styles included |
||
| 1050 | */ |
||
| 1051 | public function setPrintable() { |
||
| 1054 | |||
| 1055 | /** |
||
| 1056 | * Return whether the page is "printable" |
||
| 1057 | * |
||
| 1058 | * @return bool |
||
| 1059 | */ |
||
| 1060 | public function isPrintable() { |
||
| 1063 | |||
| 1064 | /** |
||
| 1065 | * Disable output completely, i.e. calling output() will have no effect |
||
| 1066 | */ |
||
| 1067 | public function disable() { |
||
| 1070 | |||
| 1071 | /** |
||
| 1072 | * Return whether the output will be completely disabled |
||
| 1073 | * |
||
| 1074 | * @return bool |
||
| 1075 | */ |
||
| 1076 | public function isDisabled() { |
||
| 1079 | |||
| 1080 | /** |
||
| 1081 | * Show an "add new section" link? |
||
| 1082 | * |
||
| 1083 | * @return bool |
||
| 1084 | */ |
||
| 1085 | public function showNewSectionLink() { |
||
| 1088 | |||
| 1089 | /** |
||
| 1090 | * Forcibly hide the new section link? |
||
| 1091 | * |
||
| 1092 | * @return bool |
||
| 1093 | */ |
||
| 1094 | public function forceHideNewSectionLink() { |
||
| 1097 | |||
| 1098 | /** |
||
| 1099 | * Add or remove feed links in the page header |
||
| 1100 | * This is mainly kept for backward compatibility, see OutputPage::addFeedLink() |
||
| 1101 | * for the new version |
||
| 1102 | * @see addFeedLink() |
||
| 1103 | * |
||
| 1104 | * @param bool $show True: add default feeds, false: remove all feeds |
||
| 1105 | */ |
||
| 1106 | public function setSyndicated( $show = true ) { |
||
| 1113 | |||
| 1114 | /** |
||
| 1115 | * Add default feeds to the page header |
||
| 1116 | * This is mainly kept for backward compatibility, see OutputPage::addFeedLink() |
||
| 1117 | * for the new version |
||
| 1118 | * @see addFeedLink() |
||
| 1119 | * |
||
| 1120 | * @param string $val Query to append to feed links or false to output |
||
| 1121 | * default links |
||
| 1122 | */ |
||
| 1123 | public function setFeedAppendQuery( $val ) { |
||
| 1134 | |||
| 1135 | /** |
||
| 1136 | * Add a feed link to the page header |
||
| 1137 | * |
||
| 1138 | * @param string $format Feed type, should be a key of $wgFeedClasses |
||
| 1139 | * @param string $href URL |
||
| 1140 | */ |
||
| 1141 | public function addFeedLink( $format, $href ) { |
||
| 1146 | |||
| 1147 | /** |
||
| 1148 | * Should we output feed links for this page? |
||
| 1149 | * @return bool |
||
| 1150 | */ |
||
| 1151 | public function isSyndicated() { |
||
| 1154 | |||
| 1155 | /** |
||
| 1156 | * Return URLs for each supported syndication format for this page. |
||
| 1157 | * @return array Associating format keys with URLs |
||
| 1158 | */ |
||
| 1159 | public function getSyndicationLinks() { |
||
| 1162 | |||
| 1163 | /** |
||
| 1164 | * Will currently always return null |
||
| 1165 | * |
||
| 1166 | * @return null |
||
| 1167 | */ |
||
| 1168 | public function getFeedAppendQuery() { |
||
| 1171 | |||
| 1172 | /** |
||
| 1173 | * Set whether the displayed content is related to the source of the |
||
| 1174 | * corresponding article on the wiki |
||
| 1175 | * Setting true will cause the change "article related" toggle to true |
||
| 1176 | * |
||
| 1177 | * @param bool $v |
||
| 1178 | */ |
||
| 1179 | public function setArticleFlag( $v ) { |
||
| 1185 | |||
| 1186 | /** |
||
| 1187 | * Return whether the content displayed page is related to the source of |
||
| 1188 | * the corresponding article on the wiki |
||
| 1189 | * |
||
| 1190 | * @return bool |
||
| 1191 | */ |
||
| 1192 | public function isArticle() { |
||
| 1195 | |||
| 1196 | /** |
||
| 1197 | * Set whether this page is related an article on the wiki |
||
| 1198 | * Setting false will cause the change of "article flag" toggle to false |
||
| 1199 | * |
||
| 1200 | * @param bool $v |
||
| 1201 | */ |
||
| 1202 | public function setArticleRelated( $v ) { |
||
| 1208 | |||
| 1209 | /** |
||
| 1210 | * Return whether this page is related an article on the wiki |
||
| 1211 | * |
||
| 1212 | * @return bool |
||
| 1213 | */ |
||
| 1214 | public function isArticleRelated() { |
||
| 1217 | |||
| 1218 | /** |
||
| 1219 | * Add new language links |
||
| 1220 | * |
||
| 1221 | * @param array $newLinkArray Associative array mapping language code to the page |
||
| 1222 | * name |
||
| 1223 | */ |
||
| 1224 | public function addLanguageLinks( array $newLinkArray ) { |
||
| 1227 | |||
| 1228 | /** |
||
| 1229 | * Reset the language links and add new language links |
||
| 1230 | * |
||
| 1231 | * @param array $newLinkArray Associative array mapping language code to the page |
||
| 1232 | * name |
||
| 1233 | */ |
||
| 1234 | public function setLanguageLinks( array $newLinkArray ) { |
||
| 1237 | |||
| 1238 | /** |
||
| 1239 | * Get the list of language links |
||
| 1240 | * |
||
| 1241 | * @return array Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page') |
||
| 1242 | */ |
||
| 1243 | public function getLanguageLinks() { |
||
| 1246 | |||
| 1247 | /** |
||
| 1248 | * Add an array of categories, with names in the keys |
||
| 1249 | * |
||
| 1250 | * @param array $categories Mapping category name => sort key |
||
| 1251 | */ |
||
| 1252 | public function addCategoryLinks( array $categories ) { |
||
| 1318 | |||
| 1319 | /** |
||
| 1320 | * Reset the category links (but not the category list) and add $categories |
||
| 1321 | * |
||
| 1322 | * @param array $categories Mapping category name => sort key |
||
| 1323 | */ |
||
| 1324 | public function setCategoryLinks( array $categories ) { |
||
| 1328 | |||
| 1329 | /** |
||
| 1330 | * Get the list of category links, in a 2-D array with the following format: |
||
| 1331 | * $arr[$type][] = $link, where $type is either "normal" or "hidden" (for |
||
| 1332 | * hidden categories) and $link a HTML fragment with a link to the category |
||
| 1333 | * page |
||
| 1334 | * |
||
| 1335 | * @return array |
||
| 1336 | */ |
||
| 1337 | public function getCategoryLinks() { |
||
| 1340 | |||
| 1341 | /** |
||
| 1342 | * Get the list of category names this page belongs to |
||
| 1343 | * |
||
| 1344 | * @return array Array of strings |
||
| 1345 | */ |
||
| 1346 | public function getCategories() { |
||
| 1349 | |||
| 1350 | /** |
||
| 1351 | * Add an array of indicators, with their identifiers as array |
||
| 1352 | * keys and HTML contents as values. |
||
| 1353 | * |
||
| 1354 | * In case of duplicate keys, existing values are overwritten. |
||
| 1355 | * |
||
| 1356 | * @param array $indicators |
||
| 1357 | * @since 1.25 |
||
| 1358 | */ |
||
| 1359 | public function setIndicators( array $indicators ) { |
||
| 1364 | |||
| 1365 | /** |
||
| 1366 | * Get the indicators associated with this page. |
||
| 1367 | * |
||
| 1368 | * The array will be internally ordered by item keys. |
||
| 1369 | * |
||
| 1370 | * @return array Keys: identifiers, values: HTML contents |
||
| 1371 | * @since 1.25 |
||
| 1372 | */ |
||
| 1373 | public function getIndicators() { |
||
| 1376 | |||
| 1377 | /** |
||
| 1378 | * Adds help link with an icon via page indicators. |
||
| 1379 | * Link target can be overridden by a local message containing a wikilink: |
||
| 1380 | * the message key is: lowercase action or special page name + '-helppage'. |
||
| 1381 | * @param string $to Target MediaWiki.org page title or encoded URL. |
||
| 1382 | * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o. |
||
| 1383 | * @since 1.25 |
||
| 1384 | */ |
||
| 1385 | public function addHelpLink( $to, $overrideBaseUrl = false ) { |
||
| 1408 | |||
| 1409 | /** |
||
| 1410 | * Do not allow scripts which can be modified by wiki users to load on this page; |
||
| 1411 | * only allow scripts bundled with, or generated by, the software. |
||
| 1412 | * Site-wide styles are controlled by a config setting, since they can be |
||
| 1413 | * used to create a custom skin/theme, but not user-specific ones. |
||
| 1414 | * |
||
| 1415 | * @todo this should be given a more accurate name |
||
| 1416 | */ |
||
| 1417 | public function disallowUserJs() { |
||
| 1435 | |||
| 1436 | /** |
||
| 1437 | * Show what level of JavaScript / CSS untrustworthiness is allowed on this page |
||
| 1438 | * @see ResourceLoaderModule::$origin |
||
| 1439 | * @param string $type ResourceLoaderModule TYPE_ constant |
||
| 1440 | * @return int ResourceLoaderModule ORIGIN_ class constant |
||
| 1441 | */ |
||
| 1442 | public function getAllowedModules( $type ) { |
||
| 1451 | |||
| 1452 | /** |
||
| 1453 | * Limit the highest level of CSS/JS untrustworthiness allowed. |
||
| 1454 | * |
||
| 1455 | * If passed the same or a higher level than the current level of untrustworthiness set, the |
||
| 1456 | * level will remain unchanged. |
||
| 1457 | * |
||
| 1458 | * @param string $type |
||
| 1459 | * @param int $level ResourceLoaderModule class constant |
||
| 1460 | */ |
||
| 1461 | public function reduceAllowedModules( $type, $level ) { |
||
| 1464 | |||
| 1465 | /** |
||
| 1466 | * Prepend $text to the body HTML |
||
| 1467 | * |
||
| 1468 | * @param string $text HTML |
||
| 1469 | */ |
||
| 1470 | public function prependHTML( $text ) { |
||
| 1473 | |||
| 1474 | /** |
||
| 1475 | * Append $text to the body HTML |
||
| 1476 | * |
||
| 1477 | * @param string $text HTML |
||
| 1478 | */ |
||
| 1479 | public function addHTML( $text ) { |
||
| 1482 | |||
| 1483 | /** |
||
| 1484 | * Shortcut for adding an Html::element via addHTML. |
||
| 1485 | * |
||
| 1486 | * @since 1.19 |
||
| 1487 | * |
||
| 1488 | * @param string $element |
||
| 1489 | * @param array $attribs |
||
| 1490 | * @param string $contents |
||
| 1491 | */ |
||
| 1492 | public function addElement( $element, array $attribs = [], $contents = '' ) { |
||
| 1495 | |||
| 1496 | /** |
||
| 1497 | * Clear the body HTML |
||
| 1498 | */ |
||
| 1499 | public function clearHTML() { |
||
| 1502 | |||
| 1503 | /** |
||
| 1504 | * Get the body HTML |
||
| 1505 | * |
||
| 1506 | * @return string HTML |
||
| 1507 | */ |
||
| 1508 | public function getHTML() { |
||
| 1511 | |||
| 1512 | /** |
||
| 1513 | * Get/set the ParserOptions object to use for wikitext parsing |
||
| 1514 | * |
||
| 1515 | * @param ParserOptions|null $options Either the ParserOption to use or null to only get the |
||
| 1516 | * current ParserOption object |
||
| 1517 | * @return ParserOptions |
||
| 1518 | */ |
||
| 1519 | public function parserOptions( $options = null ) { |
||
| 1557 | |||
| 1558 | /** |
||
| 1559 | * Set the revision ID which will be seen by the wiki text parser |
||
| 1560 | * for things such as embedded {{REVISIONID}} variable use. |
||
| 1561 | * |
||
| 1562 | * @param int|null $revid An positive integer, or null |
||
| 1563 | * @return mixed Previous value |
||
| 1564 | */ |
||
| 1565 | public function setRevisionId( $revid ) { |
||
| 1569 | |||
| 1570 | /** |
||
| 1571 | * Get the displayed revision ID |
||
| 1572 | * |
||
| 1573 | * @return int |
||
| 1574 | */ |
||
| 1575 | public function getRevisionId() { |
||
| 1578 | |||
| 1579 | /** |
||
| 1580 | * Set the timestamp of the revision which will be displayed. This is used |
||
| 1581 | * to avoid a extra DB call in Skin::lastModified(). |
||
| 1582 | * |
||
| 1583 | * @param string|null $timestamp |
||
| 1584 | * @return mixed Previous value |
||
| 1585 | */ |
||
| 1586 | public function setRevisionTimestamp( $timestamp ) { |
||
| 1589 | |||
| 1590 | /** |
||
| 1591 | * Get the timestamp of displayed revision. |
||
| 1592 | * This will be null if not filled by setRevisionTimestamp(). |
||
| 1593 | * |
||
| 1594 | * @return string|null |
||
| 1595 | */ |
||
| 1596 | public function getRevisionTimestamp() { |
||
| 1599 | |||
| 1600 | /** |
||
| 1601 | * Set the displayed file version |
||
| 1602 | * |
||
| 1603 | * @param File|bool $file |
||
| 1604 | * @return mixed Previous value |
||
| 1605 | */ |
||
| 1606 | public function setFileVersion( $file ) { |
||
| 1613 | |||
| 1614 | /** |
||
| 1615 | * Get the displayed file version |
||
| 1616 | * |
||
| 1617 | * @return array|null ('time' => MW timestamp, 'sha1' => sha1) |
||
| 1618 | */ |
||
| 1619 | public function getFileVersion() { |
||
| 1622 | |||
| 1623 | /** |
||
| 1624 | * Get the templates used on this page |
||
| 1625 | * |
||
| 1626 | * @return array (namespace => dbKey => revId) |
||
| 1627 | * @since 1.18 |
||
| 1628 | */ |
||
| 1629 | public function getTemplateIds() { |
||
| 1632 | |||
| 1633 | /** |
||
| 1634 | * Get the files used on this page |
||
| 1635 | * |
||
| 1636 | * @return array (dbKey => array('time' => MW timestamp or null, 'sha1' => sha1 or '')) |
||
| 1637 | * @since 1.18 |
||
| 1638 | */ |
||
| 1639 | public function getFileSearchOptions() { |
||
| 1642 | |||
| 1643 | /** |
||
| 1644 | * Convert wikitext to HTML and add it to the buffer |
||
| 1645 | * Default assumes that the current page title will be used. |
||
| 1646 | * |
||
| 1647 | * @param string $text |
||
| 1648 | * @param bool $linestart Is this the start of a line? |
||
| 1649 | * @param bool $interface Is this text in the user interface language? |
||
| 1650 | * @throws MWException |
||
| 1651 | */ |
||
| 1652 | public function addWikiText( $text, $linestart = true, $interface = true ) { |
||
| 1659 | |||
| 1660 | /** |
||
| 1661 | * Add wikitext with a custom Title object |
||
| 1662 | * |
||
| 1663 | * @param string $text Wikitext |
||
| 1664 | * @param Title $title |
||
| 1665 | * @param bool $linestart Is this the start of a line? |
||
| 1666 | */ |
||
| 1667 | public function addWikiTextWithTitle( $text, &$title, $linestart = true ) { |
||
| 1670 | |||
| 1671 | /** |
||
| 1672 | * Add wikitext with a custom Title object and tidy enabled. |
||
| 1673 | * |
||
| 1674 | * @param string $text Wikitext |
||
| 1675 | * @param Title $title |
||
| 1676 | * @param bool $linestart Is this the start of a line? |
||
| 1677 | */ |
||
| 1678 | function addWikiTextTitleTidy( $text, &$title, $linestart = true ) { |
||
| 1681 | |||
| 1682 | /** |
||
| 1683 | * Add wikitext with tidy enabled |
||
| 1684 | * |
||
| 1685 | * @param string $text Wikitext |
||
| 1686 | * @param bool $linestart Is this the start of a line? |
||
| 1687 | */ |
||
| 1688 | public function addWikiTextTidy( $text, $linestart = true ) { |
||
| 1692 | |||
| 1693 | /** |
||
| 1694 | * Add wikitext with a custom Title object |
||
| 1695 | * |
||
| 1696 | * @param string $text Wikitext |
||
| 1697 | * @param Title $title |
||
| 1698 | * @param bool $linestart Is this the start of a line? |
||
| 1699 | * @param bool $tidy Whether to use tidy |
||
| 1700 | * @param bool $interface Whether it is an interface message |
||
| 1701 | * (for example disables conversion) |
||
| 1702 | */ |
||
| 1703 | public function addWikiTextTitle( $text, Title $title, $linestart, |
||
| 1722 | |||
| 1723 | /** |
||
| 1724 | * Add a ParserOutput object, but without Html. |
||
| 1725 | * |
||
| 1726 | * @deprecated since 1.24, use addParserOutputMetadata() instead. |
||
| 1727 | * @param ParserOutput $parserOutput |
||
| 1728 | */ |
||
| 1729 | public function addParserOutputNoText( $parserOutput ) { |
||
| 1733 | |||
| 1734 | /** |
||
| 1735 | * Add all metadata associated with a ParserOutput object, but without the actual HTML. This |
||
| 1736 | * includes categories, language links, ResourceLoader modules, effects of certain magic words, |
||
| 1737 | * and so on. |
||
| 1738 | * |
||
| 1739 | * @since 1.24 |
||
| 1740 | * @param ParserOutput $parserOutput |
||
| 1741 | */ |
||
| 1742 | public function addParserOutputMetadata( $parserOutput ) { |
||
| 1797 | |||
| 1798 | /** |
||
| 1799 | * Add the HTML and enhancements for it (like ResourceLoader modules) associated with a |
||
| 1800 | * ParserOutput object, without any other metadata. |
||
| 1801 | * |
||
| 1802 | * @since 1.24 |
||
| 1803 | * @param ParserOutput $parserOutput |
||
| 1804 | */ |
||
| 1805 | public function addParserOutputContent( $parserOutput ) { |
||
| 1814 | |||
| 1815 | /** |
||
| 1816 | * Add the HTML associated with a ParserOutput object, without any metadata. |
||
| 1817 | * |
||
| 1818 | * @since 1.24 |
||
| 1819 | * @param ParserOutput $parserOutput |
||
| 1820 | */ |
||
| 1821 | public function addParserOutputText( $parserOutput ) { |
||
| 1826 | |||
| 1827 | /** |
||
| 1828 | * Add everything from a ParserOutput object. |
||
| 1829 | * |
||
| 1830 | * @param ParserOutput $parserOutput |
||
| 1831 | */ |
||
| 1832 | function addParserOutput( $parserOutput ) { |
||
| 1843 | |||
| 1844 | /** |
||
| 1845 | * Add the output of a QuickTemplate to the output buffer |
||
| 1846 | * |
||
| 1847 | * @param QuickTemplate $template |
||
| 1848 | */ |
||
| 1849 | public function addTemplate( &$template ) { |
||
| 1852 | |||
| 1853 | /** |
||
| 1854 | * Parse wikitext and return the HTML. |
||
| 1855 | * |
||
| 1856 | * @param string $text |
||
| 1857 | * @param bool $linestart Is this the start of a line? |
||
| 1858 | * @param bool $interface Use interface language ($wgLang instead of |
||
| 1859 | * $wgContLang) while parsing language sensitive magic words like GRAMMAR and PLURAL. |
||
| 1860 | * This also disables LanguageConverter. |
||
| 1861 | * @param Language $language Target language object, will override $interface |
||
| 1862 | * @throws MWException |
||
| 1863 | * @return string HTML |
||
| 1864 | */ |
||
| 1865 | public function parse( $text, $linestart = true, $interface = false, $language = null ) { |
||
| 1894 | |||
| 1895 | /** |
||
| 1896 | * Parse wikitext, strip paragraphs, and return the HTML. |
||
| 1897 | * |
||
| 1898 | * @param string $text |
||
| 1899 | * @param bool $linestart Is this the start of a line? |
||
| 1900 | * @param bool $interface Use interface language ($wgLang instead of |
||
| 1901 | * $wgContLang) while parsing language sensitive magic |
||
| 1902 | * words like GRAMMAR and PLURAL |
||
| 1903 | * @return string HTML |
||
| 1904 | */ |
||
| 1905 | public function parseInline( $text, $linestart = true, $interface = false ) { |
||
| 1909 | |||
| 1910 | /** |
||
| 1911 | * @param $maxage |
||
| 1912 | * @deprecated since 1.27 Use setCdnMaxage() instead |
||
| 1913 | */ |
||
| 1914 | public function setSquidMaxage( $maxage ) { |
||
| 1917 | |||
| 1918 | /** |
||
| 1919 | * Set the value of the "s-maxage" part of the "Cache-control" HTTP header |
||
| 1920 | * |
||
| 1921 | * @param int $maxage Maximum cache time on the CDN, in seconds. |
||
| 1922 | */ |
||
| 1923 | public function setCdnMaxage( $maxage ) { |
||
| 1926 | |||
| 1927 | /** |
||
| 1928 | * Lower the value of the "s-maxage" part of the "Cache-control" HTTP header |
||
| 1929 | * |
||
| 1930 | * @param int $maxage Maximum cache time on the CDN, in seconds |
||
| 1931 | * @since 1.27 |
||
| 1932 | */ |
||
| 1933 | public function lowerCdnMaxage( $maxage ) { |
||
| 1937 | |||
| 1938 | /** |
||
| 1939 | * Use enableClientCache(false) to force it to send nocache headers |
||
| 1940 | * |
||
| 1941 | * @param bool $state |
||
| 1942 | * |
||
| 1943 | * @return bool |
||
| 1944 | */ |
||
| 1945 | public function enableClientCache( $state ) { |
||
| 1948 | |||
| 1949 | /** |
||
| 1950 | * Get the list of cookies that will influence on the cache |
||
| 1951 | * |
||
| 1952 | * @return array |
||
| 1953 | */ |
||
| 1954 | function getCacheVaryCookies() { |
||
| 1969 | |||
| 1970 | /** |
||
| 1971 | * Check if the request has a cache-varying cookie header |
||
| 1972 | * If it does, it's very important that we don't allow public caching |
||
| 1973 | * |
||
| 1974 | * @return bool |
||
| 1975 | */ |
||
| 1976 | function haveCacheVaryCookies() { |
||
| 1987 | |||
| 1988 | /** |
||
| 1989 | * Add an HTTP header that will influence on the cache |
||
| 1990 | * |
||
| 1991 | * @param string $header Header name |
||
| 1992 | * @param string[]|null $option Options for the Key header. See |
||
| 1993 | * https://datatracker.ietf.org/doc/draft-fielding-http-key/ |
||
| 1994 | * for the list of valid options. |
||
| 1995 | */ |
||
| 1996 | public function addVaryHeader( $header, array $option = null ) { |
||
| 2005 | |||
| 2006 | /** |
||
| 2007 | * Return a Vary: header on which to vary caches. Based on the keys of $mVaryHeader, |
||
| 2008 | * such as Accept-Encoding or Cookie |
||
| 2009 | * |
||
| 2010 | * @return string |
||
| 2011 | */ |
||
| 2012 | public function getVaryHeader() { |
||
| 2023 | |||
| 2024 | /** |
||
| 2025 | * Get a complete Key header |
||
| 2026 | * |
||
| 2027 | * @return string |
||
| 2028 | */ |
||
| 2029 | public function getKeyHeader() { |
||
| 2054 | |||
| 2055 | /** |
||
| 2056 | * T23672: Add Accept-Language to Vary and Key headers |
||
| 2057 | * if there's no 'variant' parameter existed in GET. |
||
| 2058 | * |
||
| 2059 | * For example: |
||
| 2060 | * /w/index.php?title=Main_page should always be served; but |
||
| 2061 | * /w/index.php?title=Main_page&variant=zh-cn should never be served. |
||
| 2062 | */ |
||
| 2063 | function addAcceptLanguage() { |
||
| 2091 | |||
| 2092 | /** |
||
| 2093 | * Set a flag which will cause an X-Frame-Options header appropriate for |
||
| 2094 | * edit pages to be sent. The header value is controlled by |
||
| 2095 | * $wgEditPageFrameOptions. |
||
| 2096 | * |
||
| 2097 | * This is the default for special pages. If you display a CSRF-protected |
||
| 2098 | * form on an ordinary view page, then you need to call this function. |
||
| 2099 | * |
||
| 2100 | * @param bool $enable |
||
| 2101 | */ |
||
| 2102 | public function preventClickjacking( $enable = true ) { |
||
| 2105 | |||
| 2106 | /** |
||
| 2107 | * Turn off frame-breaking. Alias for $this->preventClickjacking(false). |
||
| 2108 | * This can be called from pages which do not contain any CSRF-protected |
||
| 2109 | * HTML form. |
||
| 2110 | */ |
||
| 2111 | public function allowClickjacking() { |
||
| 2114 | |||
| 2115 | /** |
||
| 2116 | * Get the prevent-clickjacking flag |
||
| 2117 | * |
||
| 2118 | * @since 1.24 |
||
| 2119 | * @return bool |
||
| 2120 | */ |
||
| 2121 | public function getPreventClickjacking() { |
||
| 2124 | |||
| 2125 | /** |
||
| 2126 | * Get the X-Frame-Options header value (without the name part), or false |
||
| 2127 | * if there isn't one. This is used by Skin to determine whether to enable |
||
| 2128 | * JavaScript frame-breaking, for clients that don't support X-Frame-Options. |
||
| 2129 | * |
||
| 2130 | * @return string |
||
| 2131 | */ |
||
| 2132 | public function getFrameOptions() { |
||
| 2141 | |||
| 2142 | /** |
||
| 2143 | * Send cache control HTTP headers |
||
| 2144 | */ |
||
| 2145 | public function sendCacheControl() { |
||
| 2210 | |||
| 2211 | /** |
||
| 2212 | * Finally, all the text has been munged and accumulated into |
||
| 2213 | * the object, let's actually output it: |
||
| 2214 | */ |
||
| 2215 | public function output() { |
||
| 2326 | |||
| 2327 | /** |
||
| 2328 | * Prepare this object to display an error page; disable caching and |
||
| 2329 | * indexing, clear the current text and redirect, set the page's title |
||
| 2330 | * and optionally an custom HTML title (content of the "<title>" tag). |
||
| 2331 | * |
||
| 2332 | * @param string|Message $pageTitle Will be passed directly to setPageTitle() |
||
| 2333 | * @param string|Message $htmlTitle Will be passed directly to setHTMLTitle(); |
||
| 2334 | * optional, if not passed the "<title>" attribute will be |
||
| 2335 | * based on $pageTitle |
||
| 2336 | */ |
||
| 2337 | public function prepareErrorPage( $pageTitle, $htmlTitle = false ) { |
||
| 2349 | |||
| 2350 | /** |
||
| 2351 | * Output a standard error page |
||
| 2352 | * |
||
| 2353 | * showErrorPage( 'titlemsg', 'pagetextmsg' ); |
||
| 2354 | * showErrorPage( 'titlemsg', 'pagetextmsg', array( 'param1', 'param2' ) ); |
||
| 2355 | * showErrorPage( 'titlemsg', $messageObject ); |
||
| 2356 | * showErrorPage( $titleMessageObject, $messageObject ); |
||
| 2357 | * |
||
| 2358 | * @param string|Message $title Message key (string) for page title, or a Message object |
||
| 2359 | * @param string|Message $msg Message key (string) for page text, or a Message object |
||
| 2360 | * @param array $params Message parameters; ignored if $msg is a Message object |
||
| 2361 | */ |
||
| 2362 | public function showErrorPage( $title, $msg, $params = [] ) { |
||
| 2382 | |||
| 2383 | /** |
||
| 2384 | * Output a standard permission error page |
||
| 2385 | * |
||
| 2386 | * @param array $errors Error message keys |
||
| 2387 | * @param string $action Action that was denied or null if unknown |
||
| 2388 | */ |
||
| 2389 | public function showPermissionsErrorPage( array $errors, $action = null ) { |
||
| 2454 | |||
| 2455 | /** |
||
| 2456 | * Display an error page indicating that a given version of MediaWiki is |
||
| 2457 | * required to use it |
||
| 2458 | * |
||
| 2459 | * @param mixed $version The version of MediaWiki needed to use the page |
||
| 2460 | */ |
||
| 2461 | public function versionRequired( $version ) { |
||
| 2467 | |||
| 2468 | /** |
||
| 2469 | * Format a list of error messages |
||
| 2470 | * |
||
| 2471 | * @param array $errors Array of arrays returned by Title::getUserPermissionsErrors |
||
| 2472 | * @param string $action Action that was denied or null if unknown |
||
| 2473 | * @return string The wikitext error-messages, formatted into a list. |
||
| 2474 | */ |
||
| 2475 | public function formatPermissionsErrorMessage( array $errors, $action = null ) { |
||
| 2504 | |||
| 2505 | /** |
||
| 2506 | * Display a page stating that the Wiki is in read-only mode. |
||
| 2507 | * Should only be called after wfReadOnly() has returned true. |
||
| 2508 | * |
||
| 2509 | * Historically, this function was used to show the source of the page that the user |
||
| 2510 | * was trying to edit and _also_ permissions error messages. The relevant code was |
||
| 2511 | * moved into EditPage in 1.19 (r102024 / d83c2a431c2a) and removed here in 1.25. |
||
| 2512 | * |
||
| 2513 | * @deprecated since 1.25; throw the exception directly |
||
| 2514 | * @throws ReadOnlyError |
||
| 2515 | */ |
||
| 2516 | public function readOnlyPage() { |
||
| 2523 | |||
| 2524 | /** |
||
| 2525 | * Turn off regular page output and return an error response |
||
| 2526 | * for when rate limiting has triggered. |
||
| 2527 | * |
||
| 2528 | * @deprecated since 1.25; throw the exception directly |
||
| 2529 | */ |
||
| 2530 | public function rateLimited() { |
||
| 2534 | |||
| 2535 | /** |
||
| 2536 | * Show a warning about slave lag |
||
| 2537 | * |
||
| 2538 | * If the lag is higher than $wgSlaveLagCritical seconds, |
||
| 2539 | * then the warning is a bit more obvious. If the lag is |
||
| 2540 | * lower than $wgSlaveLagWarning, then no warning is shown. |
||
| 2541 | * |
||
| 2542 | * @param int $lag Slave lag |
||
| 2543 | */ |
||
| 2544 | public function showLagWarning( $lag ) { |
||
| 2554 | |||
| 2555 | public function showFatalError( $message ) { |
||
| 2560 | |||
| 2561 | public function showUnexpectedValueError( $name, $val ) { |
||
| 2564 | |||
| 2565 | public function showFileCopyError( $old, $new ) { |
||
| 2568 | |||
| 2569 | public function showFileRenameError( $old, $new ) { |
||
| 2572 | |||
| 2573 | public function showFileDeleteError( $name ) { |
||
| 2576 | |||
| 2577 | public function showFileNotFoundError( $name ) { |
||
| 2580 | |||
| 2581 | /** |
||
| 2582 | * Add a "return to" link pointing to a specified title |
||
| 2583 | * |
||
| 2584 | * @param Title $title Title to link |
||
| 2585 | * @param array $query Query string parameters |
||
| 2586 | * @param string $text Text of the link (input is not escaped) |
||
| 2587 | * @param array $options Options array to pass to Linker |
||
| 2588 | */ |
||
| 2589 | public function addReturnTo( $title, array $query = [], $text = null, $options = [] ) { |
||
| 2594 | |||
| 2595 | /** |
||
| 2596 | * Add a "return to" link pointing to a specified title, |
||
| 2597 | * or the title indicated in the request, or else the main page |
||
| 2598 | * |
||
| 2599 | * @param mixed $unused |
||
| 2600 | * @param Title|string $returnto Title or String to return to |
||
| 2601 | * @param string $returntoquery Query string for the return to link |
||
| 2602 | */ |
||
| 2603 | public function returnToMain( $unused = null, $returnto = null, $returntoquery = null ) { |
||
| 2627 | |||
| 2628 | private function getRlClientContext() { |
||
| 2648 | |||
| 2649 | /** |
||
| 2650 | * Call this to freeze the module queue and JS config and create a formatter. |
||
| 2651 | * |
||
| 2652 | * Depending on the Skin, this may get lazy-initialised in either headElement() or |
||
| 2653 | * getBottomScripts(). See SkinTemplate::prepareQuickTemplate(). Calling this too early may |
||
| 2654 | * cause unexpected side-effects since disallowUserJs() may be called at any time to change |
||
| 2655 | * the module filters retroactively. Skins and extension hooks may also add modules until very |
||
| 2656 | * late in the request lifecycle. |
||
| 2657 | * |
||
| 2658 | * @return ResourceLoaderClientHtml |
||
| 2659 | */ |
||
| 2660 | public function getRlClient() { |
||
| 2691 | |||
| 2692 | /** |
||
| 2693 | * @param Skin $sk The given Skin |
||
| 2694 | * @param bool $includeStyle Unused |
||
| 2695 | * @return string The doctype, opening "<html>", and head element. |
||
| 2696 | */ |
||
| 2697 | public function headElement( Skin $sk, $includeStyle = true ) { |
||
| 2768 | |||
| 2769 | /** |
||
| 2770 | * Get a ResourceLoader object associated with this OutputPage |
||
| 2771 | * |
||
| 2772 | * @return ResourceLoader |
||
| 2773 | */ |
||
| 2774 | public function getResourceLoader() { |
||
| 2783 | |||
| 2784 | /** |
||
| 2785 | * Explicily load or embed modules on a page. |
||
| 2786 | * |
||
| 2787 | * @param array|string $modules One or more module names |
||
| 2788 | * @param string $only ResourceLoaderModule TYPE_ class constant |
||
| 2789 | * @param array $extraQuery [optional] Array with extra query parameters for the request |
||
| 2790 | * @return string|WrappedStringList HTML |
||
| 2791 | */ |
||
| 2792 | public function makeResourceLoaderLink( $modules, $only, array $extraQuery = [] ) { |
||
| 2800 | |||
| 2801 | /** |
||
| 2802 | * Combine WrappedString chunks and filter out empty ones |
||
| 2803 | * |
||
| 2804 | * @param array $chunks |
||
| 2805 | * @return string|WrappedStringList HTML |
||
| 2806 | */ |
||
| 2807 | protected static function combineWrappedStrings( array $chunks ) { |
||
| 2812 | |||
| 2813 | /** @return bool */ |
||
| 2814 | private function isUserModulePreview() { |
||
| 2821 | |||
| 2822 | /** |
||
| 2823 | * JS stuff to put at the bottom of the `<body>`. These are modules with position 'bottom', |
||
| 2824 | * legacy scripts ($this->mScripts), and user JS. |
||
| 2825 | * |
||
| 2826 | * @return string|WrappedStringList HTML |
||
| 2827 | */ |
||
| 2828 | public function getBottomScripts() { |
||
| 2878 | |||
| 2879 | /** |
||
| 2880 | * Get the javascript config vars to include on this page |
||
| 2881 | * |
||
| 2882 | * @return array Array of javascript config vars |
||
| 2883 | * @since 1.23 |
||
| 2884 | */ |
||
| 2885 | public function getJsConfigVars() { |
||
| 2888 | |||
| 2889 | /** |
||
| 2890 | * Add one or more variables to be set in mw.config in JavaScript |
||
| 2891 | * |
||
| 2892 | * @param string|array $keys Key or array of key/value pairs |
||
| 2893 | * @param mixed $value [optional] Value of the configuration variable |
||
| 2894 | */ |
||
| 2895 | View Code Duplication | public function addJsConfigVars( $keys, $value = null ) { |
|
| 2905 | |||
| 2906 | /** |
||
| 2907 | * Get an array containing the variables to be set in mw.config in JavaScript. |
||
| 2908 | * |
||
| 2909 | * Do not add things here which can be evaluated in ResourceLoaderStartUpModule |
||
| 2910 | * - in other words, page-independent/site-wide variables (without state). |
||
| 2911 | * You will only be adding bloat to the html page and causing page caches to |
||
| 2912 | * have to be purged on configuration changes. |
||
| 2913 | * @return array |
||
| 2914 | */ |
||
| 2915 | public function getJSVars() { |
||
| 3032 | |||
| 3033 | /** |
||
| 3034 | * To make it harder for someone to slip a user a fake |
||
| 3035 | * user-JavaScript or user-CSS preview, a random token |
||
| 3036 | * is associated with the login session. If it's not |
||
| 3037 | * passed back with the preview request, we won't render |
||
| 3038 | * the code. |
||
| 3039 | * |
||
| 3040 | * @return bool |
||
| 3041 | */ |
||
| 3042 | public function userCanPreview() { |
||
| 3073 | |||
| 3074 | /** |
||
| 3075 | * @return array Array in format "link name or number => 'link html'". |
||
| 3076 | */ |
||
| 3077 | public function getHeadLinksArray() { |
||
| 3338 | |||
| 3339 | /** |
||
| 3340 | * @return string HTML tag links to be put in the header. |
||
| 3341 | * @deprecated since 1.24 Use OutputPage::headElement or if you have to, |
||
| 3342 | * OutputPage::getHeadLinksArray directly. |
||
| 3343 | */ |
||
| 3344 | public function getHeadLinks() { |
||
| 3348 | |||
| 3349 | /** |
||
| 3350 | * Generate a "<link rel/>" for a feed. |
||
| 3351 | * |
||
| 3352 | * @param string $type Feed type |
||
| 3353 | * @param string $url URL to the feed |
||
| 3354 | * @param string $text Value of the "title" attribute |
||
| 3355 | * @return string HTML fragment |
||
| 3356 | */ |
||
| 3357 | private function feedLink( $type, $url, $text ) { |
||
| 3365 | |||
| 3366 | /** |
||
| 3367 | * Add a local or specified stylesheet, with the given media options. |
||
| 3368 | * Internal use only. Use OutputPage::addModuleStyles() if possible. |
||
| 3369 | * |
||
| 3370 | * @param string $style URL to the file |
||
| 3371 | * @param string $media To specify a media type, 'screen', 'printable', 'handheld' or any. |
||
| 3372 | * @param string $condition For IE conditional comments, specifying an IE version |
||
| 3373 | * @param string $dir Set to 'rtl' or 'ltr' for direction-specific sheets |
||
| 3374 | */ |
||
| 3375 | public function addStyle( $style, $media = '', $condition = '', $dir = '' ) { |
||
| 3388 | |||
| 3389 | /** |
||
| 3390 | * Adds inline CSS styles |
||
| 3391 | * Internal use only. Use OutputPage::addModuleStyles() if possible. |
||
| 3392 | * |
||
| 3393 | * @param mixed $style_css Inline CSS |
||
| 3394 | * @param string $flip Set to 'flip' to flip the CSS if needed |
||
| 3395 | */ |
||
| 3396 | public function addInlineStyle( $style_css, $flip = 'noflip' ) { |
||
| 3403 | |||
| 3404 | /** |
||
| 3405 | * Build exempt modules and legacy non-ResourceLoader styles. |
||
| 3406 | * |
||
| 3407 | * @return string|WrappedStringList HTML |
||
| 3408 | */ |
||
| 3409 | protected function buildExemptModules() { |
||
| 3500 | |||
| 3501 | /** |
||
| 3502 | * @return array |
||
| 3503 | */ |
||
| 3504 | public function buildCssLinksArray() { |
||
| 3521 | |||
| 3522 | /** |
||
| 3523 | * Generate \<link\> tags for stylesheets |
||
| 3524 | * |
||
| 3525 | * @param string $style URL to the file |
||
| 3526 | * @param array $options Option, can contain 'condition', 'dir', 'media' keys |
||
| 3527 | * @return string HTML fragment |
||
| 3528 | */ |
||
| 3529 | protected function styleLink( $style, array $options ) { |
||
| 3563 | |||
| 3564 | /** |
||
| 3565 | * Transform path to web-accessible static resource. |
||
| 3566 | * |
||
| 3567 | * This is used to add a validation hash as query string. |
||
| 3568 | * This aids various behaviors: |
||
| 3569 | * |
||
| 3570 | * - Put long Cache-Control max-age headers on responses for improved |
||
| 3571 | * cache performance. |
||
| 3572 | * - Get the correct version of a file as expected by the current page. |
||
| 3573 | * - Instantly get the updated version of a file after deployment. |
||
| 3574 | * |
||
| 3575 | * Avoid using this for urls included in HTML as otherwise clients may get different |
||
| 3576 | * versions of a resource when navigating the site depending on when the page was cached. |
||
| 3577 | * If changes to the url propagate, this is not a problem (e.g. if the url is in |
||
| 3578 | * an external stylesheet). |
||
| 3579 | * |
||
| 3580 | * @since 1.27 |
||
| 3581 | * @param Config $config |
||
| 3582 | * @param string $path Path-absolute URL to file (from document root, must start with "/") |
||
| 3583 | * @return string URL |
||
| 3584 | */ |
||
| 3585 | public static function transformResourcePath( Config $config, $path ) { |
||
| 3602 | |||
| 3603 | /** |
||
| 3604 | * Utility method for transformResourceFilePath(). |
||
| 3605 | * |
||
| 3606 | * Caller is responsible for ensuring the file exists. Emits a PHP warning otherwise. |
||
| 3607 | * |
||
| 3608 | * @since 1.27 |
||
| 3609 | * @param string $remotePath URL path prefix that points to $localPath |
||
| 3610 | * @param string $localPath File directory exposed at $remotePath |
||
| 3611 | * @param string $file Path to target file relative to $localPath |
||
| 3612 | * @return string URL |
||
| 3613 | */ |
||
| 3614 | public static function transformFilePath( $remotePathPrefix, $localPath, $file ) { |
||
| 3622 | |||
| 3623 | /** |
||
| 3624 | * Transform "media" attribute based on request parameters |
||
| 3625 | * |
||
| 3626 | * @param string $media Current value of the "media" attribute |
||
| 3627 | * @return string Modified value of the "media" attribute, or null to skip |
||
| 3628 | * this stylesheet |
||
| 3629 | */ |
||
| 3630 | public static function transformCssMedia( $media ) { |
||
| 3668 | |||
| 3669 | /** |
||
| 3670 | * Add a wikitext-formatted message to the output. |
||
| 3671 | * This is equivalent to: |
||
| 3672 | * |
||
| 3673 | * $wgOut->addWikiText( wfMessage( ... )->plain() ) |
||
| 3674 | */ |
||
| 3675 | public function addWikiMsg( /*...*/ ) { |
||
| 3680 | |||
| 3681 | /** |
||
| 3682 | * Add a wikitext-formatted message to the output. |
||
| 3683 | * Like addWikiMsg() except the parameters are taken as an array |
||
| 3684 | * instead of a variable argument list. |
||
| 3685 | * |
||
| 3686 | * @param string $name |
||
| 3687 | * @param array $args |
||
| 3688 | */ |
||
| 3689 | public function addWikiMsgArray( $name, $args ) { |
||
| 3692 | |||
| 3693 | /** |
||
| 3694 | * This function takes a number of message/argument specifications, wraps them in |
||
| 3695 | * some overall structure, and then parses the result and adds it to the output. |
||
| 3696 | * |
||
| 3697 | * In the $wrap, $1 is replaced with the first message, $2 with the second, |
||
| 3698 | * and so on. The subsequent arguments may be either |
||
| 3699 | * 1) strings, in which case they are message names, or |
||
| 3700 | * 2) arrays, in which case, within each array, the first element is the message |
||
| 3701 | * name, and subsequent elements are the parameters to that message. |
||
| 3702 | * |
||
| 3703 | * Don't use this for messages that are not in the user's interface language. |
||
| 3704 | * |
||
| 3705 | * For example: |
||
| 3706 | * |
||
| 3707 | * $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>", 'some-error' ); |
||
| 3708 | * |
||
| 3709 | * Is equivalent to: |
||
| 3710 | * |
||
| 3711 | * $wgOut->addWikiText( "<div class='error'>\n" |
||
| 3712 | * . wfMessage( 'some-error' )->plain() . "\n</div>" ); |
||
| 3713 | * |
||
| 3714 | * The newline after the opening div is needed in some wikitext. See bug 19226. |
||
| 3715 | * |
||
| 3716 | * @param string $wrap |
||
| 3717 | */ |
||
| 3718 | public function wrapWikiMsg( $wrap /*, ...*/ ) { |
||
| 3742 | |||
| 3743 | /** |
||
| 3744 | * Enables/disables TOC, doesn't override __NOTOC__ |
||
| 3745 | * @param bool $flag |
||
| 3746 | * @since 1.22 |
||
| 3747 | */ |
||
| 3748 | public function enableTOC( $flag = true ) { |
||
| 3751 | |||
| 3752 | /** |
||
| 3753 | * @return bool |
||
| 3754 | * @since 1.22 |
||
| 3755 | */ |
||
| 3756 | public function isTOCEnabled() { |
||
| 3759 | |||
| 3760 | /** |
||
| 3761 | * Enables/disables section edit links, doesn't override __NOEDITSECTION__ |
||
| 3762 | * @param bool $flag |
||
| 3763 | * @since 1.23 |
||
| 3764 | */ |
||
| 3765 | public function enableSectionEditLinks( $flag = true ) { |
||
| 3768 | |||
| 3769 | /** |
||
| 3770 | * @return bool |
||
| 3771 | * @since 1.23 |
||
| 3772 | */ |
||
| 3773 | public function sectionEditLinksEnabled() { |
||
| 3776 | |||
| 3777 | /** |
||
| 3778 | * Helper function to setup the PHP implementation of OOUI to use in this request. |
||
| 3779 | * |
||
| 3780 | * @since 1.26 |
||
| 3781 | * @param String $skinName The Skin name to determine the correct OOUI theme |
||
| 3782 | * @param String $dir Language direction |
||
| 3783 | */ |
||
| 3784 | public static function setupOOUI( $skinName = '', $dir = 'ltr' ) { |
||
| 3794 | |||
| 3795 | /** |
||
| 3796 | * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with |
||
| 3797 | * MediaWiki and this OutputPage instance. |
||
| 3798 | * |
||
| 3799 | * @since 1.25 |
||
| 3800 | */ |
||
| 3801 | public function enableOOUI() { |
||
| 3817 | |||
| 3818 | /** |
||
| 3819 | * @param array $data Data from ParserOutput::getLimitReportData() |
||
| 3820 | * @since 1.28 |
||
| 3821 | */ |
||
| 3822 | public function setLimitReportData( array $data ) { |
||
| 3825 | } |
||
| 3826 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.