* @todo document
*/
class OutputPage extends ContextSource {
- /** @var array Should be private. Used with addMeta() which adds "<meta>" */
+ /** @var string[][] Should be private. Used with addMeta() which adds "<meta>" */
protected $mMetatags = [];
/** @var array */
* @param Title $t
*/
public function setTitle( Title $t ) {
+ // @phan-suppress-next-next-line PhanUndeclaredMethod
+ // @fixme Not all implementations of IContextSource have this method!
$this->getContext()->setTitle( $t );
}
* @param string $text Wikitext
* @param Title $title
* @param bool $linestart Is this the start of a line?
- * @param bool $tidy Whether to use tidy.
- * Setting this to false (or omitting it) is deprecated
- * since 1.32; all wikitext should be tidied.
* @param bool $interface Whether it is an interface message
* (for example disables conversion)
* @param string $wrapperClass if not empty, wraps the output in
* a `<div class="$wrapperClass">`
- * @private
*/
private function addWikiTextTitleInternal(
$text, Title $title, $linestart, $interface, $wrapperClass = null
$this->mCdnMaxage != 0 &&
!$this->haveCacheVaryCookies()
) {
- if ( $config->get( 'UseESI' ) ) {
- wfDeprecated( '$wgUseESI = true', '1.33' );
- # We'll purge the proxy cache explicitly, but require end user agents
- # to revalidate against the proxy on each visit.
- # Surrogate-Control controls our CDN, Cache-Control downstream caches
- wfDebug( __METHOD__ .
- ": proxy caching with ESI; {$this->mLastModified} **", 'private' );
- # start with a shorter timeout for initial testing
- # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
- $response->header(
- "Surrogate-Control: max-age={$config->get( 'CdnMaxAge' )}" .
- "+{$this->mCdnMaxage}, content=\"ESI/1.0\""
- );
- $response->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
- } else {
- # We'll purge the proxy cache for anons explicitly, but require end user agents
- # to revalidate against the proxy on each visit.
- # IMPORTANT! The CDN needs to replace the Cache-Control header with
- # Cache-Control: s-maxage=0, must-revalidate, max-age=0
- wfDebug( __METHOD__ .
- ": local proxy caching; {$this->mLastModified} **", 'private' );
- # start with a shorter timeout for initial testing
- # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
- $response->header( "Cache-Control: " .
- "s-maxage={$this->mCdnMaxage}, must-revalidate, max-age=0" );
- }
+ # We'll purge the proxy cache for anons explicitly, but require end user agents
+ # to revalidate against the proxy on each visit.
+ # IMPORTANT! The CDN needs to replace the Cache-Control header with
+ # Cache-Control: s-maxage=0, must-revalidate, max-age=0
+ wfDebug( __METHOD__ .
+ ": local proxy caching; {$this->mLastModified} **", 'private' );
+ # start with a shorter timeout for initial testing
+ # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
+ $response->header( "Cache-Control: " .
+ "s-maxage={$this->mCdnMaxage}, must-revalidate, max-age=0" );
} else {
# We do want clients to cache if they can, but they *must* check for updates
# on revisiting the page.
$sitedir = MediaWikiServices::getInstance()->getContentLanguage()->getDir();
$pieces = [];
- $pieces[] = Html::htmlHeader( Sanitizer::mergeAttributes(
+ $htmlAttribs = Sanitizer::mergeAttributes(
$this->getRlClient()->getDocumentAttributes(),
$sk->getHtmlElementAttributes()
- ) );
+ );
+ $pieces[] = Html::htmlHeader( $htmlAttribs );
$pieces[] = Html::openElement( 'head' );
if ( $this->getHTMLTitle() == '' ) {
}
$pieces[] = Html::element( 'title', null, $this->getHTMLTitle() );
- $pieces[] = $this->getRlClient()->getHeadHtml();
+ $pieces[] = $this->getRlClient()->getHeadHtml( $htmlAttribs['class'] ?? null );
$pieces[] = $this->buildExemptModules();
$pieces = array_merge( $pieces, array_values( $this->getHeadLinksArray() ) );
$pieces = array_merge( $pieces, array_values( $this->mHeadItems ) );
$vars['wgUserVariant'] = $contLang->getPreferredVariant();
}
// Same test as SkinTemplate
- $vars['wgIsProbablyEditable'] = $title->quickUserCan( 'edit', $user )
- && ( $title->exists() || $title->quickUserCan( 'create', $user ) );
+ $vars['wgIsProbablyEditable'] = $this->userCanEditOrCreate( $user, $title );
- $vars['wgRelevantPageIsProbablyEditable'] = $relevantTitle
- && $relevantTitle->quickUserCan( 'edit', $user )
- && ( $relevantTitle->exists() || $relevantTitle->quickUserCan( 'create', $user ) );
+ $vars['wgRelevantPageIsProbablyEditable'] = $relevantTitle &&
+ $this->userCanEditOrCreate( $user, $relevantTitle );
foreach ( $title->getRestrictionTypes() as $type ) {
// Following keys are set in $vars:
return true;
}
+ /**
+ * @param User $user
+ * @param LinkTarget $title
+ * @return bool
+ */
+ private function userCanEditOrCreate(
+ User $user,
+ LinkTarget $title
+ ) {
+ $pm = MediaWikiServices::getInstance()->getPermissionManager();
+ return $pm->quickUserCan( 'edit', $user, $title )
+ && ( $this->getTitle()->exists() ||
+ $pm->quickUserCan( 'create', $user, $title ) );
+ }
+
/**
* @return array Array in format "link name or number => 'link html'".
*/
# Universal edit button
if ( $config->get( 'UniversalEditButton' ) && $this->isArticleRelated() ) {
- $user = $this->getUser();
- if ( $this->getTitle()->quickUserCan( 'edit', $user )
- && ( $this->getTitle()->exists() ||
- $this->getTitle()->quickUserCan( 'create', $user ) )
- ) {
+ if ( $this->userCanEditOrCreate( $this->getUser(), $this->getTitle() ) ) {
// Original UniversalEditButton
$msg = $this->msg( 'edit' )->text();
$tags['universal-edit-button'] = Html::element( 'link', [