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 | private $rlExemptStyleModules; |
||
| 168 | |||
| 169 | /** @var array */ |
||
| 170 | protected $mJsConfigVars = []; |
||
| 171 | |||
| 172 | /** @var array */ |
||
| 173 | protected $mTemplateIds = []; |
||
| 174 | |||
| 175 | /** @var array */ |
||
| 176 | protected $mImageTimeKeys = []; |
||
| 177 | |||
| 178 | /** @var string */ |
||
| 179 | public $mRedirectCode = ''; |
||
| 180 | |||
| 181 | protected $mFeedLinksAppendQuery = null; |
||
| 182 | |||
| 183 | /** @var array |
||
| 184 | * What level of 'untrustworthiness' is allowed in CSS/JS modules loaded on this page? |
||
| 185 | * @see ResourceLoaderModule::$origin |
||
| 186 | * ResourceLoaderModule::ORIGIN_ALL is assumed unless overridden; |
||
| 187 | */ |
||
| 188 | protected $mAllowedModules = [ |
||
| 189 | ResourceLoaderModule::TYPE_COMBINED => ResourceLoaderModule::ORIGIN_ALL, |
||
| 190 | ]; |
||
| 191 | |||
| 192 | /** @var bool Whether output is disabled. If this is true, the 'output' method will do nothing. */ |
||
| 193 | protected $mDoNothing = false; |
||
| 194 | |||
| 195 | // Parser related. |
||
| 196 | |||
| 197 | /** @var int */ |
||
| 198 | protected $mContainsNewMagic = 0; |
||
| 199 | |||
| 200 | /** |
||
| 201 | * lazy initialised, use parserOptions() |
||
| 202 | * @var ParserOptions |
||
| 203 | */ |
||
| 204 | protected $mParserOptions = null; |
||
| 205 | |||
| 206 | /** |
||
| 207 | * Handles the Atom / RSS links. |
||
| 208 | * We probably only support Atom in 2011. |
||
| 209 | * @see $wgAdvertisedFeedTypes |
||
| 210 | */ |
||
| 211 | private $mFeedLinks = []; |
||
| 212 | |||
| 213 | // Gwicke work on squid caching? Roughly from 2003. |
||
| 214 | protected $mEnableClientCache = true; |
||
| 215 | |||
| 216 | /** @var bool Flag if output should only contain the body of the article. */ |
||
| 217 | private $mArticleBodyOnly = false; |
||
| 218 | |||
| 219 | /** @var bool */ |
||
| 220 | protected $mNewSectionLink = false; |
||
| 221 | |||
| 222 | /** @var bool */ |
||
| 223 | protected $mHideNewSectionLink = false; |
||
| 224 | |||
| 225 | /** |
||
| 226 | * @var bool Comes from the parser. This was probably made to load CSS/JS |
||
| 227 | * only if we had "<gallery>". Used directly in CategoryPage.php. |
||
| 228 | * Looks like ResourceLoader can replace this. |
||
| 229 | */ |
||
| 230 | public $mNoGallery = false; |
||
| 231 | |||
| 232 | /** @var string */ |
||
| 233 | private $mPageTitleActionText = ''; |
||
| 234 | |||
| 235 | /** @var int Cache stuff. Looks like mEnableClientCache */ |
||
| 236 | protected $mCdnMaxage = 0; |
||
| 237 | /** @var int Upper limit on mCdnMaxage */ |
||
| 238 | protected $mCdnMaxageLimit = INF; |
||
| 239 | |||
| 240 | /** |
||
| 241 | * @var bool Controls if anti-clickjacking / frame-breaking headers will |
||
| 242 | * be sent. This should be done for pages where edit actions are possible. |
||
| 243 | * Setters: $this->preventClickjacking() and $this->allowClickjacking(). |
||
| 244 | */ |
||
| 245 | protected $mPreventClickjacking = true; |
||
| 246 | |||
| 247 | /** @var int To include the variable {{REVISIONID}} */ |
||
| 248 | private $mRevisionId = null; |
||
| 249 | |||
| 250 | /** @var string */ |
||
| 251 | private $mRevisionTimestamp = null; |
||
| 252 | |||
| 253 | /** @var array */ |
||
| 254 | protected $mFileVersion = null; |
||
| 255 | |||
| 256 | /** |
||
| 257 | * @var array An array of stylesheet filenames (relative from skins path), |
||
| 258 | * with options for CSS media, IE conditions, and RTL/LTR direction. |
||
| 259 | * For internal use; add settings in the skin via $this->addStyle() |
||
| 260 | * |
||
| 261 | * Style again! This seems like a code duplication since we already have |
||
| 262 | * mStyles. This is what makes Open Source amazing. |
||
| 263 | */ |
||
| 264 | protected $styles = []; |
||
| 265 | |||
| 266 | private $mIndexPolicy = 'index'; |
||
| 267 | private $mFollowPolicy = 'follow'; |
||
| 268 | private $mVaryHeader = [ |
||
| 269 | 'Accept-Encoding' => [ 'match=gzip' ], |
||
| 270 | ]; |
||
| 271 | |||
| 272 | /** |
||
| 273 | * If the current page was reached through a redirect, $mRedirectedFrom contains the Title |
||
| 274 | * of the redirect. |
||
| 275 | * |
||
| 276 | * @var Title |
||
| 277 | */ |
||
| 278 | private $mRedirectedFrom = null; |
||
| 279 | |||
| 280 | /** |
||
| 281 | * Additional key => value data |
||
| 282 | */ |
||
| 283 | private $mProperties = []; |
||
| 284 | |||
| 285 | /** |
||
| 286 | * @var string|null ResourceLoader target for load.php links. If null, will be omitted |
||
| 287 | */ |
||
| 288 | private $mTarget = null; |
||
| 289 | |||
| 290 | /** |
||
| 291 | * @var bool Whether parser output should contain table of contents |
||
| 292 | */ |
||
| 293 | private $mEnableTOC = true; |
||
| 294 | |||
| 295 | /** |
||
| 296 | * @var bool Whether parser output should contain section edit links |
||
| 297 | */ |
||
| 298 | private $mEnableSectionEditLinks = true; |
||
| 299 | |||
| 300 | /** |
||
| 301 | * @var string|null The URL to send in a <link> element with rel=copyright |
||
| 302 | */ |
||
| 303 | private $copyrightUrl; |
||
| 304 | |||
| 305 | /** @var array Profiling data */ |
||
| 306 | private $limitReportData = []; |
||
| 307 | |||
| 308 | /** |
||
| 309 | * Constructor for OutputPage. This should not be called directly. |
||
| 310 | * Instead a new RequestContext should be created and it will implicitly create |
||
| 311 | * a OutputPage tied to that context. |
||
| 312 | * @param IContextSource|null $context |
||
| 313 | */ |
||
| 314 | function __construct( IContextSource $context = null ) { |
||
| 322 | |||
| 323 | /** |
||
| 324 | * Redirect to $url rather than displaying the normal page |
||
| 325 | * |
||
| 326 | * @param string $url URL |
||
| 327 | * @param string $responsecode HTTP status code |
||
| 328 | */ |
||
| 329 | public function redirect( $url, $responsecode = '302' ) { |
||
| 334 | |||
| 335 | /** |
||
| 336 | * Get the URL to redirect to, or an empty string if not redirect URL set |
||
| 337 | * |
||
| 338 | * @return string |
||
| 339 | */ |
||
| 340 | public function getRedirect() { |
||
| 343 | |||
| 344 | /** |
||
| 345 | * Set the copyright URL to send with the output. |
||
| 346 | * Empty string to omit, null to reset. |
||
| 347 | * |
||
| 348 | * @since 1.26 |
||
| 349 | * |
||
| 350 | * @param string|null $url |
||
| 351 | */ |
||
| 352 | public function setCopyrightUrl( $url ) { |
||
| 355 | |||
| 356 | /** |
||
| 357 | * Set the HTTP status code to send with the output. |
||
| 358 | * |
||
| 359 | * @param int $statusCode |
||
| 360 | */ |
||
| 361 | public function setStatusCode( $statusCode ) { |
||
| 364 | |||
| 365 | /** |
||
| 366 | * Add a new "<meta>" tag |
||
| 367 | * To add an http-equiv meta tag, precede the name with "http:" |
||
| 368 | * |
||
| 369 | * @param string $name Tag name |
||
| 370 | * @param string $val Tag value |
||
| 371 | */ |
||
| 372 | function addMeta( $name, $val ) { |
||
| 375 | |||
| 376 | /** |
||
| 377 | * Returns the current <meta> tags |
||
| 378 | * |
||
| 379 | * @since 1.25 |
||
| 380 | * @return array |
||
| 381 | */ |
||
| 382 | public function getMetaTags() { |
||
| 385 | |||
| 386 | /** |
||
| 387 | * Add a new \<link\> tag to the page header. |
||
| 388 | * |
||
| 389 | * Note: use setCanonicalUrl() for rel=canonical. |
||
| 390 | * |
||
| 391 | * @param array $linkarr Associative array of attributes. |
||
| 392 | */ |
||
| 393 | function addLink( array $linkarr ) { |
||
| 396 | |||
| 397 | /** |
||
| 398 | * Returns the current <link> tags |
||
| 399 | * |
||
| 400 | * @since 1.25 |
||
| 401 | * @return array |
||
| 402 | */ |
||
| 403 | public function getLinkTags() { |
||
| 406 | |||
| 407 | /** |
||
| 408 | * Add a new \<link\> with "rel" attribute set to "meta" |
||
| 409 | * |
||
| 410 | * @param array $linkarr Associative array mapping attribute names to their |
||
| 411 | * values, both keys and values will be escaped, and the |
||
| 412 | * "rel" attribute will be automatically added |
||
| 413 | */ |
||
| 414 | function addMetadataLink( array $linkarr ) { |
||
| 418 | |||
| 419 | /** |
||
| 420 | * Set the URL to be used for the <link rel=canonical>. This should be used |
||
| 421 | * in preference to addLink(), to avoid duplicate link tags. |
||
| 422 | * @param string $url |
||
| 423 | */ |
||
| 424 | function setCanonicalUrl( $url ) { |
||
| 427 | |||
| 428 | /** |
||
| 429 | * Returns the URL to be used for the <link rel=canonical> if |
||
| 430 | * one is set. |
||
| 431 | * |
||
| 432 | * @since 1.25 |
||
| 433 | * @return bool|string |
||
| 434 | */ |
||
| 435 | public function getCanonicalUrl() { |
||
| 438 | |||
| 439 | /** |
||
| 440 | * Get the value of the "rel" attribute for metadata links |
||
| 441 | * |
||
| 442 | * @return string |
||
| 443 | */ |
||
| 444 | public function getMetadataAttribute() { |
||
| 454 | |||
| 455 | /** |
||
| 456 | * Add raw HTML to the list of scripts (including \<script\> tag, etc.) |
||
| 457 | * Internal use only. Use OutputPage::addModules() or OutputPage::addJsConfigVars() |
||
| 458 | * if possible. |
||
| 459 | * |
||
| 460 | * @param string $script Raw HTML |
||
| 461 | */ |
||
| 462 | function addScript( $script ) { |
||
| 465 | |||
| 466 | /** |
||
| 467 | * Register and add a stylesheet from an extension directory. |
||
| 468 | * |
||
| 469 | * @deprecated since 1.27 use addModuleStyles() or addStyle() instead |
||
| 470 | * @param string $url Path to sheet. Provide either a full url (beginning |
||
| 471 | * with 'http', etc) or a relative path from the document root |
||
| 472 | * (beginning with '/'). Otherwise it behaves identically to |
||
| 473 | * addStyle() and draws from the /skins folder. |
||
| 474 | */ |
||
| 475 | public function addExtensionStyle( $url ) { |
||
| 479 | |||
| 480 | /** |
||
| 481 | * Get all styles added by extensions |
||
| 482 | * |
||
| 483 | * @deprecated since 1.27 |
||
| 484 | * @return array |
||
| 485 | */ |
||
| 486 | function getExtStyle() { |
||
| 490 | |||
| 491 | /** |
||
| 492 | * Add a JavaScript file out of skins/common, or a given relative path. |
||
| 493 | * Internal use only. Use OutputPage::addModules() if possible. |
||
| 494 | * |
||
| 495 | * @param string $file Filename in skins/common or complete on-server path |
||
| 496 | * (/foo/bar.js) |
||
| 497 | * @param string $version Style version of the file. Defaults to $wgStyleVersion |
||
| 498 | */ |
||
| 499 | public function addScriptFile( $file, $version = null ) { |
||
| 511 | |||
| 512 | /** |
||
| 513 | * Add a self-contained script tag with the given contents |
||
| 514 | * Internal use only. Use OutputPage::addModules() if possible. |
||
| 515 | * |
||
| 516 | * @param string $script JavaScript text, no script tags |
||
| 517 | */ |
||
| 518 | public function addInlineScript( $script ) { |
||
| 521 | |||
| 522 | /** |
||
| 523 | * Filter an array of modules to remove insufficiently trustworthy members, and modules |
||
| 524 | * which are no longer registered (eg a page is cached before an extension is disabled) |
||
| 525 | * @param array $modules |
||
| 526 | * @param string|null $position If not null, only return modules with this position |
||
| 527 | * @param string $type |
||
| 528 | * @return array |
||
| 529 | */ |
||
| 530 | protected function filterModules( array $modules, $position = null, |
||
| 547 | |||
| 548 | /** |
||
| 549 | * Get the list of modules to include on this page |
||
| 550 | * |
||
| 551 | * @param bool $filter Whether to filter out insufficiently trustworthy modules |
||
| 552 | * @param string|null $position If not null, only return modules with this position |
||
| 553 | * @param string $param |
||
| 554 | * @return array Array of module names |
||
| 555 | */ |
||
| 556 | public function getModules( $filter = false, $position = null, $param = 'mModules', |
||
| 564 | |||
| 565 | /** |
||
| 566 | * Add one or more modules recognized by ResourceLoader. Modules added |
||
| 567 | * through this function will be loaded by ResourceLoader when the |
||
| 568 | * page loads. |
||
| 569 | * |
||
| 570 | * @param string|array $modules Module name (string) or array of module names |
||
| 571 | */ |
||
| 572 | public function addModules( $modules ) { |
||
| 575 | |||
| 576 | /** |
||
| 577 | * Get the list of module JS to include on this page |
||
| 578 | * |
||
| 579 | * @param bool $filter |
||
| 580 | * @param string|null $position |
||
| 581 | * @return array Array of module names |
||
| 582 | */ |
||
| 583 | public function getModuleScripts( $filter = false, $position = null ) { |
||
| 588 | |||
| 589 | /** |
||
| 590 | * Add only JS of one or more modules recognized by ResourceLoader. Module |
||
| 591 | * scripts added through this function will be loaded by ResourceLoader when |
||
| 592 | * the page loads. |
||
| 593 | * |
||
| 594 | * @param string|array $modules Module name (string) or array of module names |
||
| 595 | */ |
||
| 596 | public function addModuleScripts( $modules ) { |
||
| 599 | |||
| 600 | /** |
||
| 601 | * Get the list of module CSS to include on this page |
||
| 602 | * |
||
| 603 | * @param bool $filter |
||
| 604 | * @param string|null $position |
||
| 605 | * @return array Array of module names |
||
| 606 | */ |
||
| 607 | public function getModuleStyles( $filter = false, $position = null ) { |
||
| 612 | |||
| 613 | /** |
||
| 614 | * Add only CSS of one or more modules recognized by ResourceLoader. |
||
| 615 | * |
||
| 616 | * Module styles added through this function will be added using standard link CSS |
||
| 617 | * tags, rather than as a combined Javascript and CSS package. Thus, they will |
||
| 618 | * load when JavaScript is disabled (unless CSS also happens to be disabled). |
||
| 619 | * |
||
| 620 | * @param string|array $modules Module name (string) or array of module names |
||
| 621 | */ |
||
| 622 | public function addModuleStyles( $modules ) { |
||
| 625 | |||
| 626 | /** |
||
| 627 | * @return null|string ResourceLoader target |
||
| 628 | */ |
||
| 629 | public function getTarget() { |
||
| 632 | |||
| 633 | /** |
||
| 634 | * Sets ResourceLoader target for load.php links. If null, will be omitted |
||
| 635 | * |
||
| 636 | * @param string|null $target |
||
| 637 | */ |
||
| 638 | public function setTarget( $target ) { |
||
| 641 | |||
| 642 | /** |
||
| 643 | * Get an array of head items |
||
| 644 | * |
||
| 645 | * @return array |
||
| 646 | */ |
||
| 647 | function getHeadItemsArray() { |
||
| 650 | |||
| 651 | /** |
||
| 652 | * Add or replace a head item to the output |
||
| 653 | * |
||
| 654 | * Whenever possible, use more specific options like ResourceLoader modules, |
||
| 655 | * OutputPage::addLink(), OutputPage::addMetaLink() and OutputPage::addFeedLink() |
||
| 656 | * Fallback options for those are: OutputPage::addStyle, OutputPage::addScript(), |
||
| 657 | * OutputPage::addInlineScript() and OutputPage::addInlineStyle() |
||
| 658 | * This would be your very LAST fallback. |
||
| 659 | * |
||
| 660 | * @param string $name Item name |
||
| 661 | * @param string $value Raw HTML |
||
| 662 | */ |
||
| 663 | public function addHeadItem( $name, $value ) { |
||
| 666 | |||
| 667 | /** |
||
| 668 | * Add one or more head items to the output |
||
| 669 | * |
||
| 670 | * @since 1.28 |
||
| 671 | * @param string|string[] $value Raw HTML |
||
| 672 | */ |
||
| 673 | public function addHeadItems( $values ) { |
||
| 676 | |||
| 677 | /** |
||
| 678 | * Check if the header item $name is already set |
||
| 679 | * |
||
| 680 | * @param string $name Item name |
||
| 681 | * @return bool |
||
| 682 | */ |
||
| 683 | public function hasHeadItem( $name ) { |
||
| 686 | |||
| 687 | /** |
||
| 688 | * @deprecated since 1.28 Obsolete - wgUseETag experiment was removed. |
||
| 689 | * @param string $tag |
||
| 690 | */ |
||
| 691 | public function setETag( $tag ) { |
||
| 693 | |||
| 694 | /** |
||
| 695 | * Set whether the output should only contain the body of the article, |
||
| 696 | * without any skin, sidebar, etc. |
||
| 697 | * Used e.g. when calling with "action=render". |
||
| 698 | * |
||
| 699 | * @param bool $only Whether to output only the body of the article |
||
| 700 | */ |
||
| 701 | public function setArticleBodyOnly( $only ) { |
||
| 704 | |||
| 705 | /** |
||
| 706 | * Return whether the output will contain only the body of the article |
||
| 707 | * |
||
| 708 | * @return bool |
||
| 709 | */ |
||
| 710 | public function getArticleBodyOnly() { |
||
| 713 | |||
| 714 | /** |
||
| 715 | * Set an additional output property |
||
| 716 | * @since 1.21 |
||
| 717 | * |
||
| 718 | * @param string $name |
||
| 719 | * @param mixed $value |
||
| 720 | */ |
||
| 721 | public function setProperty( $name, $value ) { |
||
| 724 | |||
| 725 | /** |
||
| 726 | * Get an additional output property |
||
| 727 | * @since 1.21 |
||
| 728 | * |
||
| 729 | * @param string $name |
||
| 730 | * @return mixed Property value or null if not found |
||
| 731 | */ |
||
| 732 | public function getProperty( $name ) { |
||
| 739 | |||
| 740 | /** |
||
| 741 | * checkLastModified tells the client to use the client-cached page if |
||
| 742 | * possible. If successful, the OutputPage is disabled so that |
||
| 743 | * any future call to OutputPage->output() have no effect. |
||
| 744 | * |
||
| 745 | * Side effect: sets mLastModified for Last-Modified header |
||
| 746 | * |
||
| 747 | * @param string $timestamp |
||
| 748 | * |
||
| 749 | * @return bool True if cache-ok headers was sent. |
||
| 750 | */ |
||
| 751 | public function checkLastModified( $timestamp ) { |
||
| 831 | |||
| 832 | /** |
||
| 833 | * Override the last modified timestamp |
||
| 834 | * |
||
| 835 | * @param string $timestamp New timestamp, in a format readable by |
||
| 836 | * wfTimestamp() |
||
| 837 | */ |
||
| 838 | public function setLastModified( $timestamp ) { |
||
| 841 | |||
| 842 | /** |
||
| 843 | * Set the robot policy for the page: <http://www.robotstxt.org/meta.html> |
||
| 844 | * |
||
| 845 | * @param string $policy The literal string to output as the contents of |
||
| 846 | * the meta tag. Will be parsed according to the spec and output in |
||
| 847 | * standardized form. |
||
| 848 | * @return null |
||
| 849 | */ |
||
| 850 | public function setRobotPolicy( $policy ) { |
||
| 860 | |||
| 861 | /** |
||
| 862 | * Set the index policy for the page, but leave the follow policy un- |
||
| 863 | * touched. |
||
| 864 | * |
||
| 865 | * @param string $policy Either 'index' or 'noindex'. |
||
| 866 | * @return null |
||
| 867 | */ |
||
| 868 | public function setIndexPolicy( $policy ) { |
||
| 874 | |||
| 875 | /** |
||
| 876 | * Set the follow policy for the page, but leave the index policy un- |
||
| 877 | * touched. |
||
| 878 | * |
||
| 879 | * @param string $policy Either 'follow' or 'nofollow'. |
||
| 880 | * @return null |
||
| 881 | */ |
||
| 882 | public function setFollowPolicy( $policy ) { |
||
| 888 | |||
| 889 | /** |
||
| 890 | * Set the new value of the "action text", this will be added to the |
||
| 891 | * "HTML title", separated from it with " - ". |
||
| 892 | * |
||
| 893 | * @param string $text New value of the "action text" |
||
| 894 | */ |
||
| 895 | public function setPageTitleActionText( $text ) { |
||
| 898 | |||
| 899 | /** |
||
| 900 | * Get the value of the "action text" |
||
| 901 | * |
||
| 902 | * @return string |
||
| 903 | */ |
||
| 904 | public function getPageTitleActionText() { |
||
| 907 | |||
| 908 | /** |
||
| 909 | * "HTML title" means the contents of "<title>". |
||
| 910 | * It is stored as plain, unescaped text and will be run through htmlspecialchars in the skin file. |
||
| 911 | * |
||
| 912 | * @param string|Message $name |
||
| 913 | */ |
||
| 914 | public function setHTMLTitle( $name ) { |
||
| 921 | |||
| 922 | /** |
||
| 923 | * Return the "HTML title", i.e. the content of the "<title>" tag. |
||
| 924 | * |
||
| 925 | * @return string |
||
| 926 | */ |
||
| 927 | public function getHTMLTitle() { |
||
| 930 | |||
| 931 | /** |
||
| 932 | * Set $mRedirectedFrom, the Title of the page which redirected us to the current page. |
||
| 933 | * |
||
| 934 | * @param Title $t |
||
| 935 | */ |
||
| 936 | public function setRedirectedFrom( $t ) { |
||
| 939 | |||
| 940 | /** |
||
| 941 | * "Page title" means the contents of \<h1\>. It is stored as a valid HTML |
||
| 942 | * fragment. This function allows good tags like \<sup\> in the \<h1\> tag, |
||
| 943 | * but not bad tags like \<script\>. This function automatically sets |
||
| 944 | * \<title\> to the same content as \<h1\> but with all tags removed. Bad |
||
| 945 | * tags that were escaped in \<h1\> will still be escaped in \<title\>, and |
||
| 946 | * good tags like \<i\> will be dropped entirely. |
||
| 947 | * |
||
| 948 | * @param string|Message $name |
||
| 949 | */ |
||
| 950 | public function setPageTitle( $name ) { |
||
| 966 | |||
| 967 | /** |
||
| 968 | * Return the "page title", i.e. the content of the \<h1\> tag. |
||
| 969 | * |
||
| 970 | * @return string |
||
| 971 | */ |
||
| 972 | public function getPageTitle() { |
||
| 975 | |||
| 976 | /** |
||
| 977 | * Set the Title object to use |
||
| 978 | * |
||
| 979 | * @param Title $t |
||
| 980 | */ |
||
| 981 | public function setTitle( Title $t ) { |
||
| 984 | |||
| 985 | /** |
||
| 986 | * Replace the subtitle with $str |
||
| 987 | * |
||
| 988 | * @param string|Message $str New value of the subtitle. String should be safe HTML. |
||
| 989 | */ |
||
| 990 | public function setSubtitle( $str ) { |
||
| 994 | |||
| 995 | /** |
||
| 996 | * Add $str to the subtitle |
||
| 997 | * |
||
| 998 | * @param string|Message $str String or Message to add to the subtitle. String should be safe HTML. |
||
| 999 | */ |
||
| 1000 | public function addSubtitle( $str ) { |
||
| 1007 | |||
| 1008 | /** |
||
| 1009 | * Build message object for a subtitle containing a backlink to a page |
||
| 1010 | * |
||
| 1011 | * @param Title $title Title to link to |
||
| 1012 | * @param array $query Array of additional parameters to include in the link |
||
| 1013 | * @return Message |
||
| 1014 | * @since 1.25 |
||
| 1015 | */ |
||
| 1016 | public static function buildBacklinkSubtitle( Title $title, $query = [] ) { |
||
| 1023 | |||
| 1024 | /** |
||
| 1025 | * Add a subtitle containing a backlink to a page |
||
| 1026 | * |
||
| 1027 | * @param Title $title Title to link to |
||
| 1028 | * @param array $query Array of additional parameters to include in the link |
||
| 1029 | */ |
||
| 1030 | public function addBacklinkSubtitle( Title $title, $query = [] ) { |
||
| 1033 | |||
| 1034 | /** |
||
| 1035 | * Clear the subtitles |
||
| 1036 | */ |
||
| 1037 | public function clearSubtitle() { |
||
| 1040 | |||
| 1041 | /** |
||
| 1042 | * Get the subtitle |
||
| 1043 | * |
||
| 1044 | * @return string |
||
| 1045 | */ |
||
| 1046 | public function getSubtitle() { |
||
| 1049 | |||
| 1050 | /** |
||
| 1051 | * Set the page as printable, i.e. it'll be displayed with all |
||
| 1052 | * print styles included |
||
| 1053 | */ |
||
| 1054 | public function setPrintable() { |
||
| 1057 | |||
| 1058 | /** |
||
| 1059 | * Return whether the page is "printable" |
||
| 1060 | * |
||
| 1061 | * @return bool |
||
| 1062 | */ |
||
| 1063 | public function isPrintable() { |
||
| 1066 | |||
| 1067 | /** |
||
| 1068 | * Disable output completely, i.e. calling output() will have no effect |
||
| 1069 | */ |
||
| 1070 | public function disable() { |
||
| 1073 | |||
| 1074 | /** |
||
| 1075 | * Return whether the output will be completely disabled |
||
| 1076 | * |
||
| 1077 | * @return bool |
||
| 1078 | */ |
||
| 1079 | public function isDisabled() { |
||
| 1082 | |||
| 1083 | /** |
||
| 1084 | * Show an "add new section" link? |
||
| 1085 | * |
||
| 1086 | * @return bool |
||
| 1087 | */ |
||
| 1088 | public function showNewSectionLink() { |
||
| 1091 | |||
| 1092 | /** |
||
| 1093 | * Forcibly hide the new section link? |
||
| 1094 | * |
||
| 1095 | * @return bool |
||
| 1096 | */ |
||
| 1097 | public function forceHideNewSectionLink() { |
||
| 1100 | |||
| 1101 | /** |
||
| 1102 | * Add or remove feed links in the page header |
||
| 1103 | * This is mainly kept for backward compatibility, see OutputPage::addFeedLink() |
||
| 1104 | * for the new version |
||
| 1105 | * @see addFeedLink() |
||
| 1106 | * |
||
| 1107 | * @param bool $show True: add default feeds, false: remove all feeds |
||
| 1108 | */ |
||
| 1109 | public function setSyndicated( $show = true ) { |
||
| 1116 | |||
| 1117 | /** |
||
| 1118 | * Add default feeds to the page header |
||
| 1119 | * This is mainly kept for backward compatibility, see OutputPage::addFeedLink() |
||
| 1120 | * for the new version |
||
| 1121 | * @see addFeedLink() |
||
| 1122 | * |
||
| 1123 | * @param string $val Query to append to feed links or false to output |
||
| 1124 | * default links |
||
| 1125 | */ |
||
| 1126 | public function setFeedAppendQuery( $val ) { |
||
| 1137 | |||
| 1138 | /** |
||
| 1139 | * Add a feed link to the page header |
||
| 1140 | * |
||
| 1141 | * @param string $format Feed type, should be a key of $wgFeedClasses |
||
| 1142 | * @param string $href URL |
||
| 1143 | */ |
||
| 1144 | public function addFeedLink( $format, $href ) { |
||
| 1149 | |||
| 1150 | /** |
||
| 1151 | * Should we output feed links for this page? |
||
| 1152 | * @return bool |
||
| 1153 | */ |
||
| 1154 | public function isSyndicated() { |
||
| 1157 | |||
| 1158 | /** |
||
| 1159 | * Return URLs for each supported syndication format for this page. |
||
| 1160 | * @return array Associating format keys with URLs |
||
| 1161 | */ |
||
| 1162 | public function getSyndicationLinks() { |
||
| 1165 | |||
| 1166 | /** |
||
| 1167 | * Will currently always return null |
||
| 1168 | * |
||
| 1169 | * @return null |
||
| 1170 | */ |
||
| 1171 | public function getFeedAppendQuery() { |
||
| 1174 | |||
| 1175 | /** |
||
| 1176 | * Set whether the displayed content is related to the source of the |
||
| 1177 | * corresponding article on the wiki |
||
| 1178 | * Setting true will cause the change "article related" toggle to true |
||
| 1179 | * |
||
| 1180 | * @param bool $v |
||
| 1181 | */ |
||
| 1182 | public function setArticleFlag( $v ) { |
||
| 1188 | |||
| 1189 | /** |
||
| 1190 | * Return whether the content displayed page is related to the source of |
||
| 1191 | * the corresponding article on the wiki |
||
| 1192 | * |
||
| 1193 | * @return bool |
||
| 1194 | */ |
||
| 1195 | public function isArticle() { |
||
| 1198 | |||
| 1199 | /** |
||
| 1200 | * Set whether this page is related an article on the wiki |
||
| 1201 | * Setting false will cause the change of "article flag" toggle to false |
||
| 1202 | * |
||
| 1203 | * @param bool $v |
||
| 1204 | */ |
||
| 1205 | public function setArticleRelated( $v ) { |
||
| 1211 | |||
| 1212 | /** |
||
| 1213 | * Return whether this page is related an article on the wiki |
||
| 1214 | * |
||
| 1215 | * @return bool |
||
| 1216 | */ |
||
| 1217 | public function isArticleRelated() { |
||
| 1220 | |||
| 1221 | /** |
||
| 1222 | * Add new language links |
||
| 1223 | * |
||
| 1224 | * @param array $newLinkArray Associative array mapping language code to the page |
||
| 1225 | * name |
||
| 1226 | */ |
||
| 1227 | public function addLanguageLinks( array $newLinkArray ) { |
||
| 1230 | |||
| 1231 | /** |
||
| 1232 | * Reset the language links and add new language links |
||
| 1233 | * |
||
| 1234 | * @param array $newLinkArray Associative array mapping language code to the page |
||
| 1235 | * name |
||
| 1236 | */ |
||
| 1237 | public function setLanguageLinks( array $newLinkArray ) { |
||
| 1240 | |||
| 1241 | /** |
||
| 1242 | * Get the list of language links |
||
| 1243 | * |
||
| 1244 | * @return array Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page') |
||
| 1245 | */ |
||
| 1246 | public function getLanguageLinks() { |
||
| 1249 | |||
| 1250 | /** |
||
| 1251 | * Add an array of categories, with names in the keys |
||
| 1252 | * |
||
| 1253 | * @param array $categories Mapping category name => sort key |
||
| 1254 | */ |
||
| 1255 | public function addCategoryLinks( array $categories ) { |
||
| 1321 | |||
| 1322 | /** |
||
| 1323 | * Reset the category links (but not the category list) and add $categories |
||
| 1324 | * |
||
| 1325 | * @param array $categories Mapping category name => sort key |
||
| 1326 | */ |
||
| 1327 | public function setCategoryLinks( array $categories ) { |
||
| 1331 | |||
| 1332 | /** |
||
| 1333 | * Get the list of category links, in a 2-D array with the following format: |
||
| 1334 | * $arr[$type][] = $link, where $type is either "normal" or "hidden" (for |
||
| 1335 | * hidden categories) and $link a HTML fragment with a link to the category |
||
| 1336 | * page |
||
| 1337 | * |
||
| 1338 | * @return array |
||
| 1339 | */ |
||
| 1340 | public function getCategoryLinks() { |
||
| 1343 | |||
| 1344 | /** |
||
| 1345 | * Get the list of category names this page belongs to |
||
| 1346 | * |
||
| 1347 | * @return array Array of strings |
||
| 1348 | */ |
||
| 1349 | public function getCategories() { |
||
| 1352 | |||
| 1353 | /** |
||
| 1354 | * Add an array of indicators, with their identifiers as array |
||
| 1355 | * keys and HTML contents as values. |
||
| 1356 | * |
||
| 1357 | * In case of duplicate keys, existing values are overwritten. |
||
| 1358 | * |
||
| 1359 | * @param array $indicators |
||
| 1360 | * @since 1.25 |
||
| 1361 | */ |
||
| 1362 | public function setIndicators( array $indicators ) { |
||
| 1367 | |||
| 1368 | /** |
||
| 1369 | * Get the indicators associated with this page. |
||
| 1370 | * |
||
| 1371 | * The array will be internally ordered by item keys. |
||
| 1372 | * |
||
| 1373 | * @return array Keys: identifiers, values: HTML contents |
||
| 1374 | * @since 1.25 |
||
| 1375 | */ |
||
| 1376 | public function getIndicators() { |
||
| 1379 | |||
| 1380 | /** |
||
| 1381 | * Adds help link with an icon via page indicators. |
||
| 1382 | * Link target can be overridden by a local message containing a wikilink: |
||
| 1383 | * the message key is: lowercase action or special page name + '-helppage'. |
||
| 1384 | * @param string $to Target MediaWiki.org page title or encoded URL. |
||
| 1385 | * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o. |
||
| 1386 | * @since 1.25 |
||
| 1387 | */ |
||
| 1388 | public function addHelpLink( $to, $overrideBaseUrl = false ) { |
||
| 1411 | |||
| 1412 | /** |
||
| 1413 | * Do not allow scripts which can be modified by wiki users to load on this page; |
||
| 1414 | * only allow scripts bundled with, or generated by, the software. |
||
| 1415 | * Site-wide styles are controlled by a config setting, since they can be |
||
| 1416 | * used to create a custom skin/theme, but not user-specific ones. |
||
| 1417 | * |
||
| 1418 | * @todo this should be given a more accurate name |
||
| 1419 | */ |
||
| 1420 | public function disallowUserJs() { |
||
| 1438 | |||
| 1439 | /** |
||
| 1440 | * Show what level of JavaScript / CSS untrustworthiness is allowed on this page |
||
| 1441 | * @see ResourceLoaderModule::$origin |
||
| 1442 | * @param string $type ResourceLoaderModule TYPE_ constant |
||
| 1443 | * @return int ResourceLoaderModule ORIGIN_ class constant |
||
| 1444 | */ |
||
| 1445 | public function getAllowedModules( $type ) { |
||
| 1454 | |||
| 1455 | /** |
||
| 1456 | * Limit the highest level of CSS/JS untrustworthiness allowed. |
||
| 1457 | * |
||
| 1458 | * If passed the same or a higher level than the current level of untrustworthiness set, the |
||
| 1459 | * level will remain unchanged. |
||
| 1460 | * |
||
| 1461 | * @param string $type |
||
| 1462 | * @param int $level ResourceLoaderModule class constant |
||
| 1463 | */ |
||
| 1464 | public function reduceAllowedModules( $type, $level ) { |
||
| 1467 | |||
| 1468 | /** |
||
| 1469 | * Prepend $text to the body HTML |
||
| 1470 | * |
||
| 1471 | * @param string $text HTML |
||
| 1472 | */ |
||
| 1473 | public function prependHTML( $text ) { |
||
| 1476 | |||
| 1477 | /** |
||
| 1478 | * Append $text to the body HTML |
||
| 1479 | * |
||
| 1480 | * @param string $text HTML |
||
| 1481 | */ |
||
| 1482 | public function addHTML( $text ) { |
||
| 1485 | |||
| 1486 | /** |
||
| 1487 | * Shortcut for adding an Html::element via addHTML. |
||
| 1488 | * |
||
| 1489 | * @since 1.19 |
||
| 1490 | * |
||
| 1491 | * @param string $element |
||
| 1492 | * @param array $attribs |
||
| 1493 | * @param string $contents |
||
| 1494 | */ |
||
| 1495 | public function addElement( $element, array $attribs = [], $contents = '' ) { |
||
| 1498 | |||
| 1499 | /** |
||
| 1500 | * Clear the body HTML |
||
| 1501 | */ |
||
| 1502 | public function clearHTML() { |
||
| 1505 | |||
| 1506 | /** |
||
| 1507 | * Get the body HTML |
||
| 1508 | * |
||
| 1509 | * @return string HTML |
||
| 1510 | */ |
||
| 1511 | public function getHTML() { |
||
| 1514 | |||
| 1515 | /** |
||
| 1516 | * Get/set the ParserOptions object to use for wikitext parsing |
||
| 1517 | * |
||
| 1518 | * @param ParserOptions|null $options Either the ParserOption to use or null to only get the |
||
| 1519 | * current ParserOption object |
||
| 1520 | * @return ParserOptions |
||
| 1521 | */ |
||
| 1522 | public function parserOptions( $options = null ) { |
||
| 1560 | |||
| 1561 | /** |
||
| 1562 | * Set the revision ID which will be seen by the wiki text parser |
||
| 1563 | * for things such as embedded {{REVISIONID}} variable use. |
||
| 1564 | * |
||
| 1565 | * @param int|null $revid An positive integer, or null |
||
| 1566 | * @return mixed Previous value |
||
| 1567 | */ |
||
| 1568 | public function setRevisionId( $revid ) { |
||
| 1572 | |||
| 1573 | /** |
||
| 1574 | * Get the displayed revision ID |
||
| 1575 | * |
||
| 1576 | * @return int |
||
| 1577 | */ |
||
| 1578 | public function getRevisionId() { |
||
| 1581 | |||
| 1582 | /** |
||
| 1583 | * Set the timestamp of the revision which will be displayed. This is used |
||
| 1584 | * to avoid a extra DB call in Skin::lastModified(). |
||
| 1585 | * |
||
| 1586 | * @param string|null $timestamp |
||
| 1587 | * @return mixed Previous value |
||
| 1588 | */ |
||
| 1589 | public function setRevisionTimestamp( $timestamp ) { |
||
| 1592 | |||
| 1593 | /** |
||
| 1594 | * Get the timestamp of displayed revision. |
||
| 1595 | * This will be null if not filled by setRevisionTimestamp(). |
||
| 1596 | * |
||
| 1597 | * @return string|null |
||
| 1598 | */ |
||
| 1599 | public function getRevisionTimestamp() { |
||
| 1602 | |||
| 1603 | /** |
||
| 1604 | * Set the displayed file version |
||
| 1605 | * |
||
| 1606 | * @param File|bool $file |
||
| 1607 | * @return mixed Previous value |
||
| 1608 | */ |
||
| 1609 | public function setFileVersion( $file ) { |
||
| 1616 | |||
| 1617 | /** |
||
| 1618 | * Get the displayed file version |
||
| 1619 | * |
||
| 1620 | * @return array|null ('time' => MW timestamp, 'sha1' => sha1) |
||
| 1621 | */ |
||
| 1622 | public function getFileVersion() { |
||
| 1625 | |||
| 1626 | /** |
||
| 1627 | * Get the templates used on this page |
||
| 1628 | * |
||
| 1629 | * @return array (namespace => dbKey => revId) |
||
| 1630 | * @since 1.18 |
||
| 1631 | */ |
||
| 1632 | public function getTemplateIds() { |
||
| 1635 | |||
| 1636 | /** |
||
| 1637 | * Get the files used on this page |
||
| 1638 | * |
||
| 1639 | * @return array (dbKey => array('time' => MW timestamp or null, 'sha1' => sha1 or '')) |
||
| 1640 | * @since 1.18 |
||
| 1641 | */ |
||
| 1642 | public function getFileSearchOptions() { |
||
| 1645 | |||
| 1646 | /** |
||
| 1647 | * Convert wikitext to HTML and add it to the buffer |
||
| 1648 | * Default assumes that the current page title will be used. |
||
| 1649 | * |
||
| 1650 | * @param string $text |
||
| 1651 | * @param bool $linestart Is this the start of a line? |
||
| 1652 | * @param bool $interface Is this text in the user interface language? |
||
| 1653 | * @throws MWException |
||
| 1654 | */ |
||
| 1655 | public function addWikiText( $text, $linestart = true, $interface = true ) { |
||
| 1662 | |||
| 1663 | /** |
||
| 1664 | * Add wikitext with a custom Title object |
||
| 1665 | * |
||
| 1666 | * @param string $text Wikitext |
||
| 1667 | * @param Title $title |
||
| 1668 | * @param bool $linestart Is this the start of a line? |
||
| 1669 | */ |
||
| 1670 | public function addWikiTextWithTitle( $text, &$title, $linestart = true ) { |
||
| 1673 | |||
| 1674 | /** |
||
| 1675 | * Add wikitext with a custom Title object and tidy enabled. |
||
| 1676 | * |
||
| 1677 | * @param string $text Wikitext |
||
| 1678 | * @param Title $title |
||
| 1679 | * @param bool $linestart Is this the start of a line? |
||
| 1680 | */ |
||
| 1681 | function addWikiTextTitleTidy( $text, &$title, $linestart = true ) { |
||
| 1684 | |||
| 1685 | /** |
||
| 1686 | * Add wikitext with tidy enabled |
||
| 1687 | * |
||
| 1688 | * @param string $text Wikitext |
||
| 1689 | * @param bool $linestart Is this the start of a line? |
||
| 1690 | */ |
||
| 1691 | public function addWikiTextTidy( $text, $linestart = true ) { |
||
| 1695 | |||
| 1696 | /** |
||
| 1697 | * Add wikitext with a custom Title object |
||
| 1698 | * |
||
| 1699 | * @param string $text Wikitext |
||
| 1700 | * @param Title $title |
||
| 1701 | * @param bool $linestart Is this the start of a line? |
||
| 1702 | * @param bool $tidy Whether to use tidy |
||
| 1703 | * @param bool $interface Whether it is an interface message |
||
| 1704 | * (for example disables conversion) |
||
| 1705 | */ |
||
| 1706 | public function addWikiTextTitle( $text, Title $title, $linestart, |
||
| 1725 | |||
| 1726 | /** |
||
| 1727 | * Add a ParserOutput object, but without Html. |
||
| 1728 | * |
||
| 1729 | * @deprecated since 1.24, use addParserOutputMetadata() instead. |
||
| 1730 | * @param ParserOutput $parserOutput |
||
| 1731 | */ |
||
| 1732 | public function addParserOutputNoText( $parserOutput ) { |
||
| 1736 | |||
| 1737 | /** |
||
| 1738 | * Add all metadata associated with a ParserOutput object, but without the actual HTML. This |
||
| 1739 | * includes categories, language links, ResourceLoader modules, effects of certain magic words, |
||
| 1740 | * and so on. |
||
| 1741 | * |
||
| 1742 | * @since 1.24 |
||
| 1743 | * @param ParserOutput $parserOutput |
||
| 1744 | */ |
||
| 1745 | public function addParserOutputMetadata( $parserOutput ) { |
||
| 1800 | |||
| 1801 | /** |
||
| 1802 | * Add the HTML and enhancements for it (like ResourceLoader modules) associated with a |
||
| 1803 | * ParserOutput object, without any other metadata. |
||
| 1804 | * |
||
| 1805 | * @since 1.24 |
||
| 1806 | * @param ParserOutput $parserOutput |
||
| 1807 | */ |
||
| 1808 | public function addParserOutputContent( $parserOutput ) { |
||
| 1817 | |||
| 1818 | /** |
||
| 1819 | * Add the HTML associated with a ParserOutput object, without any metadata. |
||
| 1820 | * |
||
| 1821 | * @since 1.24 |
||
| 1822 | * @param ParserOutput $parserOutput |
||
| 1823 | */ |
||
| 1824 | public function addParserOutputText( $parserOutput ) { |
||
| 1829 | |||
| 1830 | /** |
||
| 1831 | * Add everything from a ParserOutput object. |
||
| 1832 | * |
||
| 1833 | * @param ParserOutput $parserOutput |
||
| 1834 | */ |
||
| 1835 | function addParserOutput( $parserOutput ) { |
||
| 1846 | |||
| 1847 | /** |
||
| 1848 | * Add the output of a QuickTemplate to the output buffer |
||
| 1849 | * |
||
| 1850 | * @param QuickTemplate $template |
||
| 1851 | */ |
||
| 1852 | public function addTemplate( &$template ) { |
||
| 1855 | |||
| 1856 | /** |
||
| 1857 | * Parse wikitext and return the HTML. |
||
| 1858 | * |
||
| 1859 | * @param string $text |
||
| 1860 | * @param bool $linestart Is this the start of a line? |
||
| 1861 | * @param bool $interface Use interface language ($wgLang instead of |
||
| 1862 | * $wgContLang) while parsing language sensitive magic words like GRAMMAR and PLURAL. |
||
| 1863 | * This also disables LanguageConverter. |
||
| 1864 | * @param Language $language Target language object, will override $interface |
||
| 1865 | * @throws MWException |
||
| 1866 | * @return string HTML |
||
| 1867 | */ |
||
| 1868 | public function parse( $text, $linestart = true, $interface = false, $language = null ) { |
||
| 1897 | |||
| 1898 | /** |
||
| 1899 | * Parse wikitext, strip paragraphs, and return the HTML. |
||
| 1900 | * |
||
| 1901 | * @param string $text |
||
| 1902 | * @param bool $linestart Is this the start of a line? |
||
| 1903 | * @param bool $interface Use interface language ($wgLang instead of |
||
| 1904 | * $wgContLang) while parsing language sensitive magic |
||
| 1905 | * words like GRAMMAR and PLURAL |
||
| 1906 | * @return string HTML |
||
| 1907 | */ |
||
| 1908 | public function parseInline( $text, $linestart = true, $interface = false ) { |
||
| 1912 | |||
| 1913 | /** |
||
| 1914 | * @param $maxage |
||
| 1915 | * @deprecated since 1.27 Use setCdnMaxage() instead |
||
| 1916 | */ |
||
| 1917 | public function setSquidMaxage( $maxage ) { |
||
| 1920 | |||
| 1921 | /** |
||
| 1922 | * Set the value of the "s-maxage" part of the "Cache-control" HTTP header |
||
| 1923 | * |
||
| 1924 | * @param int $maxage Maximum cache time on the CDN, in seconds. |
||
| 1925 | */ |
||
| 1926 | public function setCdnMaxage( $maxage ) { |
||
| 1929 | |||
| 1930 | /** |
||
| 1931 | * Lower the value of the "s-maxage" part of the "Cache-control" HTTP header |
||
| 1932 | * |
||
| 1933 | * @param int $maxage Maximum cache time on the CDN, in seconds |
||
| 1934 | * @since 1.27 |
||
| 1935 | */ |
||
| 1936 | public function lowerCdnMaxage( $maxage ) { |
||
| 1940 | |||
| 1941 | /** |
||
| 1942 | * Use enableClientCache(false) to force it to send nocache headers |
||
| 1943 | * |
||
| 1944 | * @param bool $state |
||
| 1945 | * |
||
| 1946 | * @return bool |
||
| 1947 | */ |
||
| 1948 | public function enableClientCache( $state ) { |
||
| 1951 | |||
| 1952 | /** |
||
| 1953 | * Get the list of cookies that will influence on the cache |
||
| 1954 | * |
||
| 1955 | * @return array |
||
| 1956 | */ |
||
| 1957 | function getCacheVaryCookies() { |
||
| 1972 | |||
| 1973 | /** |
||
| 1974 | * Check if the request has a cache-varying cookie header |
||
| 1975 | * If it does, it's very important that we don't allow public caching |
||
| 1976 | * |
||
| 1977 | * @return bool |
||
| 1978 | */ |
||
| 1979 | function haveCacheVaryCookies() { |
||
| 1990 | |||
| 1991 | /** |
||
| 1992 | * Add an HTTP header that will influence on the cache |
||
| 1993 | * |
||
| 1994 | * @param string $header Header name |
||
| 1995 | * @param string[]|null $option Options for the Key header. See |
||
| 1996 | * https://datatracker.ietf.org/doc/draft-fielding-http-key/ |
||
| 1997 | * for the list of valid options. |
||
| 1998 | */ |
||
| 1999 | public function addVaryHeader( $header, array $option = null ) { |
||
| 2008 | |||
| 2009 | /** |
||
| 2010 | * Return a Vary: header on which to vary caches. Based on the keys of $mVaryHeader, |
||
| 2011 | * such as Accept-Encoding or Cookie |
||
| 2012 | * |
||
| 2013 | * @return string |
||
| 2014 | */ |
||
| 2015 | public function getVaryHeader() { |
||
| 2026 | |||
| 2027 | /** |
||
| 2028 | * Get a complete Key header |
||
| 2029 | * |
||
| 2030 | * @return string |
||
| 2031 | */ |
||
| 2032 | public function getKeyHeader() { |
||
| 2057 | |||
| 2058 | /** |
||
| 2059 | * T23672: Add Accept-Language to Vary and Key headers |
||
| 2060 | * if there's no 'variant' parameter existed in GET. |
||
| 2061 | * |
||
| 2062 | * For example: |
||
| 2063 | * /w/index.php?title=Main_page should always be served; but |
||
| 2064 | * /w/index.php?title=Main_page&variant=zh-cn should never be served. |
||
| 2065 | */ |
||
| 2066 | function addAcceptLanguage() { |
||
| 2094 | |||
| 2095 | /** |
||
| 2096 | * Set a flag which will cause an X-Frame-Options header appropriate for |
||
| 2097 | * edit pages to be sent. The header value is controlled by |
||
| 2098 | * $wgEditPageFrameOptions. |
||
| 2099 | * |
||
| 2100 | * This is the default for special pages. If you display a CSRF-protected |
||
| 2101 | * form on an ordinary view page, then you need to call this function. |
||
| 2102 | * |
||
| 2103 | * @param bool $enable |
||
| 2104 | */ |
||
| 2105 | public function preventClickjacking( $enable = true ) { |
||
| 2108 | |||
| 2109 | /** |
||
| 2110 | * Turn off frame-breaking. Alias for $this->preventClickjacking(false). |
||
| 2111 | * This can be called from pages which do not contain any CSRF-protected |
||
| 2112 | * HTML form. |
||
| 2113 | */ |
||
| 2114 | public function allowClickjacking() { |
||
| 2117 | |||
| 2118 | /** |
||
| 2119 | * Get the prevent-clickjacking flag |
||
| 2120 | * |
||
| 2121 | * @since 1.24 |
||
| 2122 | * @return bool |
||
| 2123 | */ |
||
| 2124 | public function getPreventClickjacking() { |
||
| 2127 | |||
| 2128 | /** |
||
| 2129 | * Get the X-Frame-Options header value (without the name part), or false |
||
| 2130 | * if there isn't one. This is used by Skin to determine whether to enable |
||
| 2131 | * JavaScript frame-breaking, for clients that don't support X-Frame-Options. |
||
| 2132 | * |
||
| 2133 | * @return string |
||
| 2134 | */ |
||
| 2135 | public function getFrameOptions() { |
||
| 2144 | |||
| 2145 | /** |
||
| 2146 | * Send cache control HTTP headers |
||
| 2147 | */ |
||
| 2148 | public function sendCacheControl() { |
||
| 2213 | |||
| 2214 | /** |
||
| 2215 | * Finally, all the text has been munged and accumulated into |
||
| 2216 | * the object, let's actually output it: |
||
| 2217 | */ |
||
| 2218 | public function output() { |
||
| 2329 | |||
| 2330 | /** |
||
| 2331 | * Prepare this object to display an error page; disable caching and |
||
| 2332 | * indexing, clear the current text and redirect, set the page's title |
||
| 2333 | * and optionally an custom HTML title (content of the "<title>" tag). |
||
| 2334 | * |
||
| 2335 | * @param string|Message $pageTitle Will be passed directly to setPageTitle() |
||
| 2336 | * @param string|Message $htmlTitle Will be passed directly to setHTMLTitle(); |
||
| 2337 | * optional, if not passed the "<title>" attribute will be |
||
| 2338 | * based on $pageTitle |
||
| 2339 | */ |
||
| 2340 | public function prepareErrorPage( $pageTitle, $htmlTitle = false ) { |
||
| 2352 | |||
| 2353 | /** |
||
| 2354 | * Output a standard error page |
||
| 2355 | * |
||
| 2356 | * showErrorPage( 'titlemsg', 'pagetextmsg' ); |
||
| 2357 | * showErrorPage( 'titlemsg', 'pagetextmsg', array( 'param1', 'param2' ) ); |
||
| 2358 | * showErrorPage( 'titlemsg', $messageObject ); |
||
| 2359 | * showErrorPage( $titleMessageObject, $messageObject ); |
||
| 2360 | * |
||
| 2361 | * @param string|Message $title Message key (string) for page title, or a Message object |
||
| 2362 | * @param string|Message $msg Message key (string) for page text, or a Message object |
||
| 2363 | * @param array $params Message parameters; ignored if $msg is a Message object |
||
| 2364 | */ |
||
| 2365 | public function showErrorPage( $title, $msg, $params = [] ) { |
||
| 2385 | |||
| 2386 | /** |
||
| 2387 | * Output a standard permission error page |
||
| 2388 | * |
||
| 2389 | * @param array $errors Error message keys |
||
| 2390 | * @param string $action Action that was denied or null if unknown |
||
| 2391 | */ |
||
| 2392 | public function showPermissionsErrorPage( array $errors, $action = null ) { |
||
| 2457 | |||
| 2458 | /** |
||
| 2459 | * Display an error page indicating that a given version of MediaWiki is |
||
| 2460 | * required to use it |
||
| 2461 | * |
||
| 2462 | * @param mixed $version The version of MediaWiki needed to use the page |
||
| 2463 | */ |
||
| 2464 | public function versionRequired( $version ) { |
||
| 2470 | |||
| 2471 | /** |
||
| 2472 | * Format a list of error messages |
||
| 2473 | * |
||
| 2474 | * @param array $errors Array of arrays returned by Title::getUserPermissionsErrors |
||
| 2475 | * @param string $action Action that was denied or null if unknown |
||
| 2476 | * @return string The wikitext error-messages, formatted into a list. |
||
| 2477 | */ |
||
| 2478 | public function formatPermissionsErrorMessage( array $errors, $action = null ) { |
||
| 2507 | |||
| 2508 | /** |
||
| 2509 | * Display a page stating that the Wiki is in read-only mode. |
||
| 2510 | * Should only be called after wfReadOnly() has returned true. |
||
| 2511 | * |
||
| 2512 | * Historically, this function was used to show the source of the page that the user |
||
| 2513 | * was trying to edit and _also_ permissions error messages. The relevant code was |
||
| 2514 | * moved into EditPage in 1.19 (r102024 / d83c2a431c2a) and removed here in 1.25. |
||
| 2515 | * |
||
| 2516 | * @deprecated since 1.25; throw the exception directly |
||
| 2517 | * @throws ReadOnlyError |
||
| 2518 | */ |
||
| 2519 | public function readOnlyPage() { |
||
| 2526 | |||
| 2527 | /** |
||
| 2528 | * Turn off regular page output and return an error response |
||
| 2529 | * for when rate limiting has triggered. |
||
| 2530 | * |
||
| 2531 | * @deprecated since 1.25; throw the exception directly |
||
| 2532 | */ |
||
| 2533 | public function rateLimited() { |
||
| 2537 | |||
| 2538 | /** |
||
| 2539 | * Show a warning about slave lag |
||
| 2540 | * |
||
| 2541 | * If the lag is higher than $wgSlaveLagCritical seconds, |
||
| 2542 | * then the warning is a bit more obvious. If the lag is |
||
| 2543 | * lower than $wgSlaveLagWarning, then no warning is shown. |
||
| 2544 | * |
||
| 2545 | * @param int $lag Slave lag |
||
| 2546 | */ |
||
| 2547 | public function showLagWarning( $lag ) { |
||
| 2557 | |||
| 2558 | public function showFatalError( $message ) { |
||
| 2563 | |||
| 2564 | public function showUnexpectedValueError( $name, $val ) { |
||
| 2567 | |||
| 2568 | public function showFileCopyError( $old, $new ) { |
||
| 2571 | |||
| 2572 | public function showFileRenameError( $old, $new ) { |
||
| 2575 | |||
| 2576 | public function showFileDeleteError( $name ) { |
||
| 2579 | |||
| 2580 | public function showFileNotFoundError( $name ) { |
||
| 2583 | |||
| 2584 | /** |
||
| 2585 | * Add a "return to" link pointing to a specified title |
||
| 2586 | * |
||
| 2587 | * @param Title $title Title to link |
||
| 2588 | * @param array $query Query string parameters |
||
| 2589 | * @param string $text Text of the link (input is not escaped) |
||
| 2590 | * @param array $options Options array to pass to Linker |
||
| 2591 | */ |
||
| 2592 | public function addReturnTo( $title, array $query = [], $text = null, $options = [] ) { |
||
| 2597 | |||
| 2598 | /** |
||
| 2599 | * Add a "return to" link pointing to a specified title, |
||
| 2600 | * or the title indicated in the request, or else the main page |
||
| 2601 | * |
||
| 2602 | * @param mixed $unused |
||
| 2603 | * @param Title|string $returnto Title or String to return to |
||
| 2604 | * @param string $returntoquery Query string for the return to link |
||
| 2605 | */ |
||
| 2606 | public function returnToMain( $unused = null, $returnto = null, $returntoquery = null ) { |
||
| 2630 | |||
| 2631 | private function getRlClientContext() { |
||
| 2651 | |||
| 2652 | /** |
||
| 2653 | * Call this to freeze the module queue and JS config and create a formatter. |
||
| 2654 | * |
||
| 2655 | * Depending on the Skin, this may get lazy-initialised in either headElement() or |
||
| 2656 | * getBottomScripts(). See SkinTemplate::prepareQuickTemplate(). Calling this too early may |
||
| 2657 | * cause unexpected side-effects since disallowUserJs() may be called at any time to change |
||
| 2658 | * the module filters retroactively. Skins and extension hooks may also add modules until very |
||
| 2659 | * late in the request lifecycle. |
||
| 2660 | * |
||
| 2661 | * @return ResourceLoaderClientHtml |
||
| 2662 | */ |
||
| 2663 | public function getRlClient() { |
||
| 2728 | |||
| 2729 | /** |
||
| 2730 | * @param Skin $sk The given Skin |
||
| 2731 | * @param bool $includeStyle Unused |
||
| 2732 | * @return string The doctype, opening "<html>", and head element. |
||
| 2733 | */ |
||
| 2734 | public function headElement( Skin $sk, $includeStyle = true ) { |
||
| 2805 | |||
| 2806 | /** |
||
| 2807 | * Get a ResourceLoader object associated with this OutputPage |
||
| 2808 | * |
||
| 2809 | * @return ResourceLoader |
||
| 2810 | */ |
||
| 2811 | public function getResourceLoader() { |
||
| 2820 | |||
| 2821 | /** |
||
| 2822 | * Explicily load or embed modules on a page. |
||
| 2823 | * |
||
| 2824 | * @param array|string $modules One or more module names |
||
| 2825 | * @param string $only ResourceLoaderModule TYPE_ class constant |
||
| 2826 | * @param array $extraQuery [optional] Array with extra query parameters for the request |
||
| 2827 | * @return string|WrappedStringList HTML |
||
| 2828 | */ |
||
| 2829 | public function makeResourceLoaderLink( $modules, $only, array $extraQuery = [] ) { |
||
| 2840 | |||
| 2841 | /** |
||
| 2842 | * Combine WrappedString chunks and filter out empty ones |
||
| 2843 | * |
||
| 2844 | * @param array $chunks |
||
| 2845 | * @return string|WrappedStringList HTML |
||
| 2846 | */ |
||
| 2847 | protected static function combineWrappedStrings( array $chunks ) { |
||
| 2852 | |||
| 2853 | private function isUserJsPreview() { |
||
| 2859 | |||
| 2860 | private function isUserCssPreview() { |
||
| 2866 | |||
| 2867 | /** |
||
| 2868 | * JS stuff to put at the bottom of the `<body>`. These are modules with position 'bottom', |
||
| 2869 | * legacy scripts ($this->mScripts), and user JS. |
||
| 2870 | * |
||
| 2871 | * @return string|WrappedStringList HTML |
||
| 2872 | */ |
||
| 2873 | public function getBottomScripts() { |
||
| 2923 | |||
| 2924 | /** |
||
| 2925 | * Get the javascript config vars to include on this page |
||
| 2926 | * |
||
| 2927 | * @return array Array of javascript config vars |
||
| 2928 | * @since 1.23 |
||
| 2929 | */ |
||
| 2930 | public function getJsConfigVars() { |
||
| 2933 | |||
| 2934 | /** |
||
| 2935 | * Add one or more variables to be set in mw.config in JavaScript |
||
| 2936 | * |
||
| 2937 | * @param string|array $keys Key or array of key/value pairs |
||
| 2938 | * @param mixed $value [optional] Value of the configuration variable |
||
| 2939 | */ |
||
| 2940 | View Code Duplication | public function addJsConfigVars( $keys, $value = null ) { |
|
| 2950 | |||
| 2951 | /** |
||
| 2952 | * Get an array containing the variables to be set in mw.config in JavaScript. |
||
| 2953 | * |
||
| 2954 | * Do not add things here which can be evaluated in ResourceLoaderStartUpModule |
||
| 2955 | * - in other words, page-independent/site-wide variables (without state). |
||
| 2956 | * You will only be adding bloat to the html page and causing page caches to |
||
| 2957 | * have to be purged on configuration changes. |
||
| 2958 | * @return array |
||
| 2959 | */ |
||
| 2960 | public function getJSVars() { |
||
| 3077 | |||
| 3078 | /** |
||
| 3079 | * To make it harder for someone to slip a user a fake |
||
| 3080 | * user-JavaScript or user-CSS preview, a random token |
||
| 3081 | * is associated with the login session. If it's not |
||
| 3082 | * passed back with the preview request, we won't render |
||
| 3083 | * the code. |
||
| 3084 | * |
||
| 3085 | * @return bool |
||
| 3086 | */ |
||
| 3087 | public function userCanPreview() { |
||
| 3123 | |||
| 3124 | /** |
||
| 3125 | * @return array Array in format "link name or number => 'link html'". |
||
| 3126 | */ |
||
| 3127 | public function getHeadLinksArray() { |
||
| 3388 | |||
| 3389 | /** |
||
| 3390 | * @return string HTML tag links to be put in the header. |
||
| 3391 | * @deprecated since 1.24 Use OutputPage::headElement or if you have to, |
||
| 3392 | * OutputPage::getHeadLinksArray directly. |
||
| 3393 | */ |
||
| 3394 | public function getHeadLinks() { |
||
| 3398 | |||
| 3399 | /** |
||
| 3400 | * Generate a "<link rel/>" for a feed. |
||
| 3401 | * |
||
| 3402 | * @param string $type Feed type |
||
| 3403 | * @param string $url URL to the feed |
||
| 3404 | * @param string $text Value of the "title" attribute |
||
| 3405 | * @return string HTML fragment |
||
| 3406 | */ |
||
| 3407 | private function feedLink( $type, $url, $text ) { |
||
| 3415 | |||
| 3416 | /** |
||
| 3417 | * Add a local or specified stylesheet, with the given media options. |
||
| 3418 | * Internal use only. Use OutputPage::addModuleStyles() if possible. |
||
| 3419 | * |
||
| 3420 | * @param string $style URL to the file |
||
| 3421 | * @param string $media To specify a media type, 'screen', 'printable', 'handheld' or any. |
||
| 3422 | * @param string $condition For IE conditional comments, specifying an IE version |
||
| 3423 | * @param string $dir Set to 'rtl' or 'ltr' for direction-specific sheets |
||
| 3424 | */ |
||
| 3425 | public function addStyle( $style, $media = '', $condition = '', $dir = '' ) { |
||
| 3438 | |||
| 3439 | /** |
||
| 3440 | * Adds inline CSS styles |
||
| 3441 | * Internal use only. Use OutputPage::addModuleStyles() if possible. |
||
| 3442 | * |
||
| 3443 | * @param mixed $style_css Inline CSS |
||
| 3444 | * @param string $flip Set to 'flip' to flip the CSS if needed |
||
| 3445 | */ |
||
| 3446 | public function addInlineStyle( $style_css, $flip = 'noflip' ) { |
||
| 3453 | |||
| 3454 | /** |
||
| 3455 | * Build exempt modules and legacy non-ResourceLoader styles. |
||
| 3456 | * |
||
| 3457 | * @return string|WrappedStringList HTML |
||
| 3458 | */ |
||
| 3459 | protected function buildExemptModules() { |
||
| 3508 | |||
| 3509 | /** |
||
| 3510 | * @return array |
||
| 3511 | */ |
||
| 3512 | public function buildCssLinksArray() { |
||
| 3529 | |||
| 3530 | /** |
||
| 3531 | * Generate \<link\> tags for stylesheets |
||
| 3532 | * |
||
| 3533 | * @param string $style URL to the file |
||
| 3534 | * @param array $options Option, can contain 'condition', 'dir', 'media' keys |
||
| 3535 | * @return string HTML fragment |
||
| 3536 | */ |
||
| 3537 | protected function styleLink( $style, array $options ) { |
||
| 3571 | |||
| 3572 | /** |
||
| 3573 | * Transform path to web-accessible static resource. |
||
| 3574 | * |
||
| 3575 | * This is used to add a validation hash as query string. |
||
| 3576 | * This aids various behaviors: |
||
| 3577 | * |
||
| 3578 | * - Put long Cache-Control max-age headers on responses for improved |
||
| 3579 | * cache performance. |
||
| 3580 | * - Get the correct version of a file as expected by the current page. |
||
| 3581 | * - Instantly get the updated version of a file after deployment. |
||
| 3582 | * |
||
| 3583 | * Avoid using this for urls included in HTML as otherwise clients may get different |
||
| 3584 | * versions of a resource when navigating the site depending on when the page was cached. |
||
| 3585 | * If changes to the url propagate, this is not a problem (e.g. if the url is in |
||
| 3586 | * an external stylesheet). |
||
| 3587 | * |
||
| 3588 | * @since 1.27 |
||
| 3589 | * @param Config $config |
||
| 3590 | * @param string $path Path-absolute URL to file (from document root, must start with "/") |
||
| 3591 | * @return string URL |
||
| 3592 | */ |
||
| 3593 | public static function transformResourcePath( Config $config, $path ) { |
||
| 3610 | |||
| 3611 | /** |
||
| 3612 | * Utility method for transformResourceFilePath(). |
||
| 3613 | * |
||
| 3614 | * Caller is responsible for ensuring the file exists. Emits a PHP warning otherwise. |
||
| 3615 | * |
||
| 3616 | * @since 1.27 |
||
| 3617 | * @param string $remotePath URL path prefix that points to $localPath |
||
| 3618 | * @param string $localPath File directory exposed at $remotePath |
||
| 3619 | * @param string $file Path to target file relative to $localPath |
||
| 3620 | * @return string URL |
||
| 3621 | */ |
||
| 3622 | public static function transformFilePath( $remotePathPrefix, $localPath, $file ) { |
||
| 3630 | |||
| 3631 | /** |
||
| 3632 | * Transform "media" attribute based on request parameters |
||
| 3633 | * |
||
| 3634 | * @param string $media Current value of the "media" attribute |
||
| 3635 | * @return string Modified value of the "media" attribute, or null to skip |
||
| 3636 | * this stylesheet |
||
| 3637 | */ |
||
| 3638 | public static function transformCssMedia( $media ) { |
||
| 3676 | |||
| 3677 | /** |
||
| 3678 | * Add a wikitext-formatted message to the output. |
||
| 3679 | * This is equivalent to: |
||
| 3680 | * |
||
| 3681 | * $wgOut->addWikiText( wfMessage( ... )->plain() ) |
||
| 3682 | */ |
||
| 3683 | public function addWikiMsg( /*...*/ ) { |
||
| 3688 | |||
| 3689 | /** |
||
| 3690 | * Add a wikitext-formatted message to the output. |
||
| 3691 | * Like addWikiMsg() except the parameters are taken as an array |
||
| 3692 | * instead of a variable argument list. |
||
| 3693 | * |
||
| 3694 | * @param string $name |
||
| 3695 | * @param array $args |
||
| 3696 | */ |
||
| 3697 | public function addWikiMsgArray( $name, $args ) { |
||
| 3700 | |||
| 3701 | /** |
||
| 3702 | * This function takes a number of message/argument specifications, wraps them in |
||
| 3703 | * some overall structure, and then parses the result and adds it to the output. |
||
| 3704 | * |
||
| 3705 | * In the $wrap, $1 is replaced with the first message, $2 with the second, |
||
| 3706 | * and so on. The subsequent arguments may be either |
||
| 3707 | * 1) strings, in which case they are message names, or |
||
| 3708 | * 2) arrays, in which case, within each array, the first element is the message |
||
| 3709 | * name, and subsequent elements are the parameters to that message. |
||
| 3710 | * |
||
| 3711 | * Don't use this for messages that are not in the user's interface language. |
||
| 3712 | * |
||
| 3713 | * For example: |
||
| 3714 | * |
||
| 3715 | * $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>", 'some-error' ); |
||
| 3716 | * |
||
| 3717 | * Is equivalent to: |
||
| 3718 | * |
||
| 3719 | * $wgOut->addWikiText( "<div class='error'>\n" |
||
| 3720 | * . wfMessage( 'some-error' )->plain() . "\n</div>" ); |
||
| 3721 | * |
||
| 3722 | * The newline after the opening div is needed in some wikitext. See bug 19226. |
||
| 3723 | * |
||
| 3724 | * @param string $wrap |
||
| 3725 | */ |
||
| 3726 | public function wrapWikiMsg( $wrap /*, ...*/ ) { |
||
| 3750 | |||
| 3751 | /** |
||
| 3752 | * Enables/disables TOC, doesn't override __NOTOC__ |
||
| 3753 | * @param bool $flag |
||
| 3754 | * @since 1.22 |
||
| 3755 | */ |
||
| 3756 | public function enableTOC( $flag = true ) { |
||
| 3759 | |||
| 3760 | /** |
||
| 3761 | * @return bool |
||
| 3762 | * @since 1.22 |
||
| 3763 | */ |
||
| 3764 | public function isTOCEnabled() { |
||
| 3767 | |||
| 3768 | /** |
||
| 3769 | * Enables/disables section edit links, doesn't override __NOEDITSECTION__ |
||
| 3770 | * @param bool $flag |
||
| 3771 | * @since 1.23 |
||
| 3772 | */ |
||
| 3773 | public function enableSectionEditLinks( $flag = true ) { |
||
| 3776 | |||
| 3777 | /** |
||
| 3778 | * @return bool |
||
| 3779 | * @since 1.23 |
||
| 3780 | */ |
||
| 3781 | public function sectionEditLinksEnabled() { |
||
| 3784 | |||
| 3785 | /** |
||
| 3786 | * Helper function to setup the PHP implementation of OOUI to use in this request. |
||
| 3787 | * |
||
| 3788 | * @since 1.26 |
||
| 3789 | * @param String $skinName The Skin name to determine the correct OOUI theme |
||
| 3790 | * @param String $dir Language direction |
||
| 3791 | */ |
||
| 3792 | public static function setupOOUI( $skinName = '', $dir = 'ltr' ) { |
||
| 3802 | |||
| 3803 | /** |
||
| 3804 | * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with |
||
| 3805 | * MediaWiki and this OutputPage instance. |
||
| 3806 | * |
||
| 3807 | * @since 1.25 |
||
| 3808 | */ |
||
| 3809 | public function enableOOUI() { |
||
| 3822 | |||
| 3823 | /** |
||
| 3824 | * @param array $data Data from ParserOutput::getLimitReportData() |
||
| 3825 | * @since 1.28 |
||
| 3826 | */ |
||
| 3827 | public function setLimitReportData( array $data ) { |
||
| 3830 | } |
||
| 3831 |
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.