static function capturePath( &$title ) {
global $wgOut, $wgTitle, $wgUser;
+ // preload the skin - Sometimes the SpecialPage loads it at a bad point in time making a includable special page override the skin title
+ // This hack is ok for now. The plan is for
+ // - Skin to stop storing it's own title
+ // - includable special pages to stop using $wgTitle and $wgOut
+ // - and OutputPage to store it's own skin object instead of askin $wgUser
+ // Once just about any of those are implemented preloading will not be necessarily
+ $wgOut->getSkin();
+
$oldTitle = $wgTitle;
$oldOut = $wgOut;
$wgOut = new OutputPage;
* Output an error message telling the user what access level they have to have
*/
function displayRestrictionError() {
- global $wgOut;
- $wgOut->permissionRequired( $this->mRestriction );
+ $this->getOutput()->permissionRequired( $this->mRestriction );
}
/**
* Sets headers - this should be called from the execute() method of all derived classes!
*/
function setHeaders() {
- global $wgOut;
- $wgOut->setArticleRelated( false );
- $wgOut->setRobotPolicy( "noindex,nofollow" );
- $wgOut->setPageTitle( $this->getDescription() );
+ if ( $this->including() ) {
+ // Don't set these headers when special page is being included into an article
+ return;
+ }
+ $out = $this->getOutput();
+ $out->setArticleRelated( false );
+ $out->setRobotPolicy( "noindex,nofollow" );
+ $out->setPageTitle( $this->getDescription() );
}
/**
* @param $summaryMessageKey String: message key of the summary
*/
function outputHeader( $summaryMessageKey = '' ) {
- global $wgOut, $wgContLang;
+ global $wgContLang;
if( $summaryMessageKey == '' ) {
$msg = $wgContLang->lc( $this->name() ) . '-summary';
$msg = $summaryMessageKey;
}
if ( !wfMessage( $msg )->isBlank() and ! $this->including() ) {
- $wgOut->wrapWikiMsg( "<div class='mw-specialpage-summary'>\n$1\n</div>", $msg );
+ $this->getOutput()->wrapWikiMsg( "<div class='mw-specialpage-summary'>\n$1\n</div>", $msg );
}
}
return $this->getOutput()->getSkin();
}
+ /**
+ * Shortcut to call OutputPage::allowClickjacking(); which also takes
+ * transclusion into account.
+ */
+ public function allowClickjacking() {
+ if ( !$this->including() ) {
+ $this->getOutput()->allowClickjacking();
+ }
+ }
+
/**
* Wrapper around wfMessage that sets the current context. Currently this
* is only the title.
$this->setHeaders();
$this->outputHeader();
- $out->allowClickjacking();
+ $this->allowClickjacking();
# GET values
$from = $request->getVal( 'from', null );
$namespaces = $wgContLang->getNamespaces();
- $out->setPagetitle(
- ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces) ) ) ?
- wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) :
- wfMsg( 'allarticles' )
- );
- $out->addModuleStyles( 'mediawiki.special' );
+ if( !$this->including() ) {
+ $out->setPagetitle(
+ ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces) ) ) ?
+ wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) :
+ wfMsg( 'allarticles' )
+ );
+ // Note: The following will not end up in the parser output cache as
+ // a result even if we wanted to load it on pages including the
+ // special page it would be unstable.
+ $out->addModuleStyles( 'mediawiki.special' );
+ }
if( isset($par) ) {
$this->showChunk( $namespace, $par, $to );
}
public function execute( $par ){
- global $wgOut;
-
$this->setHeaders();
$this->outputHeader();
$pager = new NewFilesPager( $par );
- $form = $pager->getForm();
- $form->prepareForm();
- $form->displayForm( '' );
- $wgOut->addHTML( $pager->getBody() . $pager->getNavigationBar() );
+ if ( !$this->including() ) {
+ $form = $pager->getForm();
+ $form->prepareForm();
+ $form->displayForm( '' );
+ }
+ $this->getOutput()->addHTML( $pager->getBody() );
+ if ( !$this->including() ) {
+ $this->getOutput()->addHTML( $pager->getNavigationBar() );
+ }
}
}
*/
protected $opts;
- /**
- * @var Skin
- */
- protected $skin;
-
// Some internal settings
protected $showNavigation = false;
}
protected function setup( $par ) {
- global $wgRequest, $wgUser, $wgEnableNewpagesUserFilter;
+ global $wgEnableNewpagesUserFilter;
// Options
$opts = new FormOptions();
$this->opts = $opts; // bind
$opts->add( 'hideliu', false );
- $opts->add( 'hidepatrolled', $wgUser->getBoolOption( 'newpageshidepatrolled' ) );
+ $opts->add( 'hidepatrolled', $this->getUser()->getBoolOption( 'newpageshidepatrolled' ) );
$opts->add( 'hidebots', false );
$opts->add( 'hideredirs', true );
- $opts->add( 'limit', (int)$wgUser->getOption( 'rclimit' ) );
+ $opts->add( 'limit', (int)$this->getUser()->getOption( 'rclimit' ) );
$opts->add( 'offset', '' );
$opts->add( 'namespace', '0' );
$opts->add( 'username', '' );
$opts->add( 'tagfilter', '' );
// Set values
- $opts->fetchValuesFromRequest( $wgRequest );
+ $opts->fetchValuesFromRequest( $this->getRequest() );
if ( $par ) $this->parseParams( $par );
// Validate
if( !$wgEnableNewpagesUserFilter ) {
$opts->setValue( 'username', '' );
}
-
- // Store some objects
- $this->skin = $wgUser->getSkin();
}
protected function parseParams( $par ) {
* @return String
*/
public function execute( $par ) {
- global $wgOut;
+ $out = $this->getOutput();
$this->setHeaders();
$this->outputHeader();
if ( $this->showNavigation ) {
$navigation = $pager->getNavigationBar();
}
- $wgOut->addHTML( $navigation . $pager->getBody() . $navigation );
+ $out->addHTML( $navigation . $pager->getBody() . $navigation );
} else {
- $wgOut->addWikiMsg( 'specialpage-empty' );
+ $out->addWikiMsg( 'specialpage-empty' );
}
}
protected function filterLinks() {
- global $wgGroupPermissions, $wgUser, $wgLang;
+ global $wgGroupPermissions, $wgLang;
// show/hide links
$showhide = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) );
unset( $filters['hideliu'] );
}
- if ( !$wgUser->useNPPatrol() ) {
+ if ( !$this->getUser()->useNPPatrol() ) {
unset( $filters['hidepatrolled'] );
}
$self = $this->getTitle();
foreach ( $filters as $key => $msg ) {
$onoff = 1 - $this->opts->getValue( $key );
- $link = $this->skin->link( $self, $showhide[$onoff], array(),
+ $link = $this->getSkin()->link( $self, $showhide[$onoff], array(),
array( $key => $onoff ) + $changed
);
$links[$key] = wfMsgHtml( $msg, $link );
}
protected function form() {
- global $wgOut, $wgEnableNewpagesUserFilter, $wgScript;
+ global $wgEnableNewpagesUserFilter, $wgScript;
// Consume values
$this->opts->consumeValue( 'offset' ); // don't carry offset, DWIW
$hidden .
Xml::closeElement( 'form' );
- $wgOut->addHTML( $form );
+ $this->getOutput()->addHTML( $form );
}
protected function setSyndicated() {
- global $wgOut;
- $wgOut->setSyndicated( true );
- $wgOut->setFeedAppendQuery( wfArrayToCGI( $this->opts->getAllValues() ) );
+ $out = $this->getOutput();
+ $out->setSyndicated( true );
+ $out->setFeedAppendQuery( wfArrayToCGI( $this->opts->getAllValues() ) );
}
/**
$query['rcid'] = $result->rc_id;
}
- $plink = $this->skin->linkKnown(
+ $plink = $this->getSkin()->linkKnown(
$title,
null,
array( 'class' => 'mw-newpages-pagename' ),
$query,
array( 'known' ) // Set explicitly to avoid the default of 'known','noclasses'. This breaks the colouration for stubs
);
- $histLink = $this->skin->linkKnown(
+ $histLink = $this->getSkin()->linkKnown(
$title,
wfMsgHtml( 'hist' ),
array(),
']'
);
- $ulink = $this->skin->revUserTools( $rev );
- $comment = $this->skin->revComment( $rev );
+ $ulink = $this->getSkin()->revUserTools( $rev );
+ $comment = $this->getSkin()->revComment( $rev );
if ( $this->patrollable( $result ) ) {
$classes[] = 'not-patrolled';
* @return Boolean
*/
protected function patrollable( $result ) {
- global $wgUser;
- return ( $wgUser->useNPPatrol() && !$result->rc_patrolled );
+ return ( $this->getUser()->useNPPatrol() && !$result->rc_patrolled );
}
/**
* @param $type String
*/
protected function feed( $type ) {
- global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgOut;
+ global $wgFeed, $wgFeedClasses, $wgFeedLimit;
if ( !$wgFeed ) {
$wgOut->addWikiMsg( 'feed-unavailable' );
}
if( !isset( $wgFeedClasses[$type] ) ) {
- $wgOut->addWikiMsg( 'feed-invalid' );
+ $this->getOut()->addWikiMsg( 'feed-invalid' );
return;
}
}
function getQueryInfo() {
- global $wgEnableNewpagesUserFilter, $wgGroupPermissions, $wgUser;
+ global $wgEnableNewpagesUserFilter, $wgGroupPermissions;
$conds = array();
$conds['rc_new'] = 1;
$conds['rc_user'] = 0;
}
# If this user cannot see patrolled edits or they are off, don't do dumb queries!
- if( $this->opts->getValue( 'hidepatrolled' ) && $wgUser->useNPPatrol() ) {
+ if( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) {
$conds['rc_patrolled'] = 0;
}
if( $this->opts->getValue( 'hidebots' ) ) {
* @return FormOptions
*/
public function getDefaultOptions() {
- global $wgUser;
$opts = new FormOptions();
- $opts->add( 'days', (int)$wgUser->getOption( 'rcdays' ) );
- $opts->add( 'limit', (int)$wgUser->getOption( 'rclimit' ) );
+ $opts->add( 'days', (int)$this->getUser()->getOption( 'rcdays' ) );
+ $opts->add( 'limit', (int)$this->getUser()->getOption( 'rclimit' ) );
$opts->add( 'from', '' );
- $opts->add( 'hideminor', $wgUser->getBoolOption( 'hideminor' ) );
+ $opts->add( 'hideminor', $this->getUser()->getBoolOption( 'hideminor' ) );
$opts->add( 'hidebots', true );
$opts->add( 'hideanons', false );
$opts->add( 'hideliu', false );
- $opts->add( 'hidepatrolled', $wgUser->getBoolOption( 'hidepatrolled' ) );
+ $opts->add( 'hidepatrolled', $this->getUser()->getBoolOption( 'hidepatrolled' ) );
$opts->add( 'hidemyself', false );
$opts->add( 'namespace', '', FormOptions::INTNULL );
* @return String or false
*/
public function checkLastModified( $feedFormat ) {
- global $wgOut, $wgUser;
$dbr = wfGetDB( DB_SLAVE );
$lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ );
- if( $feedFormat || !$wgUser->useRCPatrol() ) {
- if( $lastmod && $wgOut->checkLastModified( $lastmod ) ) {
+ if( $feedFormat || !$this->getUser()->useRCPatrol() ) {
+ if( $lastmod && $this->getOutput()->checkLastModified( $lastmod ) ) {
# Client cache fresh and headers sent, nothing more to do.
return false;
}
* @return array
*/
public function buildMainQueryConds( FormOptions $opts ) {
- global $wgUser;
-
$dbr = wfGetDB( DB_SLAVE );
$conds = array();
$conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
- $hidePatrol = $wgUser->useRCPatrol() && $opts['hidepatrolled'];
+ $hidePatrol = $this->getUser()->useRCPatrol() && $opts['hidepatrolled'];
$hideLoggedInUsers = $opts['hideliu'] && !$forcebot;
$hideAnonymousUsers = $opts['hideanons'] && !$forcebot;
if( $hideAnonymousUsers ) $conds[] = 'rc_user != 0';
if( $opts['hidemyself'] ) {
- if( $wgUser->getId() ) {
- $conds[] = 'rc_user != ' . $dbr->addQuotes( $wgUser->getId() );
+ if( $this->getUser()->getId() ) {
+ $conds[] = 'rc_user != ' . $dbr->addQuotes( $this->getUser()->getId() );
} else {
- $conds[] = 'rc_user_text != ' . $dbr->addQuotes( $wgUser->getName() );
+ $conds[] = 'rc_user_text != ' . $dbr->addQuotes( $this->getUser()->getName() );
}
}
* @return database result or false (for Recentchangeslinked only)
*/
public function doMainQuery( $conds, $opts ) {
- global $wgUser;
-
$tables = array( 'recentchanges' );
$join_conds = array();
$query_options = array( 'USE INDEX' => array('recentchanges' => 'rc_timestamp') );
- $uid = $wgUser->getId();
+ $uid = $this->getUser()->getId();
$dbr = wfGetDB( DB_SLAVE );
$limit = $opts['limit'];
$namespace = $opts['namespace'];
$join_conds['watchlist'] = array('LEFT JOIN',
"wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace");
}
- if ($wgUser->isAllowed("rollback")) {
+ if ($this->getUser()->isAllowed("rollback")) {
$tables[] = 'page';
$join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
}
* @param $opts FormOptions
*/
public function webOutput( $rows, $opts ) {
- global $wgOut, $wgUser, $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
+ global $wgOut, $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
global $wgAllowCategorizedRecentChanges;
$limit = $opts['limit'];
$this->filterByCategories( $rows, $opts );
}
- $showWatcherCount = $wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' );
+ $showWatcherCount = $wgRCShowWatchingUsers && $this->getUser()->getOption( 'shownumberswatching' );
$watcherCache = array();
$dbr = wfGetDB( DB_SLAVE );
$counter = 1;
- $list = ChangesList::newFromUser( $wgUser );
+ $list = ChangesList::newFromUser( $this->getUser() );
$s = $list->beginRecentChangesList();
foreach( $rows as $obj ) {
* @param $active Boolean: whether to show the link in bold
*/
function makeOptionsLink( $title, $override, $options, $active = false ) {
- global $wgUser;
- $sk = $wgUser->getSkin();
$params = $override + $options;
if ( $active ) {
- return $sk->link( $this->getTitle(), '<strong>' . htmlspecialchars( $title ) . '</strong>',
+ return $this->getSkin()->link( $this->getTitle(), '<strong>' . htmlspecialchars( $title ) . '</strong>',
array(), $params, array( 'known' ) );
} else {
- return $sk->link( $this->getTitle(), htmlspecialchars( $title ), array() , $params, array( 'known' ) );
+ return $this->getSkin()->link( $this->getTitle(), htmlspecialchars( $title ), array() , $params, array( 'known' ) );
}
}
* @param $nondefaults Array
*/
function optionsPanel( $defaults, $nondefaults ) {
- global $wgLang, $wgUser, $wgRCLinkLimits, $wgRCLinkDays;
+ global $wgLang, $wgRCLinkLimits, $wgRCLinkDays;
$options = $nondefaults + $defaults;
$links[] = wfMsgHtml( 'rcshowhidebots', $botLink );
$links[] = wfMsgHtml( 'rcshowhideanons', $anonsLink );
$links[] = wfMsgHtml( 'rcshowhideliu', $liuLink );
- if( $wgUser->useRCPatrol() )
+ if( $this->getUser()->useRCPatrol() )
$links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink );
$links[] = wfMsgHtml( 'rcshowhidemine', $myselfLink );
$hl = $wgLang->pipeList( $links );