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 |
||
| 42 | class OutputPage extends ContextSource { |
||
| 43 | /** @var array Should be private. Used with addMeta() which adds "<meta>" */ |
||
| 44 | protected $mMetatags = []; |
||
| 45 | |||
| 46 | /** @var array */ |
||
| 47 | protected $mLinktags = []; |
||
| 48 | |||
| 49 | /** @var bool */ |
||
| 50 | protected $mCanonicalUrl = false; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var array Additional stylesheets. Looks like this is for extensions. |
||
| 54 | * Might be replaced by ResourceLoader. |
||
| 55 | */ |
||
| 56 | protected $mExtStyles = []; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @var string Should be private - has getter and setter. Contains |
||
| 60 | * the HTML title */ |
||
| 61 | public $mPagetitle = ''; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @var string Contains all of the "<body>" content. Should be private we |
||
| 65 | * got set/get accessors and the append() method. |
||
| 66 | */ |
||
| 67 | public $mBodytext = ''; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Holds the debug lines that will be output as comments in page source if |
||
| 71 | * $wgDebugComments is enabled. See also $wgShowDebug. |
||
| 72 | * @deprecated since 1.20; use MWDebug class instead. |
||
| 73 | */ |
||
| 74 | public $mDebugtext = ''; |
||
| 75 | |||
| 76 | /** @var string Stores contents of "<title>" tag */ |
||
| 77 | private $mHTMLtitle = ''; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @var bool Is the displayed content related to the source of the |
||
| 81 | * corresponding wiki article. |
||
| 82 | */ |
||
| 83 | private $mIsarticle = false; |
||
| 84 | |||
| 85 | /** @var bool Stores "article flag" toggle. */ |
||
| 86 | private $mIsArticleRelated = true; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @var bool We have to set isPrintable(). Some pages should |
||
| 90 | * never be printed (ex: redirections). |
||
| 91 | */ |
||
| 92 | private $mPrintable = false; |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @var array Contains the page subtitle. Special pages usually have some |
||
| 96 | * links here. Don't confuse with site subtitle added by skins. |
||
| 97 | */ |
||
| 98 | private $mSubtitle = []; |
||
| 99 | |||
| 100 | /** @var string */ |
||
| 101 | public $mRedirect = ''; |
||
| 102 | |||
| 103 | /** @var int */ |
||
| 104 | protected $mStatusCode; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @var string Variable mLastModified and mEtag are used for sending cache control. |
||
| 108 | * The whole caching system should probably be moved into its own class. |
||
| 109 | */ |
||
| 110 | protected $mLastModified = ''; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * Contains an HTTP Entity Tags (see RFC 2616 section 3.13) which is used |
||
| 114 | * as a unique identifier for the content. It is later used by the client |
||
| 115 | * to compare its cached version with the server version. Client sends |
||
| 116 | * headers If-Match and If-None-Match containing its locally cached ETAG value. |
||
| 117 | * |
||
| 118 | * To get more information, you will have to look at HTTP/1.1 protocol which |
||
| 119 | * is properly described in RFC 2616 : http://tools.ietf.org/html/rfc2616 |
||
| 120 | */ |
||
| 121 | private $mETag = false; |
||
| 122 | |||
| 123 | /** @var array */ |
||
| 124 | protected $mCategoryLinks = []; |
||
| 125 | |||
| 126 | /** @var array */ |
||
| 127 | protected $mCategories = []; |
||
| 128 | |||
| 129 | /** @var array */ |
||
| 130 | protected $mIndicators = []; |
||
| 131 | |||
| 132 | /** @var array Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page') */ |
||
| 133 | private $mLanguageLinks = []; |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Used for JavaScript (predates ResourceLoader) |
||
| 137 | * @todo We should split JS / CSS. |
||
| 138 | * mScripts content is inserted as is in "<head>" by Skin. This might |
||
| 139 | * contain either a link to a stylesheet or inline CSS. |
||
| 140 | */ |
||
| 141 | private $mScripts = ''; |
||
| 142 | |||
| 143 | /** @var string Inline CSS styles. Use addInlineStyle() sparingly */ |
||
| 144 | protected $mInlineStyles = ''; |
||
| 145 | |||
| 146 | /** |
||
| 147 | * @var string Used by skin template. |
||
| 148 | * Example: $tpl->set( 'displaytitle', $out->mPageLinkTitle ); |
||
| 149 | */ |
||
| 150 | public $mPageLinkTitle = ''; |
||
| 151 | |||
| 152 | /** @var array Array of elements in "<head>". Parser might add its own headers! */ |
||
| 153 | protected $mHeadItems = []; |
||
| 154 | |||
| 155 | /** @var array */ |
||
| 156 | protected $mModules = []; |
||
| 157 | |||
| 158 | /** @var array */ |
||
| 159 | protected $mModuleScripts = []; |
||
| 160 | |||
| 161 | /** @var array */ |
||
| 162 | protected $mModuleStyles = []; |
||
| 163 | |||
| 164 | /** @var ResourceLoader */ |
||
| 165 | protected $mResourceLoader; |
||
| 166 | |||
| 167 | /** @var array */ |
||
| 168 | protected $mJsConfigVars = []; |
||
| 169 | |||
| 170 | /** @var array */ |
||
| 171 | protected $mTemplateIds = []; |
||
| 172 | |||
| 173 | /** @var array */ |
||
| 174 | protected $mImageTimeKeys = []; |
||
| 175 | |||
| 176 | /** @var string */ |
||
| 177 | public $mRedirectCode = ''; |
||
| 178 | |||
| 179 | protected $mFeedLinksAppendQuery = null; |
||
| 180 | |||
| 181 | /** @var array |
||
| 182 | * What level of 'untrustworthiness' is allowed in CSS/JS modules loaded on this page? |
||
| 183 | * @see ResourceLoaderModule::$origin |
||
| 184 | * ResourceLoaderModule::ORIGIN_ALL is assumed unless overridden; |
||
| 185 | */ |
||
| 186 | protected $mAllowedModules = [ |
||
| 187 | ResourceLoaderModule::TYPE_COMBINED => ResourceLoaderModule::ORIGIN_ALL, |
||
| 188 | ]; |
||
| 189 | |||
| 190 | /** @var bool Whether output is disabled. If this is true, the 'output' method will do nothing. */ |
||
| 191 | protected $mDoNothing = false; |
||
| 192 | |||
| 193 | // Parser related. |
||
| 194 | |||
| 195 | /** @var int */ |
||
| 196 | protected $mContainsNewMagic = 0; |
||
| 197 | |||
| 198 | /** |
||
| 199 | * lazy initialised, use parserOptions() |
||
| 200 | * @var ParserOptions |
||
| 201 | */ |
||
| 202 | protected $mParserOptions = null; |
||
| 203 | |||
| 204 | /** |
||
| 205 | * Handles the Atom / RSS links. |
||
| 206 | * We probably only support Atom in 2011. |
||
| 207 | * @see $wgAdvertisedFeedTypes |
||
| 208 | */ |
||
| 209 | private $mFeedLinks = []; |
||
| 210 | |||
| 211 | // Gwicke work on squid caching? Roughly from 2003. |
||
| 212 | protected $mEnableClientCache = true; |
||
| 213 | |||
| 214 | /** @var bool Flag if output should only contain the body of the article. */ |
||
| 215 | private $mArticleBodyOnly = false; |
||
| 216 | |||
| 217 | /** @var bool */ |
||
| 218 | protected $mNewSectionLink = false; |
||
| 219 | |||
| 220 | /** @var bool */ |
||
| 221 | protected $mHideNewSectionLink = false; |
||
| 222 | |||
| 223 | /** |
||
| 224 | * @var bool Comes from the parser. This was probably made to load CSS/JS |
||
| 225 | * only if we had "<gallery>". Used directly in CategoryPage.php. |
||
| 226 | * Looks like ResourceLoader can replace this. |
||
| 227 | */ |
||
| 228 | public $mNoGallery = false; |
||
| 229 | |||
| 230 | /** @var string */ |
||
| 231 | private $mPageTitleActionText = ''; |
||
| 232 | |||
| 233 | /** @var int Cache stuff. Looks like mEnableClientCache */ |
||
| 234 | protected $mCdnMaxage = 0; |
||
| 235 | /** @var int Upper limit on mCdnMaxage */ |
||
| 236 | protected $mCdnMaxageLimit = INF; |
||
| 237 | |||
| 238 | /** |
||
| 239 | * @var bool Controls if anti-clickjacking / frame-breaking headers will |
||
| 240 | * be sent. This should be done for pages where edit actions are possible. |
||
| 241 | * Setters: $this->preventClickjacking() and $this->allowClickjacking(). |
||
| 242 | */ |
||
| 243 | protected $mPreventClickjacking = true; |
||
| 244 | |||
| 245 | /** @var int To include the variable {{REVISIONID}} */ |
||
| 246 | private $mRevisionId = null; |
||
| 247 | |||
| 248 | /** @var string */ |
||
| 249 | private $mRevisionTimestamp = null; |
||
| 250 | |||
| 251 | /** @var array */ |
||
| 252 | protected $mFileVersion = null; |
||
| 253 | |||
| 254 | /** |
||
| 255 | * @var array An array of stylesheet filenames (relative from skins path), |
||
| 256 | * with options for CSS media, IE conditions, and RTL/LTR direction. |
||
| 257 | * For internal use; add settings in the skin via $this->addStyle() |
||
| 258 | * |
||
| 259 | * Style again! This seems like a code duplication since we already have |
||
| 260 | * mStyles. This is what makes Open Source amazing. |
||
| 261 | */ |
||
| 262 | protected $styles = []; |
||
| 263 | |||
| 264 | /** |
||
| 265 | * Whether jQuery is already handled. |
||
| 266 | */ |
||
| 267 | protected $mJQueryDone = false; |
||
| 268 | |||
| 269 | private $mIndexPolicy = 'index'; |
||
| 270 | private $mFollowPolicy = 'follow'; |
||
| 271 | private $mVaryHeader = [ |
||
| 272 | 'Accept-Encoding' => [ 'match=gzip' ], |
||
| 273 | ]; |
||
| 274 | |||
| 275 | /** |
||
| 276 | * If the current page was reached through a redirect, $mRedirectedFrom contains the Title |
||
| 277 | * of the redirect. |
||
| 278 | * |
||
| 279 | * @var Title |
||
| 280 | */ |
||
| 281 | private $mRedirectedFrom = null; |
||
| 282 | |||
| 283 | /** |
||
| 284 | * Additional key => value data |
||
| 285 | */ |
||
| 286 | private $mProperties = []; |
||
| 287 | |||
| 288 | /** |
||
| 289 | * @var string|null ResourceLoader target for load.php links. If null, will be omitted |
||
| 290 | */ |
||
| 291 | private $mTarget = null; |
||
| 292 | |||
| 293 | /** |
||
| 294 | * @var bool Whether parser output should contain table of contents |
||
| 295 | */ |
||
| 296 | private $mEnableTOC = true; |
||
| 297 | |||
| 298 | /** |
||
| 299 | * @var bool Whether parser output should contain section edit links |
||
| 300 | */ |
||
| 301 | private $mEnableSectionEditLinks = true; |
||
| 302 | |||
| 303 | /** |
||
| 304 | * @var string|null The URL to send in a <link> element with rel=copyright |
||
| 305 | */ |
||
| 306 | private $copyrightUrl; |
||
| 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' ) { |
||
| 562 | |||
| 563 | /** |
||
| 564 | * Add one or more modules recognized by ResourceLoader. Modules added |
||
| 565 | * through this function will be loaded by ResourceLoader when the |
||
| 566 | * page loads. |
||
| 567 | * |
||
| 568 | * @param string|array $modules Module name (string) or array of module names |
||
| 569 | */ |
||
| 570 | public function addModules( $modules ) { |
||
| 573 | |||
| 574 | /** |
||
| 575 | * Get the list of module JS to include on this page |
||
| 576 | * |
||
| 577 | * @param bool $filter |
||
| 578 | * @param string|null $position |
||
| 579 | * |
||
| 580 | * @return array Array of module names |
||
| 581 | */ |
||
| 582 | public function getModuleScripts( $filter = false, $position = null ) { |
||
| 585 | |||
| 586 | /** |
||
| 587 | * Add only JS of one or more modules recognized by ResourceLoader. Module |
||
| 588 | * scripts added through this function will be loaded by ResourceLoader when |
||
| 589 | * the page loads. |
||
| 590 | * |
||
| 591 | * @param string|array $modules Module name (string) or array of module names |
||
| 592 | */ |
||
| 593 | public function addModuleScripts( $modules ) { |
||
| 596 | |||
| 597 | /** |
||
| 598 | * Get the list of module CSS to include on this page |
||
| 599 | * |
||
| 600 | * @param bool $filter |
||
| 601 | * @param string|null $position |
||
| 602 | * |
||
| 603 | * @return array Array of module names |
||
| 604 | */ |
||
| 605 | public function getModuleStyles( $filter = false, $position = null ) { |
||
| 608 | |||
| 609 | /** |
||
| 610 | * Add only CSS of one or more modules recognized by ResourceLoader. |
||
| 611 | * |
||
| 612 | * Module styles added through this function will be added using standard link CSS |
||
| 613 | * tags, rather than as a combined Javascript and CSS package. Thus, they will |
||
| 614 | * load when JavaScript is disabled (unless CSS also happens to be disabled). |
||
| 615 | * |
||
| 616 | * @param string|array $modules Module name (string) or array of module names |
||
| 617 | */ |
||
| 618 | public function addModuleStyles( $modules ) { |
||
| 621 | |||
| 622 | /** |
||
| 623 | * Get the list of module messages to include on this page |
||
| 624 | * |
||
| 625 | * @deprecated since 1.26 Obsolete |
||
| 626 | * @param bool $filter |
||
| 627 | * @param string|null $position |
||
| 628 | * @return array Array of module names |
||
| 629 | */ |
||
| 630 | public function getModuleMessages( $filter = false, $position = null ) { |
||
| 634 | |||
| 635 | /** |
||
| 636 | * Load messages of one or more ResourceLoader modules. |
||
| 637 | * |
||
| 638 | * @deprecated since 1.26 Use addModules() instead |
||
| 639 | * @param string|array $modules Module name (string) or array of module names |
||
| 640 | */ |
||
| 641 | public function addModuleMessages( $modules ) { |
||
| 644 | |||
| 645 | /** |
||
| 646 | * @return null|string ResourceLoader target |
||
| 647 | */ |
||
| 648 | public function getTarget() { |
||
| 651 | |||
| 652 | /** |
||
| 653 | * Sets ResourceLoader target for load.php links. If null, will be omitted |
||
| 654 | * |
||
| 655 | * @param string|null $target |
||
| 656 | */ |
||
| 657 | public function setTarget( $target ) { |
||
| 660 | |||
| 661 | /** |
||
| 662 | * Get an array of head items |
||
| 663 | * |
||
| 664 | * @return array |
||
| 665 | */ |
||
| 666 | function getHeadItemsArray() { |
||
| 669 | |||
| 670 | /** |
||
| 671 | * Add or replace an header item to the output |
||
| 672 | * |
||
| 673 | * Whenever possible, use more specific options like ResourceLoader modules, |
||
| 674 | * OutputPage::addLink(), OutputPage::addMetaLink() and OutputPage::addFeedLink() |
||
| 675 | * Fallback options for those are: OutputPage::addStyle, OutputPage::addScript(), |
||
| 676 | * OutputPage::addInlineScript() and OutputPage::addInlineStyle() |
||
| 677 | * This would be your very LAST fallback. |
||
| 678 | * |
||
| 679 | * @param string $name Item name |
||
| 680 | * @param string $value Raw HTML |
||
| 681 | */ |
||
| 682 | public function addHeadItem( $name, $value ) { |
||
| 685 | |||
| 686 | /** |
||
| 687 | * Check if the header item $name is already set |
||
| 688 | * |
||
| 689 | * @param string $name Item name |
||
| 690 | * @return bool |
||
| 691 | */ |
||
| 692 | public function hasHeadItem( $name ) { |
||
| 695 | |||
| 696 | /** |
||
| 697 | * Set the value of the ETag HTTP header, only used if $wgUseETag is true |
||
| 698 | * |
||
| 699 | * @param string $tag Value of "ETag" header |
||
| 700 | */ |
||
| 701 | function setETag( $tag ) { |
||
| 704 | |||
| 705 | /** |
||
| 706 | * Set whether the output should only contain the body of the article, |
||
| 707 | * without any skin, sidebar, etc. |
||
| 708 | * Used e.g. when calling with "action=render". |
||
| 709 | * |
||
| 710 | * @param bool $only Whether to output only the body of the article |
||
| 711 | */ |
||
| 712 | public function setArticleBodyOnly( $only ) { |
||
| 715 | |||
| 716 | /** |
||
| 717 | * Return whether the output will contain only the body of the article |
||
| 718 | * |
||
| 719 | * @return bool |
||
| 720 | */ |
||
| 721 | public function getArticleBodyOnly() { |
||
| 724 | |||
| 725 | /** |
||
| 726 | * Set an additional output property |
||
| 727 | * @since 1.21 |
||
| 728 | * |
||
| 729 | * @param string $name |
||
| 730 | * @param mixed $value |
||
| 731 | */ |
||
| 732 | public function setProperty( $name, $value ) { |
||
| 735 | |||
| 736 | /** |
||
| 737 | * Get an additional output property |
||
| 738 | * @since 1.21 |
||
| 739 | * |
||
| 740 | * @param string $name |
||
| 741 | * @return mixed Property value or null if not found |
||
| 742 | */ |
||
| 743 | public function getProperty( $name ) { |
||
| 750 | |||
| 751 | /** |
||
| 752 | * checkLastModified tells the client to use the client-cached page if |
||
| 753 | * possible. If successful, the OutputPage is disabled so that |
||
| 754 | * any future call to OutputPage->output() have no effect. |
||
| 755 | * |
||
| 756 | * Side effect: sets mLastModified for Last-Modified header |
||
| 757 | * |
||
| 758 | * @param string $timestamp |
||
| 759 | * |
||
| 760 | * @return bool True if cache-ok headers was sent. |
||
| 761 | */ |
||
| 762 | public function checkLastModified( $timestamp ) { |
||
| 842 | |||
| 843 | /** |
||
| 844 | * Override the last modified timestamp |
||
| 845 | * |
||
| 846 | * @param string $timestamp New timestamp, in a format readable by |
||
| 847 | * wfTimestamp() |
||
| 848 | */ |
||
| 849 | public function setLastModified( $timestamp ) { |
||
| 852 | |||
| 853 | /** |
||
| 854 | * Set the robot policy for the page: <http://www.robotstxt.org/meta.html> |
||
| 855 | * |
||
| 856 | * @param string $policy The literal string to output as the contents of |
||
| 857 | * the meta tag. Will be parsed according to the spec and output in |
||
| 858 | * standardized form. |
||
| 859 | * @return null |
||
| 860 | */ |
||
| 861 | public function setRobotPolicy( $policy ) { |
||
| 871 | |||
| 872 | /** |
||
| 873 | * Set the index policy for the page, but leave the follow policy un- |
||
| 874 | * touched. |
||
| 875 | * |
||
| 876 | * @param string $policy Either 'index' or 'noindex'. |
||
| 877 | * @return null |
||
| 878 | */ |
||
| 879 | public function setIndexPolicy( $policy ) { |
||
| 885 | |||
| 886 | /** |
||
| 887 | * Set the follow policy for the page, but leave the index policy un- |
||
| 888 | * touched. |
||
| 889 | * |
||
| 890 | * @param string $policy Either 'follow' or 'nofollow'. |
||
| 891 | * @return null |
||
| 892 | */ |
||
| 893 | public function setFollowPolicy( $policy ) { |
||
| 899 | |||
| 900 | /** |
||
| 901 | * Set the new value of the "action text", this will be added to the |
||
| 902 | * "HTML title", separated from it with " - ". |
||
| 903 | * |
||
| 904 | * @param string $text New value of the "action text" |
||
| 905 | */ |
||
| 906 | public function setPageTitleActionText( $text ) { |
||
| 909 | |||
| 910 | /** |
||
| 911 | * Get the value of the "action text" |
||
| 912 | * |
||
| 913 | * @return string |
||
| 914 | */ |
||
| 915 | public function getPageTitleActionText() { |
||
| 918 | |||
| 919 | /** |
||
| 920 | * "HTML title" means the contents of "<title>". |
||
| 921 | * It is stored as plain, unescaped text and will be run through htmlspecialchars in the skin file. |
||
| 922 | * |
||
| 923 | * @param string|Message $name |
||
| 924 | */ |
||
| 925 | public function setHTMLTitle( $name ) { |
||
| 932 | |||
| 933 | /** |
||
| 934 | * Return the "HTML title", i.e. the content of the "<title>" tag. |
||
| 935 | * |
||
| 936 | * @return string |
||
| 937 | */ |
||
| 938 | public function getHTMLTitle() { |
||
| 941 | |||
| 942 | /** |
||
| 943 | * Set $mRedirectedFrom, the Title of the page which redirected us to the current page. |
||
| 944 | * |
||
| 945 | * @param Title $t |
||
| 946 | */ |
||
| 947 | public function setRedirectedFrom( $t ) { |
||
| 950 | |||
| 951 | /** |
||
| 952 | * "Page title" means the contents of \<h1\>. It is stored as a valid HTML |
||
| 953 | * fragment. This function allows good tags like \<sup\> in the \<h1\> tag, |
||
| 954 | * but not bad tags like \<script\>. This function automatically sets |
||
| 955 | * \<title\> to the same content as \<h1\> but with all tags removed. Bad |
||
| 956 | * tags that were escaped in \<h1\> will still be escaped in \<title\>, and |
||
| 957 | * good tags like \<i\> will be dropped entirely. |
||
| 958 | * |
||
| 959 | * @param string|Message $name |
||
| 960 | */ |
||
| 961 | public function setPageTitle( $name ) { |
||
| 977 | |||
| 978 | /** |
||
| 979 | * Return the "page title", i.e. the content of the \<h1\> tag. |
||
| 980 | * |
||
| 981 | * @return string |
||
| 982 | */ |
||
| 983 | public function getPageTitle() { |
||
| 986 | |||
| 987 | /** |
||
| 988 | * Set the Title object to use |
||
| 989 | * |
||
| 990 | * @param Title $t |
||
| 991 | */ |
||
| 992 | public function setTitle( Title $t ) { |
||
| 995 | |||
| 996 | /** |
||
| 997 | * Replace the subtitle with $str |
||
| 998 | * |
||
| 999 | * @param string|Message $str New value of the subtitle. String should be safe HTML. |
||
| 1000 | */ |
||
| 1001 | public function setSubtitle( $str ) { |
||
| 1005 | |||
| 1006 | /** |
||
| 1007 | * Add $str to the subtitle |
||
| 1008 | * |
||
| 1009 | * @param string|Message $str String or Message to add to the subtitle. String should be safe HTML. |
||
| 1010 | */ |
||
| 1011 | public function addSubtitle( $str ) { |
||
| 1018 | |||
| 1019 | /** |
||
| 1020 | * Build message object for a subtitle containing a backlink to a page |
||
| 1021 | * |
||
| 1022 | * @param Title $title Title to link to |
||
| 1023 | * @param array $query Array of additional parameters to include in the link |
||
| 1024 | * @return Message |
||
| 1025 | * @since 1.25 |
||
| 1026 | */ |
||
| 1027 | public static function buildBacklinkSubtitle( Title $title, $query = [] ) { |
||
| 1034 | |||
| 1035 | /** |
||
| 1036 | * Add a subtitle containing a backlink to a page |
||
| 1037 | * |
||
| 1038 | * @param Title $title Title to link to |
||
| 1039 | * @param array $query Array of additional parameters to include in the link |
||
| 1040 | */ |
||
| 1041 | public function addBacklinkSubtitle( Title $title, $query = [] ) { |
||
| 1044 | |||
| 1045 | /** |
||
| 1046 | * Clear the subtitles |
||
| 1047 | */ |
||
| 1048 | public function clearSubtitle() { |
||
| 1051 | |||
| 1052 | /** |
||
| 1053 | * Get the subtitle |
||
| 1054 | * |
||
| 1055 | * @return string |
||
| 1056 | */ |
||
| 1057 | public function getSubtitle() { |
||
| 1060 | |||
| 1061 | /** |
||
| 1062 | * Set the page as printable, i.e. it'll be displayed with all |
||
| 1063 | * print styles included |
||
| 1064 | */ |
||
| 1065 | public function setPrintable() { |
||
| 1068 | |||
| 1069 | /** |
||
| 1070 | * Return whether the page is "printable" |
||
| 1071 | * |
||
| 1072 | * @return bool |
||
| 1073 | */ |
||
| 1074 | public function isPrintable() { |
||
| 1077 | |||
| 1078 | /** |
||
| 1079 | * Disable output completely, i.e. calling output() will have no effect |
||
| 1080 | */ |
||
| 1081 | public function disable() { |
||
| 1084 | |||
| 1085 | /** |
||
| 1086 | * Return whether the output will be completely disabled |
||
| 1087 | * |
||
| 1088 | * @return bool |
||
| 1089 | */ |
||
| 1090 | public function isDisabled() { |
||
| 1093 | |||
| 1094 | /** |
||
| 1095 | * Show an "add new section" link? |
||
| 1096 | * |
||
| 1097 | * @return bool |
||
| 1098 | */ |
||
| 1099 | public function showNewSectionLink() { |
||
| 1102 | |||
| 1103 | /** |
||
| 1104 | * Forcibly hide the new section link? |
||
| 1105 | * |
||
| 1106 | * @return bool |
||
| 1107 | */ |
||
| 1108 | public function forceHideNewSectionLink() { |
||
| 1111 | |||
| 1112 | /** |
||
| 1113 | * Add or remove feed links in the page header |
||
| 1114 | * This is mainly kept for backward compatibility, see OutputPage::addFeedLink() |
||
| 1115 | * for the new version |
||
| 1116 | * @see addFeedLink() |
||
| 1117 | * |
||
| 1118 | * @param bool $show True: add default feeds, false: remove all feeds |
||
| 1119 | */ |
||
| 1120 | public function setSyndicated( $show = true ) { |
||
| 1127 | |||
| 1128 | /** |
||
| 1129 | * Add default feeds to the page header |
||
| 1130 | * This is mainly kept for backward compatibility, see OutputPage::addFeedLink() |
||
| 1131 | * for the new version |
||
| 1132 | * @see addFeedLink() |
||
| 1133 | * |
||
| 1134 | * @param string $val Query to append to feed links or false to output |
||
| 1135 | * default links |
||
| 1136 | */ |
||
| 1137 | public function setFeedAppendQuery( $val ) { |
||
| 1148 | |||
| 1149 | /** |
||
| 1150 | * Add a feed link to the page header |
||
| 1151 | * |
||
| 1152 | * @param string $format Feed type, should be a key of $wgFeedClasses |
||
| 1153 | * @param string $href URL |
||
| 1154 | */ |
||
| 1155 | public function addFeedLink( $format, $href ) { |
||
| 1160 | |||
| 1161 | /** |
||
| 1162 | * Should we output feed links for this page? |
||
| 1163 | * @return bool |
||
| 1164 | */ |
||
| 1165 | public function isSyndicated() { |
||
| 1168 | |||
| 1169 | /** |
||
| 1170 | * Return URLs for each supported syndication format for this page. |
||
| 1171 | * @return array Associating format keys with URLs |
||
| 1172 | */ |
||
| 1173 | public function getSyndicationLinks() { |
||
| 1176 | |||
| 1177 | /** |
||
| 1178 | * Will currently always return null |
||
| 1179 | * |
||
| 1180 | * @return null |
||
| 1181 | */ |
||
| 1182 | public function getFeedAppendQuery() { |
||
| 1185 | |||
| 1186 | /** |
||
| 1187 | * Set whether the displayed content is related to the source of the |
||
| 1188 | * corresponding article on the wiki |
||
| 1189 | * Setting true will cause the change "article related" toggle to true |
||
| 1190 | * |
||
| 1191 | * @param bool $v |
||
| 1192 | */ |
||
| 1193 | public function setArticleFlag( $v ) { |
||
| 1199 | |||
| 1200 | /** |
||
| 1201 | * Return whether the content displayed page is related to the source of |
||
| 1202 | * the corresponding article on the wiki |
||
| 1203 | * |
||
| 1204 | * @return bool |
||
| 1205 | */ |
||
| 1206 | public function isArticle() { |
||
| 1209 | |||
| 1210 | /** |
||
| 1211 | * Set whether this page is related an article on the wiki |
||
| 1212 | * Setting false will cause the change of "article flag" toggle to false |
||
| 1213 | * |
||
| 1214 | * @param bool $v |
||
| 1215 | */ |
||
| 1216 | public function setArticleRelated( $v ) { |
||
| 1222 | |||
| 1223 | /** |
||
| 1224 | * Return whether this page is related an article on the wiki |
||
| 1225 | * |
||
| 1226 | * @return bool |
||
| 1227 | */ |
||
| 1228 | public function isArticleRelated() { |
||
| 1231 | |||
| 1232 | /** |
||
| 1233 | * Add new language links |
||
| 1234 | * |
||
| 1235 | * @param array $newLinkArray Associative array mapping language code to the page |
||
| 1236 | * name |
||
| 1237 | */ |
||
| 1238 | public function addLanguageLinks( array $newLinkArray ) { |
||
| 1241 | |||
| 1242 | /** |
||
| 1243 | * Reset the language links and add new language links |
||
| 1244 | * |
||
| 1245 | * @param array $newLinkArray Associative array mapping language code to the page |
||
| 1246 | * name |
||
| 1247 | */ |
||
| 1248 | public function setLanguageLinks( array $newLinkArray ) { |
||
| 1251 | |||
| 1252 | /** |
||
| 1253 | * Get the list of language links |
||
| 1254 | * |
||
| 1255 | * @return array Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page') |
||
| 1256 | */ |
||
| 1257 | public function getLanguageLinks() { |
||
| 1260 | |||
| 1261 | /** |
||
| 1262 | * Add an array of categories, with names in the keys |
||
| 1263 | * |
||
| 1264 | * @param array $categories Mapping category name => sort key |
||
| 1265 | */ |
||
| 1266 | public function addCategoryLinks( array $categories ) { |
||
| 1337 | |||
| 1338 | /** |
||
| 1339 | * Reset the category links (but not the category list) and add $categories |
||
| 1340 | * |
||
| 1341 | * @param array $categories Mapping category name => sort key |
||
| 1342 | */ |
||
| 1343 | public function setCategoryLinks( array $categories ) { |
||
| 1347 | |||
| 1348 | /** |
||
| 1349 | * Get the list of category links, in a 2-D array with the following format: |
||
| 1350 | * $arr[$type][] = $link, where $type is either "normal" or "hidden" (for |
||
| 1351 | * hidden categories) and $link a HTML fragment with a link to the category |
||
| 1352 | * page |
||
| 1353 | * |
||
| 1354 | * @return array |
||
| 1355 | */ |
||
| 1356 | public function getCategoryLinks() { |
||
| 1359 | |||
| 1360 | /** |
||
| 1361 | * Get the list of category names this page belongs to |
||
| 1362 | * |
||
| 1363 | * @return array Array of strings |
||
| 1364 | */ |
||
| 1365 | public function getCategories() { |
||
| 1368 | |||
| 1369 | /** |
||
| 1370 | * Add an array of indicators, with their identifiers as array |
||
| 1371 | * keys and HTML contents as values. |
||
| 1372 | * |
||
| 1373 | * In case of duplicate keys, existing values are overwritten. |
||
| 1374 | * |
||
| 1375 | * @param array $indicators |
||
| 1376 | * @since 1.25 |
||
| 1377 | */ |
||
| 1378 | public function setIndicators( array $indicators ) { |
||
| 1383 | |||
| 1384 | /** |
||
| 1385 | * Get the indicators associated with this page. |
||
| 1386 | * |
||
| 1387 | * The array will be internally ordered by item keys. |
||
| 1388 | * |
||
| 1389 | * @return array Keys: identifiers, values: HTML contents |
||
| 1390 | * @since 1.25 |
||
| 1391 | */ |
||
| 1392 | public function getIndicators() { |
||
| 1395 | |||
| 1396 | /** |
||
| 1397 | * Adds help link with an icon via page indicators. |
||
| 1398 | * Link target can be overridden by a local message containing a wikilink: |
||
| 1399 | * the message key is: lowercase action or special page name + '-helppage'. |
||
| 1400 | * @param string $to Target MediaWiki.org page title or encoded URL. |
||
| 1401 | * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o. |
||
| 1402 | * @since 1.25 |
||
| 1403 | */ |
||
| 1404 | public function addHelpLink( $to, $overrideBaseUrl = false ) { |
||
| 1427 | |||
| 1428 | /** |
||
| 1429 | * Do not allow scripts which can be modified by wiki users to load on this page; |
||
| 1430 | * only allow scripts bundled with, or generated by, the software. |
||
| 1431 | * Site-wide styles are controlled by a config setting, since they can be |
||
| 1432 | * used to create a custom skin/theme, but not user-specific ones. |
||
| 1433 | * |
||
| 1434 | * @todo this should be given a more accurate name |
||
| 1435 | */ |
||
| 1436 | public function disallowUserJs() { |
||
| 1454 | |||
| 1455 | /** |
||
| 1456 | * Show what level of JavaScript / CSS untrustworthiness is allowed on this page |
||
| 1457 | * @see ResourceLoaderModule::$origin |
||
| 1458 | * @param string $type ResourceLoaderModule TYPE_ constant |
||
| 1459 | * @return int ResourceLoaderModule ORIGIN_ class constant |
||
| 1460 | */ |
||
| 1461 | public function getAllowedModules( $type ) { |
||
| 1470 | |||
| 1471 | /** |
||
| 1472 | * Limit the highest level of CSS/JS untrustworthiness allowed. |
||
| 1473 | * |
||
| 1474 | * If passed the same or a higher level than the current level of untrustworthiness set, the |
||
| 1475 | * level will remain unchanged. |
||
| 1476 | * |
||
| 1477 | * @param string $type |
||
| 1478 | * @param int $level ResourceLoaderModule class constant |
||
| 1479 | */ |
||
| 1480 | public function reduceAllowedModules( $type, $level ) { |
||
| 1483 | |||
| 1484 | /** |
||
| 1485 | * Prepend $text to the body HTML |
||
| 1486 | * |
||
| 1487 | * @param string $text HTML |
||
| 1488 | */ |
||
| 1489 | public function prependHTML( $text ) { |
||
| 1492 | |||
| 1493 | /** |
||
| 1494 | * Append $text to the body HTML |
||
| 1495 | * |
||
| 1496 | * @param string $text HTML |
||
| 1497 | */ |
||
| 1498 | public function addHTML( $text ) { |
||
| 1501 | |||
| 1502 | /** |
||
| 1503 | * Shortcut for adding an Html::element via addHTML. |
||
| 1504 | * |
||
| 1505 | * @since 1.19 |
||
| 1506 | * |
||
| 1507 | * @param string $element |
||
| 1508 | * @param array $attribs |
||
| 1509 | * @param string $contents |
||
| 1510 | */ |
||
| 1511 | public function addElement( $element, array $attribs = [], $contents = '' ) { |
||
| 1514 | |||
| 1515 | /** |
||
| 1516 | * Clear the body HTML |
||
| 1517 | */ |
||
| 1518 | public function clearHTML() { |
||
| 1521 | |||
| 1522 | /** |
||
| 1523 | * Get the body HTML |
||
| 1524 | * |
||
| 1525 | * @return string HTML |
||
| 1526 | */ |
||
| 1527 | public function getHTML() { |
||
| 1530 | |||
| 1531 | /** |
||
| 1532 | * Get/set the ParserOptions object to use for wikitext parsing |
||
| 1533 | * |
||
| 1534 | * @param ParserOptions|null $options Either the ParserOption to use or null to only get the |
||
| 1535 | * current ParserOption object |
||
| 1536 | * @return ParserOptions |
||
| 1537 | */ |
||
| 1538 | public function parserOptions( $options = null ) { |
||
| 1576 | |||
| 1577 | /** |
||
| 1578 | * Set the revision ID which will be seen by the wiki text parser |
||
| 1579 | * for things such as embedded {{REVISIONID}} variable use. |
||
| 1580 | * |
||
| 1581 | * @param int|null $revid An positive integer, or null |
||
| 1582 | * @return mixed Previous value |
||
| 1583 | */ |
||
| 1584 | public function setRevisionId( $revid ) { |
||
| 1588 | |||
| 1589 | /** |
||
| 1590 | * Get the displayed revision ID |
||
| 1591 | * |
||
| 1592 | * @return int |
||
| 1593 | */ |
||
| 1594 | public function getRevisionId() { |
||
| 1597 | |||
| 1598 | /** |
||
| 1599 | * Set the timestamp of the revision which will be displayed. This is used |
||
| 1600 | * to avoid a extra DB call in Skin::lastModified(). |
||
| 1601 | * |
||
| 1602 | * @param string|null $timestamp |
||
| 1603 | * @return mixed Previous value |
||
| 1604 | */ |
||
| 1605 | public function setRevisionTimestamp( $timestamp ) { |
||
| 1608 | |||
| 1609 | /** |
||
| 1610 | * Get the timestamp of displayed revision. |
||
| 1611 | * This will be null if not filled by setRevisionTimestamp(). |
||
| 1612 | * |
||
| 1613 | * @return string|null |
||
| 1614 | */ |
||
| 1615 | public function getRevisionTimestamp() { |
||
| 1618 | |||
| 1619 | /** |
||
| 1620 | * Set the displayed file version |
||
| 1621 | * |
||
| 1622 | * @param File|bool $file |
||
| 1623 | * @return mixed Previous value |
||
| 1624 | */ |
||
| 1625 | public function setFileVersion( $file ) { |
||
| 1632 | |||
| 1633 | /** |
||
| 1634 | * Get the displayed file version |
||
| 1635 | * |
||
| 1636 | * @return array|null ('time' => MW timestamp, 'sha1' => sha1) |
||
| 1637 | */ |
||
| 1638 | public function getFileVersion() { |
||
| 1641 | |||
| 1642 | /** |
||
| 1643 | * Get the templates used on this page |
||
| 1644 | * |
||
| 1645 | * @return array (namespace => dbKey => revId) |
||
| 1646 | * @since 1.18 |
||
| 1647 | */ |
||
| 1648 | public function getTemplateIds() { |
||
| 1651 | |||
| 1652 | /** |
||
| 1653 | * Get the files used on this page |
||
| 1654 | * |
||
| 1655 | * @return array (dbKey => array('time' => MW timestamp or null, 'sha1' => sha1 or '')) |
||
| 1656 | * @since 1.18 |
||
| 1657 | */ |
||
| 1658 | public function getFileSearchOptions() { |
||
| 1661 | |||
| 1662 | /** |
||
| 1663 | * Convert wikitext to HTML and add it to the buffer |
||
| 1664 | * Default assumes that the current page title will be used. |
||
| 1665 | * |
||
| 1666 | * @param string $text |
||
| 1667 | * @param bool $linestart Is this the start of a line? |
||
| 1668 | * @param bool $interface Is this text in the user interface language? |
||
| 1669 | * @throws MWException |
||
| 1670 | */ |
||
| 1671 | public function addWikiText( $text, $linestart = true, $interface = true ) { |
||
| 1678 | |||
| 1679 | /** |
||
| 1680 | * Add wikitext with a custom Title object |
||
| 1681 | * |
||
| 1682 | * @param string $text Wikitext |
||
| 1683 | * @param Title $title |
||
| 1684 | * @param bool $linestart Is this the start of a line? |
||
| 1685 | */ |
||
| 1686 | public function addWikiTextWithTitle( $text, &$title, $linestart = true ) { |
||
| 1689 | |||
| 1690 | /** |
||
| 1691 | * Add wikitext with a custom Title object and tidy enabled. |
||
| 1692 | * |
||
| 1693 | * @param string $text Wikitext |
||
| 1694 | * @param Title $title |
||
| 1695 | * @param bool $linestart Is this the start of a line? |
||
| 1696 | */ |
||
| 1697 | function addWikiTextTitleTidy( $text, &$title, $linestart = true ) { |
||
| 1700 | |||
| 1701 | /** |
||
| 1702 | * Add wikitext with tidy enabled |
||
| 1703 | * |
||
| 1704 | * @param string $text Wikitext |
||
| 1705 | * @param bool $linestart Is this the start of a line? |
||
| 1706 | */ |
||
| 1707 | public function addWikiTextTidy( $text, $linestart = true ) { |
||
| 1711 | |||
| 1712 | /** |
||
| 1713 | * Add wikitext with a custom Title object |
||
| 1714 | * |
||
| 1715 | * @param string $text Wikitext |
||
| 1716 | * @param Title $title |
||
| 1717 | * @param bool $linestart Is this the start of a line? |
||
| 1718 | * @param bool $tidy Whether to use tidy |
||
| 1719 | * @param bool $interface Whether it is an interface message |
||
| 1720 | * (for example disables conversion) |
||
| 1721 | */ |
||
| 1722 | public function addWikiTextTitle( $text, Title $title, $linestart, |
||
| 1741 | |||
| 1742 | /** |
||
| 1743 | * Add a ParserOutput object, but without Html. |
||
| 1744 | * |
||
| 1745 | * @deprecated since 1.24, use addParserOutputMetadata() instead. |
||
| 1746 | * @param ParserOutput $parserOutput |
||
| 1747 | */ |
||
| 1748 | public function addParserOutputNoText( $parserOutput ) { |
||
| 1752 | |||
| 1753 | /** |
||
| 1754 | * Add all metadata associated with a ParserOutput object, but without the actual HTML. This |
||
| 1755 | * includes categories, language links, ResourceLoader modules, effects of certain magic words, |
||
| 1756 | * and so on. |
||
| 1757 | * |
||
| 1758 | * @since 1.24 |
||
| 1759 | * @param ParserOutput $parserOutput |
||
| 1760 | */ |
||
| 1761 | public function addParserOutputMetadata( $parserOutput ) { |
||
| 1813 | |||
| 1814 | /** |
||
| 1815 | * Add the HTML and enhancements for it (like ResourceLoader modules) associated with a |
||
| 1816 | * ParserOutput object, without any other metadata. |
||
| 1817 | * |
||
| 1818 | * @since 1.24 |
||
| 1819 | * @param ParserOutput $parserOutput |
||
| 1820 | */ |
||
| 1821 | public function addParserOutputContent( $parserOutput ) { |
||
| 1830 | |||
| 1831 | /** |
||
| 1832 | * Add the HTML associated with a ParserOutput object, without any metadata. |
||
| 1833 | * |
||
| 1834 | * @since 1.24 |
||
| 1835 | * @param ParserOutput $parserOutput |
||
| 1836 | */ |
||
| 1837 | public function addParserOutputText( $parserOutput ) { |
||
| 1842 | |||
| 1843 | /** |
||
| 1844 | * Add everything from a ParserOutput object. |
||
| 1845 | * |
||
| 1846 | * @param ParserOutput $parserOutput |
||
| 1847 | */ |
||
| 1848 | function addParserOutput( $parserOutput ) { |
||
| 1859 | |||
| 1860 | /** |
||
| 1861 | * Add the output of a QuickTemplate to the output buffer |
||
| 1862 | * |
||
| 1863 | * @param QuickTemplate $template |
||
| 1864 | */ |
||
| 1865 | public function addTemplate( &$template ) { |
||
| 1868 | |||
| 1869 | /** |
||
| 1870 | * Parse wikitext and return the HTML. |
||
| 1871 | * |
||
| 1872 | * @param string $text |
||
| 1873 | * @param bool $linestart Is this the start of a line? |
||
| 1874 | * @param bool $interface Use interface language ($wgLang instead of |
||
| 1875 | * $wgContLang) while parsing language sensitive magic words like GRAMMAR and PLURAL. |
||
| 1876 | * This also disables LanguageConverter. |
||
| 1877 | * @param Language $language Target language object, will override $interface |
||
| 1878 | * @throws MWException |
||
| 1879 | * @return string HTML |
||
| 1880 | */ |
||
| 1881 | public function parse( $text, $linestart = true, $interface = false, $language = null ) { |
||
| 1910 | |||
| 1911 | /** |
||
| 1912 | * Parse wikitext, strip paragraphs, and return the HTML. |
||
| 1913 | * |
||
| 1914 | * @param string $text |
||
| 1915 | * @param bool $linestart Is this the start of a line? |
||
| 1916 | * @param bool $interface Use interface language ($wgLang instead of |
||
| 1917 | * $wgContLang) while parsing language sensitive magic |
||
| 1918 | * words like GRAMMAR and PLURAL |
||
| 1919 | * @return string HTML |
||
| 1920 | */ |
||
| 1921 | public function parseInline( $text, $linestart = true, $interface = false ) { |
||
| 1925 | |||
| 1926 | /** |
||
| 1927 | * @param $maxage |
||
| 1928 | * @deprecated since 1.27 Use setCdnMaxage() instead |
||
| 1929 | */ |
||
| 1930 | public function setSquidMaxage( $maxage ) { |
||
| 1933 | |||
| 1934 | /** |
||
| 1935 | * Set the value of the "s-maxage" part of the "Cache-control" HTTP header |
||
| 1936 | * |
||
| 1937 | * @param int $maxage Maximum cache time on the CDN, in seconds. |
||
| 1938 | */ |
||
| 1939 | public function setCdnMaxage( $maxage ) { |
||
| 1942 | |||
| 1943 | /** |
||
| 1944 | * Lower the value of the "s-maxage" part of the "Cache-control" HTTP header |
||
| 1945 | * |
||
| 1946 | * @param int $maxage Maximum cache time on the CDN, in seconds |
||
| 1947 | * @since 1.27 |
||
| 1948 | */ |
||
| 1949 | public function lowerCdnMaxage( $maxage ) { |
||
| 1953 | |||
| 1954 | /** |
||
| 1955 | * Use enableClientCache(false) to force it to send nocache headers |
||
| 1956 | * |
||
| 1957 | * @param bool $state |
||
| 1958 | * |
||
| 1959 | * @return bool |
||
| 1960 | */ |
||
| 1961 | public function enableClientCache( $state ) { |
||
| 1964 | |||
| 1965 | /** |
||
| 1966 | * Get the list of cookies that will influence on the cache |
||
| 1967 | * |
||
| 1968 | * @return array |
||
| 1969 | */ |
||
| 1970 | function getCacheVaryCookies() { |
||
| 1985 | |||
| 1986 | /** |
||
| 1987 | * Check if the request has a cache-varying cookie header |
||
| 1988 | * If it does, it's very important that we don't allow public caching |
||
| 1989 | * |
||
| 1990 | * @return bool |
||
| 1991 | */ |
||
| 1992 | function haveCacheVaryCookies() { |
||
| 2003 | |||
| 2004 | /** |
||
| 2005 | * Add an HTTP header that will influence on the cache |
||
| 2006 | * |
||
| 2007 | * @param string $header Header name |
||
| 2008 | * @param string[]|null $option Options for the Key header. See |
||
| 2009 | * https://datatracker.ietf.org/doc/draft-fielding-http-key/ |
||
| 2010 | * for the list of valid options. |
||
| 2011 | */ |
||
| 2012 | public function addVaryHeader( $header, array $option = null ) { |
||
| 2021 | |||
| 2022 | /** |
||
| 2023 | * Return a Vary: header on which to vary caches. Based on the keys of $mVaryHeader, |
||
| 2024 | * such as Accept-Encoding or Cookie |
||
| 2025 | * |
||
| 2026 | * @return string |
||
| 2027 | */ |
||
| 2028 | public function getVaryHeader() { |
||
| 2034 | |||
| 2035 | /** |
||
| 2036 | * Get a complete Key header |
||
| 2037 | * |
||
| 2038 | * @return string |
||
| 2039 | */ |
||
| 2040 | public function getKeyHeader() { |
||
| 2065 | |||
| 2066 | /** |
||
| 2067 | * T23672: Add Accept-Language to Vary and Key headers |
||
| 2068 | * if there's no 'variant' parameter existed in GET. |
||
| 2069 | * |
||
| 2070 | * For example: |
||
| 2071 | * /w/index.php?title=Main_page should always be served; but |
||
| 2072 | * /w/index.php?title=Main_page&variant=zh-cn should never be served. |
||
| 2073 | */ |
||
| 2074 | function addAcceptLanguage() { |
||
| 2102 | |||
| 2103 | /** |
||
| 2104 | * Set a flag which will cause an X-Frame-Options header appropriate for |
||
| 2105 | * edit pages to be sent. The header value is controlled by |
||
| 2106 | * $wgEditPageFrameOptions. |
||
| 2107 | * |
||
| 2108 | * This is the default for special pages. If you display a CSRF-protected |
||
| 2109 | * form on an ordinary view page, then you need to call this function. |
||
| 2110 | * |
||
| 2111 | * @param bool $enable |
||
| 2112 | */ |
||
| 2113 | public function preventClickjacking( $enable = true ) { |
||
| 2116 | |||
| 2117 | /** |
||
| 2118 | * Turn off frame-breaking. Alias for $this->preventClickjacking(false). |
||
| 2119 | * This can be called from pages which do not contain any CSRF-protected |
||
| 2120 | * HTML form. |
||
| 2121 | */ |
||
| 2122 | public function allowClickjacking() { |
||
| 2125 | |||
| 2126 | /** |
||
| 2127 | * Get the prevent-clickjacking flag |
||
| 2128 | * |
||
| 2129 | * @since 1.24 |
||
| 2130 | * @return bool |
||
| 2131 | */ |
||
| 2132 | public function getPreventClickjacking() { |
||
| 2135 | |||
| 2136 | /** |
||
| 2137 | * Get the X-Frame-Options header value (without the name part), or false |
||
| 2138 | * if there isn't one. This is used by Skin to determine whether to enable |
||
| 2139 | * JavaScript frame-breaking, for clients that don't support X-Frame-Options. |
||
| 2140 | * |
||
| 2141 | * @return string |
||
| 2142 | */ |
||
| 2143 | public function getFrameOptions() { |
||
| 2152 | |||
| 2153 | /** |
||
| 2154 | * Send cache control HTTP headers |
||
| 2155 | */ |
||
| 2156 | public function sendCacheControl() { |
||
| 2224 | |||
| 2225 | /** |
||
| 2226 | * Finally, all the text has been munged and accumulated into |
||
| 2227 | * the object, let's actually output it: |
||
| 2228 | */ |
||
| 2229 | 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 | /** |
||
| 2632 | * @param Skin $sk The given Skin |
||
| 2633 | * @param bool $includeStyle Unused |
||
| 2634 | * @return string The doctype, opening "<html>", and head element. |
||
| 2635 | */ |
||
| 2636 | public function headElement( Skin $sk, $includeStyle = true ) { |
||
| 2714 | |||
| 2715 | /** |
||
| 2716 | * Get a ResourceLoader object associated with this OutputPage |
||
| 2717 | * |
||
| 2718 | * @return ResourceLoader |
||
| 2719 | */ |
||
| 2720 | public function getResourceLoader() { |
||
| 2729 | |||
| 2730 | /** |
||
| 2731 | * Construct neccecary html and loader preset states to load modules on a page. |
||
| 2732 | * |
||
| 2733 | * Use getHtmlFromLoaderLinks() to convert this array to HTML. |
||
| 2734 | * |
||
| 2735 | * @param array|string $modules One or more module names |
||
| 2736 | * @param string $only ResourceLoaderModule TYPE_ class constant |
||
| 2737 | * @param array $extraQuery [optional] Array with extra query parameters for the request |
||
| 2738 | * @return array A list of HTML strings and array of client loader preset states |
||
| 2739 | */ |
||
| 2740 | public function makeResourceLoaderLink( $modules, $only, array $extraQuery = [] ) { |
||
| 2909 | |||
| 2910 | /** |
||
| 2911 | * Build html output from an array of links from makeResourceLoaderLink. |
||
| 2912 | * @param array $links |
||
| 2913 | * @return string HTML |
||
| 2914 | */ |
||
| 2915 | protected static function getHtmlFromLoaderLinks( array $links ) { |
||
| 2937 | |||
| 2938 | /** |
||
| 2939 | * JS stuff to put in the "<head>". This is the startup module, config |
||
| 2940 | * vars and modules marked with position 'top' |
||
| 2941 | * |
||
| 2942 | * @return string HTML fragment |
||
| 2943 | */ |
||
| 2944 | function getHeadScripts() { |
||
| 2947 | |||
| 2948 | /** |
||
| 2949 | * <script src="..."> tags for "<head>". This is the startup module |
||
| 2950 | * and other modules marked with position 'top'. |
||
| 2951 | * |
||
| 2952 | * @return string HTML fragment |
||
| 2953 | */ |
||
| 2954 | function getExternalHeadScripts() { |
||
| 2963 | |||
| 2964 | /** |
||
| 2965 | * <script>...</script> tags to put in "<head>". |
||
| 2966 | * |
||
| 2967 | * @return string HTML fragment |
||
| 2968 | */ |
||
| 2969 | function getInlineHeadScripts() { |
||
| 3019 | |||
| 3020 | /** |
||
| 3021 | * JS stuff to put at the 'bottom', which goes at the bottom of the `<body>`. |
||
| 3022 | * These are modules marked with position 'bottom', legacy scripts ($this->mScripts), |
||
| 3023 | * site JS, and user JS. |
||
| 3024 | * |
||
| 3025 | * @param bool $unused Previously used to let this method change its output based |
||
| 3026 | * on whether it was called by getExternalHeadScripts() or getBottomScripts(). |
||
| 3027 | * @return string |
||
| 3028 | */ |
||
| 3029 | function getScriptsForBottomQueue( $unused = null ) { |
||
| 3097 | |||
| 3098 | /** |
||
| 3099 | * JS stuff to put at the bottom of the "<body>" |
||
| 3100 | * @return string |
||
| 3101 | */ |
||
| 3102 | function getBottomScripts() { |
||
| 3105 | |||
| 3106 | /** |
||
| 3107 | * Get the javascript config vars to include on this page |
||
| 3108 | * |
||
| 3109 | * @return array Array of javascript config vars |
||
| 3110 | * @since 1.23 |
||
| 3111 | */ |
||
| 3112 | public function getJsConfigVars() { |
||
| 3115 | |||
| 3116 | /** |
||
| 3117 | * Add one or more variables to be set in mw.config in JavaScript |
||
| 3118 | * |
||
| 3119 | * @param string|array $keys Key or array of key/value pairs |
||
| 3120 | * @param mixed $value [optional] Value of the configuration variable |
||
| 3121 | */ |
||
| 3122 | View Code Duplication | public function addJsConfigVars( $keys, $value = null ) { |
|
| 3132 | |||
| 3133 | /** |
||
| 3134 | * Get an array containing the variables to be set in mw.config in JavaScript. |
||
| 3135 | * |
||
| 3136 | * Do not add things here which can be evaluated in ResourceLoaderStartUpModule |
||
| 3137 | * - in other words, page-independent/site-wide variables (without state). |
||
| 3138 | * You will only be adding bloat to the html page and causing page caches to |
||
| 3139 | * have to be purged on configuration changes. |
||
| 3140 | * @return array |
||
| 3141 | */ |
||
| 3142 | public function getJSVars() { |
||
| 3258 | |||
| 3259 | /** |
||
| 3260 | * To make it harder for someone to slip a user a fake |
||
| 3261 | * user-JavaScript or user-CSS preview, a random token |
||
| 3262 | * is associated with the login session. If it's not |
||
| 3263 | * passed back with the preview request, we won't render |
||
| 3264 | * the code. |
||
| 3265 | * |
||
| 3266 | * @return bool |
||
| 3267 | */ |
||
| 3268 | public function userCanPreview() { |
||
| 3299 | |||
| 3300 | /** |
||
| 3301 | * @return array Array in format "link name or number => 'link html'". |
||
| 3302 | */ |
||
| 3303 | public function getHeadLinksArray() { |
||
| 3564 | |||
| 3565 | /** |
||
| 3566 | * @return string HTML tag links to be put in the header. |
||
| 3567 | * @deprecated since 1.24 Use OutputPage::headElement or if you have to, |
||
| 3568 | * OutputPage::getHeadLinksArray directly. |
||
| 3569 | */ |
||
| 3570 | public function getHeadLinks() { |
||
| 3574 | |||
| 3575 | /** |
||
| 3576 | * Generate a "<link rel/>" for a feed. |
||
| 3577 | * |
||
| 3578 | * @param string $type Feed type |
||
| 3579 | * @param string $url URL to the feed |
||
| 3580 | * @param string $text Value of the "title" attribute |
||
| 3581 | * @return string HTML fragment |
||
| 3582 | */ |
||
| 3583 | private function feedLink( $type, $url, $text ) { |
||
| 3591 | |||
| 3592 | /** |
||
| 3593 | * Add a local or specified stylesheet, with the given media options. |
||
| 3594 | * Internal use only. Use OutputPage::addModuleStyles() if possible. |
||
| 3595 | * |
||
| 3596 | * @param string $style URL to the file |
||
| 3597 | * @param string $media To specify a media type, 'screen', 'printable', 'handheld' or any. |
||
| 3598 | * @param string $condition For IE conditional comments, specifying an IE version |
||
| 3599 | * @param string $dir Set to 'rtl' or 'ltr' for direction-specific sheets |
||
| 3600 | */ |
||
| 3601 | public function addStyle( $style, $media = '', $condition = '', $dir = '' ) { |
||
| 3614 | |||
| 3615 | /** |
||
| 3616 | * Adds inline CSS styles |
||
| 3617 | * Internal use only. Use OutputPage::addModuleStyles() if possible. |
||
| 3618 | * |
||
| 3619 | * @param mixed $style_css Inline CSS |
||
| 3620 | * @param string $flip Set to 'flip' to flip the CSS if needed |
||
| 3621 | */ |
||
| 3622 | public function addInlineStyle( $style_css, $flip = 'noflip' ) { |
||
| 3629 | |||
| 3630 | /** |
||
| 3631 | * Build a set of "<link>" elements for the stylesheets specified in the $this->styles array. |
||
| 3632 | * These will be applied to various media & IE conditionals. |
||
| 3633 | * |
||
| 3634 | * @return string |
||
| 3635 | */ |
||
| 3636 | public function buildCssLinks() { |
||
| 3739 | |||
| 3740 | /** |
||
| 3741 | * @return array |
||
| 3742 | */ |
||
| 3743 | public function buildCssLinksArray() { |
||
| 3760 | |||
| 3761 | /** |
||
| 3762 | * Generate \<link\> tags for stylesheets |
||
| 3763 | * |
||
| 3764 | * @param string $style URL to the file |
||
| 3765 | * @param array $options Option, can contain 'condition', 'dir', 'media' keys |
||
| 3766 | * @return string HTML fragment |
||
| 3767 | */ |
||
| 3768 | protected function styleLink( $style, array $options ) { |
||
| 3802 | |||
| 3803 | /** |
||
| 3804 | * Transform path to web-accessible static resource. |
||
| 3805 | * |
||
| 3806 | * This is used to add a validation hash as query string. |
||
| 3807 | * This aids various behaviors: |
||
| 3808 | * |
||
| 3809 | * - Put long Cache-Control max-age headers on responses for improved |
||
| 3810 | * cache performance. |
||
| 3811 | * - Get the correct version of a file as expected by the current page. |
||
| 3812 | * - Instantly get the updated version of a file after deployment. |
||
| 3813 | * |
||
| 3814 | * Avoid using this for urls included in HTML as otherwise clients may get different |
||
| 3815 | * versions of a resource when navigating the site depending on when the page was cached. |
||
| 3816 | * If changes to the url propagate, this is not a problem (e.g. if the url is in |
||
| 3817 | * an external stylesheet). |
||
| 3818 | * |
||
| 3819 | * @since 1.27 |
||
| 3820 | * @param Config $config |
||
| 3821 | * @param string $path Path-absolute URL to file (from document root, must start with "/") |
||
| 3822 | * @return string URL |
||
| 3823 | */ |
||
| 3824 | public static function transformResourcePath( Config $config, $path ) { |
||
| 3841 | |||
| 3842 | /** |
||
| 3843 | * Utility method for transformResourceFilePath(). |
||
| 3844 | * |
||
| 3845 | * Caller is responsible for ensuring the file exists. Emits a PHP warning otherwise. |
||
| 3846 | * |
||
| 3847 | * @since 1.27 |
||
| 3848 | * @param string $remotePath URL path prefix that points to $localPath |
||
| 3849 | * @param string $localPath File directory exposed at $remotePath |
||
| 3850 | * @param string $file Path to target file relative to $localPath |
||
| 3851 | * @return string URL |
||
| 3852 | */ |
||
| 3853 | public static function transformFilePath( $remotePathPrefix, $localPath, $file ) { |
||
| 3861 | |||
| 3862 | /** |
||
| 3863 | * Transform "media" attribute based on request parameters |
||
| 3864 | * |
||
| 3865 | * @param string $media Current value of the "media" attribute |
||
| 3866 | * @return string Modified value of the "media" attribute, or null to skip |
||
| 3867 | * this stylesheet |
||
| 3868 | */ |
||
| 3869 | public static function transformCssMedia( $media ) { |
||
| 3907 | |||
| 3908 | /** |
||
| 3909 | * Add a wikitext-formatted message to the output. |
||
| 3910 | * This is equivalent to: |
||
| 3911 | * |
||
| 3912 | * $wgOut->addWikiText( wfMessage( ... )->plain() ) |
||
| 3913 | */ |
||
| 3914 | public function addWikiMsg( /*...*/ ) { |
||
| 3919 | |||
| 3920 | /** |
||
| 3921 | * Add a wikitext-formatted message to the output. |
||
| 3922 | * Like addWikiMsg() except the parameters are taken as an array |
||
| 3923 | * instead of a variable argument list. |
||
| 3924 | * |
||
| 3925 | * @param string $name |
||
| 3926 | * @param array $args |
||
| 3927 | */ |
||
| 3928 | public function addWikiMsgArray( $name, $args ) { |
||
| 3931 | |||
| 3932 | /** |
||
| 3933 | * This function takes a number of message/argument specifications, wraps them in |
||
| 3934 | * some overall structure, and then parses the result and adds it to the output. |
||
| 3935 | * |
||
| 3936 | * In the $wrap, $1 is replaced with the first message, $2 with the second, |
||
| 3937 | * and so on. The subsequent arguments may be either |
||
| 3938 | * 1) strings, in which case they are message names, or |
||
| 3939 | * 2) arrays, in which case, within each array, the first element is the message |
||
| 3940 | * name, and subsequent elements are the parameters to that message. |
||
| 3941 | * |
||
| 3942 | * Don't use this for messages that are not in the user's interface language. |
||
| 3943 | * |
||
| 3944 | * For example: |
||
| 3945 | * |
||
| 3946 | * $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>", 'some-error' ); |
||
| 3947 | * |
||
| 3948 | * Is equivalent to: |
||
| 3949 | * |
||
| 3950 | * $wgOut->addWikiText( "<div class='error'>\n" |
||
| 3951 | * . wfMessage( 'some-error' )->plain() . "\n</div>" ); |
||
| 3952 | * |
||
| 3953 | * The newline after the opening div is needed in some wikitext. See bug 19226. |
||
| 3954 | * |
||
| 3955 | * @param string $wrap |
||
| 3956 | */ |
||
| 3957 | public function wrapWikiMsg( $wrap /*, ...*/ ) { |
||
| 3981 | |||
| 3982 | /** |
||
| 3983 | * Enables/disables TOC, doesn't override __NOTOC__ |
||
| 3984 | * @param bool $flag |
||
| 3985 | * @since 1.22 |
||
| 3986 | */ |
||
| 3987 | public function enableTOC( $flag = true ) { |
||
| 3990 | |||
| 3991 | /** |
||
| 3992 | * @return bool |
||
| 3993 | * @since 1.22 |
||
| 3994 | */ |
||
| 3995 | public function isTOCEnabled() { |
||
| 3998 | |||
| 3999 | /** |
||
| 4000 | * Enables/disables section edit links, doesn't override __NOEDITSECTION__ |
||
| 4001 | * @param bool $flag |
||
| 4002 | * @since 1.23 |
||
| 4003 | */ |
||
| 4004 | public function enableSectionEditLinks( $flag = true ) { |
||
| 4007 | |||
| 4008 | /** |
||
| 4009 | * @return bool |
||
| 4010 | * @since 1.23 |
||
| 4011 | */ |
||
| 4012 | public function sectionEditLinksEnabled() { |
||
| 4015 | |||
| 4016 | /** |
||
| 4017 | * Helper function to setup the PHP implementation of OOUI to use in this request. |
||
| 4018 | * |
||
| 4019 | * @since 1.26 |
||
| 4020 | * @param String $skinName The Skin name to determine the correct OOUI theme |
||
| 4021 | * @param String $dir Language direction |
||
| 4022 | */ |
||
| 4023 | public static function setupOOUI( $skinName = '', $dir = 'ltr' ) { |
||
| 4033 | |||
| 4034 | /** |
||
| 4035 | * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with |
||
| 4036 | * MediaWiki and this OutputPage instance. |
||
| 4037 | * |
||
| 4038 | * @since 1.25 |
||
| 4039 | */ |
||
| 4040 | public function enableOOUI() { |
||
| 4056 | } |
||
| 4057 |
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.