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 | /** @var string Stores contents of "<title>" tag */ |
||
| 71 | private $mHTMLtitle = ''; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var bool Is the displayed content related to the source of the |
||
| 75 | * corresponding wiki article. |
||
| 76 | */ |
||
| 77 | private $mIsarticle = false; |
||
| 78 | |||
| 79 | /** @var bool Stores "article flag" toggle. */ |
||
| 80 | private $mIsArticleRelated = true; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @var bool We have to set isPrintable(). Some pages should |
||
| 84 | * never be printed (ex: redirections). |
||
| 85 | */ |
||
| 86 | private $mPrintable = false; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @var array Contains the page subtitle. Special pages usually have some |
||
| 90 | * links here. Don't confuse with site subtitle added by skins. |
||
| 91 | */ |
||
| 92 | private $mSubtitle = []; |
||
| 93 | |||
| 94 | /** @var string */ |
||
| 95 | public $mRedirect = ''; |
||
| 96 | |||
| 97 | /** @var int */ |
||
| 98 | protected $mStatusCode; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @var string Used for sending cache control. |
||
| 102 | * The whole caching system should probably be moved into its own class. |
||
| 103 | */ |
||
| 104 | protected $mLastModified = ''; |
||
| 105 | |||
| 106 | /** @var array */ |
||
| 107 | protected $mCategoryLinks = []; |
||
| 108 | |||
| 109 | /** @var array */ |
||
| 110 | protected $mCategories = []; |
||
| 111 | |||
| 112 | /** @var array */ |
||
| 113 | protected $mIndicators = []; |
||
| 114 | |||
| 115 | /** @var array Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page') */ |
||
| 116 | private $mLanguageLinks = []; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * Used for JavaScript (predates ResourceLoader) |
||
| 120 | * @todo We should split JS / CSS. |
||
| 121 | * mScripts content is inserted as is in "<head>" by Skin. This might |
||
| 122 | * contain either a link to a stylesheet or inline CSS. |
||
| 123 | */ |
||
| 124 | private $mScripts = ''; |
||
| 125 | |||
| 126 | /** @var string Inline CSS styles. Use addInlineStyle() sparingly */ |
||
| 127 | protected $mInlineStyles = ''; |
||
| 128 | |||
| 129 | /** |
||
| 130 | * @var string Used by skin template. |
||
| 131 | * Example: $tpl->set( 'displaytitle', $out->mPageLinkTitle ); |
||
| 132 | */ |
||
| 133 | public $mPageLinkTitle = ''; |
||
| 134 | |||
| 135 | /** @var array Array of elements in "<head>". Parser might add its own headers! */ |
||
| 136 | protected $mHeadItems = []; |
||
| 137 | |||
| 138 | /** @var array */ |
||
| 139 | protected $mModules = []; |
||
| 140 | |||
| 141 | /** @var array */ |
||
| 142 | protected $mModuleScripts = []; |
||
| 143 | |||
| 144 | /** @var array */ |
||
| 145 | protected $mModuleStyles = []; |
||
| 146 | |||
| 147 | /** @var ResourceLoader */ |
||
| 148 | protected $mResourceLoader; |
||
| 149 | |||
| 150 | /** @var ResourceLoaderClientHtml */ |
||
| 151 | private $rlClient; |
||
| 152 | |||
| 153 | /** @var ResourceLoaderContext */ |
||
| 154 | private $rlClientContext; |
||
| 155 | |||
| 156 | /** @var string */ |
||
| 157 | private $rlUserModuleState; |
||
| 158 | |||
| 159 | /** @var array */ |
||
| 160 | private $rlExemptStyleModules; |
||
| 161 | |||
| 162 | /** @var array */ |
||
| 163 | protected $mJsConfigVars = []; |
||
| 164 | |||
| 165 | /** @var array */ |
||
| 166 | protected $mTemplateIds = []; |
||
| 167 | |||
| 168 | /** @var array */ |
||
| 169 | protected $mImageTimeKeys = []; |
||
| 170 | |||
| 171 | /** @var string */ |
||
| 172 | public $mRedirectCode = ''; |
||
| 173 | |||
| 174 | protected $mFeedLinksAppendQuery = null; |
||
| 175 | |||
| 176 | /** @var array |
||
| 177 | * What level of 'untrustworthiness' is allowed in CSS/JS modules loaded on this page? |
||
| 178 | * @see ResourceLoaderModule::$origin |
||
| 179 | * ResourceLoaderModule::ORIGIN_ALL is assumed unless overridden; |
||
| 180 | */ |
||
| 181 | protected $mAllowedModules = [ |
||
| 182 | ResourceLoaderModule::TYPE_COMBINED => ResourceLoaderModule::ORIGIN_ALL, |
||
| 183 | ]; |
||
| 184 | |||
| 185 | /** @var bool Whether output is disabled. If this is true, the 'output' method will do nothing. */ |
||
| 186 | protected $mDoNothing = false; |
||
| 187 | |||
| 188 | // Parser related. |
||
| 189 | |||
| 190 | /** @var int */ |
||
| 191 | protected $mContainsNewMagic = 0; |
||
| 192 | |||
| 193 | /** |
||
| 194 | * lazy initialised, use parserOptions() |
||
| 195 | * @var ParserOptions |
||
| 196 | */ |
||
| 197 | protected $mParserOptions = null; |
||
| 198 | |||
| 199 | /** |
||
| 200 | * Handles the Atom / RSS links. |
||
| 201 | * We probably only support Atom in 2011. |
||
| 202 | * @see $wgAdvertisedFeedTypes |
||
| 203 | */ |
||
| 204 | private $mFeedLinks = []; |
||
| 205 | |||
| 206 | // Gwicke work on squid caching? Roughly from 2003. |
||
| 207 | protected $mEnableClientCache = true; |
||
| 208 | |||
| 209 | /** @var bool Flag if output should only contain the body of the article. */ |
||
| 210 | private $mArticleBodyOnly = false; |
||
| 211 | |||
| 212 | /** @var bool */ |
||
| 213 | protected $mNewSectionLink = false; |
||
| 214 | |||
| 215 | /** @var bool */ |
||
| 216 | protected $mHideNewSectionLink = false; |
||
| 217 | |||
| 218 | /** |
||
| 219 | * @var bool Comes from the parser. This was probably made to load CSS/JS |
||
| 220 | * only if we had "<gallery>". Used directly in CategoryPage.php. |
||
| 221 | * Looks like ResourceLoader can replace this. |
||
| 222 | */ |
||
| 223 | public $mNoGallery = false; |
||
| 224 | |||
| 225 | /** @var string */ |
||
| 226 | private $mPageTitleActionText = ''; |
||
| 227 | |||
| 228 | /** @var int Cache stuff. Looks like mEnableClientCache */ |
||
| 229 | protected $mCdnMaxage = 0; |
||
| 230 | /** @var int Upper limit on mCdnMaxage */ |
||
| 231 | protected $mCdnMaxageLimit = INF; |
||
| 232 | |||
| 233 | /** |
||
| 234 | * @var bool Controls if anti-clickjacking / frame-breaking headers will |
||
| 235 | * be sent. This should be done for pages where edit actions are possible. |
||
| 236 | * Setters: $this->preventClickjacking() and $this->allowClickjacking(). |
||
| 237 | */ |
||
| 238 | protected $mPreventClickjacking = true; |
||
| 239 | |||
| 240 | /** @var int To include the variable {{REVISIONID}} */ |
||
| 241 | private $mRevisionId = null; |
||
| 242 | |||
| 243 | /** @var string */ |
||
| 244 | private $mRevisionTimestamp = null; |
||
| 245 | |||
| 246 | /** @var array */ |
||
| 247 | protected $mFileVersion = null; |
||
| 248 | |||
| 249 | /** |
||
| 250 | * @var array An array of stylesheet filenames (relative from skins path), |
||
| 251 | * with options for CSS media, IE conditions, and RTL/LTR direction. |
||
| 252 | * For internal use; add settings in the skin via $this->addStyle() |
||
| 253 | * |
||
| 254 | * Style again! This seems like a code duplication since we already have |
||
| 255 | * mStyles. This is what makes Open Source amazing. |
||
| 256 | */ |
||
| 257 | protected $styles = []; |
||
| 258 | |||
| 259 | private $mIndexPolicy = 'index'; |
||
| 260 | private $mFollowPolicy = 'follow'; |
||
| 261 | private $mVaryHeader = [ |
||
| 262 | 'Accept-Encoding' => [ 'match=gzip' ], |
||
| 263 | ]; |
||
| 264 | |||
| 265 | /** |
||
| 266 | * If the current page was reached through a redirect, $mRedirectedFrom contains the Title |
||
| 267 | * of the redirect. |
||
| 268 | * |
||
| 269 | * @var Title |
||
| 270 | */ |
||
| 271 | private $mRedirectedFrom = null; |
||
| 272 | |||
| 273 | /** |
||
| 274 | * Additional key => value data |
||
| 275 | */ |
||
| 276 | private $mProperties = []; |
||
| 277 | |||
| 278 | /** |
||
| 279 | * @var string|null ResourceLoader target for load.php links. If null, will be omitted |
||
| 280 | */ |
||
| 281 | private $mTarget = null; |
||
| 282 | |||
| 283 | /** |
||
| 284 | * @var bool Whether parser output should contain table of contents |
||
| 285 | */ |
||
| 286 | private $mEnableTOC = true; |
||
| 287 | |||
| 288 | /** |
||
| 289 | * @var bool Whether parser output should contain section edit links |
||
| 290 | */ |
||
| 291 | private $mEnableSectionEditLinks = true; |
||
| 292 | |||
| 293 | /** |
||
| 294 | * @var string|null The URL to send in a <link> element with rel=copyright |
||
| 295 | */ |
||
| 296 | private $copyrightUrl; |
||
| 297 | |||
| 298 | /** |
||
| 299 | * Constructor for OutputPage. This should not be called directly. |
||
| 300 | * Instead a new RequestContext should be created and it will implicitly create |
||
| 301 | * a OutputPage tied to that context. |
||
| 302 | * @param IContextSource|null $context |
||
| 303 | */ |
||
| 304 | function __construct( IContextSource $context = null ) { |
||
| 312 | |||
| 313 | /** |
||
| 314 | * Redirect to $url rather than displaying the normal page |
||
| 315 | * |
||
| 316 | * @param string $url URL |
||
| 317 | * @param string $responsecode HTTP status code |
||
| 318 | */ |
||
| 319 | public function redirect( $url, $responsecode = '302' ) { |
||
| 324 | |||
| 325 | /** |
||
| 326 | * Get the URL to redirect to, or an empty string if not redirect URL set |
||
| 327 | * |
||
| 328 | * @return string |
||
| 329 | */ |
||
| 330 | public function getRedirect() { |
||
| 333 | |||
| 334 | /** |
||
| 335 | * Set the copyright URL to send with the output. |
||
| 336 | * Empty string to omit, null to reset. |
||
| 337 | * |
||
| 338 | * @since 1.26 |
||
| 339 | * |
||
| 340 | * @param string|null $url |
||
| 341 | */ |
||
| 342 | public function setCopyrightUrl( $url ) { |
||
| 345 | |||
| 346 | /** |
||
| 347 | * Set the HTTP status code to send with the output. |
||
| 348 | * |
||
| 349 | * @param int $statusCode |
||
| 350 | */ |
||
| 351 | public function setStatusCode( $statusCode ) { |
||
| 354 | |||
| 355 | /** |
||
| 356 | * Add a new "<meta>" tag |
||
| 357 | * To add an http-equiv meta tag, precede the name with "http:" |
||
| 358 | * |
||
| 359 | * @param string $name Tag name |
||
| 360 | * @param string $val Tag value |
||
| 361 | */ |
||
| 362 | function addMeta( $name, $val ) { |
||
| 365 | |||
| 366 | /** |
||
| 367 | * Returns the current <meta> tags |
||
| 368 | * |
||
| 369 | * @since 1.25 |
||
| 370 | * @return array |
||
| 371 | */ |
||
| 372 | public function getMetaTags() { |
||
| 375 | |||
| 376 | /** |
||
| 377 | * Add a new \<link\> tag to the page header. |
||
| 378 | * |
||
| 379 | * Note: use setCanonicalUrl() for rel=canonical. |
||
| 380 | * |
||
| 381 | * @param array $linkarr Associative array of attributes. |
||
| 382 | */ |
||
| 383 | function addLink( array $linkarr ) { |
||
| 386 | |||
| 387 | /** |
||
| 388 | * Returns the current <link> tags |
||
| 389 | * |
||
| 390 | * @since 1.25 |
||
| 391 | * @return array |
||
| 392 | */ |
||
| 393 | public function getLinkTags() { |
||
| 396 | |||
| 397 | /** |
||
| 398 | * Add a new \<link\> with "rel" attribute set to "meta" |
||
| 399 | * |
||
| 400 | * @param array $linkarr Associative array mapping attribute names to their |
||
| 401 | * values, both keys and values will be escaped, and the |
||
| 402 | * "rel" attribute will be automatically added |
||
| 403 | */ |
||
| 404 | function addMetadataLink( array $linkarr ) { |
||
| 408 | |||
| 409 | /** |
||
| 410 | * Set the URL to be used for the <link rel=canonical>. This should be used |
||
| 411 | * in preference to addLink(), to avoid duplicate link tags. |
||
| 412 | * @param string $url |
||
| 413 | */ |
||
| 414 | function setCanonicalUrl( $url ) { |
||
| 417 | |||
| 418 | /** |
||
| 419 | * Returns the URL to be used for the <link rel=canonical> if |
||
| 420 | * one is set. |
||
| 421 | * |
||
| 422 | * @since 1.25 |
||
| 423 | * @return bool|string |
||
| 424 | */ |
||
| 425 | public function getCanonicalUrl() { |
||
| 428 | |||
| 429 | /** |
||
| 430 | * Get the value of the "rel" attribute for metadata links |
||
| 431 | * |
||
| 432 | * @return string |
||
| 433 | */ |
||
| 434 | public function getMetadataAttribute() { |
||
| 444 | |||
| 445 | /** |
||
| 446 | * Add raw HTML to the list of scripts (including \<script\> tag, etc.) |
||
| 447 | * Internal use only. Use OutputPage::addModules() or OutputPage::addJsConfigVars() |
||
| 448 | * if possible. |
||
| 449 | * |
||
| 450 | * @param string $script Raw HTML |
||
| 451 | */ |
||
| 452 | function addScript( $script ) { |
||
| 455 | |||
| 456 | /** |
||
| 457 | * Register and add a stylesheet from an extension directory. |
||
| 458 | * |
||
| 459 | * @deprecated since 1.27 use addModuleStyles() or addStyle() instead |
||
| 460 | * @param string $url Path to sheet. Provide either a full url (beginning |
||
| 461 | * with 'http', etc) or a relative path from the document root |
||
| 462 | * (beginning with '/'). Otherwise it behaves identically to |
||
| 463 | * addStyle() and draws from the /skins folder. |
||
| 464 | */ |
||
| 465 | public function addExtensionStyle( $url ) { |
||
| 469 | |||
| 470 | /** |
||
| 471 | * Get all styles added by extensions |
||
| 472 | * |
||
| 473 | * @deprecated since 1.27 |
||
| 474 | * @return array |
||
| 475 | */ |
||
| 476 | function getExtStyle() { |
||
| 480 | |||
| 481 | /** |
||
| 482 | * Add a JavaScript file out of skins/common, or a given relative path. |
||
| 483 | * Internal use only. Use OutputPage::addModules() if possible. |
||
| 484 | * |
||
| 485 | * @param string $file Filename in skins/common or complete on-server path |
||
| 486 | * (/foo/bar.js) |
||
| 487 | * @param string $version Style version of the file. Defaults to $wgStyleVersion |
||
| 488 | */ |
||
| 489 | public function addScriptFile( $file, $version = null ) { |
||
| 501 | |||
| 502 | /** |
||
| 503 | * Add a self-contained script tag with the given contents |
||
| 504 | * Internal use only. Use OutputPage::addModules() if possible. |
||
| 505 | * |
||
| 506 | * @param string $script JavaScript text, no script tags |
||
| 507 | */ |
||
| 508 | public function addInlineScript( $script ) { |
||
| 511 | |||
| 512 | /** |
||
| 513 | * Filter an array of modules to remove insufficiently trustworthy members, and modules |
||
| 514 | * which are no longer registered (eg a page is cached before an extension is disabled) |
||
| 515 | * @param array $modules |
||
| 516 | * @param string|null $position If not null, only return modules with this position |
||
| 517 | * @param string $type |
||
| 518 | * @return array |
||
| 519 | */ |
||
| 520 | protected function filterModules( array $modules, $position = null, |
||
| 537 | |||
| 538 | /** |
||
| 539 | * Get the list of modules to include on this page |
||
| 540 | * |
||
| 541 | * @param bool $filter Whether to filter out insufficiently trustworthy modules |
||
| 542 | * @param string|null $position If not null, only return modules with this position |
||
| 543 | * @param string $param |
||
| 544 | * @return array Array of module names |
||
| 545 | */ |
||
| 546 | public function getModules( $filter = false, $position = null, $param = 'mModules', |
||
| 554 | |||
| 555 | /** |
||
| 556 | * Add one or more modules recognized by ResourceLoader. Modules added |
||
| 557 | * through this function will be loaded by ResourceLoader when the |
||
| 558 | * page loads. |
||
| 559 | * |
||
| 560 | * @param string|array $modules Module name (string) or array of module names |
||
| 561 | */ |
||
| 562 | public function addModules( $modules ) { |
||
| 565 | |||
| 566 | /** |
||
| 567 | * Get the list of module JS to include on this page |
||
| 568 | * |
||
| 569 | * @param bool $filter |
||
| 570 | * @param string|null $position |
||
| 571 | * @return array Array of module names |
||
| 572 | */ |
||
| 573 | public function getModuleScripts( $filter = false, $position = null ) { |
||
| 578 | |||
| 579 | /** |
||
| 580 | * Add only JS of one or more modules recognized by ResourceLoader. Module |
||
| 581 | * scripts added through this function will be loaded by ResourceLoader when |
||
| 582 | * the page loads. |
||
| 583 | * |
||
| 584 | * @param string|array $modules Module name (string) or array of module names |
||
| 585 | */ |
||
| 586 | public function addModuleScripts( $modules ) { |
||
| 589 | |||
| 590 | /** |
||
| 591 | * Get the list of module CSS to include on this page |
||
| 592 | * |
||
| 593 | * @param bool $filter |
||
| 594 | * @param string|null $position |
||
| 595 | * @return array Array of module names |
||
| 596 | */ |
||
| 597 | public function getModuleStyles( $filter = false, $position = null ) { |
||
| 602 | |||
| 603 | /** |
||
| 604 | * Add only CSS of one or more modules recognized by ResourceLoader. |
||
| 605 | * |
||
| 606 | * Module styles added through this function will be added using standard link CSS |
||
| 607 | * tags, rather than as a combined Javascript and CSS package. Thus, they will |
||
| 608 | * load when JavaScript is disabled (unless CSS also happens to be disabled). |
||
| 609 | * |
||
| 610 | * @param string|array $modules Module name (string) or array of module names |
||
| 611 | */ |
||
| 612 | public function addModuleStyles( $modules ) { |
||
| 615 | |||
| 616 | /** |
||
| 617 | * @return null|string ResourceLoader target |
||
| 618 | */ |
||
| 619 | public function getTarget() { |
||
| 622 | |||
| 623 | /** |
||
| 624 | * Sets ResourceLoader target for load.php links. If null, will be omitted |
||
| 625 | * |
||
| 626 | * @param string|null $target |
||
| 627 | */ |
||
| 628 | public function setTarget( $target ) { |
||
| 631 | |||
| 632 | /** |
||
| 633 | * Get an array of head items |
||
| 634 | * |
||
| 635 | * @return array |
||
| 636 | */ |
||
| 637 | function getHeadItemsArray() { |
||
| 640 | |||
| 641 | /** |
||
| 642 | * Add or replace a head item to the output |
||
| 643 | * |
||
| 644 | * Whenever possible, use more specific options like ResourceLoader modules, |
||
| 645 | * OutputPage::addLink(), OutputPage::addMetaLink() and OutputPage::addFeedLink() |
||
| 646 | * Fallback options for those are: OutputPage::addStyle, OutputPage::addScript(), |
||
| 647 | * OutputPage::addInlineScript() and OutputPage::addInlineStyle() |
||
| 648 | * This would be your very LAST fallback. |
||
| 649 | * |
||
| 650 | * @param string $name Item name |
||
| 651 | * @param string $value Raw HTML |
||
| 652 | */ |
||
| 653 | public function addHeadItem( $name, $value ) { |
||
| 656 | |||
| 657 | /** |
||
| 658 | * Add one or more head items to the output |
||
| 659 | * |
||
| 660 | * @since 1.28 |
||
| 661 | * @param string|string[] $value Raw HTML |
||
| 662 | */ |
||
| 663 | public function addHeadItems( $values ) { |
||
| 666 | |||
| 667 | /** |
||
| 668 | * Check if the header item $name is already set |
||
| 669 | * |
||
| 670 | * @param string $name Item name |
||
| 671 | * @return bool |
||
| 672 | */ |
||
| 673 | public function hasHeadItem( $name ) { |
||
| 676 | |||
| 677 | /** |
||
| 678 | * @deprecated since 1.28 Obsolete - wgUseETag experiment was removed. |
||
| 679 | * @param string $tag |
||
| 680 | */ |
||
| 681 | public function setETag( $tag ) { |
||
| 683 | |||
| 684 | /** |
||
| 685 | * Set whether the output should only contain the body of the article, |
||
| 686 | * without any skin, sidebar, etc. |
||
| 687 | * Used e.g. when calling with "action=render". |
||
| 688 | * |
||
| 689 | * @param bool $only Whether to output only the body of the article |
||
| 690 | */ |
||
| 691 | public function setArticleBodyOnly( $only ) { |
||
| 694 | |||
| 695 | /** |
||
| 696 | * Return whether the output will contain only the body of the article |
||
| 697 | * |
||
| 698 | * @return bool |
||
| 699 | */ |
||
| 700 | public function getArticleBodyOnly() { |
||
| 703 | |||
| 704 | /** |
||
| 705 | * Set an additional output property |
||
| 706 | * @since 1.21 |
||
| 707 | * |
||
| 708 | * @param string $name |
||
| 709 | * @param mixed $value |
||
| 710 | */ |
||
| 711 | public function setProperty( $name, $value ) { |
||
| 714 | |||
| 715 | /** |
||
| 716 | * Get an additional output property |
||
| 717 | * @since 1.21 |
||
| 718 | * |
||
| 719 | * @param string $name |
||
| 720 | * @return mixed Property value or null if not found |
||
| 721 | */ |
||
| 722 | public function getProperty( $name ) { |
||
| 729 | |||
| 730 | /** |
||
| 731 | * checkLastModified tells the client to use the client-cached page if |
||
| 732 | * possible. If successful, the OutputPage is disabled so that |
||
| 733 | * any future call to OutputPage->output() have no effect. |
||
| 734 | * |
||
| 735 | * Side effect: sets mLastModified for Last-Modified header |
||
| 736 | * |
||
| 737 | * @param string $timestamp |
||
| 738 | * |
||
| 739 | * @return bool True if cache-ok headers was sent. |
||
| 740 | */ |
||
| 741 | public function checkLastModified( $timestamp ) { |
||
| 821 | |||
| 822 | /** |
||
| 823 | * Override the last modified timestamp |
||
| 824 | * |
||
| 825 | * @param string $timestamp New timestamp, in a format readable by |
||
| 826 | * wfTimestamp() |
||
| 827 | */ |
||
| 828 | public function setLastModified( $timestamp ) { |
||
| 831 | |||
| 832 | /** |
||
| 833 | * Set the robot policy for the page: <http://www.robotstxt.org/meta.html> |
||
| 834 | * |
||
| 835 | * @param string $policy The literal string to output as the contents of |
||
| 836 | * the meta tag. Will be parsed according to the spec and output in |
||
| 837 | * standardized form. |
||
| 838 | * @return null |
||
| 839 | */ |
||
| 840 | public function setRobotPolicy( $policy ) { |
||
| 850 | |||
| 851 | /** |
||
| 852 | * Set the index policy for the page, but leave the follow policy un- |
||
| 853 | * touched. |
||
| 854 | * |
||
| 855 | * @param string $policy Either 'index' or 'noindex'. |
||
| 856 | * @return null |
||
| 857 | */ |
||
| 858 | public function setIndexPolicy( $policy ) { |
||
| 864 | |||
| 865 | /** |
||
| 866 | * Set the follow policy for the page, but leave the index policy un- |
||
| 867 | * touched. |
||
| 868 | * |
||
| 869 | * @param string $policy Either 'follow' or 'nofollow'. |
||
| 870 | * @return null |
||
| 871 | */ |
||
| 872 | public function setFollowPolicy( $policy ) { |
||
| 878 | |||
| 879 | /** |
||
| 880 | * Set the new value of the "action text", this will be added to the |
||
| 881 | * "HTML title", separated from it with " - ". |
||
| 882 | * |
||
| 883 | * @param string $text New value of the "action text" |
||
| 884 | */ |
||
| 885 | public function setPageTitleActionText( $text ) { |
||
| 888 | |||
| 889 | /** |
||
| 890 | * Get the value of the "action text" |
||
| 891 | * |
||
| 892 | * @return string |
||
| 893 | */ |
||
| 894 | public function getPageTitleActionText() { |
||
| 897 | |||
| 898 | /** |
||
| 899 | * "HTML title" means the contents of "<title>". |
||
| 900 | * It is stored as plain, unescaped text and will be run through htmlspecialchars in the skin file. |
||
| 901 | * |
||
| 902 | * @param string|Message $name |
||
| 903 | */ |
||
| 904 | public function setHTMLTitle( $name ) { |
||
| 911 | |||
| 912 | /** |
||
| 913 | * Return the "HTML title", i.e. the content of the "<title>" tag. |
||
| 914 | * |
||
| 915 | * @return string |
||
| 916 | */ |
||
| 917 | public function getHTMLTitle() { |
||
| 920 | |||
| 921 | /** |
||
| 922 | * Set $mRedirectedFrom, the Title of the page which redirected us to the current page. |
||
| 923 | * |
||
| 924 | * @param Title $t |
||
| 925 | */ |
||
| 926 | public function setRedirectedFrom( $t ) { |
||
| 929 | |||
| 930 | /** |
||
| 931 | * "Page title" means the contents of \<h1\>. It is stored as a valid HTML |
||
| 932 | * fragment. This function allows good tags like \<sup\> in the \<h1\> tag, |
||
| 933 | * but not bad tags like \<script\>. This function automatically sets |
||
| 934 | * \<title\> to the same content as \<h1\> but with all tags removed. Bad |
||
| 935 | * tags that were escaped in \<h1\> will still be escaped in \<title\>, and |
||
| 936 | * good tags like \<i\> will be dropped entirely. |
||
| 937 | * |
||
| 938 | * @param string|Message $name |
||
| 939 | */ |
||
| 940 | public function setPageTitle( $name ) { |
||
| 956 | |||
| 957 | /** |
||
| 958 | * Return the "page title", i.e. the content of the \<h1\> tag. |
||
| 959 | * |
||
| 960 | * @return string |
||
| 961 | */ |
||
| 962 | public function getPageTitle() { |
||
| 965 | |||
| 966 | /** |
||
| 967 | * Set the Title object to use |
||
| 968 | * |
||
| 969 | * @param Title $t |
||
| 970 | */ |
||
| 971 | public function setTitle( Title $t ) { |
||
| 974 | |||
| 975 | /** |
||
| 976 | * Replace the subtitle with $str |
||
| 977 | * |
||
| 978 | * @param string|Message $str New value of the subtitle. String should be safe HTML. |
||
| 979 | */ |
||
| 980 | public function setSubtitle( $str ) { |
||
| 984 | |||
| 985 | /** |
||
| 986 | * Add $str to the subtitle |
||
| 987 | * |
||
| 988 | * @param string|Message $str String or Message to add to the subtitle. String should be safe HTML. |
||
| 989 | */ |
||
| 990 | public function addSubtitle( $str ) { |
||
| 997 | |||
| 998 | /** |
||
| 999 | * Build message object for a subtitle containing a backlink to a page |
||
| 1000 | * |
||
| 1001 | * @param Title $title Title to link to |
||
| 1002 | * @param array $query Array of additional parameters to include in the link |
||
| 1003 | * @return Message |
||
| 1004 | * @since 1.25 |
||
| 1005 | */ |
||
| 1006 | public static function buildBacklinkSubtitle( Title $title, $query = [] ) { |
||
| 1013 | |||
| 1014 | /** |
||
| 1015 | * Add a subtitle containing a backlink to a page |
||
| 1016 | * |
||
| 1017 | * @param Title $title Title to link to |
||
| 1018 | * @param array $query Array of additional parameters to include in the link |
||
| 1019 | */ |
||
| 1020 | public function addBacklinkSubtitle( Title $title, $query = [] ) { |
||
| 1023 | |||
| 1024 | /** |
||
| 1025 | * Clear the subtitles |
||
| 1026 | */ |
||
| 1027 | public function clearSubtitle() { |
||
| 1030 | |||
| 1031 | /** |
||
| 1032 | * Get the subtitle |
||
| 1033 | * |
||
| 1034 | * @return string |
||
| 1035 | */ |
||
| 1036 | public function getSubtitle() { |
||
| 1039 | |||
| 1040 | /** |
||
| 1041 | * Set the page as printable, i.e. it'll be displayed with all |
||
| 1042 | * print styles included |
||
| 1043 | */ |
||
| 1044 | public function setPrintable() { |
||
| 1047 | |||
| 1048 | /** |
||
| 1049 | * Return whether the page is "printable" |
||
| 1050 | * |
||
| 1051 | * @return bool |
||
| 1052 | */ |
||
| 1053 | public function isPrintable() { |
||
| 1056 | |||
| 1057 | /** |
||
| 1058 | * Disable output completely, i.e. calling output() will have no effect |
||
| 1059 | */ |
||
| 1060 | public function disable() { |
||
| 1063 | |||
| 1064 | /** |
||
| 1065 | * Return whether the output will be completely disabled |
||
| 1066 | * |
||
| 1067 | * @return bool |
||
| 1068 | */ |
||
| 1069 | public function isDisabled() { |
||
| 1072 | |||
| 1073 | /** |
||
| 1074 | * Show an "add new section" link? |
||
| 1075 | * |
||
| 1076 | * @return bool |
||
| 1077 | */ |
||
| 1078 | public function showNewSectionLink() { |
||
| 1081 | |||
| 1082 | /** |
||
| 1083 | * Forcibly hide the new section link? |
||
| 1084 | * |
||
| 1085 | * @return bool |
||
| 1086 | */ |
||
| 1087 | public function forceHideNewSectionLink() { |
||
| 1090 | |||
| 1091 | /** |
||
| 1092 | * Add or remove feed links in the page header |
||
| 1093 | * This is mainly kept for backward compatibility, see OutputPage::addFeedLink() |
||
| 1094 | * for the new version |
||
| 1095 | * @see addFeedLink() |
||
| 1096 | * |
||
| 1097 | * @param bool $show True: add default feeds, false: remove all feeds |
||
| 1098 | */ |
||
| 1099 | public function setSyndicated( $show = true ) { |
||
| 1106 | |||
| 1107 | /** |
||
| 1108 | * Add default feeds to the page header |
||
| 1109 | * This is mainly kept for backward compatibility, see OutputPage::addFeedLink() |
||
| 1110 | * for the new version |
||
| 1111 | * @see addFeedLink() |
||
| 1112 | * |
||
| 1113 | * @param string $val Query to append to feed links or false to output |
||
| 1114 | * default links |
||
| 1115 | */ |
||
| 1116 | public function setFeedAppendQuery( $val ) { |
||
| 1127 | |||
| 1128 | /** |
||
| 1129 | * Add a feed link to the page header |
||
| 1130 | * |
||
| 1131 | * @param string $format Feed type, should be a key of $wgFeedClasses |
||
| 1132 | * @param string $href URL |
||
| 1133 | */ |
||
| 1134 | public function addFeedLink( $format, $href ) { |
||
| 1139 | |||
| 1140 | /** |
||
| 1141 | * Should we output feed links for this page? |
||
| 1142 | * @return bool |
||
| 1143 | */ |
||
| 1144 | public function isSyndicated() { |
||
| 1147 | |||
| 1148 | /** |
||
| 1149 | * Return URLs for each supported syndication format for this page. |
||
| 1150 | * @return array Associating format keys with URLs |
||
| 1151 | */ |
||
| 1152 | public function getSyndicationLinks() { |
||
| 1155 | |||
| 1156 | /** |
||
| 1157 | * Will currently always return null |
||
| 1158 | * |
||
| 1159 | * @return null |
||
| 1160 | */ |
||
| 1161 | public function getFeedAppendQuery() { |
||
| 1164 | |||
| 1165 | /** |
||
| 1166 | * Set whether the displayed content is related to the source of the |
||
| 1167 | * corresponding article on the wiki |
||
| 1168 | * Setting true will cause the change "article related" toggle to true |
||
| 1169 | * |
||
| 1170 | * @param bool $v |
||
| 1171 | */ |
||
| 1172 | public function setArticleFlag( $v ) { |
||
| 1178 | |||
| 1179 | /** |
||
| 1180 | * Return whether the content displayed page is related to the source of |
||
| 1181 | * the corresponding article on the wiki |
||
| 1182 | * |
||
| 1183 | * @return bool |
||
| 1184 | */ |
||
| 1185 | public function isArticle() { |
||
| 1188 | |||
| 1189 | /** |
||
| 1190 | * Set whether this page is related an article on the wiki |
||
| 1191 | * Setting false will cause the change of "article flag" toggle to false |
||
| 1192 | * |
||
| 1193 | * @param bool $v |
||
| 1194 | */ |
||
| 1195 | public function setArticleRelated( $v ) { |
||
| 1201 | |||
| 1202 | /** |
||
| 1203 | * Return whether this page is related an article on the wiki |
||
| 1204 | * |
||
| 1205 | * @return bool |
||
| 1206 | */ |
||
| 1207 | public function isArticleRelated() { |
||
| 1210 | |||
| 1211 | /** |
||
| 1212 | * Add new language links |
||
| 1213 | * |
||
| 1214 | * @param string[] $newLinkArray Array of interwiki-prefixed (non DB key) titles |
||
| 1215 | * (e.g. 'fr:Test page') |
||
| 1216 | */ |
||
| 1217 | public function addLanguageLinks( array $newLinkArray ) { |
||
| 1220 | |||
| 1221 | /** |
||
| 1222 | * Reset the language links and add new language links |
||
| 1223 | * |
||
| 1224 | * @param string[] $newLinkArray Array of interwiki-prefixed (non DB key) titles |
||
| 1225 | * (e.g. 'fr:Test page') |
||
| 1226 | */ |
||
| 1227 | public function setLanguageLinks( array $newLinkArray ) { |
||
| 1230 | |||
| 1231 | /** |
||
| 1232 | * Get the list of language links |
||
| 1233 | * |
||
| 1234 | * @return string[] Array of interwiki-prefixed (non DB key) titles (e.g. 'fr:Test page') |
||
| 1235 | */ |
||
| 1236 | public function getLanguageLinks() { |
||
| 1239 | |||
| 1240 | /** |
||
| 1241 | * Add an array of categories, with names in the keys |
||
| 1242 | * |
||
| 1243 | * @param array $categories Mapping category name => sort key |
||
| 1244 | */ |
||
| 1245 | public function addCategoryLinks( array $categories ) { |
||
| 1311 | |||
| 1312 | /** |
||
| 1313 | * Reset the category links (but not the category list) and add $categories |
||
| 1314 | * |
||
| 1315 | * @param array $categories Mapping category name => sort key |
||
| 1316 | */ |
||
| 1317 | public function setCategoryLinks( array $categories ) { |
||
| 1321 | |||
| 1322 | /** |
||
| 1323 | * Get the list of category links, in a 2-D array with the following format: |
||
| 1324 | * $arr[$type][] = $link, where $type is either "normal" or "hidden" (for |
||
| 1325 | * hidden categories) and $link a HTML fragment with a link to the category |
||
| 1326 | * page |
||
| 1327 | * |
||
| 1328 | * @return array |
||
| 1329 | */ |
||
| 1330 | public function getCategoryLinks() { |
||
| 1333 | |||
| 1334 | /** |
||
| 1335 | * Get the list of category names this page belongs to |
||
| 1336 | * |
||
| 1337 | * @return array Array of strings |
||
| 1338 | */ |
||
| 1339 | public function getCategories() { |
||
| 1342 | |||
| 1343 | /** |
||
| 1344 | * Add an array of indicators, with their identifiers as array |
||
| 1345 | * keys and HTML contents as values. |
||
| 1346 | * |
||
| 1347 | * In case of duplicate keys, existing values are overwritten. |
||
| 1348 | * |
||
| 1349 | * @param array $indicators |
||
| 1350 | * @since 1.25 |
||
| 1351 | */ |
||
| 1352 | public function setIndicators( array $indicators ) { |
||
| 1357 | |||
| 1358 | /** |
||
| 1359 | * Get the indicators associated with this page. |
||
| 1360 | * |
||
| 1361 | * The array will be internally ordered by item keys. |
||
| 1362 | * |
||
| 1363 | * @return array Keys: identifiers, values: HTML contents |
||
| 1364 | * @since 1.25 |
||
| 1365 | */ |
||
| 1366 | public function getIndicators() { |
||
| 1369 | |||
| 1370 | /** |
||
| 1371 | * Adds help link with an icon via page indicators. |
||
| 1372 | * Link target can be overridden by a local message containing a wikilink: |
||
| 1373 | * the message key is: lowercase action or special page name + '-helppage'. |
||
| 1374 | * @param string $to Target MediaWiki.org page title or encoded URL. |
||
| 1375 | * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o. |
||
| 1376 | * @since 1.25 |
||
| 1377 | */ |
||
| 1378 | public function addHelpLink( $to, $overrideBaseUrl = false ) { |
||
| 1401 | |||
| 1402 | /** |
||
| 1403 | * Do not allow scripts which can be modified by wiki users to load on this page; |
||
| 1404 | * only allow scripts bundled with, or generated by, the software. |
||
| 1405 | * Site-wide styles are controlled by a config setting, since they can be |
||
| 1406 | * used to create a custom skin/theme, but not user-specific ones. |
||
| 1407 | * |
||
| 1408 | * @todo this should be given a more accurate name |
||
| 1409 | */ |
||
| 1410 | public function disallowUserJs() { |
||
| 1428 | |||
| 1429 | /** |
||
| 1430 | * Show what level of JavaScript / CSS untrustworthiness is allowed on this page |
||
| 1431 | * @see ResourceLoaderModule::$origin |
||
| 1432 | * @param string $type ResourceLoaderModule TYPE_ constant |
||
| 1433 | * @return int ResourceLoaderModule ORIGIN_ class constant |
||
| 1434 | */ |
||
| 1435 | public function getAllowedModules( $type ) { |
||
| 1444 | |||
| 1445 | /** |
||
| 1446 | * Limit the highest level of CSS/JS untrustworthiness allowed. |
||
| 1447 | * |
||
| 1448 | * If passed the same or a higher level than the current level of untrustworthiness set, the |
||
| 1449 | * level will remain unchanged. |
||
| 1450 | * |
||
| 1451 | * @param string $type |
||
| 1452 | * @param int $level ResourceLoaderModule class constant |
||
| 1453 | */ |
||
| 1454 | public function reduceAllowedModules( $type, $level ) { |
||
| 1457 | |||
| 1458 | /** |
||
| 1459 | * Prepend $text to the body HTML |
||
| 1460 | * |
||
| 1461 | * @param string $text HTML |
||
| 1462 | */ |
||
| 1463 | public function prependHTML( $text ) { |
||
| 1466 | |||
| 1467 | /** |
||
| 1468 | * Append $text to the body HTML |
||
| 1469 | * |
||
| 1470 | * @param string $text HTML |
||
| 1471 | */ |
||
| 1472 | public function addHTML( $text ) { |
||
| 1475 | |||
| 1476 | /** |
||
| 1477 | * Shortcut for adding an Html::element via addHTML. |
||
| 1478 | * |
||
| 1479 | * @since 1.19 |
||
| 1480 | * |
||
| 1481 | * @param string $element |
||
| 1482 | * @param array $attribs |
||
| 1483 | * @param string $contents |
||
| 1484 | */ |
||
| 1485 | public function addElement( $element, array $attribs = [], $contents = '' ) { |
||
| 1488 | |||
| 1489 | /** |
||
| 1490 | * Clear the body HTML |
||
| 1491 | */ |
||
| 1492 | public function clearHTML() { |
||
| 1495 | |||
| 1496 | /** |
||
| 1497 | * Get the body HTML |
||
| 1498 | * |
||
| 1499 | * @return string HTML |
||
| 1500 | */ |
||
| 1501 | public function getHTML() { |
||
| 1504 | |||
| 1505 | /** |
||
| 1506 | * Get/set the ParserOptions object to use for wikitext parsing |
||
| 1507 | * |
||
| 1508 | * @param ParserOptions|null $options Either the ParserOption to use or null to only get the |
||
| 1509 | * current ParserOption object |
||
| 1510 | * @return ParserOptions |
||
| 1511 | */ |
||
| 1512 | public function parserOptions( $options = null ) { |
||
| 1550 | |||
| 1551 | /** |
||
| 1552 | * Set the revision ID which will be seen by the wiki text parser |
||
| 1553 | * for things such as embedded {{REVISIONID}} variable use. |
||
| 1554 | * |
||
| 1555 | * @param int|null $revid An positive integer, or null |
||
| 1556 | * @return mixed Previous value |
||
| 1557 | */ |
||
| 1558 | public function setRevisionId( $revid ) { |
||
| 1562 | |||
| 1563 | /** |
||
| 1564 | * Get the displayed revision ID |
||
| 1565 | * |
||
| 1566 | * @return int |
||
| 1567 | */ |
||
| 1568 | public function getRevisionId() { |
||
| 1571 | |||
| 1572 | /** |
||
| 1573 | * Set the timestamp of the revision which will be displayed. This is used |
||
| 1574 | * to avoid a extra DB call in Skin::lastModified(). |
||
| 1575 | * |
||
| 1576 | * @param string|null $timestamp |
||
| 1577 | * @return mixed Previous value |
||
| 1578 | */ |
||
| 1579 | public function setRevisionTimestamp( $timestamp ) { |
||
| 1582 | |||
| 1583 | /** |
||
| 1584 | * Get the timestamp of displayed revision. |
||
| 1585 | * This will be null if not filled by setRevisionTimestamp(). |
||
| 1586 | * |
||
| 1587 | * @return string|null |
||
| 1588 | */ |
||
| 1589 | public function getRevisionTimestamp() { |
||
| 1592 | |||
| 1593 | /** |
||
| 1594 | * Set the displayed file version |
||
| 1595 | * |
||
| 1596 | * @param File|bool $file |
||
| 1597 | * @return mixed Previous value |
||
| 1598 | */ |
||
| 1599 | public function setFileVersion( $file ) { |
||
| 1606 | |||
| 1607 | /** |
||
| 1608 | * Get the displayed file version |
||
| 1609 | * |
||
| 1610 | * @return array|null ('time' => MW timestamp, 'sha1' => sha1) |
||
| 1611 | */ |
||
| 1612 | public function getFileVersion() { |
||
| 1615 | |||
| 1616 | /** |
||
| 1617 | * Get the templates used on this page |
||
| 1618 | * |
||
| 1619 | * @return array (namespace => dbKey => revId) |
||
| 1620 | * @since 1.18 |
||
| 1621 | */ |
||
| 1622 | public function getTemplateIds() { |
||
| 1625 | |||
| 1626 | /** |
||
| 1627 | * Get the files used on this page |
||
| 1628 | * |
||
| 1629 | * @return array (dbKey => array('time' => MW timestamp or null, 'sha1' => sha1 or '')) |
||
| 1630 | * @since 1.18 |
||
| 1631 | */ |
||
| 1632 | public function getFileSearchOptions() { |
||
| 1635 | |||
| 1636 | /** |
||
| 1637 | * Convert wikitext to HTML and add it to the buffer |
||
| 1638 | * Default assumes that the current page title will be used. |
||
| 1639 | * |
||
| 1640 | * @param string $text |
||
| 1641 | * @param bool $linestart Is this the start of a line? |
||
| 1642 | * @param bool $interface Is this text in the user interface language? |
||
| 1643 | * @throws MWException |
||
| 1644 | */ |
||
| 1645 | public function addWikiText( $text, $linestart = true, $interface = true ) { |
||
| 1652 | |||
| 1653 | /** |
||
| 1654 | * Add wikitext with a custom Title object |
||
| 1655 | * |
||
| 1656 | * @param string $text Wikitext |
||
| 1657 | * @param Title $title |
||
| 1658 | * @param bool $linestart Is this the start of a line? |
||
| 1659 | */ |
||
| 1660 | public function addWikiTextWithTitle( $text, &$title, $linestart = true ) { |
||
| 1663 | |||
| 1664 | /** |
||
| 1665 | * Add wikitext with a custom Title object and tidy enabled. |
||
| 1666 | * |
||
| 1667 | * @param string $text Wikitext |
||
| 1668 | * @param Title $title |
||
| 1669 | * @param bool $linestart Is this the start of a line? |
||
| 1670 | */ |
||
| 1671 | function addWikiTextTitleTidy( $text, &$title, $linestart = true ) { |
||
| 1674 | |||
| 1675 | /** |
||
| 1676 | * Add wikitext with tidy enabled |
||
| 1677 | * |
||
| 1678 | * @param string $text Wikitext |
||
| 1679 | * @param bool $linestart Is this the start of a line? |
||
| 1680 | */ |
||
| 1681 | public function addWikiTextTidy( $text, $linestart = true ) { |
||
| 1685 | |||
| 1686 | /** |
||
| 1687 | * Add wikitext with a custom Title object |
||
| 1688 | * |
||
| 1689 | * @param string $text Wikitext |
||
| 1690 | * @param Title $title |
||
| 1691 | * @param bool $linestart Is this the start of a line? |
||
| 1692 | * @param bool $tidy Whether to use tidy |
||
| 1693 | * @param bool $interface Whether it is an interface message |
||
| 1694 | * (for example disables conversion) |
||
| 1695 | */ |
||
| 1696 | public function addWikiTextTitle( $text, Title $title, $linestart, |
||
| 1714 | |||
| 1715 | /** |
||
| 1716 | * Add a ParserOutput object, but without Html. |
||
| 1717 | * |
||
| 1718 | * @deprecated since 1.24, use addParserOutputMetadata() instead. |
||
| 1719 | * @param ParserOutput $parserOutput |
||
| 1720 | */ |
||
| 1721 | public function addParserOutputNoText( $parserOutput ) { |
||
| 1725 | |||
| 1726 | /** |
||
| 1727 | * Add all metadata associated with a ParserOutput object, but without the actual HTML. This |
||
| 1728 | * includes categories, language links, ResourceLoader modules, effects of certain magic words, |
||
| 1729 | * and so on. |
||
| 1730 | * |
||
| 1731 | * @since 1.24 |
||
| 1732 | * @param ParserOutput $parserOutput |
||
| 1733 | */ |
||
| 1734 | public function addParserOutputMetadata( $parserOutput ) { |
||
| 1786 | |||
| 1787 | /** |
||
| 1788 | * Add the HTML and enhancements for it (like ResourceLoader modules) associated with a |
||
| 1789 | * ParserOutput object, without any other metadata. |
||
| 1790 | * |
||
| 1791 | * @since 1.24 |
||
| 1792 | * @param ParserOutput $parserOutput |
||
| 1793 | */ |
||
| 1794 | public function addParserOutputContent( $parserOutput ) { |
||
| 1803 | |||
| 1804 | /** |
||
| 1805 | * Add the HTML associated with a ParserOutput object, without any metadata. |
||
| 1806 | * |
||
| 1807 | * @since 1.24 |
||
| 1808 | * @param ParserOutput $parserOutput |
||
| 1809 | */ |
||
| 1810 | public function addParserOutputText( $parserOutput ) { |
||
| 1815 | |||
| 1816 | /** |
||
| 1817 | * Add everything from a ParserOutput object. |
||
| 1818 | * |
||
| 1819 | * @param ParserOutput $parserOutput |
||
| 1820 | */ |
||
| 1821 | function addParserOutput( $parserOutput ) { |
||
| 1832 | |||
| 1833 | /** |
||
| 1834 | * Add the output of a QuickTemplate to the output buffer |
||
| 1835 | * |
||
| 1836 | * @param QuickTemplate $template |
||
| 1837 | */ |
||
| 1838 | public function addTemplate( &$template ) { |
||
| 1841 | |||
| 1842 | /** |
||
| 1843 | * Parse wikitext and return the HTML. |
||
| 1844 | * |
||
| 1845 | * @param string $text |
||
| 1846 | * @param bool $linestart Is this the start of a line? |
||
| 1847 | * @param bool $interface Use interface language ($wgLang instead of |
||
| 1848 | * $wgContLang) while parsing language sensitive magic words like GRAMMAR and PLURAL. |
||
| 1849 | * This also disables LanguageConverter. |
||
| 1850 | * @param Language $language Target language object, will override $interface |
||
| 1851 | * @throws MWException |
||
| 1852 | * @return string HTML |
||
| 1853 | */ |
||
| 1854 | public function parse( $text, $linestart = true, $interface = false, $language = null ) { |
||
| 1883 | |||
| 1884 | /** |
||
| 1885 | * Parse wikitext, strip paragraphs, and return the HTML. |
||
| 1886 | * |
||
| 1887 | * @param string $text |
||
| 1888 | * @param bool $linestart Is this the start of a line? |
||
| 1889 | * @param bool $interface Use interface language ($wgLang instead of |
||
| 1890 | * $wgContLang) while parsing language sensitive magic |
||
| 1891 | * words like GRAMMAR and PLURAL |
||
| 1892 | * @return string HTML |
||
| 1893 | */ |
||
| 1894 | public function parseInline( $text, $linestart = true, $interface = false ) { |
||
| 1898 | |||
| 1899 | /** |
||
| 1900 | * @param $maxage |
||
| 1901 | * @deprecated since 1.27 Use setCdnMaxage() instead |
||
| 1902 | */ |
||
| 1903 | public function setSquidMaxage( $maxage ) { |
||
| 1906 | |||
| 1907 | /** |
||
| 1908 | * Set the value of the "s-maxage" part of the "Cache-control" HTTP header |
||
| 1909 | * |
||
| 1910 | * @param int $maxage Maximum cache time on the CDN, in seconds. |
||
| 1911 | */ |
||
| 1912 | public function setCdnMaxage( $maxage ) { |
||
| 1915 | |||
| 1916 | /** |
||
| 1917 | * Lower the value of the "s-maxage" part of the "Cache-control" HTTP header |
||
| 1918 | * |
||
| 1919 | * @param int $maxage Maximum cache time on the CDN, in seconds |
||
| 1920 | * @since 1.27 |
||
| 1921 | */ |
||
| 1922 | public function lowerCdnMaxage( $maxage ) { |
||
| 1926 | |||
| 1927 | /** |
||
| 1928 | * Get TTL in [$minTTL,$maxTTL] in pass it to lowerCdnMaxage() |
||
| 1929 | * |
||
| 1930 | * This sets and returns $minTTL if $mtime is false or null. Otherwise, |
||
| 1931 | * the TTL is higher the older the $mtime timestamp is. Essentially, the |
||
| 1932 | * TTL is 90% of the age of the object, subject to the min and max. |
||
| 1933 | * |
||
| 1934 | * @param string|integer|float|bool|null $mtime Last-Modified timestamp |
||
| 1935 | * @param integer $minTTL Mimimum TTL in seconds [default: 1 minute] |
||
| 1936 | * @param integer $maxTTL Maximum TTL in seconds [default: $wgSquidMaxage] |
||
| 1937 | * @return integer TTL in seconds |
||
| 1938 | * @since 1.28 |
||
| 1939 | */ |
||
| 1940 | public function adaptCdnTTL( $mtime, $minTTL = 0, $maxTTL = 0 ) { |
||
| 1956 | |||
| 1957 | /** |
||
| 1958 | * Use enableClientCache(false) to force it to send nocache headers |
||
| 1959 | * |
||
| 1960 | * @param bool $state |
||
| 1961 | * |
||
| 1962 | * @return bool |
||
| 1963 | */ |
||
| 1964 | public function enableClientCache( $state ) { |
||
| 1967 | |||
| 1968 | /** |
||
| 1969 | * Get the list of cookies that will influence on the cache |
||
| 1970 | * |
||
| 1971 | * @return array |
||
| 1972 | */ |
||
| 1973 | function getCacheVaryCookies() { |
||
| 1988 | |||
| 1989 | /** |
||
| 1990 | * Check if the request has a cache-varying cookie header |
||
| 1991 | * If it does, it's very important that we don't allow public caching |
||
| 1992 | * |
||
| 1993 | * @return bool |
||
| 1994 | */ |
||
| 1995 | function haveCacheVaryCookies() { |
||
| 2006 | |||
| 2007 | /** |
||
| 2008 | * Add an HTTP header that will influence on the cache |
||
| 2009 | * |
||
| 2010 | * @param string $header Header name |
||
| 2011 | * @param string[]|null $option Options for the Key header. See |
||
| 2012 | * https://datatracker.ietf.org/doc/draft-fielding-http-key/ |
||
| 2013 | * for the list of valid options. |
||
| 2014 | */ |
||
| 2015 | public function addVaryHeader( $header, array $option = null ) { |
||
| 2024 | |||
| 2025 | /** |
||
| 2026 | * Return a Vary: header on which to vary caches. Based on the keys of $mVaryHeader, |
||
| 2027 | * such as Accept-Encoding or Cookie |
||
| 2028 | * |
||
| 2029 | * @return string |
||
| 2030 | */ |
||
| 2031 | public function getVaryHeader() { |
||
| 2042 | |||
| 2043 | /** |
||
| 2044 | * Get a complete Key header |
||
| 2045 | * |
||
| 2046 | * @return string |
||
| 2047 | */ |
||
| 2048 | public function getKeyHeader() { |
||
| 2073 | |||
| 2074 | /** |
||
| 2075 | * T23672: Add Accept-Language to Vary and Key headers |
||
| 2076 | * if there's no 'variant' parameter existed in GET. |
||
| 2077 | * |
||
| 2078 | * For example: |
||
| 2079 | * /w/index.php?title=Main_page should always be served; but |
||
| 2080 | * /w/index.php?title=Main_page&variant=zh-cn should never be served. |
||
| 2081 | */ |
||
| 2082 | function addAcceptLanguage() { |
||
| 2110 | |||
| 2111 | /** |
||
| 2112 | * Set a flag which will cause an X-Frame-Options header appropriate for |
||
| 2113 | * edit pages to be sent. The header value is controlled by |
||
| 2114 | * $wgEditPageFrameOptions. |
||
| 2115 | * |
||
| 2116 | * This is the default for special pages. If you display a CSRF-protected |
||
| 2117 | * form on an ordinary view page, then you need to call this function. |
||
| 2118 | * |
||
| 2119 | * @param bool $enable |
||
| 2120 | */ |
||
| 2121 | public function preventClickjacking( $enable = true ) { |
||
| 2124 | |||
| 2125 | /** |
||
| 2126 | * Turn off frame-breaking. Alias for $this->preventClickjacking(false). |
||
| 2127 | * This can be called from pages which do not contain any CSRF-protected |
||
| 2128 | * HTML form. |
||
| 2129 | */ |
||
| 2130 | public function allowClickjacking() { |
||
| 2133 | |||
| 2134 | /** |
||
| 2135 | * Get the prevent-clickjacking flag |
||
| 2136 | * |
||
| 2137 | * @since 1.24 |
||
| 2138 | * @return bool |
||
| 2139 | */ |
||
| 2140 | public function getPreventClickjacking() { |
||
| 2143 | |||
| 2144 | /** |
||
| 2145 | * Get the X-Frame-Options header value (without the name part), or false |
||
| 2146 | * if there isn't one. This is used by Skin to determine whether to enable |
||
| 2147 | * JavaScript frame-breaking, for clients that don't support X-Frame-Options. |
||
| 2148 | * |
||
| 2149 | * @return string |
||
| 2150 | */ |
||
| 2151 | public function getFrameOptions() { |
||
| 2160 | |||
| 2161 | /** |
||
| 2162 | * Send cache control HTTP headers |
||
| 2163 | */ |
||
| 2164 | public function sendCacheControl() { |
||
| 2233 | |||
| 2234 | /** |
||
| 2235 | * Finally, all the text has been munged and accumulated into |
||
| 2236 | * the object, let's actually output it: |
||
| 2237 | * |
||
| 2238 | * @param bool $return Set to true to get the result as a string rather than sending it |
||
| 2239 | * @return string|null |
||
| 2240 | * @throws Exception |
||
| 2241 | * @throws FatalError |
||
| 2242 | * @throws MWException |
||
| 2243 | */ |
||
| 2244 | public function output( $return = false ) { |
||
| 2360 | |||
| 2361 | /** |
||
| 2362 | * Prepare this object to display an error page; disable caching and |
||
| 2363 | * indexing, clear the current text and redirect, set the page's title |
||
| 2364 | * and optionally an custom HTML title (content of the "<title>" tag). |
||
| 2365 | * |
||
| 2366 | * @param string|Message $pageTitle Will be passed directly to setPageTitle() |
||
| 2367 | * @param string|Message $htmlTitle Will be passed directly to setHTMLTitle(); |
||
| 2368 | * optional, if not passed the "<title>" attribute will be |
||
| 2369 | * based on $pageTitle |
||
| 2370 | */ |
||
| 2371 | public function prepareErrorPage( $pageTitle, $htmlTitle = false ) { |
||
| 2383 | |||
| 2384 | /** |
||
| 2385 | * Output a standard error page |
||
| 2386 | * |
||
| 2387 | * showErrorPage( 'titlemsg', 'pagetextmsg' ); |
||
| 2388 | * showErrorPage( 'titlemsg', 'pagetextmsg', [ 'param1', 'param2' ] ); |
||
| 2389 | * showErrorPage( 'titlemsg', $messageObject ); |
||
| 2390 | * showErrorPage( $titleMessageObject, $messageObject ); |
||
| 2391 | * |
||
| 2392 | * @param string|Message $title Message key (string) for page title, or a Message object |
||
| 2393 | * @param string|Message $msg Message key (string) for page text, or a Message object |
||
| 2394 | * @param array $params Message parameters; ignored if $msg is a Message object |
||
| 2395 | */ |
||
| 2396 | public function showErrorPage( $title, $msg, $params = [] ) { |
||
| 2416 | |||
| 2417 | /** |
||
| 2418 | * Output a standard permission error page |
||
| 2419 | * |
||
| 2420 | * @param array $errors Error message keys or [key, param...] arrays |
||
| 2421 | * @param string $action Action that was denied or null if unknown |
||
| 2422 | */ |
||
| 2423 | public function showPermissionsErrorPage( array $errors, $action = null ) { |
||
| 2492 | |||
| 2493 | /** |
||
| 2494 | * Display an error page indicating that a given version of MediaWiki is |
||
| 2495 | * required to use it |
||
| 2496 | * |
||
| 2497 | * @param mixed $version The version of MediaWiki needed to use the page |
||
| 2498 | */ |
||
| 2499 | public function versionRequired( $version ) { |
||
| 2505 | |||
| 2506 | /** |
||
| 2507 | * Format a list of error messages |
||
| 2508 | * |
||
| 2509 | * @param array $errors Array of arrays returned by Title::getUserPermissionsErrors |
||
| 2510 | * @param string $action Action that was denied or null if unknown |
||
| 2511 | * @return string The wikitext error-messages, formatted into a list. |
||
| 2512 | */ |
||
| 2513 | public function formatPermissionsErrorMessage( array $errors, $action = null ) { |
||
| 2542 | |||
| 2543 | /** |
||
| 2544 | * Display a page stating that the Wiki is in read-only mode. |
||
| 2545 | * Should only be called after wfReadOnly() has returned true. |
||
| 2546 | * |
||
| 2547 | * Historically, this function was used to show the source of the page that the user |
||
| 2548 | * was trying to edit and _also_ permissions error messages. The relevant code was |
||
| 2549 | * moved into EditPage in 1.19 (r102024 / d83c2a431c2a) and removed here in 1.25. |
||
| 2550 | * |
||
| 2551 | * @deprecated since 1.25; throw the exception directly |
||
| 2552 | * @throws ReadOnlyError |
||
| 2553 | */ |
||
| 2554 | public function readOnlyPage() { |
||
| 2561 | |||
| 2562 | /** |
||
| 2563 | * Turn off regular page output and return an error response |
||
| 2564 | * for when rate limiting has triggered. |
||
| 2565 | * |
||
| 2566 | * @deprecated since 1.25; throw the exception directly |
||
| 2567 | */ |
||
| 2568 | public function rateLimited() { |
||
| 2572 | |||
| 2573 | /** |
||
| 2574 | * Show a warning about replica DB lag |
||
| 2575 | * |
||
| 2576 | * If the lag is higher than $wgSlaveLagCritical seconds, |
||
| 2577 | * then the warning is a bit more obvious. If the lag is |
||
| 2578 | * lower than $wgSlaveLagWarning, then no warning is shown. |
||
| 2579 | * |
||
| 2580 | * @param int $lag Slave lag |
||
| 2581 | */ |
||
| 2582 | public function showLagWarning( $lag ) { |
||
| 2593 | |||
| 2594 | public function showFatalError( $message ) { |
||
| 2599 | |||
| 2600 | public function showUnexpectedValueError( $name, $val ) { |
||
| 2603 | |||
| 2604 | public function showFileCopyError( $old, $new ) { |
||
| 2607 | |||
| 2608 | public function showFileRenameError( $old, $new ) { |
||
| 2611 | |||
| 2612 | public function showFileDeleteError( $name ) { |
||
| 2615 | |||
| 2616 | public function showFileNotFoundError( $name ) { |
||
| 2619 | |||
| 2620 | /** |
||
| 2621 | * Add a "return to" link pointing to a specified title |
||
| 2622 | * |
||
| 2623 | * @param Title $title Title to link |
||
| 2624 | * @param array $query Query string parameters |
||
| 2625 | * @param string $text Text of the link (input is not escaped) |
||
| 2626 | * @param array $options Options array to pass to Linker |
||
| 2627 | */ |
||
| 2628 | public function addReturnTo( $title, array $query = [], $text = null, $options = [] ) { |
||
| 2633 | |||
| 2634 | /** |
||
| 2635 | * Add a "return to" link pointing to a specified title, |
||
| 2636 | * or the title indicated in the request, or else the main page |
||
| 2637 | * |
||
| 2638 | * @param mixed $unused |
||
| 2639 | * @param Title|string $returnto Title or String to return to |
||
| 2640 | * @param string $returntoquery Query string for the return to link |
||
| 2641 | */ |
||
| 2642 | public function returnToMain( $unused = null, $returnto = null, $returntoquery = null ) { |
||
| 2666 | |||
| 2667 | private function getRlClientContext() { |
||
| 2687 | |||
| 2688 | /** |
||
| 2689 | * Call this to freeze the module queue and JS config and create a formatter. |
||
| 2690 | * |
||
| 2691 | * Depending on the Skin, this may get lazy-initialised in either headElement() or |
||
| 2692 | * getBottomScripts(). See SkinTemplate::prepareQuickTemplate(). Calling this too early may |
||
| 2693 | * cause unexpected side-effects since disallowUserJs() may be called at any time to change |
||
| 2694 | * the module filters retroactively. Skins and extension hooks may also add modules until very |
||
| 2695 | * late in the request lifecycle. |
||
| 2696 | * |
||
| 2697 | * @return ResourceLoaderClientHtml |
||
| 2698 | */ |
||
| 2699 | public function getRlClient() { |
||
| 2775 | |||
| 2776 | /** |
||
| 2777 | * @param Skin $sk The given Skin |
||
| 2778 | * @param bool $includeStyle Unused |
||
| 2779 | * @return string The doctype, opening "<html>", and head element. |
||
| 2780 | */ |
||
| 2781 | public function headElement( Skin $sk, $includeStyle = true ) { |
||
| 2852 | |||
| 2853 | /** |
||
| 2854 | * Get a ResourceLoader object associated with this OutputPage |
||
| 2855 | * |
||
| 2856 | * @return ResourceLoader |
||
| 2857 | */ |
||
| 2858 | public function getResourceLoader() { |
||
| 2867 | |||
| 2868 | /** |
||
| 2869 | * Explicily load or embed modules on a page. |
||
| 2870 | * |
||
| 2871 | * @param array|string $modules One or more module names |
||
| 2872 | * @param string $only ResourceLoaderModule TYPE_ class constant |
||
| 2873 | * @param array $extraQuery [optional] Array with extra query parameters for the request |
||
| 2874 | * @return string|WrappedStringList HTML |
||
| 2875 | */ |
||
| 2876 | public function makeResourceLoaderLink( $modules, $only, array $extraQuery = [] ) { |
||
| 2887 | |||
| 2888 | /** |
||
| 2889 | * Combine WrappedString chunks and filter out empty ones |
||
| 2890 | * |
||
| 2891 | * @param array $chunks |
||
| 2892 | * @return string|WrappedStringList HTML |
||
| 2893 | */ |
||
| 2894 | protected static function combineWrappedStrings( array $chunks ) { |
||
| 2899 | |||
| 2900 | private function isUserJsPreview() { |
||
| 2906 | |||
| 2907 | private function isUserCssPreview() { |
||
| 2913 | |||
| 2914 | /** |
||
| 2915 | * JS stuff to put at the bottom of the `<body>`. These are modules with position 'bottom', |
||
| 2916 | * legacy scripts ($this->mScripts), and user JS. |
||
| 2917 | * |
||
| 2918 | * @return string|WrappedStringList HTML |
||
| 2919 | */ |
||
| 2920 | public function getBottomScripts() { |
||
| 2963 | |||
| 2964 | /** |
||
| 2965 | * Get the javascript config vars to include on this page |
||
| 2966 | * |
||
| 2967 | * @return array Array of javascript config vars |
||
| 2968 | * @since 1.23 |
||
| 2969 | */ |
||
| 2970 | public function getJsConfigVars() { |
||
| 2973 | |||
| 2974 | /** |
||
| 2975 | * Add one or more variables to be set in mw.config in JavaScript |
||
| 2976 | * |
||
| 2977 | * @param string|array $keys Key or array of key/value pairs |
||
| 2978 | * @param mixed $value [optional] Value of the configuration variable |
||
| 2979 | */ |
||
| 2980 | View Code Duplication | public function addJsConfigVars( $keys, $value = null ) { |
|
| 2990 | |||
| 2991 | /** |
||
| 2992 | * Get an array containing the variables to be set in mw.config in JavaScript. |
||
| 2993 | * |
||
| 2994 | * Do not add things here which can be evaluated in ResourceLoaderStartUpModule |
||
| 2995 | * - in other words, page-independent/site-wide variables (without state). |
||
| 2996 | * You will only be adding bloat to the html page and causing page caches to |
||
| 2997 | * have to be purged on configuration changes. |
||
| 2998 | * @return array |
||
| 2999 | */ |
||
| 3000 | public function getJSVars() { |
||
| 3117 | |||
| 3118 | /** |
||
| 3119 | * To make it harder for someone to slip a user a fake |
||
| 3120 | * user-JavaScript or user-CSS preview, a random token |
||
| 3121 | * is associated with the login session. If it's not |
||
| 3122 | * passed back with the preview request, we won't render |
||
| 3123 | * the code. |
||
| 3124 | * |
||
| 3125 | * @return bool |
||
| 3126 | */ |
||
| 3127 | public function userCanPreview() { |
||
| 3163 | |||
| 3164 | /** |
||
| 3165 | * @return array Array in format "link name or number => 'link html'". |
||
| 3166 | */ |
||
| 3167 | public function getHeadLinksArray() { |
||
| 3428 | |||
| 3429 | /** |
||
| 3430 | * @return string HTML tag links to be put in the header. |
||
| 3431 | * @deprecated since 1.24 Use OutputPage::headElement or if you have to, |
||
| 3432 | * OutputPage::getHeadLinksArray directly. |
||
| 3433 | */ |
||
| 3434 | public function getHeadLinks() { |
||
| 3438 | |||
| 3439 | /** |
||
| 3440 | * Generate a "<link rel/>" for a feed. |
||
| 3441 | * |
||
| 3442 | * @param string $type Feed type |
||
| 3443 | * @param string $url URL to the feed |
||
| 3444 | * @param string $text Value of the "title" attribute |
||
| 3445 | * @return string HTML fragment |
||
| 3446 | */ |
||
| 3447 | private function feedLink( $type, $url, $text ) { |
||
| 3455 | |||
| 3456 | /** |
||
| 3457 | * Add a local or specified stylesheet, with the given media options. |
||
| 3458 | * Internal use only. Use OutputPage::addModuleStyles() if possible. |
||
| 3459 | * |
||
| 3460 | * @param string $style URL to the file |
||
| 3461 | * @param string $media To specify a media type, 'screen', 'printable', 'handheld' or any. |
||
| 3462 | * @param string $condition For IE conditional comments, specifying an IE version |
||
| 3463 | * @param string $dir Set to 'rtl' or 'ltr' for direction-specific sheets |
||
| 3464 | */ |
||
| 3465 | public function addStyle( $style, $media = '', $condition = '', $dir = '' ) { |
||
| 3478 | |||
| 3479 | /** |
||
| 3480 | * Adds inline CSS styles |
||
| 3481 | * Internal use only. Use OutputPage::addModuleStyles() if possible. |
||
| 3482 | * |
||
| 3483 | * @param mixed $style_css Inline CSS |
||
| 3484 | * @param string $flip Set to 'flip' to flip the CSS if needed |
||
| 3485 | */ |
||
| 3486 | public function addInlineStyle( $style_css, $flip = 'noflip' ) { |
||
| 3493 | |||
| 3494 | /** |
||
| 3495 | * Build exempt modules and legacy non-ResourceLoader styles. |
||
| 3496 | * |
||
| 3497 | * @return string|WrappedStringList HTML |
||
| 3498 | */ |
||
| 3499 | protected function buildExemptModules() { |
||
| 3548 | |||
| 3549 | /** |
||
| 3550 | * @return array |
||
| 3551 | */ |
||
| 3552 | public function buildCssLinksArray() { |
||
| 3569 | |||
| 3570 | /** |
||
| 3571 | * Generate \<link\> tags for stylesheets |
||
| 3572 | * |
||
| 3573 | * @param string $style URL to the file |
||
| 3574 | * @param array $options Option, can contain 'condition', 'dir', 'media' keys |
||
| 3575 | * @return string HTML fragment |
||
| 3576 | */ |
||
| 3577 | protected function styleLink( $style, array $options ) { |
||
| 3611 | |||
| 3612 | /** |
||
| 3613 | * Transform path to web-accessible static resource. |
||
| 3614 | * |
||
| 3615 | * This is used to add a validation hash as query string. |
||
| 3616 | * This aids various behaviors: |
||
| 3617 | * |
||
| 3618 | * - Put long Cache-Control max-age headers on responses for improved |
||
| 3619 | * cache performance. |
||
| 3620 | * - Get the correct version of a file as expected by the current page. |
||
| 3621 | * - Instantly get the updated version of a file after deployment. |
||
| 3622 | * |
||
| 3623 | * Avoid using this for urls included in HTML as otherwise clients may get different |
||
| 3624 | * versions of a resource when navigating the site depending on when the page was cached. |
||
| 3625 | * If changes to the url propagate, this is not a problem (e.g. if the url is in |
||
| 3626 | * an external stylesheet). |
||
| 3627 | * |
||
| 3628 | * @since 1.27 |
||
| 3629 | * @param Config $config |
||
| 3630 | * @param string $path Path-absolute URL to file (from document root, must start with "/") |
||
| 3631 | * @return string URL |
||
| 3632 | */ |
||
| 3633 | public static function transformResourcePath( Config $config, $path ) { |
||
| 3650 | |||
| 3651 | /** |
||
| 3652 | * Utility method for transformResourceFilePath(). |
||
| 3653 | * |
||
| 3654 | * Caller is responsible for ensuring the file exists. Emits a PHP warning otherwise. |
||
| 3655 | * |
||
| 3656 | * @since 1.27 |
||
| 3657 | * @param string $remotePath URL path prefix that points to $localPath |
||
| 3658 | * @param string $localPath File directory exposed at $remotePath |
||
| 3659 | * @param string $file Path to target file relative to $localPath |
||
| 3660 | * @return string URL |
||
| 3661 | */ |
||
| 3662 | public static function transformFilePath( $remotePathPrefix, $localPath, $file ) { |
||
| 3670 | |||
| 3671 | /** |
||
| 3672 | * Transform "media" attribute based on request parameters |
||
| 3673 | * |
||
| 3674 | * @param string $media Current value of the "media" attribute |
||
| 3675 | * @return string Modified value of the "media" attribute, or null to skip |
||
| 3676 | * this stylesheet |
||
| 3677 | */ |
||
| 3678 | public static function transformCssMedia( $media ) { |
||
| 3716 | |||
| 3717 | /** |
||
| 3718 | * Add a wikitext-formatted message to the output. |
||
| 3719 | * This is equivalent to: |
||
| 3720 | * |
||
| 3721 | * $wgOut->addWikiText( wfMessage( ... )->plain() ) |
||
| 3722 | */ |
||
| 3723 | public function addWikiMsg( /*...*/ ) { |
||
| 3728 | |||
| 3729 | /** |
||
| 3730 | * Add a wikitext-formatted message to the output. |
||
| 3731 | * Like addWikiMsg() except the parameters are taken as an array |
||
| 3732 | * instead of a variable argument list. |
||
| 3733 | * |
||
| 3734 | * @param string $name |
||
| 3735 | * @param array $args |
||
| 3736 | */ |
||
| 3737 | public function addWikiMsgArray( $name, $args ) { |
||
| 3740 | |||
| 3741 | /** |
||
| 3742 | * This function takes a number of message/argument specifications, wraps them in |
||
| 3743 | * some overall structure, and then parses the result and adds it to the output. |
||
| 3744 | * |
||
| 3745 | * In the $wrap, $1 is replaced with the first message, $2 with the second, |
||
| 3746 | * and so on. The subsequent arguments may be either |
||
| 3747 | * 1) strings, in which case they are message names, or |
||
| 3748 | * 2) arrays, in which case, within each array, the first element is the message |
||
| 3749 | * name, and subsequent elements are the parameters to that message. |
||
| 3750 | * |
||
| 3751 | * Don't use this for messages that are not in the user's interface language. |
||
| 3752 | * |
||
| 3753 | * For example: |
||
| 3754 | * |
||
| 3755 | * $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>", 'some-error' ); |
||
| 3756 | * |
||
| 3757 | * Is equivalent to: |
||
| 3758 | * |
||
| 3759 | * $wgOut->addWikiText( "<div class='error'>\n" |
||
| 3760 | * . wfMessage( 'some-error' )->plain() . "\n</div>" ); |
||
| 3761 | * |
||
| 3762 | * The newline after the opening div is needed in some wikitext. See bug 19226. |
||
| 3763 | * |
||
| 3764 | * @param string $wrap |
||
| 3765 | */ |
||
| 3766 | public function wrapWikiMsg( $wrap /*, ...*/ ) { |
||
| 3790 | |||
| 3791 | /** |
||
| 3792 | * Enables/disables TOC, doesn't override __NOTOC__ |
||
| 3793 | * @param bool $flag |
||
| 3794 | * @since 1.22 |
||
| 3795 | */ |
||
| 3796 | public function enableTOC( $flag = true ) { |
||
| 3799 | |||
| 3800 | /** |
||
| 3801 | * @return bool |
||
| 3802 | * @since 1.22 |
||
| 3803 | */ |
||
| 3804 | public function isTOCEnabled() { |
||
| 3807 | |||
| 3808 | /** |
||
| 3809 | * Enables/disables section edit links, doesn't override __NOEDITSECTION__ |
||
| 3810 | * @param bool $flag |
||
| 3811 | * @since 1.23 |
||
| 3812 | */ |
||
| 3813 | public function enableSectionEditLinks( $flag = true ) { |
||
| 3816 | |||
| 3817 | /** |
||
| 3818 | * @return bool |
||
| 3819 | * @since 1.23 |
||
| 3820 | */ |
||
| 3821 | public function sectionEditLinksEnabled() { |
||
| 3824 | |||
| 3825 | /** |
||
| 3826 | * Helper function to setup the PHP implementation of OOUI to use in this request. |
||
| 3827 | * |
||
| 3828 | * @since 1.26 |
||
| 3829 | * @param String $skinName The Skin name to determine the correct OOUI theme |
||
| 3830 | * @param String $dir Language direction |
||
| 3831 | */ |
||
| 3832 | public static function setupOOUI( $skinName = '', $dir = 'ltr' ) { |
||
| 3842 | |||
| 3843 | /** |
||
| 3844 | * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with |
||
| 3845 | * MediaWiki and this OutputPage instance. |
||
| 3846 | * |
||
| 3847 | * @since 1.25 |
||
| 3848 | */ |
||
| 3849 | public function enableOOUI() { |
||
| 3862 | } |
||
| 3863 |
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.