Go to the documentation of this file.
240 'Accept-Encoding' =>
array(
'list-contains=gzip' ),
278 # Extensions should use `new RequestContext` instead of `new OutputPage` now.
291 public function redirect( $url, $responsecode =
'302' ) {
292 # Strip newlines as a paranoia check for header injection in PHP<5.1.2
293 $this->mRedirect = str_replace(
"\n",
'', $url );
294 $this->mRedirectCode = $responsecode;
312 $this->mStatusCode = $statusCode;
323 array_push( $this->mMetatags,
array(
$name, $val ) );
334 array_push( $this->mLinktags, $linkarr );
354 $this->mCanonicalUrl = $url;
363 # note: buggy CC software only reads first "meta" link
364 static $haveMeta =
false;
366 return 'alternate meta';
379 $this->mScripts .= $script .
"\n";
391 array_push( $this->mExtStyles, $url );
411 global $wgStylePath, $wgStyleVersion;
413 if ( substr(
$file, 0, 1 ) ==
'/' || preg_match(
'#^[a-z]*://#i',
$file ) ) {
416 $path =
"{$wgStylePath}/common/{$file}";
452 $filteredModules =
array();
453 foreach ( $modules
as $val ) {
457 && ( is_null( $position ) || $module->getPosition() == $position )
458 && ( !$this->mTarget || in_array( $this->mTarget, $module->getTargets() ) )
460 $filteredModules[] = $val;
463 return $filteredModules;
474 public function getModules( $filter =
false, $position =
null, $param =
'mModules' ) {
475 $modules = array_values( array_unique( $this->$param ) );
489 $this->mModules = array_merge( $this->mModules, (
array)$modules );
501 return $this->
getModules( $filter, $position,
'mModuleScripts' );
512 $this->mModuleScripts = array_merge( $this->mModuleScripts, (
array)$modules );
524 return $this->
getModules( $filter, $position,
'mModuleStyles' );
537 $this->mModuleStyles = array_merge( $this->mModuleStyles, (
array)$modules );
549 return $this->
getModules( $filter, $position,
'mModuleMessages' );
560 $this->mModuleMessages = array_merge( $this->mModuleMessages, (
array)$modules );
576 $this->mTarget = $target;
595 foreach ( $this->mHeadItems
as $item ) {
618 return isset( $this->mHeadItems[
$name] );
638 $this->mArticleBodyOnly = $only;
669 if ( isset( $this->mProperties[
$name] ) ) {
670 return $this->mProperties[
$name];
688 global $wgCachePages, $wgCacheEpoch, $wgUseSquid, $wgSquidMaxage;
691 wfDebug( __METHOD__ .
": CACHE DISABLED, NO TIMESTAMP\n" );
694 if ( !$wgCachePages ) {
695 wfDebug( __METHOD__ .
": CACHE DISABLED\n" );
700 $modifiedTimes =
array(
702 'user' => $this->
getUser()->getTouched(),
703 'epoch' => $wgCacheEpoch
711 $maxModified = max( $modifiedTimes );
714 $clientHeader = $this->
getRequest()->getHeader(
'If-Modified-Since' );
715 if ( $clientHeader ===
false ) {
716 wfDebug( __METHOD__ .
": client did not send If-Modified-Since header\n",
'log' );
720 # IE sends sizes after the date like this:
721 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
722 # this breaks strtotime().
723 $clientHeader = preg_replace(
'/;.*$/',
'', $clientHeader );
726 $clientHeaderTime = strtotime( $clientHeader );
728 if ( !$clientHeaderTime ) {
729 wfDebug( __METHOD__ .
": unable to parse the client's If-Modified-Since header: $clientHeader\n" );
737 if ( $info !==
'' ) {
743 wfDebug( __METHOD__ .
": client sent If-Modified-Since: " .
745 wfDebug( __METHOD__ .
": effective Last-Modified: " .
747 if ( $clientHeaderTime < $maxModified ) {
748 wfDebug( __METHOD__ .
": STALE, $info\n",
'log' );
753 # Give a 304 response code and disable body output
754 wfDebug( __METHOD__ .
": NOT MODIFIED, $info\n",
'log' );
755 ini_set(
'zlib.output_compression', 0 );
756 $this->
getRequest()->response()->header(
"HTTP/1.1 304 Not Modified" );
789 if ( isset( $policy[
'index'] ) ) {
792 if ( isset( $policy[
'follow'] ) ) {
805 $policy = trim( $policy );
806 if ( in_array( $policy,
array(
'index',
'noindex' ) ) ) {
807 $this->mIndexPolicy = $policy;
819 $policy = trim( $policy );
820 if ( in_array( $policy,
array(
'follow',
'nofollow' ) ) ) {
821 $this->mFollowPolicy = $policy;
832 $this->mPageTitleActionText = $text;
841 if ( isset( $this->mPageTitleActionText ) ) {
854 if (
$name instanceof Message ) {
857 $this->mHTMLtitle =
$name;
876 $this->mRedirectedFrom =
$t;
888 if (
$name instanceof Message ) {
892 # change "<script>foo&bar</script>" to "<script>foo&bar</script>"
893 # but leave "<i>foobar</i>" alone
895 $this->mPagetitle = $nameWithTags;
897 # change "<i>foo&bar</i>" to "foo&bar"
900 ->inContentLanguage()
948 if ( $str instanceof Message ) {
949 $this->mSubtitle[] = $str->setContext( $this->
getContext() )->parse();
951 $this->mSubtitle[] = $str;
962 if (
$title->isRedirect() ) {
963 $query[
'redirect'] =
'no';
972 $this->mSubtitle =
array();
981 return implode(
"<br />\n\t\t\t\t", $this->mSubtitle );
989 $this->mPrintable =
true;
1005 $this->mDoNothing =
true;
1047 $this->mFeedLinks =
array();
1061 global $wgAdvertisedFeedTypes;
1063 $this->mFeedLinks =
array();
1065 foreach ( $wgAdvertisedFeedTypes
as $type ) {
1067 if ( is_string( $val ) ) {
1081 global $wgAdvertisedFeedTypes;
1083 if ( in_array( $format, $wgAdvertisedFeedTypes ) ) {
1084 $this->mFeedLinks[$format] = $href;
1093 return count( $this->mFeedLinks ) > 0;
1121 $this->mIsarticle = $v;
1123 $this->mIsArticleRelated = $v;
1144 $this->mIsArticleRelated = $v;
1146 $this->mIsarticle =
false;
1166 $this->mLanguageLinks += $newLinkArray;
1176 $this->mLanguageLinks = $newLinkArray;
1196 if ( !is_array( $categories ) || count( $categories ) == 0 ) {
1200 # Add the links to a LinkBatch
1203 $lb->setArray( $arr );
1205 # Fetch existence plus the hiddencat property
1208 array(
'page_id',
'page_namespace',
'page_title',
'page_len',
'page_is_redirect',
'page_latest',
'pp_value' ),
1209 $lb->constructSet(
'page',
$dbr ),
1212 array(
'page_props' =>
array(
'LEFT JOIN',
array(
'pp_propname' =>
'hiddencat',
'pp_page = page_id' ) ) )
1215 # Add the results to the link cache
1218 # Set all the values to 'normal'. This can be done with array_fill_keys in PHP 5.2.0+
1219 $categories = array_combine(
1220 array_keys( $categories ),
1221 array_fill( 0, count( $categories ),
'normal' )
1224 # Mark hidden categories
1225 foreach (
$res as $row ) {
1226 if ( isset( $row->pp_value ) ) {
1227 $categories[$row->page_title] =
'hidden';
1231 # Add the remaining categories to the skin
1232 if (
wfRunHooks(
'OutputPageMakeCategoryLinks',
array( &$this, $categories, &$this->mCategoryLinks ) ) ) {
1233 foreach ( $categories
as $category =>
$type ) {
1234 $origcategory = $category;
1237 if ( $category != $origcategory ) {
1238 if ( array_key_exists( $category, $categories ) ) {
1243 $this->mCategories[] =
$title->getText();
1255 $this->mCategoryLinks =
array();
1296 if ( $this->
getConfig()->
get(
'AllowSiteCSSOnRestrictedPages' ) ) {
1327 return min( array_values( $this->mAllowedModules ) );
1329 return isset( $this->mAllowedModules[
$type] )
1330 ? $this->mAllowedModules[
$type]
1375 public function addHTML( $text ) {
1376 $this->mBodytext .= $text;
1396 $this->mBodytext =
'';
1416 if ( !$this->mParserOptions ) {
1418 $this->mParserOptions->setEditSection(
false );
1431 $val = is_null( $revid ) ? null : intval( $revid );
1432 return wfSetVar( $this->mRevisionId, $val );
1474 $val =
array(
'time' =>
$file->getTimestamp(),
'sha1' =>
$file->getSha1() );
1476 return wfSetVar( $this->mFileVersion, $val,
true );
1516 public function addWikiText( $text, $linestart =
true, $interface =
true ) {
1573 $oldTidy = $popts->setTidy( $tidy );
1574 $popts->setInterfaceMessage( (
bool)$interface );
1578 $linestart,
true, $this->mRevisionId
1581 $popts->setTidy( $oldTidy );
1594 $this->mLanguageLinks += $parserOutput->getLanguageLinks();
1596 $this->mNewSectionLink = $parserOutput->getNewSection();
1597 $this->mHideNewSectionLink = $parserOutput->getHideNewSection();
1599 $this->mParseWarnings = $parserOutput->getWarnings();
1600 if ( !$parserOutput->isCacheable() ) {
1603 $this->mNoGallery = $parserOutput->getNoGallery();
1604 $this->mHeadItems = array_merge( $this->mHeadItems, $parserOutput->getHeadItems() );
1605 $this->
addModules( $parserOutput->getModules() );
1610 $this->mPreventClickjacking = $this->mPreventClickjacking
1611 || $parserOutput->preventClickjacking();
1614 foreach ( (
array)$parserOutput->getTemplateIds()
as $ns => $dbks ) {
1615 if ( isset( $this->mTemplateIds[$ns] ) ) {
1616 $this->mTemplateIds[$ns] = $dbks + $this->mTemplateIds[$ns];
1618 $this->mTemplateIds[$ns] = $dbks;
1622 foreach ( (
array)$parserOutput->getFileSearchOptions()
as $dbk => $data ) {
1623 $this->mImageTimeKeys[$dbk] = $data;
1627 global $wgParserOutputHooks;
1628 foreach ( $parserOutput->getOutputHooks()
as $hookInfo ) {
1629 list( $hookName, $data ) = $hookInfo;
1630 if ( isset( $wgParserOutputHooks[$hookName] ) ) {
1631 call_user_func( $wgParserOutputHooks[$hookName], $this, $parserOutput, $data );
1637 $linkFlags =
array();
1639 wfRunHooks(
'OutputPageParserOutput',
array( &$this, $parserOutput ) );
1649 $parserOutput->setTOCEnabled( $this->mEnableTOC );
1652 if ( $parserOutput->getEditSectionTokens() ) {
1653 $parserOutput->setEditSectionTokens( $this->mEnableSectionEditLinks );
1655 $text = $parserOutput->getText();
1666 $this->
addHTML( $template->getHTML() );
1681 public function parse( $text, $linestart =
true, $interface =
false, $language =
null ) {
1684 if ( is_null( $this->
getTitle() ) ) {
1685 throw new MWException(
'Empty $mTitle in ' . __METHOD__ );
1690 $popts->setInterfaceMessage(
true );
1692 if ( $language !==
null ) {
1693 $oldLang = $popts->setTargetLanguage( $language );
1698 $linestart,
true, $this->mRevisionId
1702 $popts->setInterfaceMessage(
false );
1704 if ( $language !==
null ) {
1705 $popts->setTargetLanguage( $oldLang );
1708 return $parserOutput->getText();
1721 public function parseInline( $text, $linestart =
true, $interface =
false ) {
1722 $parsed = $this->
parse( $text, $linestart, $interface );
1725 if ( preg_match(
'/^<p>(.*)\n?<\/p>\n?/sU', $parsed, $m ) ) {
1738 $this->mSquidMaxage = $maxage;
1749 return wfSetVar( $this->mEnableClientCache, $state );
1763 "{$wgCookiePrefix}Token",
1764 "{$wgCookiePrefix}LoggedOut",
1782 $cookieHeader = $this->
getRequest()->getHeader(
'cookie' );
1783 if ( $cookieHeader ===
false ) {
1787 foreach ( $cvCookies
as $cookieName ) {
1788 # Check for a simple string match, like the way squid does it
1789 if ( strpos( $cookieHeader, $cookieName ) !==
false ) {
1790 wfDebug( __METHOD__ .
": found $cookieName\n" );
1794 wfDebug( __METHOD__ .
": no cache-varying cookies found\n" );
1807 if ( !array_key_exists( $header, $this->mVaryHeader ) ) {
1808 $this->mVaryHeader[$header] = (
array)$option;
1809 } elseif ( is_array( $option ) ) {
1810 if ( is_array( $this->mVaryHeader[$header] ) ) {
1811 $this->mVaryHeader[$header] = array_merge( $this->mVaryHeader[$header], $option );
1813 $this->mVaryHeader[$header] = $option;
1816 $this->mVaryHeader[$header] = array_unique( (
array)$this->mVaryHeader[$header] );
1826 return 'Vary: ' . join(
', ', array_keys( $this->mVaryHeader ) );
1834 public function getXVO() {
1837 $cookiesOption =
array();
1838 foreach ( $cvCookies
as $cookieName ) {
1839 $cookiesOption[] =
'string-contains=' . $cookieName;
1844 foreach ( $this->mVaryHeader
as $header => $option ) {
1845 $newheader = $header;
1846 if ( is_array( $option ) && count( $option ) > 0 ) {
1847 $newheader .=
';' . implode(
';', $option );
1849 $headers[] = $newheader;
1851 $xvo =
'X-Vary-Options: ' . implode(
',', $headers );
1865 $lang = $this->
getTitle()->getPageLanguage();
1866 if ( !$this->
getRequest()->getCheck(
'variant' ) && $lang->hasVariants() ) {
1867 $variants = $lang->getVariants();
1868 $aloption =
array();
1869 foreach ( $variants
as $variant ) {
1870 if ( $variant === $lang->getCode() ) {
1873 $aloption[] =
'string-contains=' . $variant;
1878 $variantBCP47 =
wfBCP47( $variant );
1879 if ( $variantBCP47 !== $variant ) {
1880 $aloption[] =
'string-contains=' . $variantBCP47;
1899 $this->mPreventClickjacking = $enable;
1908 $this->mPreventClickjacking =
false;
1929 global $wgBreakFrames, $wgEditPageFrameOptions;
1930 if ( $wgBreakFrames ) {
1932 } elseif ( $this->mPreventClickjacking && $wgEditPageFrameOptions ) {
1933 return $wgEditPageFrameOptions;
1942 global $wgUseSquid, $wgUseESI, $wgUseETag, $wgSquidMaxage, $wgUseXVO;
1945 if ( $wgUseETag && $this->mETag ) {
1946 $response->header(
"ETag: $this->mETag" );
1952 # don't serve compressed data to clients who can't handle it
1953 # maintain different caches for logged-in users and non-logged in ones
1957 # Add an X-Vary-Options header for Squid with Wikimedia patches
1961 if ( $this->mEnableClientCache ) {
1963 $wgUseSquid && session_id() ==
'' && !$this->
isPrintable() &&
1967 # We'll purge the proxy cache explicitly, but require end user agents
1968 # to revalidate against the proxy on each visit.
1969 # Surrogate-Control controls our Squid, Cache-Control downstream caches
1970 wfDebug( __METHOD__ .
": proxy caching with ESI; {$this->mLastModified} **\n",
'log' );
1971 # start with a shorter timeout for initial testing
1972 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
1973 $response->header(
'Surrogate-Control: max-age=' . $wgSquidMaxage .
'+' . $this->mSquidMaxage .
', content="ESI/1.0"' );
1974 $response->header(
'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
1976 # We'll purge the proxy cache for anons explicitly, but require end user agents
1977 # to revalidate against the proxy on each visit.
1978 # IMPORTANT! The Squid needs to replace the Cache-Control header with
1979 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
1980 wfDebug( __METHOD__ .
": local proxy caching; {$this->mLastModified} **\n",
'log' );
1981 # start with a shorter timeout for initial testing
1982 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
1983 $response->header(
'Cache-Control: s-maxage=' . $this->mSquidMaxage .
', must-revalidate, max-age=0' );
1986 # We do want clients to cache if they can, but they *must* check for updates
1987 # on revisiting the page.
1988 wfDebug( __METHOD__ .
": private caching; {$this->mLastModified} **\n",
'log' );
1989 $response->header(
'Expires: ' . gmdate(
'D, d M Y H:i:s', 0 ) .
' GMT' );
1990 $response->header(
"Cache-Control: private, must-revalidate, max-age=0" );
1992 if ( $this->mLastModified ) {
1993 $response->header(
"Last-Modified: {$this->mLastModified}" );
1996 wfDebug( __METHOD__ .
": no caching **\n",
'log' );
1998 # In general, the absence of a last modified header should be enough to prevent
1999 # the client from using its cache. We send a few other things just to make sure.
2000 $response->header(
'Expires: ' . gmdate(
'D, d M Y H:i:s', 0 ) .
' GMT' );
2001 $response->header(
'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
2002 $response->header(
'Pragma: no-cache' );
2023 public function output() {
2024 global $wgLanguageCode, $wgDebugRedirects, $wgMimeType, $wgVaryOnXFP,
2025 $wgUseAjax, $wgResponsiveImages;
2027 if ( $this->mDoNothing ) {
2035 if ( $this->mRedirect !=
'' ) {
2036 # Standards require redirect URLs to be absolute
2042 if (
wfRunHooks(
"BeforePageRedirect",
array( $this, &$redirect, &$code ) ) ) {
2043 if ( $code ==
'301' || $code ==
'303' ) {
2044 if ( !$wgDebugRedirects ) {
2046 $response->header(
"HTTP/1.1 $code $message" );
2050 if ( $wgVaryOnXFP ) {
2055 $response->header(
"Content-Type: text/html; charset=utf-8" );
2056 if ( $wgDebugRedirects ) {
2057 $url = htmlspecialchars( $redirect );
2058 print
"<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
2059 print
"<p>Location: <a href=\"$url\">$url</a></p>\n";
2060 print
"</body>\n</html>\n";
2062 $response->header(
'Location: ' . $redirect );
2068 } elseif ( $this->mStatusCode ) {
2071 $response->header(
'HTTP/1.1 ' . $this->mStatusCode .
' ' . $message );
2075 # Buffer output; final headers may depend on later processing
2078 $response->header(
"Content-type: $wgMimeType; charset=UTF-8" );
2079 $response->header(
'Content-language: ' . $wgLanguageCode );
2083 if ( $frameOptions ) {
2084 $response->header(
"X-Frame-Options: $frameOptions" );
2087 if ( $this->mArticleBodyOnly ) {
2093 $modules = $sk->getDefaultModules();
2096 $coreModules =
array(
2098 'mediawiki.page.startup',
2103 if ( $wgResponsiveImages ) {
2104 $coreModules[] =
'mediawiki.hidpi';
2108 foreach ( $modules
as $group ) {
2142 public function out( $ins ) {
2167 if ( $htmlTitle !==
false ) {
2173 $this->mRedirect =
'';
2191 if ( !
$title instanceof Message ) {
2197 if ( $msg instanceof Message ) {
2199 trigger_error(
'Argument ignored: $params. The message parameters argument is discarded when the $msg argument is a Message object instead of a string.', E_USER_NOTICE );
2201 $this->
addHTML( $msg->parseAsBlock() );
2221 if ( in_array( $action,
array(
'read',
'edit',
'createpage',
'createtalk',
'upload' ) )
2222 && $this->
getUser()->isAnon() && count( $errors ) == 1 && isset( $errors[0][0] )
2223 && ( $errors[0][0] ==
'badaccess-groups' || $errors[0][0] ==
'badaccess-group0' )
2227 $displayReturnto =
null;
2229 # Due to bug 32276, if a user does not have read permissions,
2230 # $this->getTitle() will just give Special:Badtitle, which is
2231 # not especially useful as a returnto parameter. Use the title
2232 # from the request instead, if there was one.
2235 if ( $action ==
'edit' ) {
2236 $msg =
'whitelistedittext';
2237 $displayReturnto = $returnto;
2238 } elseif ( $action ==
'createpage' || $action ==
'createtalk' ) {
2239 $msg =
'nocreatetext';
2240 } elseif ( $action ==
'upload' ) {
2241 $msg =
'uploadnologintext';
2243 $msg =
'loginreqpagetext';
2250 $query[
'returnto'] = $returnto->getPrefixedText();
2252 if ( !$request->wasPosted() ) {
2253 $returntoquery = $request->getValues();
2254 unset( $returntoquery[
'title'] );
2255 unset( $returntoquery[
'returnto'] );
2256 unset( $returntoquery[
'returntoquery'] );
2262 $this->
msg(
'loginreqlink' )->escaped(),
2268 $this->
addHTML( $this->
msg( $msg )->rawParams( $loginLink )->
parse() );
2270 # Don't return to a page the user can't read otherwise
2271 # we'll end up in a pointless loop
2272 if ( $displayReturnto && $displayReturnto->userCan(
'read', $this->getUser() ) ) {
2321 if ( $action ==
null ) {
2322 $text = $this->
msg(
'permissionserrorstext', count( $errors ) )->plain() .
"\n\n";
2324 $action_desc = $this->
msg(
"action-$action" )->plain();
2326 'permissionserrorstext-withaction',
2329 )->plain() .
"\n\n";
2332 if ( count( $errors ) > 1 ) {
2333 $text .=
'<ul class="permissions-errors">' .
"\n";
2337 $text .= call_user_func_array(
array( $this,
'msg' ),
$error )->plain();
2342 $text .=
"<div class=\"permissions-errors\">\n" .
2343 call_user_func_array(
array( $this,
'msg' ), reset( $errors ) )->plain() .
2377 if ( $protected && empty( $reasons ) ) {
2378 $reasons[] =
array(
'badaccess-group0' );
2381 if ( !empty( $reasons ) ) {
2399 $pageLang = $this->
getTitle()->getPageLanguage();
2401 'id' =>
'wpTextbox1',
2402 'name' =>
'wpTextbox1',
2403 'cols' => $this->
getUser()->getOption(
'cols' ),
2404 'rows' => $this->
getUser()->getOption(
'rows' ),
2405 'readonly' =>
'readonly',
2406 'lang' => $pageLang->getHtmlCode(),
2407 'dir' => $pageLang->getDir(),
2413 $this->
addHTML(
"<div class='templatesUsed'>
2419 # If the title doesn't exist, it's fairly pointless to print a return
2420 # link to it. After all, you just tried editing it and couldn't, so
2421 # what's there to do there?
2422 if ( $this->
getTitle()->exists() ) {
2445 global $wgSlaveLagWarning, $wgSlaveLagCritical;
2446 if ( $lag >= $wgSlaveLagWarning ) {
2447 $message = $lag < $wgSlaveLagCritical
2490 $link = $this->
msg(
'returnto' )->rawParams(
2492 $this->
addHTML(
"<p id=\"mw-returnto\">{$link}</p>\n" );
2503 public function returnToMain( $unused =
null, $returnto =
null, $returntoquery =
null ) {
2504 if ( $returnto ==
null ) {
2505 $returnto = $this->
getRequest()->getText(
'returnto' );
2508 if ( $returntoquery ==
null ) {
2509 $returntoquery = $this->
getRequest()->getText(
'returntoquery' );
2512 if ( $returnto ===
'' ) {
2516 if ( is_object( $returnto ) ) {
2517 $titleObj = $returnto;
2521 if ( !is_object( $titleObj ) ) {
2547 # Don't bother with the newline if $head == ''
2548 $ret .=
"$openHead\n";
2567 $ret .=
Html::element(
'meta',
array(
'http-equiv' =>
'X-UA-Compatible',
'content' =>
'IE=EDGE' ) ) .
"\n";
2581 $ret .=
"$closeHead\n";
2584 $bodyClasses =
array();
2585 $bodyClasses[] =
'mediawiki';
2587 # Classes for LTR/RTL directionality support
2588 $bodyClasses[] = $userdir;
2589 $bodyClasses[] =
"sitedir-$sitedir";
2591 if ( $this->
getLanguage()->capitalizeAllNouns() ) {
2592 # A <body> class is probably not the best way to do this . . .
2593 $bodyClasses[] =
'capitalize-all-nouns';
2600 $bodyAttrs =
array();
2603 $bodyAttrs[
'class'] = implode(
' ', $bodyClasses );
2607 wfRunHooks(
'OutputPageBodyAttributes',
array( $this, $sk, &$bodyAttrs ) );
2620 if ( is_null( $this->mResourceLoader ) ) {
2636 global $wgResourceLoaderUseESI;
2638 $modules = (
array)$modules;
2642 'states' =>
array(),
2645 if ( !count( $modules ) ) {
2650 if ( count( $modules ) > 1 ) {
2652 $modules = array_unique( $modules );
2658 foreach ( $modules
as $name ) {
2660 $links[
'html'] .=
$link[
'html'];
2661 $links[
'states'] +=
$link[
'states'];
2667 if ( !is_null( $this->mTarget ) ) {
2674 foreach ( $modules
as $name ) {
2676 # Check that we're allowed to include this module on this page
2682 || ( $this->mTarget && !in_array( $this->mTarget, $module->getTargets() ) )
2687 $group = $module->getGroup();
2688 if ( !isset( $groups[$group] ) ) {
2689 $groups[$group] =
array();
2691 $groups[$group][
$name] = $module;
2694 foreach ( $groups
as $group => $grpModules ) {
2697 if ( ( $group ===
'user' || $group ===
'private' ) && $this->
getUser()->isLoggedIn() ) {
2706 $this->
getSkin()->getSkinName(),
2718 foreach ( $grpModules
as $key => $module ) {
2721 if ( $module->isKnownEmpty(
$context ) ) {
2722 unset( $grpModules[$key] );
2724 $links[
'states'][$key] =
'ready';
2730 if ( count( $grpModules ) === 0 ) {
2738 if ( $group ===
'private' ) {
2750 $links[
'html'] .=
"\n";
2760 if ( $group ===
'user' ) {
2763 foreach ( $grpModules
as $module ) {
2771 array_keys( $grpModules ),
2773 $this->
getSkin()->getSkinName(),
2782 if ( $useESI && $wgResourceLoaderUseESI ) {
2793 } elseif ( $loadCall ) {
2804 foreach ( $grpModules
as $key => $module ) {
2806 if ( $key !==
'startup' ) {
2807 $links[
'states'][$key] =
'loading';
2813 if ( $group ==
'noscript' ) {
2816 $links[
'html'] .=
$link .
"\n";
2832 if ( !is_array(
$link ) ) {
2836 $states +=
$link[
'states'];
2840 if ( count( $states ) ) {
2858 global $wgResourceLoaderExperimentalAsyncLoading;
2874 $embedScripts =
array(
'user.options',
'user.tokens' );
2893 if ( $wgResourceLoaderExperimentalAsyncLoading ) {
2910 global $wgUseSiteJs, $wgAllowUserJs;
2927 $modules = $this->
getModules(
true,
'bottom' );
2941 false,
array(), $inHead
2946 # XXX: additional security check/prompt?
2950 array(
'excludepage' => $this->
getTitle()->getPrefixedDBkey() ), $inHead
2961 false,
array(), $inHead
2967 false,
array(), $inHead
2978 global $wgResourceLoaderExperimentalAsyncLoading;
2986 if ( !$wgResourceLoaderExperimentalAsyncLoading ) {
3010 if ( is_array(
$keys ) ) {
3012 $this->mJsConfigVars[$key] =
$value;
3037 $canonicalSpecialPageName =
false; # bug 21115
3040 $ns =
$title->getNamespace();
3046 $relevantTitle = $sk->getRelevantTitle();
3047 $relevantUser = $sk->getRelevantUser();
3053 $curRevisionId = $wikiPage->getLatest();
3054 $articleId = $wikiPage->getId();
3057 $lang =
$title->getPageLanguage();
3060 $separatorTransTable = $lang->separatorTransformTable();
3061 $separatorTransTable = $separatorTransTable ? $separatorTransTable :
array();
3062 $compactSeparatorTransTable =
array(
3063 implode(
"\t", array_keys( $separatorTransTable ) ),
3064 implode(
"\t", $separatorTransTable ),
3066 $digitTransTable = $lang->digitTransformTable();
3067 $digitTransTable = $digitTransTable ? $digitTransTable :
array();
3068 $compactDigitTransTable =
array(
3069 implode(
"\t", array_keys( $digitTransTable ) ),
3070 implode(
"\t", $digitTransTable ),
3076 'wgCanonicalNamespace' => $canonicalNamespace,
3077 'wgCanonicalSpecialPageName' => $canonicalSpecialPageName,
3078 'wgNamespaceNumber' =>
$title->getNamespace(),
3079 'wgPageName' =>
$title->getPrefixedDBkey(),
3080 'wgTitle' =>
$title->getText(),
3081 'wgCurRevisionId' => $curRevisionId,
3083 'wgArticleId' => $articleId,
3085 'wgIsRedirect' => $title->isRedirect(),
3087 'wgUserName' =>
$user->isAnon() ? null :
$user->getName(),
3088 'wgUserGroups' =>
$user->getEffectiveGroups(),
3091 'wgPageContentLanguage' => $lang->getCode(),
3092 'wgPageContentModel' =>
$title->getContentModel(),
3093 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
3094 'wgDigitTransformTable' => $compactDigitTransTable,
3095 'wgDefaultDateFormat' => $lang->getDefaultDateFormat(),
3096 'wgMonthNames' => $lang->getMonthNamesArray(),
3097 'wgMonthNamesShort' => $lang->getMonthAbbreviationsArray(),
3098 'wgRelevantPageName' => $relevantTitle->getPrefixedDBkey(),
3100 if (
$user->isLoggedIn() ) {
3102 $vars[
'wgUserEditCount'] =
$user->getEditCount();
3104 $vars[
'wgUserRegistration'] = $userReg !==
null ? ( $userReg * 1000 ) :
null;
3108 $vars[
'wgUserNewMsgRevisionId'] =
$user->getNewMessageRevisionId();
3118 if (
$title->isMainPage() ) {
3119 $vars[
'wgIsMainPage'] =
true;
3121 if ( $this->mRedirectedFrom ) {
3122 $vars[
'wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBkey();
3124 if ( $relevantUser ) {
3125 $vars[
'wgRelevantUserName'] = $relevantUser->getName();
3148 if ( $this->
getRequest()->getVal(
'action' ) !=
'submit'
3150 || !$this->
getUser()->matchEditToken(
3151 $this->
getRequest()->getVal(
'wpEditToken' ) )
3155 if ( !$this->
getTitle()->isJsSubpage() && !$this->
getTitle()->isCssSubpage() ) {
3166 global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI,
3167 $wgSitename, $wgVersion,
3168 $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes,
3169 $wgDisableLangConversion, $wgCanonicalLanguageLinks,
3170 $wgRightsPage, $wgRightsUrl;
3177 'name' =>
'generator',
3178 'content' =>
"MediaWiki $wgVersion",
3181 $p =
"{$this->mIndexPolicy},{$this->mFollowPolicy}";
3182 if ( $p !==
'index,follow' ) {
3191 foreach ( $this->mMetatags
as $tag ) {
3192 if ( 0 == strcasecmp(
'http:', substr( $tag[0], 0, 5 ) ) ) {
3194 $tag[0] = substr( $tag[0], 5 );
3198 $tagName =
"meta-{$tag[0]}";
3199 if ( isset( $tags[$tagName] ) ) {
3200 $tagName .= $tag[1];
3205 'content' => $tag[1]
3210 foreach ( $this->mLinktags
as $tag ) {
3214 # Universal edit button
3220 $msg = $this->
msg(
'edit' )->text();
3222 'rel' =>
'alternate',
3223 'type' =>
'application/x-wiki',
3225 'href' => $this->
getTitle()->getLocalURL(
'action=edit' )
3231 'href' => $this->
getTitle()->getLocalURL(
'action=edit' )
3236 # Generally the order of the favicon and apple-touch-icon links
3237 # should not matter, but Konqueror (3.5.9 at least) incorrectly
3238 # uses whichever one appears later in the HTML source. Make sure
3239 # apple-touch-icon is specified first to avoid this.
3240 if ( $wgAppleTouchIcon !==
false ) {
3241 $tags[
'apple-touch-icon'] =
Html::element(
'link',
array(
'rel' =>
'apple-touch-icon',
'href' => $wgAppleTouchIcon ) );
3244 if ( $wgFavicon !==
false ) {
3245 $tags[
'favicon'] =
Html::element(
'link',
array(
'rel' =>
'shortcut icon',
'href' => $wgFavicon ) );
3248 # OpenSearch description link
3251 'type' =>
'application/opensearchdescription+xml',
3252 'href' =>
wfScript(
'opensearch_desc' ),
3253 'title' => $this->
msg(
'opensearch-desc' )->inContentLanguage()->
text(),
3256 if ( $wgEnableAPI ) {
3257 # Real Simple Discovery link, provides auto-discovery information
3258 # for the MediaWiki API (and potentially additional custom API
3259 # support such as WordPress or Twitter-compatible APIs for a
3260 # blogging extension, etc)
3263 'type' =>
'application/rsd+xml',
3271 if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks ) {
3272 $lang = $this->
getTitle()->getPageLanguage();
3273 if ( $lang->hasVariants() ) {
3275 $urlvar = $lang->getURLVariant();
3278 $variants = $lang->getVariants();
3279 foreach ( $variants
as $_v ) {
3281 'rel' =>
'alternate',
3283 'href' => $this->
getTitle()->getLocalURL(
array(
'variant' => $_v ) ) )
3287 $canonicalUrl = $this->
getTitle()->getLocalURL();
3294 if ( $wgRightsPage ) {
3298 $copyright = $copy->getLocalURL();
3302 if ( !$copyright && $wgRightsUrl ) {
3303 $copyright = $wgRightsUrl;
3308 'rel' =>
'copyright',
3309 'href' => $copyright )
3316 # Use the page name for the title. In principle, this could
3317 # lead to issues with having the same name for different feeds
3318 # corresponding to the same page, but we can't avoid that at
3324 # Used
messages:
'page-rss-feed' and
'page-atom-feed' (
for an easier grep)
3325 $this->
msg(
"page-{$format}-feed", $this->
getTitle()->getPrefixedText() )->
text()
3329 # Recent changes feed should appear on every page (except recentchanges,
3330 # that would be redundant). Put it after the per-page feed to avoid
3331 # changing existing behavior. It's still available, probably via a
3332 # menu in your browser. Some sites might have a different feed they'd
3333 # like to promote instead of the RC feed (maybe like a "Recent New Articles"
3334 # or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined.
3335 # If so, use it instead.
3336 if ( $wgOverrideSiteFeed ) {
3337 foreach ( $wgOverrideSiteFeed
as $type => $feedUrl ) {
3342 $this->
msg(
"site-{$type}-feed", $wgSitename )->
text()
3345 } elseif ( !$this->
getTitle()->isSpecial(
'Recentchanges' ) ) {
3347 foreach ( $wgAdvertisedFeedTypes
as $format ) {
3350 $rctitle->getLocalURL(
array(
'feed' => $format ) ),
3351 $this->
msg(
"site-{$format}-feed", $wgSitename )->text() # For grep:
'site-rss-feed',
'site-atom-feed'.
3358 global $wgEnableCanonicalServerLink;
3359 if ( $wgEnableCanonicalServerLink ) {
3360 if ( $canonicalUrl !==
false ) {
3363 $reqUrl = $this->
getRequest()->getRequestURL();
3367 if ( $canonicalUrl !==
false ) {
3369 'rel' =>
'canonical',
3370 'href' => $canonicalUrl
3392 private function feedLink( $type, $url, $text ) {
3394 'rel' =>
'alternate',
3395 'type' =>
"application/$type+xml",
3410 public function addStyle( $style, $media =
'', $condition =
'',
$dir =
'' ) {
3418 $options[
'condition'] = $condition;
3432 if ( $flip ===
'flip' && $this->
getLanguage()->isRTL() ) {
3433 # If wanted, and the interface is right-to-left, flip the CSS
3448 $this->
getSkin()->setupSkinUserCss( $this );
3460 $moduleStyles[] =
'site';
3461 $moduleStyles[] =
'noscript';
3462 $moduleStyles[] =
'user.groups';
3469 array(
'excludepage' => $this->
getTitle()->getPrefixedDBkey() )
3471 $otherTags .=
$link[
'html'];
3476 $previewedCSS = $this->
getRequest()->getText(
'wpTextbox1' );
3483 $moduleStyles[] =
'user';
3487 $moduleStyles[] =
'user.cssprefs';
3489 foreach ( $moduleStyles
as $name ) {
3494 $group = $module->getGroup();
3509 $links[] =
Html::element(
'meta',
array(
'name' =>
'ResourceLoaderDynamicStyles',
'content' =>
'' ) ) .
"\n";
3514 foreach (
array(
'site',
'noscript',
'private',
'user' )
as $group ) {
3531 foreach ( $this->mExtStyles
as $url ) {
3534 $this->mExtStyles =
array();
3559 if ( isset(
$options[
'media'] ) ) {
3561 if ( is_null( $media ) ) {
3568 if ( substr( $style, 0, 1 ) ==
'/' ||
3569 substr( $style, 0, 5 ) ==
'http:' ||
3570 substr( $style, 0, 6 ) ==
'https:' ) {
3573 global $wgStylePath, $wgStyleVersion;
3574 $url = $wgStylePath .
'/' . $style .
'?' . $wgStyleVersion;
3579 if ( isset(
$options[
'condition'] ) ) {
3580 $condition = htmlspecialchars(
$options[
'condition'] );
3581 $link =
"<!--[if $condition]>$link<![endif]-->";
3597 $screenMediaQueryRegex =
'/^(?:only\s+)?screen\b/i';
3601 'printable' =>
'print',
3602 'handheld' =>
'handheld',
3604 foreach ( $switches
as $switch => $targetMedia ) {
3605 if ( $wgRequest->getBool( $switch ) ) {
3606 if ( $media == $targetMedia ) {
3608 } elseif ( preg_match( $screenMediaQueryRegex, $media ) === 1 ) {
3619 if ( $targetMedia ==
'print' || $media ==
'screen' ) {
3636 $args = func_get_args();
3677 $msgSpecs = func_get_args();
3678 array_shift( $msgSpecs );
3679 $msgSpecs = array_values( $msgSpecs );
3681 foreach ( $msgSpecs
as $n => $spec ) {
3682 if ( is_array( $spec ) ) {
3685 if ( isset(
$args[
'options'] ) ) {
3686 unset(
$args[
'options'] );
3688 'Adding "options" to ' . __METHOD__ .
' is no longer supported',
3696 $s = str_replace(
'$' . (
$n + 1 ), $this->
msg( $name,
$args )->plain(),
$s );
3719 public function enableTOC( $flag =
true ) {
3720 $this->mEnableTOC = $flag;
3737 $this->mEnableSectionEditLinks = $flag;
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
static getActionName(IContextSource $context)
Get the action that will be executed, not necessarily the one passed passed through the "action" requ...
preventClickjacking( $enable=true)
Set a flag which will cause an X-Frame-Options header appropriate for edit pages to be sent.
static makeLoaderConditionalScript( $script)
Returns JS code which runs given JS code if the client-side framework is present.
addCategoryLinks( $categories)
Add an array of categories, with names in the keys.
Set options of the Parser.
getCategoryLinks()
Get the list of category links, in a 2-D array with the following format: $arr[$type][] = $link,...
addMeta( $name, $val)
Add a new "<meta>" tag To add an http-equiv meta tag, precede the name with "http:".
getConfig()
Get the Config object.
setArticleRelated( $v)
Set whether this page is related an article on the wiki Setting false will cause the change of "artic...
Object passed around to modules which contains information about the state of a specific loader reque...
$mRevisionId
should be private. To include the variable {{REVISIONID}}
$mHeadItems
Array of elements in "<head>". Parser might add its own headers!
getSubtitle()
Get the subtitle.
WebRequest clone which takes values from a provided array.
setAllowedModules( $type, $level)
Set the highest level of CSS/JS untrustworthiness allowed.
enableClientCache( $state)
Use enableClientCache(false) to force it to send nocache headers.
styleLink( $style, $options)
Generate <link> tags for stylesheets.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
addWikiMsg()
Add a wikitext-formatted message to the output.
getContext()
Get the RequestContext object.
getLanguageLinks()
Get the list of language links.
reduceAllowedModules( $type, $level)
Limit the highest level of CSS/JS untrustworthiness allowed.
wfBCP47( $code)
Get the normalised IETF language tag See unit test for examples.
addSubtitle( $str)
Add $str to the subtitle.
addAcceptLanguage()
bug 21672: Add Accept-Language to Vary and XVO headers if there's no 'variant' parameter existed in G...
bool $mEnableSectionEditLinks
Whether parser output should contain section edit links.
static formatRobotPolicy( $policy)
Converts a String robot policy into an associative array, to allow merging of several policies using ...
getJSVars()
Get an array containing the variables to be set in mw.config in JavaScript.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
static makeConfigSetScript(array $configuration)
Returns JS code which will set the MediaWiki configuration array to the given value.
static htmlHeader( $attribs=array())
Constructs the opening html-tag with necessary doctypes depending on global variables.
Show an error when the user tries to do something whilst blocked.
showFileRenameError( $old, $new)
$mBodytext
Contains all of the "<body>" content. Should be private we got set/get accessors and the append() met...
getScriptsForBottomQueue( $inHead)
JS stuff to put at the 'bottom', which can either be the bottom of the "<body>" or the bottom of the ...
Title $mRedirectedFrom
If the current page was reached through a redirect, $mRedirectedFrom contains the Title of the redire...
setTitle(Title $t)
Set the Title object to use.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Class representing a list of titles The execute() method checks them all for existence and adds them ...
hasHeadItem( $name)
Check if the header item $name is already set.
__construct(IContextSource $context=null)
Constructor for OutputPage.
addModuleMessages( $modules)
Add only messages of one or more modules recognized by the resource loader.
getScript()
Get all registered JS and CSS tags for the header.
addModuleStyles( $modules)
Add only CSS of one or more modules recognized by the resource loader.
loginToUse()
Produce the stock "please login to use the wiki" page.
$mLanguageLinks
Should be private. Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page')
$mSubtitle
Should be private.
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
isArticleRelated()
Return whether this page is related an article on the wiki.
enableSectionEditLinks( $flag=true)
Enables/disables section edit links, doesn't override NOEDITSECTION
const ORIGIN_USER_SITEWIDE
setArticleBodyOnly( $only)
Set whether the output should only contain the body of the article, without any skin,...
getFrameOptions()
Get the X-Frame-Options header value (without the name part), or false if there isn't one.
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
blockedPage()
Produce a "user is blocked" page.
getRevisionId()
Get the displayed revision ID.
addParserOutput(&$parserOutput)
Add a ParserOutput object.
addWikiTextTitleTidy( $text, &$title, $linestart=true)
Add wikitext with a custom Title object and tidy enabled.
clearHTML()
Clear the body HTML.
static newMainPage()
Create a new Title for the Main Page.
setCategoryLinks( $categories)
Reset the category links (but not the category list) and add $categories.
addScript( $script)
Add raw HTML to the list of scripts (including <script> tag, etc.)
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
returnToMain( $unused=null, $returnto=null, $returntoquery=null)
Add a "return to" link pointing to a specified title, or the title indicated in the request,...
$mIsArticleRelated
Should be private.
$mHTMLtitle
Should be private. Stores contents of "<title>" tag.
wfProfileIn( $functionname)
Begin profiling of a function.
setPageTitleActionText( $text)
Set the new value of the "action text", this will be added to the "HTML title", separated from it wit...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
if( $wgRCFilterByAge) if( $wgSkipSkin) if( $wgLocalInterwiki) if( $wgSharedPrefix===false) if(! $wgCookiePrefix) $wgCookiePrefix
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
isUserJsAllowed()
Return whether user JavaScript is allowed for this page.
getBottomScripts()
JS stuff to put at the bottom of the "<body>".
showFileNotFoundError( $name)
static getHtmlFromLoaderLinks(Array $links)
Build html output from an array of links from makeResourceLoaderLink.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled also a ContextSource error or success such as when responding to a resource loader request or generating HTML output & $resourceLoader
getModuleStyles( $filter=false, $position=null)
Get the list of module CSS to include on this page.
addToBodyAttributes( $out, &$bodyAttrs)
This will be called by OutputPage::headElement when it is creating the "<body>" tag,...
versionRequired( $version)
Display an error page indicating that a given version of MediaWiki is required to use it.
parseInline( $text, $linestart=true, $interface=false)
Parse wikitext, strip paragraphs, and return the HTML.
addScriptFile( $file, $version=null)
Add a JavaScript file out of skins/common, or a given relative path.
parserOptions( $options=null)
Get/set the ParserOptions object to use for wikitext parsing.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
static escapeClass( $class)
Given a value, escape it so that it can be used as a CSS class and return it.
getFileVersion()
Get the displayed file version.
getSyndicationLinks()
Return URLs for each supported syndication format for this page.
canUseWikiPage()
Check whether a WikiPage object can be get with getWikiPage().
getRequest()
Get the WebRequest object.
Show an error when a user tries to do something they do not have the necessary permissions for.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
namespace and then decline to actually register it RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok in case the handler function wants to provide a converted Content object Note that $result getContentModel() must return $toModel. Handler functions that modify $result should generally return false to further attempts at conversion. 'ContribsPager you ll need to handle error messages
static groupHasPermission( $group, $role)
Check, if the given group has the given permission.
getRedirect()
Get the URL to redirect to, or an empty string if not redirect URL set.
setCanonicalUrl( $url)
Set the URL to be used for the <link rel="canonical">.
$mExtStyles
Additional stylesheets. Looks like this is for extensions. Might be replaced by resource loader.
getUser()
Get the User object.
set to $title object and return false for a match for latest after cache objects are set use the ContentHandler facility to handle CSS and JavaScript for highlighting & $link
getTitle()
Get the Title object.
getHtmlElementAttributes()
static inlineScript( $contents)
Output a "<script>" tag with the given contents.
permissionRequired( $permission)
Display an error page noting that a given permission bit is required.
static stripAllTags( $text)
Take a fragment of (potentially invalid) HTML and return a version with any tags removed,...
showFileDeleteError( $name)
static linkKnown( $target, $html=null, $customAttribs=array(), $query=array(), $options=array( 'known', 'noclasses'))
Identical to link(), except $options defaults to 'known'.
addHTML( $text)
Append $text to the body HTML.
addHeadItem( $name, $value)
Add or replace an header item to the output.
addWikiTextTidy( $text, $linestart=true)
Add wikitext with tidy enabled.
$mArticleBodyOnly
Flag if output should only contain the body of the article.
getModuleScripts( $filter=false, $position=null)
Get the list of module JS to include on this page.
getRevisionTimestamp()
Get the timestamp of displayed revision.
addWikiMsgArray( $name, $args)
Add a wikitext-formatted message to the output.
enableTOC( $flag=true)
Enables/disables TOC, doesn't override NOTOC
static transformCssMedia( $media)
Transform "media" attribute based on request parameters.
setLastModified( $timestamp)
Override the last modified timestamp.
$mNoGallery
Comes from the parser.
static link( $target, $html=null, $customAttribs=array(), $query=array(), $options=array())
This function returns an HTML link to the given target.
getLanguage()
Get the Language object.
static makeLoaderQuery( $modules, $lang, $skin, $user=null, $version=null, $debug=false, $only=null, $printable=false, $handheld=false, $extraQuery=array())
Build a query array (array representation of query string) for load.php.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
forceHideNewSectionLink()
Forcibly hide the new section link?
addWikiTextWithTitle( $text, &$title, $linestart=true)
Add wikitext with a custom Title object.
static closeElement( $element)
Returns "</$element>", except if $wgWellFormedXml is off, in which case it returns the empty string w...
static encodeJsCall( $name, $args, $pretty=false)
Create a call to a JavaScript function.
static isXmlMimeType( $mimetype)
Determines if the given mime type is xml.
readOnlyPage( $source=null, $protected=false, $reasons=array(), $action=null)
Display a page stating that the Wiki is in read-only mode, and optionally show the source of the page...
showErrorPage( $title, $msg, $params=array())
Output a standard error page.
static openElement( $element, $attribs=array())
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
getModuleMessages( $filter=false, $position=null)
Get the list of module messages to include on this page.
if( $wgAPIRequestLog) $lb
Implements some public methods and some protected utility functions which are required by multiple ch...
feedLink( $type, $url, $text)
Generate a "<link rel/>" for a feed.
$mLastModified
mLastModified and mEtag are used for sending cache control.
addStyle( $style, $media='', $condition='', $dir='')
Add a local or specified stylesheet, with the given media options.
sendCacheControl()
Send cache control HTTP headers.
setETag( $tag)
Set the value of the ETag HTTP header, only used if $wgUseETag is true.
out( $ins)
Actually output something with print.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
wfRestoreWarnings()
Restore error level to previous value.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
output()
Finally, all the text has been munged and accumulated into the object, let's actually output it:
bool $mEnableTOC
Whether parser output should contain table of contents.
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
$mInlineStyles
Inline CSS styles.
setFileVersion( $file)
Set the displayed file version.
showUnexpectedValueError( $name, $val)
static makeLoaderStateScript( $name, $state=null)
Returns a JS call to mw.loader.state, which sets the state of a module or modules to a given value.
getResourceLoader()
Get a ResourceLoader object associated with this OutputPage.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
static linkedScript( $url)
Output a "<script>" tag linking to the given URL, e.g., "<script src=foo.js></script>".
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
getWikiPage()
Get the WikiPage object.
setFeedAppendQuery( $val)
Add default feeds to the page header This is mainly kept for backward compatibility,...
isDisabled()
Return whether the output will be completely disabled.
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
setRevisionId( $revid)
Set the revision ID which will be seen by the wiki text parser for things such as embedded {{REVISION...
wfProfileOut( $functionname='missing')
Stop profiling of a function.
setArticleFlag( $v)
Set whether the displayed content is related to the source of the corresponding article on the wiki S...
disallowUserJs()
Do not allow scripts which can be modified by wiki users to load on this page; only allow scripts bun...
getSkin()
Get the Skin object.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
setSubtitle( $str)
Replace the subtitle with $str.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
addVaryHeader( $header, $option=null)
Add an HTTP header that will influence on the cache.
static getStatusMessage( $code)
Get the message associated with the HTTP response code $code.
addWikiText( $text, $linestart=true, $interface=true)
Convert wikitext to HTML and add it to the buffer Default assumes that the current page title will be...
Show an error when the user hits a rate limit.
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
getVaryHeader()
Return a Vary: header on which to vary caches.
addModules( $modules)
Add one or more modules recognized by the resource loader.
showLagWarning( $lag)
Show a warning about slave lag.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
appendSubtitle( $str)
Add $str to the subtitle.
getPageTitleActionText()
Get the value of the "action text".
getCacheVaryCookies()
Get the list of cookies that will influence on the cache.
getHeadItems()
Get all header items in a string.
when a variable name is used in a it is silently declared as a new masking the global
addLanguageLinks( $newLinkArray)
Add new language links.
formatPermissionsErrorMessage( $errors, $action=null)
Format a list of error messages.
static makeLoaderURL( $modules, $lang, $skin, $user=null, $version=null, $debug=false, $only=null, $printable=false, $handheld=false, $extraQuery=array())
Build a load.php URL.
return false to override stock group removal can be modified modifiable will be added to $_SESSION & $cookies
getOrigin()
Get this module's origin.
addBacklinkSubtitle(Title $title)
Add a subtitle containing a backlink to a page.
setContext(IContextSource $context)
Set the IContextSource object.
addParserOutputNoText(&$parserOutput)
Add a ParserOutput object, but without Html.
isArticle()
Return whether the content displayed page is related to the source of the corresponding article on th...
This class should be covered by a general architecture document which does not exist as of January 20...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
ParserOptions $mParserOptions
lazy initialised, use parserOptions()
addLink( $linkarr)
Add a new <link> tag to the page header.
addInlineScript( $script)
Add a self-contained script tag with the given contents.
getArticleBodyOnly()
Return whether the output will contain only the body of the article.
getPreventClickjacking()
Get the prevent-clickjacking flag.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
getExtStyle()
Get all styles added by extensions.
setStatusCode( $statusCode)
Set the HTTP status code to send with the output.
includeJQuery( $modules=array())
Include jQuery core.
makeResourceLoaderLink( $modules, $only, $useESI=false, array $extraQuery=array(), $loadCall=false)
TODO: Document.
haveCacheVaryCookies()
Check if the request has a cache-varying cookie header If it does, it's very important that we don't ...
getPageTitle()
Return the "page title", i.e.
disable()
Disable output completely, i.e.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
sectionEditLinksEnabled()
setIndexPolicy( $policy)
Set the index policy for the page, but leave the follow policy un- touched.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
presenting them properly to the user as errors is done by the caller $title
getPageClasses( $title)
TODO: document.
showPermissionsErrorPage( $errors, $action=null)
Output a standard permission error page.
setRevisionTimestamp( $timestamp)
Set the timestamp of the revision which will be displayed.
Allows to change the fields on the form that will be generated $name
getHeadItemsArray()
Get an array of head items.
wfClearOutputBuffers()
More legible than passing a 'false' parameter to wfResetOutputBuffers():
rateLimited()
Turn off regular page output and return an error response for when rate limiting has triggered.
const ORIGIN_USER_INDIVIDUAL
const TS_ISO_8601_BASIC
ISO 8601 basic format with no timezone: 19860209T200000Z.
getProperty( $name)
Get an additional output property.
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
setSquidMaxage( $maxage)
Set the value of the "s-maxage" part of the "Cache-control" HTTP header.
setTarget( $target)
Sets ResourceLoader target for load.php links.
setHTMLTitle( $name)
"HTML title" means the contents of "<title>".
$styles
An array of stylesheet filenames (relative from skins path), with options for CSS media,...
static newFromURL( $url)
THIS IS NOT THE FUNCTION YOU WANT.
static resolveAlias( $alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
$mProperties
Additional key => value data.
wrapWikiMsg( $wrap)
This function takes a number of message/argument specifications, wraps them in some overall structure...
buildCssLinks()
Build a set of "<link>" elements for the stylesheets specified in the $this->styles array.
static inlineStyle( $contents, $media='all')
Output a "<style>" tag with the given contents for the given media type (if any).
filterModules( $modules, $position=null, $type=ResourceLoaderModule::TYPE_COMBINED)
Filter an array of modules to remove insufficiently trustworthy members, and modules which are no lon...
prependHTML( $text)
Prepend $text to the body HTML.
static formatTemplates( $templates, $preview=false, $section=false, $more=null)
Returns HTML for the "templates used on this page" list.
static exists( $index)
Returns whether the specified namespace exists.
getHTMLTitle()
Return the "HTML title", i.e.
showFileCopyError( $old, $new)
const ORIGIN_CORE_INDIVIDUAL
clearSubtitle()
Clear the subtitles.
getMetadataAttribute()
Get the value of the "rel" attribute for metadata links.
static getMessage( $code)
Get the message associated with HTTP response code $code.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
$mScripts
Should be private.
getModules( $filter=false, $position=null, $param='mModules')
Get the list of modules to include on this page.
Interface for objects which can provide a context on request.
setFollowPolicy( $policy)
Set the follow policy for the page, but leave the index policy un- touched.
setPageTitle( $name)
"Page title" means the contents of <h1>.
$mDebugtext
Holds the debug lines that will be output as comments in page source if $wgDebugComments is enabled.
if(PHP_SAPI !='cli') $file
checkLastModified( $timestamp)
checkLastModified tells the client to use the client-cached page if possible.
Represents a title within MediaWiki.
Abstraction for resource loader modules, with name registration and maxage functionality.
addReturnTo( $title, $query=array(), $text=null, $options=array())
Add a "return to" link pointing to a specified title.
getAllowedModules( $type)
Get the level of JavaScript / CSS untrustworthiness allowed on this page.
Dynamic JavaScript and CSS resource loading system.
setProperty( $name, $value)
Set an additional output property.
isPrintable()
Return whether the page is "printable".
setSyndicated( $show=true)
Add or remove feed links in the page header This is mainly kept for backward compatibility,...
string null $mTarget
ResourceLoader target for load.php links.
addInlineStyle( $style_css, $flip='noflip')
Adds inline CSS styles.
if(count( $args)==0) $dir
userCanPreview()
To make it harder for someone to slip a user a fake user-JavaScript or user-CSS preview,...
static linkedStyle( $url, $media='all')
Output a "<link rel=stylesheet>" linking to the given URL for the given media type (if any).
addExtensionStyle( $url)
Register and add a stylesheet from an extension directory.
static inDebugMode()
Determine whether debug mode was requested Order of priority is 1) request param, 2) cookie,...
setLanguageLinks( $newLinkArray)
Reset the language links and add new language links.
setRedirectedFrom( $t)
Set $mRedirectedFrom, the Title of the page which redirected us to the current page.
addWikiTextTitle( $text, Title $title, $linestart, $tidy=false, $interface=false)
Add wikitext with a custom Title object.
$mMetatags
Should be private. Used with addMeta() which adds "<meta>".
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
getHeadScripts()
JS stuff to put in the "<head>".
redirect( $url, $responsecode='302')
Redirect to $url rather than displaying the normal page.
setPrintable()
Set the page as printable, i.e.
$mJQueryDone
Whether jQuery is already handled.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
addModuleScripts( $modules)
Add only JS of one or more modules recognized by the resource loader.
allowClickjacking()
Turn off frame-breaking.
addElement( $element, $attribs=array(), $contents='')
Shortcut for adding an Html::element via addHTML.
showFatalError( $message)
getHTML()
Get the body HTML.
if(PHP_SAPI !='cli') $source
static normalizeCharReferences( $text)
Ensure that any entities and character references are legal for XML and XHTML specifically.
static addModules(OutputPage $out)
Add ResourceLoader modules to the OutputPage object if debugging is enabled.
addMetadataLink( $linkarr)
Add a new <link> with "rel" attribute set to "meta".
showNewSectionLink()
Show an "add new section" link?
static transform( $css, $swapLtrRtlInURL=false, $swapLeftRightInURL=false)
Transform an LTR stylesheet to RTL.
parse( $text, $linestart=true, $interface=false, $language=null)
Parse wikitext and return the HTML.
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
addJsConfigVars( $keys, $value=null)
Add one or more variables to be set in mw.config in JavaScript.
$mPrintable
Should be private.
The main skin class which provides methods and properties for all other skins.
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
$mPagetitle
Should be private - has getter and setter. Contains the HTML title.
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
getJsConfigVars()
Get the javascript config vars to include on this page.
getTemplateIds()
Get the templates used on this page.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
isSyndicated()
Should we output feed links for this page?
getFileSearchOptions()
Get the files used on this page.
$mFeedLinks
Handles the atom / rss links.
bool $mDoNothing
Whether output is disabled.
static & singleton()
Get an instance of this class.
getXVO()
Get a complete X-Vary-Options header.
const TS_RFC2822
RFC 2822 format, for E-mail and HTTP headers.
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
prepareErrorPage( $pageTitle, $htmlTitle=false)
Prepare this object to display an error page; disable caching and indexing, clear the current text an...
addTemplate(&$template)
Add the output of a QuickTemplate to the output buffer.
getFeedAppendQuery()
Will currently always return null.
$mPageLinkTitle
Used by skin template.
$mIsarticle
Should be private. Is the displayed content related to the source of the corresponding wiki article.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
addFeedLink( $format, $href)
Add a feed link to the page header.
setRobotPolicy( $policy)
Set the robot policy for the page: http://www.robotstxt.org/meta.html
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes two arrays as input, and returns a CGI-style string, e.g.
static removeHTMLtags( $text, $processCallback=null, $args=array(), $extratags=array(), $removetags=array())
Cleans up HTML, removes dangerous tags and attributes, and removes HTML comments.
headElement(Skin $sk, $includeStyle=true)
getCategories()
Get the list of category names this page belongs to.