From 00b6d465f1d8a9923e68d98297a4e915c101ff79 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Tue, 20 Sep 2011 20:00:05 +0000 Subject: [PATCH] * Made IndexPager extend ContextSource * Updated special pages using IndexPager or one if its subclasses to pass the context object and use it instead of global variables * Call Linker methods statically * Changed LogPager::getUser() to LogPager::getAuthor() to avoid conflict with ContextSource::getUser() --- includes/LogEventsList.php | 43 ++--- includes/Pager.php | 100 ++++-------- includes/specials/SpecialActiveusers.php | 38 ++--- includes/specials/SpecialAllmessages.php | 22 +-- includes/specials/SpecialBlockList.php | 80 +++++---- includes/specials/SpecialCategories.php | 21 +-- includes/specials/SpecialContributions.php | 152 ++++++++---------- .../specials/SpecialDeletedContributions.php | 114 +++++++------ includes/specials/SpecialListfiles.php | 32 ++-- includes/specials/SpecialListusers.php | 39 ++--- includes/specials/SpecialLog.php | 18 +-- includes/specials/SpecialMergeHistory.php | 100 +++++------- includes/specials/SpecialNewimages.php | 33 ++-- includes/specials/SpecialNewpages.php | 34 +--- includes/specials/SpecialProtectedpages.php | 57 +++---- includes/specials/SpecialProtectedtitles.php | 39 ++--- 16 files changed, 390 insertions(+), 532 deletions(-) diff --git a/includes/LogEventsList.php b/includes/LogEventsList.php index ffa9f8357e..fabfe8339f 100644 --- a/includes/LogEventsList.php +++ b/includes/LogEventsList.php @@ -213,6 +213,10 @@ class LogEventsList { return $this->out->getTitle(); } + public function getContext() { + return $this->out->getContext(); + } + /** * @param $queryTypes Array * @return String: Formatted HTML @@ -630,7 +634,6 @@ class LogEventsList { public static function showLogExtract( &$out, $types=array(), $page='', $user='', $param = array() ) { - global $wgUser, $wgOut; $defaultParameters = array( 'lim' => 25, 'conds' => array(), @@ -652,8 +655,15 @@ class LogEventsList { if ( !is_array( $msgKey ) ) { $msgKey = array( $msgKey ); } + + if ( $out instanceof OutputPage ) { + $context = $out->getContext(); + } else { + $context = RequestContext::getMain(); + } + # Insert list of top 50 (or top $lim) items - $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, $flags ); + $loglist = new LogEventsList( $context->getSkin(), $context->getOutput(), $flags ); $pager = new LogPager( $loglist, $types, $user, $page, '', $conds ); if ( isset( $param['offset'] ) ) { # Tell pager to ignore $wgRequest offset $pager->setOffset( $param['offset'] ); @@ -769,7 +779,7 @@ class LogEventsList { * @ingroup Pager */ class LogPager extends ReverseChronologicalPager { - private $types = array(), $user = '', $title = '', $pattern = ''; + private $types = array(), $author = '', $title = '', $pattern = ''; private $typeCGI = ''; public $mLogEventsList; @@ -778,7 +788,7 @@ class LogPager extends ReverseChronologicalPager { * * @param $list LogEventsList * @param $types String or Array: log types to show - * @param $user String: the user who made the log entries + * @param $author String: the user who made the log entries * @param $title String: the page title the log entries are for * @param $pattern String: do a prefix search rather than an exact title match * @param $conds Array: extra conditions for the query @@ -786,15 +796,15 @@ class LogPager extends ReverseChronologicalPager { * @param $month Integer: the month to start from * @param $tagFilter String: tag */ - public function __construct( $list, $types = array(), $user = '', $title = '', $pattern = '', + public function __construct( $list, $types = array(), $author = '', $title = '', $pattern = '', $conds = array(), $year = false, $month = false, $tagFilter = '' ) { - parent::__construct(); + parent::__construct( $list->getContext() ); $this->mConds = $conds; $this->mLogEventsList = $list; $this->limitType( $types ); // also excludes hidden types - $this->limitUser( $user ); + $this->limitAuthor( $author ); $this->limitTitle( $title, $pattern ); $this->getDateCond( $year, $month ); $this->mTagFilter = $tagFilter; @@ -803,19 +813,12 @@ class LogPager extends ReverseChronologicalPager { public function getDefaultQuery() { $query = parent::getDefaultQuery(); $query['type'] = $this->typeCGI; // arrays won't work here - $query['user'] = $this->user; + $query['user'] = $this->author; $query['month'] = $this->mMonth; $query['year'] = $this->mYear; return $query; } - /** - * @return Title - */ - function getTitle() { - return $this->mLogEventsList->getDisplayTitle(); - } - // Call ONLY after calling $this->limitType() already! public function getFilterParams() { global $wgFilterLogTypes, $wgUser, $wgRequest; @@ -874,7 +877,7 @@ class LogPager extends ReverseChronologicalPager { * * @param $name String: (In)valid user name */ - private function limitUser( $name ) { + private function limitAuthor( $name ) { if( $name == '' ) { return false; } @@ -898,7 +901,7 @@ class LogPager extends ReverseChronologicalPager { $this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::SUPPRESSED_USER) . ' != ' . LogPage::SUPPRESSED_USER; } - $this->user = $usertitle->getText(); + $this->author = $usertitle->getText(); } } @@ -982,7 +985,7 @@ class LogPager extends ReverseChronologicalPager { # Avoid usage of the wrong index by limiting # the choices of available indexes. This mainly # avoids site-breaking filesorts. - } elseif( $this->title || $this->pattern || $this->user ) { + } elseif( $this->title || $this->pattern || $this->author ) { $index['logging'] = array( 'page_time', 'user_time' ); if( count($this->types) == 1 ) { $index['logging'][] = 'log_user_type_time'; @@ -1053,8 +1056,8 @@ class LogPager extends ReverseChronologicalPager { /** * @return string */ - public function getUser() { - return $this->user; + public function getAuthor() { + return $this->author; } /** diff --git a/includes/Pager.php b/includes/Pager.php index 6178b9a620..c9388e0b8a 100644 --- a/includes/Pager.php +++ b/includes/Pager.php @@ -57,7 +57,7 @@ interface Pager { * * @ingroup Pager */ -abstract class IndexPager implements Pager { +abstract class IndexPager extends ContextSource implements Pager { public $mRequest; public $mLimitsShown = array( 20, 50, 100, 250, 500 ); public $mDefaultLimit = 50; @@ -103,9 +103,12 @@ abstract class IndexPager implements Pager { */ public $mResult; - public function __construct() { - global $wgRequest, $wgUser; - $this->mRequest = $wgRequest; + public function __construct( RequestContext $context = null ) { + if ( $context ) { + $this->setContext( $context ); + } + + $this->mRequest = $this->getRequest(); # NB: the offset is quoted, not validated. It is treated as an # arbitrary string to support the widest variety of index types. Be @@ -113,7 +116,7 @@ abstract class IndexPager implements Pager { $this->mOffset = $this->mRequest->getText( 'offset' ); # Use consistent behavior for the limit options - $this->mDefaultLimit = intval( $wgUser->getOption( 'rclimit' ) ); + $this->mDefaultLimit = intval( $this->getUser()->getOption( 'rclimit' ) ); list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset(); $this->mIsBackwards = ( $this->mRequest->getVal( 'dir' ) == 'prev' ); @@ -186,13 +189,13 @@ abstract class IndexPager implements Pager { } /** - * Set the offset from an other source than $wgRequest + * Set the offset from an other source than the request */ function setOffset( $offset ) { $this->mOffset = $offset; } /** - * Set the limit from an other source than $wgRequest + * Set the limit from an other source than the request */ function setLimit( $limit ) { $this->mLimit = $limit; @@ -366,12 +369,11 @@ abstract class IndexPager implements Pager { if( $type ) { $attrs['class'] = "mw-{$type}link"; } - return $this->getSkin()->link( + return Linker::linkKnown( $this->getTitle(), $text, $attrs, - $query + $this->getDefaultQuery(), - array( 'noclasses', 'known' ) + $query + $this->getDefaultQuery() ); } @@ -404,29 +406,6 @@ abstract class IndexPager implements Pager { return ''; } - /** - * Title used for self-links. Override this if you want to be able to - * use a title other than $wgTitle - * - * @return Title object - */ - function getTitle() { - return $GLOBALS['wgTitle']; - } - - /** - * Get the current skin. This can be overridden if necessary. - * - * @return Skin object - */ - function getSkin() { - if ( !isset( $this->mSkin ) ) { - global $wgUser; - $this->mSkin = $wgUser->getSkin(); - } - return $this->mSkin; - } - /** * Get an array of query parameters that should be put into self-links. * By default, all parameters passed in the URL are used, except for a @@ -435,10 +414,8 @@ abstract class IndexPager implements Pager { * @return Associative array */ function getDefaultQuery() { - global $wgRequest; - if ( !isset( $this->mDefaultQuery ) ) { - $this->mDefaultQuery = $wgRequest->getQueryValues(); + $this->mDefaultQuery = $this->getRequest()->getQueryValues(); unset( $this->mDefaultQuery['title'] ); unset( $this->mDefaultQuery['dir'] ); unset( $this->mDefaultQuery['offset'] ); @@ -542,7 +519,6 @@ abstract class IndexPager implements Pager { } function getLimitLinks() { - global $wgLang; $links = array(); if ( $this->mIsBackwards ) { $offset = $this->mPastTheEndIndex; @@ -551,7 +527,7 @@ abstract class IndexPager implements Pager { } foreach ( $this->mLimitsShown as $limit ) { $links[] = $this->makeLink( - $wgLang->formatNum( $limit ), + $this->getLang()->formatNum( $limit ), array( 'offset' => $offset, 'limit' => $limit ), 'num' ); @@ -648,25 +624,25 @@ abstract class AlphabeticPager extends IndexPager { * didn't want to do class magic as may be still revamped */ function getNavigationBar() { - global $wgLang; - if ( !$this->isNavigationBarShown() ) return ''; if( isset( $this->mNavigationBar ) ) { return $this->mNavigationBar; } + $lang = $this->getLang(); + $opts = array( 'parsemag', 'escapenoentities' ); $linkTexts = array( 'prev' => wfMsgExt( 'prevn', $opts, - $wgLang->formatNum( $this->mLimit ) + $lang->formatNum( $this->mLimit ) ), 'next' => wfMsgExt( 'nextn', $opts, - $wgLang->formatNum($this->mLimit ) + $lang->formatNum($this->mLimit ) ), 'first' => wfMsgExt( 'page_first', $opts ), 'last' => wfMsgExt( 'page_last', $opts ) @@ -674,10 +650,10 @@ abstract class AlphabeticPager extends IndexPager { $pagingLinks = $this->getPagingLinks( $linkTexts ); $limitLinks = $this->getLimitLinks(); - $limits = $wgLang->pipeList( $limitLinks ); + $limits = $lang->pipeList( $limitLinks ); $this->mNavigationBar = - "(" . $wgLang->pipeList( + "(" . $lang->pipeList( array( $pagingLinks['first'], $pagingLinks['last'] ) ) . ") " . @@ -738,13 +714,7 @@ abstract class ReverseChronologicalPager extends IndexPager { public $mYear; public $mMonth; - function __construct() { - parent::__construct(); - } - function getNavigationBar() { - global $wgLang; - if ( !$this->isNavigationBarShown() ) { return ''; } @@ -752,7 +722,8 @@ abstract class ReverseChronologicalPager extends IndexPager { if ( isset( $this->mNavigationBar ) ) { return $this->mNavigationBar; } - $nicenumber = $wgLang->formatNum( $this->mLimit ); + + $nicenumber = $this->getLang()->formatNum( $this->mLimit ); $linkTexts = array( 'prev' => wfMsgExt( 'pager-newer-n', @@ -770,7 +741,7 @@ abstract class ReverseChronologicalPager extends IndexPager { $pagingLinks = $this->getPagingLinks( $linkTexts ); $limitLinks = $this->getLimitLinks(); - $limits = $wgLang->pipeList( $limitLinks ); + $limits = $this->getLang()->pipeList( $limitLinks ); $this->mNavigationBar = "({$pagingLinks['first']}" . wfMsgExt( 'pipe-separator' , 'escapenoentities' ) . @@ -839,15 +810,18 @@ abstract class TablePager extends IndexPager { var $mSort; var $mCurrentRow; - function __construct() { - global $wgRequest; - $this->mSort = $wgRequest->getText( 'sort' ); + function __construct( RequestContext $context = null ) { + if ( $context ) { + $this->setContext( $context ); + } + + $this->mSort = $this->getRequest()->getText( 'sort' ); if ( !array_key_exists( $this->mSort, $this->getFieldNames() ) ) { $this->mSort = $this->getDefaultSort(); } - if ( $wgRequest->getBool( 'asc' ) ) { + if ( $this->getRequest()->getBool( 'asc' ) ) { $this->mDefaultDirection = false; - } elseif ( $wgRequest->getBool( 'desc' ) ) { + } elseif ( $this->getRequest()->getBool( 'desc' ) ) { $this->mDefaultDirection = true; } /* Else leave it at whatever the class default is */ @@ -985,7 +959,7 @@ abstract class TablePager extends IndexPager { * A navigation bar with images */ function getNavigationBar() { - global $wgStylePath, $wgLang; + global $wgStylePath; if ( !$this->isNavigationBarShown() ) { return ''; @@ -1010,7 +984,7 @@ abstract class TablePager extends IndexPager { 'next' => 'arrow_disabled_right_25.png', 'last' => 'arrow_disabled_last_25.png', ); - if( $wgLang->isRTL() ) { + if( $this->getLang()->isRTL() ) { $keys = array_keys( $labels ); $images = array_combine( $keys, array_reverse( $images ) ); $disabledImages = array_combine( $keys, array_reverse( $disabledImages ) ); @@ -1041,8 +1015,6 @@ abstract class TablePager extends IndexPager { * @return String: HTML fragment */ function getLimitSelect() { - global $wgLang; - # Add the current limit from the query string # to avoid that the limit is lost after clicking Go next time if ( !in_array( $this->mLimit, $this->mLimitsShown ) ) { @@ -1056,7 +1028,7 @@ abstract class TablePager extends IndexPager { # will be a string. if( is_int( $value ) ){ $limit = $value; - $text = $wgLang->formatNum( $limit ); + $text = $this->getLang()->formatNum( $limit ); } else { $limit = $key; $text = $value; @@ -1075,10 +1047,8 @@ abstract class TablePager extends IndexPager { * @return String: HTML fragment */ function getHiddenFields( $blacklist = array() ) { - global $wgRequest; - $blacklist = (array)$blacklist; - $query = $wgRequest->getQueryValues(); + $query = $this->getRequest()->getQueryValues(); foreach ( $blacklist as $name ) { unset( $query[$name] ); } diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index e4bf42d3cf..4394d4246b 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -42,10 +42,13 @@ class ActiveUsersPager extends UsersPager { */ protected $groups; - function __construct( $group = null ) { - global $wgRequest, $wgActiveUserDays; + function __construct( RequestContext $context = null, $group = null ) { + global $wgActiveUserDays; + + parent::__construct( $context ); + $this->RCMaxAge = $wgActiveUserDays; - $un = $wgRequest->getText( 'username' ); + $un = $this->getRequest()->getText( 'username' ); $this->requestedUser = ''; if ( $un != '' ) { $username = Title::makeTitleSafe( NS_USER, $un ); @@ -55,23 +58,15 @@ class ActiveUsersPager extends UsersPager { } $this->setupOptions(); - - parent::__construct(); - } - - function getTitle() { - return SpecialPage::getTitleFor( 'Activeusers' ); } public function setupOptions() { - global $wgRequest; - $this->opts = new FormOptions(); $this->opts->add( 'hidebots', false, FormOptions::BOOL ); $this->opts->add( 'hidesysops', false, FormOptions::BOOL ); - $this->opts->fetchValuesFromRequest( $wgRequest ); + $this->opts->fetchValuesFromRequest( $this->getRequest() ); $this->groups = array(); if ( $this->opts->getValue( 'hidebots' ) == 1 ) { @@ -119,11 +114,10 @@ class ActiveUsersPager extends UsersPager { } function formatRow( $row ) { - global $wgLang; $userName = $row->user_name; - $ulinks = $this->getSkin()->userLink( $row->user_id, $userName ); - $ulinks .= $this->getSkin()->userToolLinks( $row->user_id, $userName ); + $ulinks = Linker::userLink( $row->user_id, $userName ); + $ulinks .= Linker::userToolLinks( $row->user_id, $userName ); $list = array(); foreach( self::getGroups( $row->user_id ) as $group ) { @@ -132,14 +126,14 @@ class ActiveUsersPager extends UsersPager { } $list[] = self::buildGroupLink( $group ); } - $groups = $wgLang->commaList( $list ); + $groups = $this->getLang()->commaList( $list ); $item = wfSpecialList( $ulinks, $groups ); $count = wfMsgExt( 'activeusers-count', array( 'parsemag' ), - $wgLang->formatNum( $row->recentedits ), + $this->getLang()->formatNum( $row->recentedits ), $userName, - $wgLang->formatNum ( $this->RCMaxAge ) + $this->getLang()->formatNum( $this->RCMaxAge ) ); $blocked = $row->blocked ? ' ' . wfMsgExt( 'listusers-blocked', array( 'parsemag' ), $userName ) : ''; @@ -188,18 +182,18 @@ class SpecialActiveUsers extends SpecialPage { * @param $par Mixed: parameter passed to the page or null */ public function execute( $par ) { - global $wgOut, $wgLang, $wgActiveUserDays; + global $wgActiveUserDays; $this->setHeaders(); $this->outputHeader(); - $up = new ActiveUsersPager(); + $up = new ActiveUsersPager( $this->getContext() ); # getBody() first to check, if empty $usersbody = $up->getBody(); $s = Html::rawElement( 'div', array( 'class' => 'mw-activeusers-intro' ), - wfMsgExt( 'activeusers-intro', array( 'parsemag', 'escape' ), $wgLang->formatNum( $wgActiveUserDays ) ) + wfMsgExt( 'activeusers-intro', array( 'parsemag', 'escape' ), $this->getLang()->formatNum( $wgActiveUserDays ) ) ); $s .= $up->getPageHeader(); @@ -211,7 +205,7 @@ class SpecialActiveUsers extends SpecialPage { $s .= Html::element( 'p', array(), wfMsg( 'activeusers-noresult' ) ); } - $wgOut->addHTML( $s ); + $this->getOutput()->addHTML( $s ); } } diff --git a/includes/specials/SpecialAllmessages.php b/includes/specials/SpecialAllmessages.php index 7b7ed42276..5cd5e2d0e1 100644 --- a/includes/specials/SpecialAllmessages.php +++ b/includes/specials/SpecialAllmessages.php @@ -103,14 +103,14 @@ class AllmessagesTablePager extends TablePager { public $custom; function __construct( $page, $conds, $langObj = null ) { - parent::__construct(); + parent::__construct( $page->getContext() ); $this->mIndexField = 'am_title'; $this->mPage = $page; $this->mConds = $conds; $this->mDefaultDirection = true; // always sort ascending $this->mLimitsShown = array( 20, 50, 100, 250, 500, 5000 ); - global $wgLang, $wgContLang, $wgRequest; + global $wgContLang; $this->talk = htmlspecialchars( wfMsg( 'talkpagelinktext' ) ); @@ -118,14 +118,16 @@ class AllmessagesTablePager extends TablePager { $this->langcode = $this->lang->getCode(); $this->foreign = $this->langcode != $wgContLang->getCode(); - if( $wgRequest->getVal( 'filter', 'all' ) === 'all' ){ + $request = $this->getRequest(); + + if( $request->getVal( 'filter', 'all' ) === 'all' ){ $this->custom = null; // So won't match in either case } else { - $this->custom = ($wgRequest->getVal( 'filter' ) == 'unmodified'); + $this->custom = ($request->getVal( 'filter' ) == 'unmodified'); } - $prefix = $wgLang->ucfirst( $wgRequest->getVal( 'prefix', '' ) ); - $prefix = $prefix != '' ? Title::makeTitleSafe( NS_MEDIAWIKI, $wgRequest->getVal( 'prefix', null ) ) : null; + $prefix = $this->getLang()->ucfirst( $request->getVal( 'prefix', '' ) ); + $prefix = $prefix != '' ? Title::makeTitleSafe( NS_MEDIAWIKI, $request->getVal( 'prefix', null ) ) : null; if( $prefix !== null ){ $this->displayPrefix = $prefix->getDBkey(); $this->prefix = '/^' . preg_quote( $this->displayPrefix ) . '/i'; @@ -337,7 +339,6 @@ class AllmessagesTablePager extends TablePager { } function formatValue( $field, $value ){ - global $wgLang; switch( $field ){ case 'am_title' : @@ -346,11 +347,11 @@ class AllmessagesTablePager extends TablePager { $talk = Title::makeTitle( NS_MEDIAWIKI_TALK, $value . $this->suffix ); if( $this->mCurrentRow->am_customised ){ - $title = Linker::linkKnown( $title, $wgLang->lcfirst( $value ) ); + $title = Linker::linkKnown( $title, $this->getLang()->lcfirst( $value ) ); } else { $title = Linker::link( $title, - $wgLang->lcfirst( $value ), + $this->getLang()->lcfirst( $value ), array(), array(), array( 'broken' ) @@ -395,12 +396,11 @@ class AllmessagesTablePager extends TablePager { function getRowAttrs( $row, $isSecond = false ){ $arr = array(); - global $wgLang; if( $row->am_customised ){ $arr['class'] = 'allmessages-customised'; } if( !$isSecond ){ - $arr['id'] = Sanitizer::escapeId( 'msg_' . $wgLang->lcfirst( $row->am_title ) ); + $arr['id'] = Sanitizer::escapeId( 'msg_' . $this->getLang()->lcfirst( $row->am_title ) ); } return $arr; } diff --git a/includes/specials/SpecialBlockList.php b/includes/specials/SpecialBlockList.php index 76915df245..964c63e2d4 100644 --- a/includes/specials/SpecialBlockList.php +++ b/includes/specials/SpecialBlockList.php @@ -40,24 +40,24 @@ class SpecialBlockList extends SpecialPage { * @param $par String title fragment */ public function execute( $par ) { - global $wgOut, $wgRequest; - $this->setHeaders(); $this->outputHeader(); - $wgOut->setPageTitle( wfMsg( 'ipblocklist' ) ); - $wgOut->addModuleStyles( 'mediawiki.special' ); + $out = $this->getOutput(); + $out->setPageTitle( wfMsg( 'ipblocklist' ) ); + $out->addModuleStyles( 'mediawiki.special' ); - $par = $wgRequest->getVal( 'ip', $par ); - $this->target = trim( $wgRequest->getVal( 'wpTarget', $par ) ); + $request = $this->getRequest(); + $par = $request->getVal( 'ip', $par ); + $this->target = trim( $request->getVal( 'wpTarget', $par ) ); - $this->options = $wgRequest->getArray( 'wpOptions', array() ); + $this->options = $request->getArray( 'wpOptions', array() ); - $action = $wgRequest->getText( 'action' ); + $action = $request->getText( 'action' ); - if( $action == 'unblock' || $action == 'submit' && $wgRequest->wasPosted() ) { + if( $action == 'unblock' || $action == 'submit' && $request->wasPosted() ) { # B/C @since 1.18: Unblock interface is now at Special:Unblock $title = SpecialPage::getTitleFor( 'Unblock', $this->target ); - $wgOut->redirect( $title->getFullUrl() ); + $out->redirect( $title->getFullUrl() ); return; } @@ -91,8 +91,6 @@ class SpecialBlockList extends SpecialPage { } function showList() { - global $wgOut, $wgUser; - # Purge expired entries on one in every 10 queries if ( !mt_rand( 0, 10 ) ) { Block::purgeExpired(); @@ -100,7 +98,7 @@ class SpecialBlockList extends SpecialPage { $conds = array(); # Is the user allowed to see hidden blocks? - if ( !$wgUser->isAllowed( 'hideuser' ) ){ + if ( !$this->getUser()->isAllowed( 'hideuser' ) ){ $conds['ipb_deleted'] = 0; } @@ -151,31 +149,33 @@ class SpecialBlockList extends SpecialPage { $otherBlockLink = array(); wfRunHooks( 'OtherBlockLogLink', array( &$otherBlockLink, $this->target ) ); + $out = $this->getOutput(); + # Show additional header for the local block only when other blocks exists. # Not necessary in a standard installation without such extensions enabled if( count( $otherBlockLink ) ) { - $wgOut->addHTML( + $out->addHTML( Html::rawElement( 'h2', array(), wfMsg( 'ipblocklist-localblock' ) ) . "\n" ); } $pager = new BlockListPager( $this, $conds ); if ( $pager->getNumRows() ) { - $wgOut->addHTML( + $out->addHTML( $pager->getNavigationBar() . $pager->getBody(). $pager->getNavigationBar() ); } elseif ( $this->target ) { - $wgOut->addWikiMsg( 'ipblocklist-no-results' ); + $out->addWikiMsg( 'ipblocklist-no-results' ); } else { - $wgOut->addWikiMsg( 'ipblocklist-empty' ); + $out->addWikiMsg( 'ipblocklist-empty' ); } if( count( $otherBlockLink ) ) { - $wgOut->addHTML( + $out->addHTML( Html::rawElement( 'h2', array(), @@ -190,7 +190,7 @@ class SpecialBlockList extends SpecialPage { foreach( $otherBlockLink as $link ) { $list .= Html::rawElement( 'li', array(), $link ) . "\n"; } - $wgOut->addHTML( Html::rawElement( 'ul', array( 'class' => 'mw-ipblocklist-otherblocks' ), $list ) . "\n" ); + $out->addHTML( Html::rawElement( 'ul', array( 'class' => 'mw-ipblocklist-otherblocks' ), $list ) . "\n" ); } } } @@ -203,7 +203,7 @@ class BlockListPager extends TablePager { $this->page = $page; $this->conds = $conds; $this->mDefaultDirection = true; - parent::__construct(); + parent::__construct( $page->getContext() ); } function getFieldNames() { @@ -225,11 +225,8 @@ class BlockListPager extends TablePager { } function formatValue( $name, $value ) { - global $wgLang, $wgUser; - - static $sk, $msg; - if ( empty( $sk ) ) { - $sk = $this->getSkin(); + static $msg = null; + if ( $msg === null ) { $msg = array( 'anononlyblock', 'createaccountblock', @@ -248,7 +245,7 @@ class BlockListPager extends TablePager { switch( $name ) { case 'ipb_timestamp': - $formatted = $wgLang->timeanddate( $value ); + $formatted = $this->getLang()->timeanddate( $value ); break; case 'ipb_target': @@ -259,8 +256,8 @@ class BlockListPager extends TablePager { switch( $type ){ case Block::TYPE_USER: case Block::TYPE_IP: - $formatted = $sk->userLink( $target->getId(), $target ); - $formatted .= $sk->userToolLinks( + $formatted = Linker::userLink( $target->getId(), $target ); + $formatted .= Linker::userToolLinks( $target->getId(), $target, false, @@ -274,21 +271,21 @@ class BlockListPager extends TablePager { break; case 'ipb_expiry': - $formatted = $wgLang->formatExpiry( $value ); - if( $wgUser->isAllowed( 'block' ) ){ + $formatted = $this->getLang()->formatExpiry( $value ); + if( $this->getUser()->isAllowed( 'block' ) ){ if( $row->ipb_auto ){ - $links[] = $sk->linkKnown( + $links[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Unblock' ), $msg['unblocklink'], array(), array( 'wpTarget' => "#{$row->ipb_id}" ) ); } else { - $links[] = $sk->linkKnown( + $links[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Unblock', $row->ipb_address ), $msg['unblocklink'] ); - $links[] = $sk->linkKnown( + $links[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Block', $row->ipb_address ), $msg['change-blocklink'] ); @@ -296,7 +293,7 @@ class BlockListPager extends TablePager { $formatted .= ' ' . Html::rawElement( 'span', array( 'class' => 'mw-blocklist-actions' ), - wfMsg( 'parentheses', $wgLang->pipeList( $links ) ) + wfMsg( 'parentheses', $this->getLang()->pipeList( $links ) ) ); } break; @@ -304,13 +301,13 @@ class BlockListPager extends TablePager { case 'ipb_by': $user = User::newFromId( $value ); if( $user instanceof User ){ - $formatted = $sk->userLink( $user->getId(), $user->getName() ); - $formatted .= $sk->userToolLinks( $user->getId(), $user->getName() ); + $formatted = Linker::userLink( $user->getId(), $user->getName() ); + $formatted .= Linker::userToolLinks( $user->getId(), $user->getName() ); } break; case 'ipb_reason': - $formatted = $sk->commentBlock( $value ); + $formatted = Linker::commentBlock( $value ); break; case 'ipb_params': @@ -333,7 +330,7 @@ class BlockListPager extends TablePager { $properties[] = $msg['blocklist-nousertalk']; } - $formatted = $wgLang->commaList( $properties ); + $formatted = $this->getLang()->commaList( $properties ); break; default: @@ -367,9 +364,8 @@ class BlockListPager extends TablePager { 'conds' => $this->conds, ); - global $wgUser; # Is the user allowed to see hidden blocks? - if ( !$wgUser->isAllowed( 'hideuser' ) ){ + if ( !$this->getUser()->isAllowed( 'hideuser' ) ){ $conds['ipb_deleted'] = 0; } @@ -391,8 +387,4 @@ class BlockListPager extends TablePager { function isFieldSortable( $name ) { return false; } - - function getTitle() { - return $this->page->getTitle(); - } } diff --git a/includes/specials/SpecialCategories.php b/includes/specials/SpecialCategories.php index 91d98b8683..a957b0c2f5 100644 --- a/includes/specials/SpecialCategories.php +++ b/includes/specials/SpecialCategories.php @@ -31,18 +31,16 @@ class SpecialCategories extends SpecialPage { } function execute( $par ) { - global $wgOut, $wgRequest; - $this->setHeaders(); $this->outputHeader(); - $wgOut->allowClickjacking(); + $this->getOutput()->allowClickjacking(); - $from = $wgRequest->getText( 'from', $par ); + $from = $this->getRequest()->getText( 'from', $par ); - $cap = new CategoryPager( $from ); + $cap = new CategoryPager( $this->getContext(), $from ); $cap->doQuery(); - $wgOut->addHTML( + $this->getOutput()->addHTML( Html::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) . wfMsgExt( 'categoriespagetext', array( 'parse' ), $cap->getNumRows() ) . $cap->getStartForm( $from ) . @@ -61,8 +59,8 @@ class SpecialCategories extends SpecialPage { * @ingroup SpecialPage Pager */ class CategoryPager extends AlphabeticPager { - function __construct( $from ) { - parent::__construct(); + function __construct( RequestContext $context, $from ) { + parent::__construct( $context ); $from = str_replace( ' ', '_', $from ); if( $from !== '' ) { $from = Title::capitalize( $from, NS_CATEGORY ); @@ -79,10 +77,6 @@ class CategoryPager extends AlphabeticPager { ); } - function getTitle() { - return SpecialPage::getTitleFor( 'Categories' ); - } - function getIndexField() { # return array( 'abc' => 'cat_title', 'count' => 'cat_pages' ); return 'cat_title'; @@ -118,11 +112,10 @@ class CategoryPager extends AlphabeticPager { } function formatRow($result) { - global $wgLang; $title = Title::makeTitle( NS_CATEGORY, $result->cat_title ); $titleText = Linker::link( $title, htmlspecialchars( $title->getText() ) ); $count = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ), - $wgLang->formatNum( $result->cat_pages ) ); + $this->getLang()->formatNum( $result->cat_pages ) ); return Xml::tags('li', null, wfSpecialList( $titleText, $count ) ) . "\n"; } diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 2d220d6b57..a9b7bf5c1b 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -36,85 +36,87 @@ class SpecialContributions extends SpecialPage { } public function execute( $par ) { - global $wgUser, $wgOut, $wgRequest; - $this->setHeaders(); $this->outputHeader(); - $wgOut->addModuleStyles( 'mediawiki.special' ); + $out = $this->getOutput(); + $out->addModuleStyles( 'mediawiki.special' ); $this->opts = array(); + $request = $this->getRequest(); if( $par == 'newbies' ) { $target = 'newbies'; $this->opts['contribs'] = 'newbie'; - } elseif( isset( $par ) ) { + } elseif( $par !== null ) { $target = $par; } else { - $target = $wgRequest->getVal( 'target' ); + $target = $request->getVal( 'target' ); } // check for radiobox - if( $wgRequest->getVal( 'contribs' ) == 'newbie' ) { + if( $request->getVal( 'contribs' ) == 'newbie' ) { $target = 'newbies'; $this->opts['contribs'] = 'newbie'; } - $this->opts['deletedOnly'] = $wgRequest->getBool( 'deletedOnly' ); + $this->opts['deletedOnly'] = $request->getBool( 'deletedOnly' ); if( !strlen( $target ) ) { - $wgOut->addHTML( $this->getForm() ); + $out->addHTML( $this->getForm() ); return; } - $this->opts['limit'] = $wgRequest->getInt( 'limit', $wgUser->getOption('rclimit') ); + $user = $this->getUser(); + + $this->opts['limit'] = $request->getInt( 'limit', $user->getOption('rclimit') ); $this->opts['target'] = $target; - $this->opts['topOnly'] = $wgRequest->getBool( 'topOnly' ); + $this->opts['topOnly'] = $request->getBool( 'topOnly' ); $nt = Title::makeTitleSafe( NS_USER, $target ); if( !$nt ) { - $wgOut->addHTML( $this->getForm() ); + $out->addHTML( $this->getForm() ); return; } $id = User::idFromName( $nt->getText() ); if( $target != 'newbies' ) { $target = $nt->getText(); - $wgOut->setSubtitle( $this->contributionsSub( $nt, $id ) ); - $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsgExt( 'contributions-title', array( 'parsemag' ),$target ) ) ); - $user = User::newFromName( $target, false ); - if ( is_object( $user ) ) { - $this->getSkin()->setRelevantUser( $user ); + $out->setSubtitle( $this->contributionsSub( $nt, $id ) ); + $out->setHTMLTitle( wfMsg( 'pagetitle', wfMsgExt( 'contributions-title', array( 'parsemag' ),$target ) ) ); + $userObj = User::newFromName( $target, false ); + if ( is_object( $userObj ) ) { + $this->getSkin()->setRelevantUser( $userObj ); } } else { - $wgOut->setSubtitle( wfMsgHtml( 'sp-contributions-newbies-sub') ); - $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) ) ); + $out->setSubtitle( wfMsgHtml( 'sp-contributions-newbies-sub') ); + $out->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) ) ); } - if( ( $ns = $wgRequest->getVal( 'namespace', null ) ) !== null && $ns !== '' ) { + if( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) { $this->opts['namespace'] = intval( $ns ); } else { $this->opts['namespace'] = ''; } - $this->opts['tagFilter'] = (string) $wgRequest->getVal( 'tagFilter' ); + $this->opts['tagFilter'] = (string) $request->getVal( 'tagFilter' ); // Allows reverts to have the bot flag in recent changes. It is just here to // be passed in the form at the top of the page - if( $wgUser->isAllowed( 'markbotedits' ) && $wgRequest->getBool( 'bot' ) ) { + if( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) { $this->opts['bot'] = '1'; } - $skip = $wgRequest->getText( 'offset' ) || $wgRequest->getText( 'dir' ) == 'prev'; + $skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev'; # Offset overrides year/month selection if( $skip ) { $this->opts['year'] = ''; $this->opts['month'] = ''; } else { - $this->opts['year'] = $wgRequest->getIntOrNull( 'year' ); - $this->opts['month'] = $wgRequest->getIntOrNull( 'month' ); + $this->opts['year'] = $request->getIntOrNull( 'year' ); + $this->opts['month'] = $request->getIntOrNull( 'month' ); } - $feedType = $wgRequest->getVal( 'feed' ); + $feedType = $request->getVal( 'feed' ); if( $feedType ) { // Maintain some level of backwards compatability // If people request feeds using the old parameters, redirect to API @@ -144,7 +146,7 @@ class SpecialContributions extends SpecialPage { $url = wfScript( 'api' ) . '?' . wfArrayToCGI( $apiParams ); - $wgOut->redirect( $url, '301' ); + $out->redirect( $url, '301' ); return; } @@ -153,7 +155,7 @@ class SpecialContributions extends SpecialPage { if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( $id ) ) ) { - $wgOut->addHTML( $this->getForm() ); + $out->addHTML( $this->getForm() ); $pager = new ContribsPager( array( 'target' => $target, @@ -164,20 +166,20 @@ class SpecialContributions extends SpecialPage { 'topOnly' => $this->opts['topOnly'], ) ); if( !$pager->getNumRows() ) { - $wgOut->addWikiMsg( 'nocontribs', $target ); + $out->addWikiMsg( 'nocontribs', $target ); } else { # Show a message about slave lag, if applicable $lag = wfGetLB()->safeGetLag( $pager->getDatabase() ); if( $lag > 0 ) - $wgOut->showLagWarning( $lag ); + $out->showLagWarning( $lag ); - $wgOut->addHTML( + $out->addHTML( '

' . $pager->getNavigationBar() . '

' . $pager->getBody() . '

' . $pager->getNavigationBar() . '

' ); } - $wgOut->preventClickjacking( $pager->getPreventClickjacking() ); + $out->preventClickjacking( $pager->getPreventClickjacking() ); # Show the appropriate "footer" message - WHOIS tools, etc. if( $target != 'newbies' ) { @@ -185,15 +187,15 @@ class SpecialContributions extends SpecialPage { if ( IP::isIPAddress( $target ) ) { $message = 'sp-contributions-footer-anon'; } else { - $user = User::newFromName( $target ); - if ( !$user || $user->isAnon() ) { + $userObj = User::newFromName( $target ); + if ( !$userObj || $userObj->isAnon() ) { // No message for non-existing users return; } } if( !wfMessage( $message, $target )->isDisabled() ) { - $wgOut->wrapWikiMsg( + $out->wrapWikiMsg( "", array( $message, $target ) ); } @@ -209,25 +211,22 @@ class SpecialContributions extends SpecialPage { * @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php. Could be combined. */ protected function contributionsSub( $nt, $id ) { - global $wgLang, $wgUser, $wgOut; - - $sk = $this->getSkin(); - if ( $id === null ) { $user = htmlspecialchars( $nt->getText() ); } else { - $user = $sk->link( $nt, htmlspecialchars( $nt->getText() ) ); + $user = Linker::link( $nt, htmlspecialchars( $nt->getText() ) ); } $userObj = User::newFromName( $nt->getText(), /* check for username validity not needed */ false ); $talk = $nt->getTalkPage(); if( $talk ) { - $tools = self::getUserLinks( $nt, $talk, $userObj, $wgUser ); - $links = $wgLang->pipeList( $tools ); + $tools = self::getUserLinks( $nt, $talk, $userObj, $this->getUser() ); + $links = $this->getLang()->pipeList( $tools ); // Show a note if the user is blocked and display the last block log entry. if ( $userObj->isBlocked() ) { + $out = $this->getOutput(); // showLogExtract() wants first parameter by reference LogEventsList::showLogExtract( - $wgOut, + $out, 'block', $nt->getPrefixedText(), '', @@ -240,7 +239,7 @@ class SpecialContributions extends SpecialPage { 'sp-contributions-blocked-notice', $nt->getText() # Support GENDER in 'sp-contributions-blocked-notice' ), - 'offset' => '' # don't use $wgRequest parameter offset + 'offset' => '' # don't use WebRequest parameter offset ) ); } @@ -262,36 +261,35 @@ class SpecialContributions extends SpecialPage { * @param $userpage Title: Target user page * @param $talkpage Title: Talk page * @param $target User: Target user object - * @param $subject User: The viewing user ($wgUser is still checked in some cases, like userrights page!!) + * @param $subject User: The viewing user ($wgUser might be still checked in some cases) */ public static function getUserLinks( Title $userpage, Title $talkpage, User $target, User $subject ) { - $sk = $subject->getSkin(); $id = $target->getId(); $username = $target->getName(); - $tools[] = $sk->link( $talkpage, wfMsgHtml( 'sp-contributions-talk' ) ); + $tools[] = Linker::link( $talkpage, wfMsgHtml( 'sp-contributions-talk' ) ); if( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) { if( $subject->isAllowed( 'block' ) ) { # Block / Change block / Unblock links if ( $target->isBlocked() ) { - $tools[] = $sk->linkKnown( # Change block link + $tools[] = Linker::linkKnown( # Change block link SpecialPage::getTitleFor( 'Block', $username ), wfMsgHtml( 'change-blocklink' ) ); - $tools[] = $sk->linkKnown( # Unblock link + $tools[] = Linker::linkKnown( # Unblock link SpecialPage::getTitleFor( 'Unblock', $username ), wfMsgHtml( 'unblocklink' ) ); } else { # User is not blocked - $tools[] = $sk->linkKnown( # Block link + $tools[] = Linker::linkKnown( # Block link SpecialPage::getTitleFor( 'Block', $username ), wfMsgHtml( 'blocklink' ) ); } } # Block log link - $tools[] = $sk->linkKnown( + $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log', 'block' ), wfMsgHtml( 'sp-contributions-blocklog' ), array(), @@ -301,20 +299,20 @@ class SpecialContributions extends SpecialPage { ); } # Uploads - $tools[] = $sk->linkKnown( + $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Listfiles', $username ), wfMsgHtml( 'sp-contributions-uploads' ) ); # Other logs link - $tools[] = $sk->linkKnown( + $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log', $username ), wfMsgHtml( 'sp-contributions-logs' ) ); # Add link to deleted user contributions for priviledged users if( $subject->isAllowed( 'deletedhistory' ) && !$subject->isBlocked() ) { - $tools[] = $sk->linkKnown( + $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'DeletedContributions', $username ), wfMsgHtml( 'sp-contributions-deleted' ) ); @@ -322,8 +320,9 @@ class SpecialContributions extends SpecialPage { # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); + $userrightsPage->getContext()->setUser( $subject ); if( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) { - $tools[] = $sk->linkKnown( + $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Userrights', $username ), wfMsgHtml( 'sp-contributions-userrights' ) ); @@ -462,19 +461,15 @@ class ContribsPager extends ReverseChronologicalPager { return $query; } - function getTitle() { - return SpecialPage::getTitleFor( 'Contributions' ); - } - function getQueryInfo() { - global $wgUser; list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond(); + $user = $this->getUser(); $conds = array_merge( $userCond, $this->getNamespaceCond() ); // Paranoia: avoid brute force searches (bug 17342) - if( !$wgUser->isAllowed( 'deletedhistory' ) || $wgUser->isBlocked() ) { + if( !$user->isAllowed( 'deletedhistory' ) || $user->isBlocked() ) { $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::DELETED_USER) . ' = 0'; - } elseif( !$wgUser->isAllowed( 'suppressrevision' ) ) { + } elseif( !$user->isAllowed( 'suppressrevision' ) ) { $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::SUPPRESSED_USER) . ' != ' . Revision::SUPPRESSED_USER; } @@ -601,15 +596,13 @@ class ContribsPager extends ReverseChronologicalPager { * @todo This would probably look a lot nicer in a table. */ function formatRow( $row ) { - global $wgUser, $wgLang; wfProfileIn( __METHOD__ ); - $sk = $this->getSkin(); $rev = new Revision( $row ); $classes = array(); $page = Title::newFromRow( $row ); - $link = $sk->link( + $link = Linker::link( $page, htmlspecialchars( $page->getPrefixedText() ), array(), @@ -624,12 +617,12 @@ class ContribsPager extends ReverseChronologicalPager { && $page->quickUserCan( 'edit' ) ) { $this->preventClickjacking(); - $topmarktext .= ' '.$sk->generateRollback( $rev ); + $topmarktext .= ' '.Linker::generateRollback( $rev ); } } # Is there a visible previous revision? if( $rev->userCan( Revision::DELETED_TEXT ) && $rev->getParentId() !== 0 ) { - $difftext = $sk->linkKnown( + $difftext = Linker::linkKnown( $page, $this->messages['diff'], array(), @@ -641,24 +634,17 @@ class ContribsPager extends ReverseChronologicalPager { } else { $difftext = $this->messages['diff']; } - $histlink = $sk->linkKnown( + $histlink = Linker::linkKnown( $page, $this->messages['hist'], array(), array( 'action' => 'history' ) ); - if ( isset( $this->mParentLens[$row->rev_parent_id] ) ) { - $chardiff = ' . . ' . ChangesList::showCharacterDifference( - $this->mParentLens[$row->rev_parent_id], $row->rev_len ) . ' . . '; - } else { - $chardiff = ''; - } - - $comment = $wgLang->getDirMark() . $sk->revComment( $rev, false, true ); - $date = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true ); + $comment = $this->getLang()->getDirMark() . Linker::revComment( $rev, false, true ); + $date = $this->getLang()->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true ); if( $rev->userCan( Revision::DELETED_TEXT ) ) { - $d = $sk->linkKnown( + $d = Linker::linkKnown( $page, htmlspecialchars($date), array(), @@ -672,8 +658,8 @@ class ContribsPager extends ReverseChronologicalPager { } if( $this->target == 'newbies' ) { - $userlink = ' . . ' . $sk->userLink( $row->rev_user, $row->rev_user_text ); - $userlink .= ' ' . wfMsg( 'parentheses', $sk->userTalkLink( $row->rev_user, $row->rev_user_text ) ) . ' '; + $userlink = ' . . ' . Linker::userLink( $row->rev_user, $row->rev_user_text ); + $userlink .= ' ' . wfMsg( 'parentheses', Linker::userTalkLink( $row->rev_user, $row->rev_user_text ) ) . ' '; } else { $userlink = ''; } @@ -691,17 +677,17 @@ class ContribsPager extends ReverseChronologicalPager { } // Don't show useless link to people who cannot hide revisions - $canHide = $wgUser->isAllowed( 'deleterevision' ); - if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) { + $canHide = $this->getUser()->isAllowed( 'deleterevision' ); + if( $canHide || ($rev->getVisibility() && $this->getUser()->isAllowed('deletedhistory')) ) { if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { - $del = $this->mSkin->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops + $del = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops } else { $query = array( 'type' => 'revision', 'target' => $page->getPrefixedDbkey(), 'ids' => $rev->getId() ); - $del = $this->mSkin->revDeleteLink( $query, + $del = Linker::revDeleteLink( $query, $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide ); } $del .= ' '; diff --git a/includes/specials/SpecialDeletedContributions.php b/includes/specials/SpecialDeletedContributions.php index 2d8854e4fa..99f16547fe 100644 --- a/includes/specials/SpecialDeletedContributions.php +++ b/includes/specials/SpecialDeletedContributions.php @@ -49,13 +49,13 @@ class DeletedContribsPager extends IndexPager { } function getQueryInfo() { - global $wgUser; list( $index, $userCond ) = $this->getUserCond(); $conds = array_merge( $userCond, $this->getNamespaceCond() ); + $user = $this->getUser(); // Paranoia: avoid brute force searches (bug 17792) - if( !$wgUser->isAllowed( 'deletedhistory' ) ) { + if( !$user->isAllowed( 'deletedhistory' ) ) { $conds[] = $this->mDb->bitAnd('ar_deleted',Revision::DELETED_USER) . ' = 0'; - } elseif( !$wgUser->isAllowed( 'suppressrevision' ) ) { + } elseif( !$user->isAllowed( 'suppressrevision' ) ) { $conds[] = $this->mDb->bitAnd('ar_deleted',Revision::SUPPRESSED_USER) . ' != ' . Revision::SUPPRESSED_USER; } @@ -92,12 +92,11 @@ class DeletedContribsPager extends IndexPager { } function getNavigationBar() { - global $wgLang; - if ( isset( $this->mNavigationBar ) ) { return $this->mNavigationBar; } - $fmtLimit = $wgLang->formatNum( $this->mLimit ); + $lang = $this->getLang(); + $fmtLimit = $lang->formatNum( $this->mLimit ); $linkTexts = array( 'prev' => wfMsgExt( 'pager-newer-n', array( 'escape', 'parsemag' ), $fmtLimit ), 'next' => wfMsgExt( 'pager-older-n', array( 'escape', 'parsemag' ), $fmtLimit ), @@ -107,9 +106,9 @@ class DeletedContribsPager extends IndexPager { $pagingLinks = $this->getPagingLinks( $linkTexts ); $limitLinks = $this->getLimitLinks(); - $limits = $wgLang->pipeList( $limitLinks ); + $limits = $lang->pipeList( $limitLinks ); - $this->mNavigationBar = "(" . $wgLang->pipeList( array( $pagingLinks['first'], $pagingLinks['last'] ) ) . ") " . + $this->mNavigationBar = "(" . $lang->pipeList( array( $pagingLinks['first'], $pagingLinks['last'] ) ) . ") " . wfMsgExt( 'viewprevnext', array( 'parsemag', 'escape', 'replaceafter' ), $pagingLinks['prev'], $pagingLinks['next'], $limits ); return $this->mNavigationBar; } @@ -133,11 +132,8 @@ class DeletedContribsPager extends IndexPager { * @todo This would probably look a lot nicer in a table. */ function formatRow( $row ) { - global $wgUser, $wgLang; wfProfileIn( __METHOD__ ); - $sk = $this->getSkin(); - $rev = new Revision( array( 'id' => $row->ar_rev_id, 'comment' => $row->ar_comment, @@ -153,7 +149,7 @@ class DeletedContribsPager extends IndexPager { $undelete = SpecialPage::getTitleFor( 'Undelete' ); $logs = SpecialPage::getTitleFor( 'Log' ); - $dellog = $sk->linkKnown( + $dellog = Linker::linkKnown( $logs, $this->messages['deletionlog'], array(), @@ -163,13 +159,15 @@ class DeletedContribsPager extends IndexPager { ) ); - $reviewlink = $sk->linkKnown( + $reviewlink = Linker::linkKnown( SpecialPage::getTitleFor( 'Undelete', $page->getPrefixedDBkey() ), $this->messages['undeleteviewlink'] ); - if( $wgUser->isAllowed('deletedtext') ) { - $last = $sk->linkKnown( + $user = $this->getUser(); + + if( $user->isAllowed('deletedtext') ) { + $last = Linker::linkKnown( $undelete, $this->messages['diff'], array(), @@ -183,13 +181,13 @@ class DeletedContribsPager extends IndexPager { $last = $this->messages['diff']; } - $comment = $sk->revComment( $rev ); - $date = htmlspecialchars( $wgLang->timeanddate( $rev->getTimestamp(), true ) ); + $comment = Linker::revComment( $rev ); + $date = htmlspecialchars( $this->getLang()->timeanddate( $rev->getTimestamp(), true ) ); - if( !$wgUser->isAllowed('undelete') || !$rev->userCan(Revision::DELETED_TEXT) ) { + if( !$user->isAllowed('undelete') || !$rev->userCan(Revision::DELETED_TEXT) ) { $link = $date; // unusable link } else { - $link = $sk->linkKnown( + $link = Linker::linkKnown( $undelete, $date, array(), @@ -204,7 +202,7 @@ class DeletedContribsPager extends IndexPager { $link = '' . $link . ''; } - $pagelink = $sk->link( $page ); + $pagelink = Linker::link( $page ); if( $rev->isMinor() ) { $mflag = ChangesList::flag( 'minor' ); @@ -213,13 +211,13 @@ class DeletedContribsPager extends IndexPager { } // Revision delete link - $del = Linker::getRevDeleteLink( $wgUser, $rev, $page ); + $del = Linker::getRevDeleteLink( $user, $rev, $page ); if ( $del ) $del .= ' '; $tools = Html::rawElement( 'span', array( 'class' => 'mw-deletedcontribs-tools' ), - wfMsg( 'parentheses', $wgLang->pipeList( array( $last, $dellog, $reviewlink ) ) ) + wfMsg( 'parentheses', $this->getLang()->pipeList( array( $last, $dellog, $reviewlink ) ) ) ); $ret = "{$del}{$link} {$tools} . . {$mflag} {$pagelink} {$comment}"; @@ -259,68 +257,69 @@ class DeletedContributionsPage extends SpecialPage { * @param $par String: (optional) user name of the user for which to show the contributions */ function execute( $par ) { - global $wgUser; $this->setHeaders(); - if ( !$this->userCanExecute( $wgUser ) ) { + $user = $this->getUser(); + + if ( !$this->userCanExecute( $user ) ) { $this->displayRestrictionError(); return; } - if( $wgUser->isBlocked() ){ - throw new UserBlockedError( $wgUser->getBlock() ); + if( $user->isBlocked() ){ + throw new UserBlockedError( $user->getBlock() ); } - global $wgOut, $wgRequest; - - $wgOut->setPageTitle( wfMsgExt( 'deletedcontributions-title', array( 'parsemag' ) ) ); + $request = $this->getRequest(); + $out = $this->getOutput(); + $out->setPageTitle( wfMsgExt( 'deletedcontributions-title', array( 'parsemag' ) ) ); $options = array(); - if ( isset( $par ) ) { + if ( $par !== null ) { $target = $par; } else { - $target = $wgRequest->getVal( 'target' ); + $target = $request->getVal( 'target' ); } if ( !strlen( $target ) ) { - $wgOut->addHTML( $this->getForm( '' ) ); + $out->addHTML( $this->getForm( '' ) ); return; } - $options['limit'] = $wgRequest->getInt( 'limit', 50 ); + $options['limit'] = $request->getInt( 'limit', 50 ); $options['target'] = $target; $nt = Title::makeTitleSafe( NS_USER, $target ); if ( !$nt ) { - $wgOut->addHTML( $this->getForm( '' ) ); + $out->addHTML( $this->getForm( '' ) ); return; } $id = User::idFromName( $nt->getText() ); $target = $nt->getText(); - $wgOut->setSubtitle( $this->getSubTitle( $nt, $id ) ); + $out->setSubtitle( $this->getSubTitle( $nt, $id ) ); - if ( ( $ns = $wgRequest->getVal( 'namespace', null ) ) !== null && $ns !== '' ) { + if ( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) { $options['namespace'] = intval( $ns ); } else { $options['namespace'] = ''; } - $wgOut->addHTML( $this->getForm( $options ) ); + $out->addHTML( $this->getForm( $options ) ); $pager = new DeletedContribsPager( $target, $options['namespace'] ); if ( !$pager->getNumRows() ) { - $wgOut->addWikiMsg( 'nocontribs' ); + $out->addWikiMsg( 'nocontribs' ); return; } # Show a message about slave lag, if applicable $lag = wfGetLB()->safeGetLag( $pager->getDatabase() ); if( $lag > 0 ) - $wgOut->showLagWarning( $lag ); + $out->showLagWarning( $lag ); - $wgOut->addHTML( + $out->addHTML( '

' . $pager->getNavigationBar() . '

' . $pager->getBody() . '

' . $pager->getNavigationBar() . '

' ); @@ -333,7 +332,7 @@ class DeletedContributionsPage extends SpecialPage { : 'sp-contributions-footer'; if( !wfMessage( $message )->isDisabled() ) { - $wgOut->wrapWikiMsg( "", array( $message, $target ) ); + $out->wrapWikiMsg( "", array( $message, $target ) ); } } } @@ -346,28 +345,24 @@ class DeletedContributionsPage extends SpecialPage { * @todo FIXME: Almost the same as contributionsSub in SpecialContributions.php. Could be combined. */ function getSubTitle( $nt, $id ) { - global $wgLang, $wgUser, $wgOut; - - $sk = $this->getSkin(); - if ( $id === null ) { $user = htmlspecialchars( $nt->getText() ); } else { - $user = $sk->link( $nt, htmlspecialchars( $nt->getText() ) ); + $user = Linker::link( $nt, htmlspecialchars( $nt->getText() ) ); } $userObj = User::newFromName( $nt->getText(), /* check for username validity not needed */ false ); $talk = $nt->getTalkPage(); if( $talk ) { # Talk page link - $tools[] = $sk->link( $talk, wfMsgHtml( 'sp-contributions-talk' ) ); + $tools[] = Linker::link( $talk, wfMsgHtml( 'sp-contributions-talk' ) ); if( ( $id !== null ) || ( $id === null && IP::isIPAddress( $nt->getText() ) ) ) { - if( $wgUser->isAllowed( 'block' ) ) { # Block / Change block / Unblock links + if( $this->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links if ( $userObj->isBlocked() ) { - $tools[] = $sk->linkKnown( # Change block link + $tools[] = Linker::linkKnown( # Change block link SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ), wfMsgHtml( 'change-blocklink' ) ); - $tools[] = $sk->linkKnown( # Unblock link + $tools[] = Linker::linkKnown( # Unblock link SpecialPage::getTitleFor( 'BlockList' ), wfMsgHtml( 'unblocklink' ), array(), @@ -378,14 +373,14 @@ class DeletedContributionsPage extends SpecialPage { ); } else { # User is not blocked - $tools[] = $sk->linkKnown( # Block link + $tools[] = Linker::linkKnown( # Block link SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ), wfMsgHtml( 'blocklink' ) ); } } # Block log link - $tools[] = $sk->linkKnown( + $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log' ), wfMsgHtml( 'sp-contributions-blocklog' ), array(), @@ -396,14 +391,14 @@ class DeletedContributionsPage extends SpecialPage { ); } # Other logs link - $tools[] = $sk->linkKnown( + $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log' ), wfMsgHtml( 'sp-contributions-logs' ), array(), array( 'user' => $nt->getText() ) ); # Link to contributions - $tools[] = $sk->linkKnown( + $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Contributions', $nt->getDBkey() ), wfMsgHtml( 'sp-deletedcontributions-contribs' ) ); @@ -411,7 +406,7 @@ class DeletedContributionsPage extends SpecialPage { # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); if( $id !== null && $userrightsPage->userCanChangeRights( User::newFromId( $id ) ) ) { - $tools[] = $sk->linkKnown( + $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ), wfMsgHtml( 'sp-contributions-userrights' ) ); @@ -419,12 +414,13 @@ class DeletedContributionsPage extends SpecialPage { wfRunHooks( 'ContributionsToolLinks', array( $id, $nt, &$tools ) ); - $links = $wgLang->pipeList( $tools ); + $links = $this->getLang()->pipeList( $tools ); // Show a note if the user is blocked and display the last block log entry. if ( $userObj->isBlocked() ) { + $out = $this->getOutput(); // LogEventsList::showLogExtract() wants the first parameter by ref LogEventsList::showLogExtract( - $wgOut, + $out, 'block', $nt->getPrefixedText(), '', @@ -435,7 +431,7 @@ class DeletedContributionsPage extends SpecialPage { 'sp-contributions-blocked-notice', $nt->getText() # Support GENDER in 'sp-contributions-blocked-notice' ), - 'offset' => '' # don't use $wgRequest parameter offset + 'offset' => '' # don't use $this->getRequest() parameter offset ) ); } @@ -459,7 +455,7 @@ class DeletedContributionsPage extends SpecialPage { function getForm( $options ) { global $wgScript; - $options['title'] = SpecialPage::getTitleFor( 'DeletedContributions' )->getPrefixedText(); + $options['title'] = $this->getTitle()->getPrefixedText(); if ( !isset( $options['target'] ) ) { $options['target'] = ''; } else { diff --git a/includes/specials/SpecialListfiles.php b/includes/specials/SpecialListfiles.php index 427de167b6..c6afe5fde9 100644 --- a/includes/specials/SpecialListfiles.php +++ b/includes/specials/SpecialListfiles.php @@ -28,7 +28,6 @@ class SpecialListFiles extends IncludableSpecialPage { } public function execute( $par ){ - global $wgOut, $wgRequest; $this->setHeaders(); $this->outputHeader(); @@ -36,11 +35,11 @@ class SpecialListFiles extends IncludableSpecialPage { $userName = $par; $search = ''; } else { - $userName = $wgRequest->getText( 'user', $par ); - $search = $wgRequest->getText( 'ilsearch', '' ); + $userName = $this->getRequest()->getText( 'user', $par ); + $search = $this->getRequest()->getText( 'ilsearch', '' ); } - $pager = new ImageListPager( $userName, $search, $this->including() ); + $pager = new ImageListPager( $this->getContext(), $userName, $search, $this->including() ); if ( $this->including() ) { $html = $pager->getBody(); @@ -50,7 +49,7 @@ class SpecialListFiles extends IncludableSpecialPage { $nav = $pager->getNavigationBar(); $html = "$form
\n$body
\n$nav"; } - $wgOut->addHTML( $html ); + $this->getOutput()->addHTML( $html ); } } @@ -64,8 +63,8 @@ class ImageListPager extends TablePager { var $mSearch = ''; var $mIncluding = false; - function __construct( $userName = null, $search = '', $including = false ) { - global $wgRequest, $wgMiserMode; + function __construct( RequestContext $context, $userName = null, $search = '', $including = false ) { + global $wgMiserMode; $this->mIncluding = $including; @@ -89,7 +88,7 @@ class ImageListPager extends TablePager { } if ( !$including ) { - if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) { + if ( $context->getRequest()->getText( 'sort', 'img_date' ) == 'img_date' ) { $this->mDefaultDirection = true; } else { $this->mDefaultDirection = false; @@ -98,11 +97,7 @@ class ImageListPager extends TablePager { $this->mDefaultDirection = true; } - parent::__construct(); - } - - function getTitle() { - return SpecialPage::getTitleFor( 'Listfiles' ); + parent::__construct( $context ); } /** @@ -197,14 +192,13 @@ class ImageListPager extends TablePager { } function formatValue( $field, $value ) { - global $wgLang; switch ( $field ) { case 'thumb': $file = wfLocalFile( $value ); $thumb = $file->transform( array( 'width' => 180, 'height' => 360 ) ); return $thumb->toHtml( array( 'desc-link' => true ) ); case 'img_timestamp': - return htmlspecialchars( $wgLang->timeanddate( $value, true ) ); + return htmlspecialchars( $this->getLang()->timeanddate( $value, true ) ); case 'img_name': static $imgfile = null; if ( $imgfile === null ) $imgfile = wfMsg( 'imgfile' ); @@ -212,7 +206,7 @@ class ImageListPager extends TablePager { // Weird files can maybe exist? Bug 22227 $filePage = Title::makeTitleSafe( NS_FILE, $value ); if( $filePage ) { - $link = $this->getSkin()->linkKnown( $filePage, htmlspecialchars( $filePage->getText() ) ); + $link = Linker::linkKnown( $filePage, htmlspecialchars( $filePage->getText() ) ); $download = Xml::element( 'a', array( 'href' => wfLocalFile( $filePage )->getURL() ), $imgfile @@ -223,7 +217,7 @@ class ImageListPager extends TablePager { } case 'img_user_text': if ( $this->mCurrentRow->img_user ) { - $link = $this->getSkin()->link( + $link = Linker::link( Title::makeTitle( NS_USER, $value ), htmlspecialchars( $value ) ); @@ -232,9 +226,9 @@ class ImageListPager extends TablePager { } return $link; case 'img_size': - return $this->getSkin()->formatSize( $value ); + return htmlspecialchars( $this->getLang()->formatSize( $value ) ); case 'img_description': - return $this->getSkin()->commentBlock( $value ); + return Linker::commentBlock( $value ); case 'count': return intval( $value ) + 1; } diff --git a/includes/specials/SpecialListusers.php b/includes/specials/SpecialListusers.php index 0531444a1f..3c807e00b5 100644 --- a/includes/specials/SpecialListusers.php +++ b/includes/specials/SpecialListusers.php @@ -34,25 +34,27 @@ */ class UsersPager extends AlphabeticPager { - function __construct( $par=null ) { - global $wgRequest; + function __construct( RequestContext $context = null, $par = null ) { + parent::__construct( $context ); + + $request = $this->getRequest(); $parms = explode( '/', ($par = ( $par !== null ) ? $par : '' ) ); $symsForAll = array( '*', 'user' ); if ( $parms[0] != '' && ( in_array( $par, User::getAllGroups() ) || in_array( $par, $symsForAll ) ) ) { $this->requestedGroup = $par; - $un = $wgRequest->getText( 'username' ); + $un = $request->getText( 'username' ); } elseif ( count( $parms ) == 2 ) { $this->requestedGroup = $parms[0]; $un = $parms[1]; } else { - $this->requestedGroup = $wgRequest->getVal( 'group' ); - $un = ( $par != '' ) ? $par : $wgRequest->getText( 'username' ); + $this->requestedGroup = $request->getVal( 'group' ); + $un = ( $par != '' ) ? $par : $request->getText( 'username' ); } if ( in_array( $this->requestedGroup, $symsForAll ) ) { $this->requestedGroup = ''; } - $this->editsOnly = $wgRequest->getBool( 'editsOnly' ); - $this->creationSort = $wgRequest->getBool( 'creationSort' ); + $this->editsOnly = $request->getBool( 'editsOnly' ); + $this->creationSort = $request->getBool( 'creationSort' ); $this->requestedUser = ''; if ( $un != '' ) { @@ -64,20 +66,15 @@ class UsersPager extends AlphabeticPager { parent::__construct(); } - function getTitle() { - return SpecialPage::getTitleFor( 'Listusers' ); - } - function getIndexField() { return $this->creationSort ? 'user_id' : 'user_name'; } function getQueryInfo() { - global $wgUser; $dbr = wfGetDB( DB_SLAVE ); $conds = array(); // Don't show hidden names - if( !$wgUser->isAllowed('hideuser') ) { + if( !$this->getUser()->isAllowed('hideuser') ) { $conds[] = 'ipb_deleted IS NULL'; } @@ -126,8 +123,6 @@ class UsersPager extends AlphabeticPager { } function formatRow( $row ) { - global $wgLang; - if ($row->user_id == 0) #Bug 16487 return ''; @@ -139,7 +134,7 @@ class UsersPager extends AlphabeticPager { $list = array(); foreach( $groups_list as $group ) $list[] = self::buildGroupLink( $group ); - $groups = $wgLang->commaList( $list ); + $groups = $this->getLang()->commaList( $list ); } else { $groups = ''; } @@ -151,7 +146,7 @@ class UsersPager extends AlphabeticPager { global $wgEdititis; if ( $wgEdititis ) { - $editCount = $wgLang->formatNum( $row->edits ); + $editCount = $this->getLang()->formatNum( $row->edits ); $edits = ' [' . wfMsgExt( 'usereditcount', array( 'parsemag', 'escape' ), $editCount ) . ']'; } else { $edits = ''; @@ -160,8 +155,8 @@ class UsersPager extends AlphabeticPager { $created = ''; # Some rows may be NULL if( $row->creation ) { - $d = $wgLang->date( wfTimestamp( TS_MW, $row->creation ), true ); - $t = $wgLang->time( wfTimestamp( TS_MW, $row->creation ), true ); + $d = $this->getLang()->date( wfTimestamp( TS_MW, $row->creation ), true ); + $t = $this->getLang()->time( wfTimestamp( TS_MW, $row->creation ), true ); $created = ' (' . wfMsg( 'usercreated', $d, $t ) . ')'; $created = htmlspecialchars( $created ); } @@ -292,12 +287,10 @@ class SpecialListUsers extends SpecialPage { * @param $par string (optional) A group to list users from */ public function execute( $par ) { - global $wgOut; - $this->setHeaders(); $this->outputHeader(); - $up = new UsersPager( $par ); + $up = new UsersPager( $this->getContext(), $par ); # getBody() first to check, if empty $usersbody = $up->getBody(); @@ -311,6 +304,6 @@ class SpecialListUsers extends SpecialPage { $s .= wfMessage( 'listusers-noresult' )->parseAsBlock(); } - $wgOut->addHTML( $s ); + $this->getOutput()->addHTML( $s ); } } diff --git a/includes/specials/SpecialLog.php b/includes/specials/SpecialLog.php index 584e6b630a..ba5678296c 100644 --- a/includes/specials/SpecialLog.php +++ b/includes/specials/SpecialLog.php @@ -35,8 +35,6 @@ class SpecialLog extends SpecialPage { } public function execute( $par ) { - global $wgRequest; - $this->setHeaders(); $this->outputHeader(); @@ -53,7 +51,7 @@ class SpecialLog extends SpecialPage { $opts->add( 'offender', '' ); // Set values - $opts->fetchValuesFromRequest( $wgRequest ); + $opts->fetchValuesFromRequest( $this->getRequest() ); if ( $par ) { $this->parseParams( $opts, (string)$par ); } @@ -99,10 +97,8 @@ class SpecialLog extends SpecialPage { } private function show( FormOptions $opts, array $extraConds ) { - global $wgOut; - # Create a LogPager item to get the results and a LogEventsList item to format them... - $loglist = new LogEventsList( $this->getSkin(), $wgOut, 0 ); + $loglist = new LogEventsList( $this->getSkin(), $this->getOutput(), 0 ); $pager = new LogPager( $loglist, $opts->getValue( 'type' ), $opts->getValue( 'user' ), $opts->getValue( 'page' ), $opts->getValue( 'pattern' ), $extraConds, $opts->getValue( 'year' ), $opts->getValue( 'month' ), $opts->getValue( 'tagfilter' ) ); @@ -110,18 +106,18 @@ class SpecialLog extends SpecialPage { $this->addHeader( $opts->getValue( 'type' ) ); # Set relevant user - if ( $pager->getUser() ) { - $this->getSkin()->setRelevantUser( User::newFromName( $pager->getUser() ) ); + if ( $pager->getAuthor() ) { + $this->getSkin()->setRelevantUser( User::newFromName( $pager->getAuthor() ) ); } # Show form options - $loglist->showOptions( $pager->getType(), $pager->getUser(), $pager->getPage(), $pager->getPattern(), + $loglist->showOptions( $pager->getType(), $pager->getAuthor(), $pager->getPage(), $pager->getPattern(), $pager->getYear(), $pager->getMonth(), $pager->getFilterParams(), $opts->getValue( 'tagfilter' ) ); # Insert list $logBody = $pager->getBody(); if ( $logBody ) { - $wgOut->addHTML( + $this->getOutput()->addHTML( $pager->getNavigationBar() . $loglist->beginLogEventsList() . $logBody . @@ -129,7 +125,7 @@ class SpecialLog extends SpecialPage { $pager->getNavigationBar() ); } else { - $wgOut->addWikiMsg( 'logempty' ); + $this->getOutput()->addWikiMsg( 'logempty' ); } } diff --git a/includes/specials/SpecialMergeHistory.php b/includes/specials/SpecialMergeHistory.php index 88e90ee5d7..e6580ea0c9 100644 --- a/includes/specials/SpecialMergeHistory.php +++ b/includes/specials/SpecialMergeHistory.php @@ -40,12 +40,10 @@ class SpecialMergeHistory extends SpecialPage { } /** - * @param $request WebRequest * @return void */ - private function loadRequestParams( $request ) { - global $wgUser; - + private function loadRequestParams() { + $request = $this->getRequest(); $this->mAction = $request->getVal( 'action' ); $this->mTarget = $request->getVal( 'target' ); $this->mDest = $request->getVal( 'dest' ); @@ -59,7 +57,7 @@ class SpecialMergeHistory extends SpecialPage { } $this->mComment = $request->getText( 'wpComment' ); - $this->mMerge = $request->wasPosted() && $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) ); + $this->mMerge = $request->wasPosted() && $this->getUser()->matchEditToken( $request->getVal( 'wpEditToken' ) ); // target page if( $this->mSubmitted ) { $this->mTargetObj = Title::newFromURL( $this->mTarget ); @@ -83,19 +81,17 @@ class SpecialMergeHistory extends SpecialPage { } public function execute( $par ) { - global $wgOut, $wgRequest, $wgUser; - - if ( wfReadOnly() ) { - $wgOut->readOnlyPage(); + $user = $this->getUser(); + if( !$this->userCanExecute( $user ) ) { + $this->displayRestrictionError(); return; } - if( !$this->userCanExecute( $wgUser ) ) { - $this->displayRestrictionError(); - return; + if ( wfReadOnly() ) { + throw new ReadOnlyError; } - $this->loadRequestParams( $wgRequest ); + $this->loadRequestParams(); $this->setHeaders(); $this->outputHeader(); @@ -132,7 +128,7 @@ class SpecialMergeHistory extends SpecialPage { if ( count( $errors ) ) { $this->showMergeForm(); - $wgOut->addHTML( implode( "\n", $errors ) ); + $this->getOutput()->addHTML( implode( "\n", $errors ) ); } else { $this->showHistory(); } @@ -140,11 +136,11 @@ class SpecialMergeHistory extends SpecialPage { } function showMergeForm() { - global $wgOut, $wgScript; + global $wgScript; - $wgOut->addWikiMsg( 'mergehistory-header' ); + $this->getOutput()->addWikiMsg( 'mergehistory-header' ); - $wgOut->addHTML( + $this->getOutput()->addHTML( Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . @@ -171,11 +167,8 @@ class SpecialMergeHistory extends SpecialPage { } private function showHistory() { - global $wgUser, $wgOut; - - $this->sk = $this->getSkin(); - - $wgOut->setPageTitle( wfMsg( 'mergehistory' ) ); + $out = $this->getOutput(); + $out->setPageTitle( wfMsg( 'mergehistory' ) ); $this->showMergeForm(); @@ -196,7 +189,7 @@ class SpecialMergeHistory extends SpecialPage { 'id' => 'merge' ) ); - $wgOut->addHTML( $top ); + $out->addHTML( $top ); if( $haveRevisions ) { # Format the user-visible controls (comment field, submission button) @@ -223,27 +216,27 @@ class SpecialMergeHistory extends SpecialPage { Xml::closeElement( 'table' ) . Xml::closeElement( 'fieldset' ); - $wgOut->addHTML( $table ); + $out->addHTML( $table ); } - $wgOut->addHTML( + $out->addHTML( '

' . wfMsgHtml( 'mergehistory-list' ) . "

\n" ); if( $haveRevisions ) { - $wgOut->addHTML( $revisions->getNavigationBar() ); - $wgOut->addHTML( '' ); - $wgOut->addHTML( $revisions->getNavigationBar() ); + $out->addHTML( $revisions->getNavigationBar() ); + $out->addHTML( '' ); + $out->addHTML( $revisions->getNavigationBar() ); } else { - $wgOut->addWikiMsg( 'mergehistory-empty' ); + $out->addWikiMsg( 'mergehistory-empty' ); } # Show relevant lines from the deletion log: - $wgOut->addHTML( '

' . htmlspecialchars( LogPage::logName( 'merge' ) ) . "

\n" ); - LogEventsList::showLogExtract( $wgOut, 'merge', $this->mTargetObj->getPrefixedText() ); + $out->addHTML( '

' . htmlspecialchars( LogPage::logName( 'merge' ) ) . "

\n" ); + LogEventsList::showLogExtract( $out, 'merge', $this->mTargetObj->getPrefixedText() ); # When we submit, go by page ID to avoid some nasty but unlikely collisions. # Such would happen if a page was renamed after the form loaded, but before submit @@ -251,16 +244,14 @@ class SpecialMergeHistory extends SpecialPage { $misc .= Html::hidden( 'destID', $this->mDestObj->getArticleID() ); $misc .= Html::hidden( 'target', $this->mTarget ); $misc .= Html::hidden( 'dest', $this->mDest ); - $misc .= Html::hidden( 'wpEditToken', $wgUser->editToken() ); + $misc .= Html::hidden( 'wpEditToken', $this->getUser()->editToken() ); $misc .= Xml::closeElement( 'form' ); - $wgOut->addHTML( $misc ); + $out->addHTML( $misc ); return true; } function formatRevisionRow( $row ) { - global $wgLang; - $rev = new Revision( $row ); $stxt = ''; @@ -269,9 +260,9 @@ class SpecialMergeHistory extends SpecialPage { $ts = wfTimestamp( TS_MW, $row->rev_timestamp ); $checkBox = Xml::radio( 'mergepoint', $ts, false ); - $pageLink = $this->sk->linkKnown( + $pageLink = Linker::linkKnown( $rev->getTitle(), - htmlspecialchars( $wgLang->timeanddate( $ts ) ), + htmlspecialchars( $this->getLang()->timeanddate( $ts ) ), array(), array( 'oldid' => $rev->getId() ) ); @@ -283,7 +274,7 @@ class SpecialMergeHistory extends SpecialPage { if( !$rev->userCan( Revision::DELETED_TEXT ) ) { $last = $this->message['last']; } elseif( isset( $this->prevId[$row->rev_id] ) ) { - $last = $this->sk->linkKnown( + $last = Linker::linkKnown( $rev->getTitle(), $this->message['last'], array(), @@ -294,13 +285,13 @@ class SpecialMergeHistory extends SpecialPage { ); } - $userLink = $this->sk->revUserTools( $rev ); + $userLink = Linker::revUserTools( $rev ); $size = $row->rev_len; if( !is_null( $size ) ) { - $stxt = $this->sk->formatRevisionSize( $size ); + $stxt = Linker::formatRevisionSize( $size ); } - $comment = $this->sk->revComment( $rev ); + $comment = Linker::revComment( $rev ); return "
  • $checkBox ($last) $pageLink . . $userLink $stxt $comment
  • "; } @@ -310,15 +301,13 @@ class SpecialMergeHistory extends SpecialPage { * @return string */ function getPageLink( $row, $titleObj, $ts, $target ) { - global $wgLang; - if( !$this->userCan( $row, Revision::DELETED_TEXT ) ) { return '' . - $wgLang->timeanddate( $ts, true ) . ''; + $this->getLang()->timeanddate( $ts, true ) . ''; } else { - $link = $this->sk->linkKnown( + $link = Linker::linkKnown( $titleObj, - $wgLang->timeanddate( $ts, true ), + $this->getLang()->timeanddate( $ts, true ), array(), array( 'target' => $target, @@ -333,7 +322,6 @@ class SpecialMergeHistory extends SpecialPage { } function merge() { - global $wgOut; # Get the titles directly from the IDs, in case the target page params # were spoofed. The queries are done based on the IDs, so it's best to # keep it consistent... @@ -359,7 +347,7 @@ class SpecialMergeHistory extends SpecialPage { ); # Destination page must exist with revisions if( !$maxtimestamp ) { - $wgOut->addWikiMsg( 'mergehistory-fail' ); + $this->getOutput()->addWikiMsg( 'mergehistory-fail' ); return false; } # Get the latest timestamp of the source @@ -371,7 +359,7 @@ class SpecialMergeHistory extends SpecialPage { ); # $this->mTimestamp must be older than $maxtimestamp if( $this->mTimestamp >= $maxtimestamp ) { - $wgOut->addWikiMsg( 'mergehistory-fail' ); + $this->getOutput()->addWikiMsg( 'mergehistory-fail' ); return false; } # Update the revisions @@ -440,7 +428,7 @@ class SpecialMergeHistory extends SpecialPage { $destTitle->invalidateCache(); // update histories # Check if this did anything if( !$count ) { - $wgOut->addWikiMsg( 'mergehistory-fail' ); + $this->getOutput()->addWikiMsg( 'mergehistory-fail' ); return false; } # Update our logs @@ -450,7 +438,7 @@ class SpecialMergeHistory extends SpecialPage { array( $destTitle->getPrefixedText(), $timestampLimit ) ); - $wgOut->addHTML( + $this->getOutput()->addHTML( wfMsgExt( 'mergehistory-success', array('parseinline'), $targetTitle->getPrefixedText(), $destTitle->getPrefixedText(), $count ) ); @@ -478,11 +466,7 @@ class MergeHistoryPager extends ReverseChronologicalPager { ); $this->maxTimestamp = $maxtimestamp; - parent::__construct(); - } - - function getTitle() { - return SpecialPage::getTitleFor( 'Contributions' ); + parent::__construct( $form->getContext() ); } function getStartBody() { diff --git a/includes/specials/SpecialNewimages.php b/includes/specials/SpecialNewimages.php index ea20c2f722..401380f18d 100644 --- a/includes/specials/SpecialNewimages.php +++ b/includes/specials/SpecialNewimages.php @@ -30,7 +30,7 @@ class SpecialNewFiles extends IncludableSpecialPage { $this->setHeaders(); $this->outputHeader(); - $pager = new NewFilesPager( $par ); + $pager = new NewFilesPager( $this->getContext(), $par ); if ( !$this->including() ) { $form = $pager->getForm(); @@ -50,18 +50,11 @@ class SpecialNewFiles extends IncludableSpecialPage { */ class NewFilesPager extends ReverseChronologicalPager { - function __construct( $par = null ) { - global $wgRequest; + function __construct( RequestContext $context, $par = null ) { + $this->like = $context->getRequest()->getText( 'like' ); + $this->showbots = $context->getRequest()->getBool( 'showbots' , 0 ); - $this->like = $wgRequest->getText( 'like' ); - $this->showbots = $wgRequest->getBool( 'showbots' , 0 ); - $this->skin = $this->getSkin(); - - parent::__construct(); - } - - function getTitle() { - return SpecialPage::getTitleFor( 'Newimages' ); + parent::__construct( $context ); } function getQueryInfo() { @@ -113,24 +106,22 @@ class NewFilesPager extends ReverseChronologicalPager { } function formatRow( $row ) { - global $wgLang; - $name = $row->img_name; $user = User::newFromId( $row->img_user ); $title = Title::makeTitle( NS_FILE, $name ); - $ul = $this->skin->link( $user->getUserpage(), $user->getName() ); + $ul = Linker::link( $user->getUserpage(), $user->getName() ); $this->gallery->add( $title, "$ul
    \n" - . htmlspecialchars( $wgLang->timeanddate( $row->img_timestamp, true ) ) + . htmlspecialchars( $this->getLang()->timeanddate( $row->img_timestamp, true ) ) . "
    \n" ); } function getForm() { - global $wgRequest, $wgMiserMode; + global $wgMiserMode; $fields = array( 'like' => array( @@ -142,16 +133,16 @@ class NewFilesPager extends ReverseChronologicalPager { 'type' => 'check', 'label' => wfMessage( 'showhidebots', wfMsg( 'show' ) ), 'name' => 'showbots', - # 'default' => $wgRequest->getBool( 'showbots', 0 ), + # 'default' => $this->getRequest()->getBool( 'showbots', 0 ), ), 'limit' => array( 'type' => 'hidden', - 'default' => $wgRequest->getText( 'limit' ), + 'default' => $this->getRequest()->getText( 'limit' ), 'name' => 'limit', ), 'offset' => array( 'type' => 'hidden', - 'default' => $wgRequest->getText( 'offset' ), + 'default' => $this->getRequest()->getText( 'offset' ), 'name' => 'offset', ), ); @@ -160,7 +151,7 @@ class NewFilesPager extends ReverseChronologicalPager { unset( $fields['like'] ); } - $form = new HTMLForm( $fields ); + $form = new HTMLForm( $fields, $this->getContext() ); $form->setTitle( $this->getTitle() ); $form->setSubmitText( wfMsg( 'ilsubmit' ) ); $form->setMethod( 'get' ); diff --git a/includes/specials/SpecialNewpages.php b/includes/specials/SpecialNewpages.php index bf9fb9f7bb..5d4a2455f8 100644 --- a/includes/specials/SpecialNewpages.php +++ b/includes/specials/SpecialNewpages.php @@ -194,7 +194,7 @@ class SpecialNewpages extends IncludableSpecialPage { $self = $this->getTitle(); foreach ( $filters as $key => $msg ) { $onoff = 1 - $this->opts->getValue( $key ); - $link = $this->getSkin()->link( $self, $showhide[$onoff], array(), + $link = Linker::link( $self, $showhide[$onoff], array(), array( $key => $onoff ) + $changed ); $links[$key] = wfMsgHtml( $msg, $link ); @@ -315,14 +315,14 @@ class SpecialNewpages extends IncludableSpecialPage { $query['rcid'] = $result->rc_id; } - $plink = $this->getSkin()->linkKnown( + $plink = Linker::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->getSkin()->linkKnown( + $histLink = Linker::linkKnown( $title, wfMsgHtml( 'hist' ), array(), @@ -335,8 +335,8 @@ class SpecialNewpages extends IncludableSpecialPage { ']' ); - $ulink = $this->getSkin()->revUserTools( $rev ); - $comment = $this->getSkin()->revComment( $rev ); + $ulink = Linker::revUserTools( $rev ); + $comment = Linker::revComment( $rev ); if ( $this->patrollable( $result ) ) { $classes[] = 'not-patrolled'; @@ -461,33 +461,11 @@ class NewPagesPager extends ReverseChronologicalPager { protected $mForm; function __construct( $form, FormOptions $opts ) { - parent::__construct(); + parent::__construct( $form->getContext() ); $this->mForm = $form; $this->opts = $opts; } - /** - * @return Title - */ - function getTitle() { - static $title = null; - if ( $title === null ) { - $title = $this->mForm->getTitle(); - } - return $title; - } - - /** - * @return User - */ - function getUser() { - static $user = null; - if ( $user === null ) { - $user = $this->mForm->getUser(); - } - return $user; - } - function getQueryInfo() { global $wgEnableNewpagesUserFilter, $wgGroupPermissions; $conds = array(); diff --git a/includes/specials/SpecialProtectedpages.php b/includes/specials/SpecialProtectedpages.php index 21451086f3..fd6026ae50 100644 --- a/includes/specials/SpecialProtectedpages.php +++ b/includes/specials/SpecialProtectedpages.php @@ -36,8 +36,6 @@ class SpecialProtectedpages extends SpecialPage { } public function execute( $par ) { - global $wgOut, $wgRequest; - $this->setHeaders(); $this->outputHeader(); @@ -46,17 +44,18 @@ class SpecialProtectedpages extends SpecialPage { Title::purgeExpiredRestrictions(); } - $type = $wgRequest->getVal( $this->IdType ); - $level = $wgRequest->getVal( $this->IdLevel ); - $sizetype = $wgRequest->getVal( 'sizetype' ); - $size = $wgRequest->getIntOrNull( 'size' ); - $NS = $wgRequest->getIntOrNull( 'namespace' ); - $indefOnly = $wgRequest->getBool( 'indefonly' ) ? 1 : 0; - $cascadeOnly = $wgRequest->getBool('cascadeonly') ? 1 : 0; + $request = $this->getRequest(); + $type = $request->getVal( $this->IdType ); + $level = $request->getVal( $this->IdLevel ); + $sizetype = $request->getVal( 'sizetype' ); + $size = $request->getIntOrNull( 'size' ); + $NS = $request->getIntOrNull( 'namespace' ); + $indefOnly = $request->getBool( 'indefonly' ) ? 1 : 0; + $cascadeOnly = $request->getBool('cascadeonly') ? 1 : 0; $pager = new ProtectedPagesPager( $this, array(), $type, $level, $NS, $sizetype, $size, $indefOnly, $cascadeOnly ); - $wgOut->addHTML( $this->showOptions( $NS, $type, $level, $sizetype, $size, $indefOnly, $cascadeOnly ) ); + $this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level, $sizetype, $size, $indefOnly, $cascadeOnly ) ); if( $pager->getNumRows() ) { $s = $pager->getNavigationBar(); @@ -67,7 +66,7 @@ class SpecialProtectedpages extends SpecialPage { } else { $s = '

    ' . wfMsgHtml( 'protectedpagesempty' ) . '

    '; } - $wgOut->addHTML( $s ); + $this->getOutput()->addHTML( $s ); } /** @@ -76,19 +75,16 @@ class SpecialProtectedpages extends SpecialPage { * @return string Formatted
  • element */ public function formatRow( $row ) { - global $wgUser, $wgLang; - wfProfileIn( __METHOD__ ); - static $skin = null, $infinity = null; + static $infinity = null; - if( is_null( $skin ) ){ - $skin = $this->getSkin(); + if( is_null( $infinity ) ){ $infinity = wfGetDB( DB_SLAVE )->getInfinity(); } $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); - $link = $skin->link( $title ); + $link = Linker::link( $title ); $description_items = array (); @@ -101,27 +97,28 @@ class SpecialProtectedpages extends SpecialPage { } $stxt = ''; + $lang = $this->getLang(); - $expiry = $wgLang->formatExpiry( $row->pr_expiry, TS_MW ); + $expiry = $lang->formatExpiry( $row->pr_expiry, TS_MW ); if( $expiry != $infinity ) { $expiry_description = wfMsg( 'protect-expiring-local', - $wgLang->timeanddate( $expiry, true ), - $wgLang->date( $expiry, true ), - $wgLang->time( $expiry, true ) + $lang->timeanddate( $expiry, true ), + $lang->date( $expiry, true ), + $lang->time( $expiry, true ) ); $description_items[] = htmlspecialchars($expiry_description); } if(!is_null($size = $row->page_len)) { - $stxt = $wgLang->getDirMark() . ' ' . $skin->formatRevisionSize( $size ); + $stxt = $lang->getDirMark() . ' ' . Linker::formatRevisionSize( $size ); } # Show a link to the change protection form for allowed users otherwise a link to the protection log - if( $wgUser->isAllowed( 'protect' ) ) { - $changeProtection = ' (' . $skin->linkKnown( + if( $this->getUser()->isAllowed( 'protect' ) ) { + $changeProtection = ' (' . Linker::linkKnown( $title, wfMsgHtml( 'protect_change' ), array(), @@ -129,7 +126,7 @@ class SpecialProtectedpages extends SpecialPage { ) . ')'; } else { $ltitle = SpecialPage::getTitleFor( 'Log' ); - $changeProtection = ' (' . $skin->linkKnown( + $changeProtection = ' (' . Linker::linkKnown( $ltitle, wfMsgHtml( 'protectlogpage' ), array(), @@ -145,7 +142,7 @@ class SpecialProtectedpages extends SpecialPage { return Html::rawElement( 'li', array(), - wfSpecialList( $link . $stxt, $wgLang->commaList( $description_items ), false ) . $changeProtection ) . "\n"; + wfSpecialList( $link . $stxt, $lang->commaList( $description_items ), false ) . $changeProtection ) . "\n"; } /** @@ -160,7 +157,7 @@ class SpecialProtectedpages extends SpecialPage { */ protected function showOptions( $namespace, $type='edit', $level, $sizetype, $size, $indefOnly, $cascadeOnly ) { global $wgScript; - $title = SpecialPage::getTitleFor( 'Protectedpages' ); + $title = $this->getTitle(); return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . Xml::openElement( 'fieldset' ) . Xml::element( 'legend', array(), wfMsg( 'protectedpages' ) ) . @@ -306,7 +303,7 @@ class ProtectedPagesPager extends AlphabeticPager { $this->size = intval($size); $this->indefonly = (bool)$indefonly; $this->cascadeonly = (bool)$cascadeonly; - parent::__construct(); + parent::__construct( $form->getContext() ); } function getStartBody() { @@ -319,10 +316,6 @@ class ProtectedPagesPager extends AlphabeticPager { return ''; } - function getTitle() { - return SpecialPage::getTitleFor( 'Protectedpages' ); - } - function formatRow( $row ) { return $this->mForm->formatRow( $row ); } diff --git a/includes/specials/SpecialProtectedtitles.php b/includes/specials/SpecialProtectedtitles.php index 40e58bc415..fe2fd05b8b 100644 --- a/includes/specials/SpecialProtectedtitles.php +++ b/includes/specials/SpecialProtectedtitles.php @@ -36,8 +36,6 @@ class SpecialProtectedtitles extends SpecialPage { } function execute( $par ) { - global $wgOut, $wgRequest; - $this->setHeaders(); $this->outputHeader(); @@ -46,15 +44,16 @@ class SpecialProtectedtitles extends SpecialPage { Title::purgeExpiredRestrictions(); } - $type = $wgRequest->getVal( $this->IdType ); - $level = $wgRequest->getVal( $this->IdLevel ); - $sizetype = $wgRequest->getVal( 'sizetype' ); - $size = $wgRequest->getIntOrNull( 'size' ); - $NS = $wgRequest->getIntOrNull( 'namespace' ); + $request = $this->getRequest(); + $type = $request->getVal( $this->IdType ); + $level = $request->getVal( $this->IdLevel ); + $sizetype = $request->getVal( 'sizetype' ); + $size = $request->getIntOrNull( 'size' ); + $NS = $request->getIntOrNull( 'namespace' ); $pager = new ProtectedTitlesPager( $this, array(), $type, $level, $NS, $sizetype, $size ); - $wgOut->addHTML( $this->showOptions( $NS, $type, $level ) ); + $this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level ) ); if ( $pager->getNumRows() ) { $s = $pager->getNavigationBar(); @@ -65,7 +64,7 @@ class SpecialProtectedtitles extends SpecialPage { } else { $s = '

    ' . wfMsgHtml( 'protectedtitlesempty' ) . '

    '; } - $wgOut->addHTML( $s ); + $this->getOutput()->addHTML( $s ); } /** @@ -74,19 +73,16 @@ class SpecialProtectedtitles extends SpecialPage { * @return string */ function formatRow( $row ) { - global $wgLang; - wfProfileIn( __METHOD__ ); - static $skin = null, $infinity = null; + static $infinity = null; - if( is_null( $skin ) ){ - $skin = $this->getSkin(); + if( is_null( $infinity ) ){ $infinity = wfGetDB( DB_SLAVE )->getInfinity(); } $title = Title::makeTitleSafe( $row->pt_namespace, $row->pt_title ); - $link = $skin->link( $title ); + $link = Linker::link( $title ); $description_items = array (); @@ -94,14 +90,13 @@ class SpecialProtectedtitles extends SpecialPage { $description_items[] = $protType; - $expiry = strlen( $row->pt_expiry ) ? $wgLang->formatExpiry( $row->pt_expiry, TS_MW ) : $infinity; + $expiry = strlen( $row->pt_expiry ) ? $lang->formatExpiry( $row->pt_expiry, TS_MW ) : $infinity; if( $expiry != $infinity ) { - $expiry_description = wfMsg( 'protect-expiring-local', - $wgLang->timeanddate( $expiry, true ), - $wgLang->date( $expiry, true ), - $wgLang->time( $expiry, true ) + $lang->timeanddate( $expiry, true ), + $lang->date( $expiry, true ), + $lang->time( $expiry, true ) ); $description_items[] = htmlspecialchars($expiry_description); @@ -121,7 +116,7 @@ class SpecialProtectedtitles extends SpecialPage { function showOptions( $namespace, $type='edit', $level ) { global $wgScript; $action = htmlspecialchars( $wgScript ); - $title = SpecialPage::getTitleFor( 'Protectedtitles' ); + $title = $this->getTitle(); $special = htmlspecialchars( $title->getPrefixedDBkey() ); return "
    \n" . '
    ' . @@ -194,7 +189,7 @@ class ProtectedTitlesPager extends AlphabeticPager { $this->level = $level; $this->namespace = $namespace; $this->size = intval($size); - parent::__construct(); + parent::__construct( $form->getContext() ); } function getStartBody() { -- 2.20.1