MediaWiki  master
SpecialListUsers.php
Go to the documentation of this file.
1 <?php
28 namespace MediaWiki\Specials;
29 
35 use UsersPager;
37 
42 
44  private $linkBatchFactory;
45 
47  private $dbProvider;
48 
50  private $userGroupManager;
51 
53  private $userIdentityLookup;
54 
61  public function __construct(
62  LinkBatchFactory $linkBatchFactory,
63  IConnectionProvider $dbProvider,
64  UserGroupManager $userGroupManager,
65  UserIdentityLookup $userIdentityLookup
66  ) {
67  parent::__construct( 'Listusers' );
68  $this->linkBatchFactory = $linkBatchFactory;
69  $this->dbProvider = $dbProvider;
70  $this->userGroupManager = $userGroupManager;
71  $this->userIdentityLookup = $userIdentityLookup;
72  }
73 
77  public function execute( $par ) {
78  $this->setHeaders();
79  $this->outputHeader();
80 
81  $up = new UsersPager(
82  $this->getContext(),
83  $this->getHookContainer(),
84  $this->linkBatchFactory,
85  $this->dbProvider,
86  $this->userGroupManager,
87  $this->userIdentityLookup,
88  $par,
89  $this->including()
90  );
91 
92  # getBody() first to check, if empty
93  $usersbody = $up->getBody();
94 
95  $s = '';
96  if ( !$this->including() ) {
97  $s = $up->getPageHeader();
98  }
99 
100  if ( $usersbody ) {
101  $s .= $up->getNavigationBar();
102  $s .= Html::rawElement( 'ul', [], $usersbody );
103  $s .= $up->getNavigationBar();
104  } else {
105  $s .= $this->msg( 'listusers-noresult' )->parseAsBlock();
106  }
107 
108  $out = $this->getOutput();
109  $out->addHTML( $s );
110  $out->addModuleStyles( 'mediawiki.interface.helpers.styles' );
111  }
112 
118  public function getSubpagesForPrefixSearch() {
119  return $this->userGroupManager->listAllGroups();
120  }
121 
122  protected function getGroupName() {
123  return 'users';
124  }
125 }
126 
130 class_alias( SpecialListUsers::class, 'SpecialListUsers' );
Shortcut to construct an includable special page.
This class is a collection of static functions that serve two purposes:
Definition: Html.php:55
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:219
getSubpagesForPrefixSearch()
Return an array of subpages that this special page will accept.
__construct(LinkBatchFactory $linkBatchFactory, IConnectionProvider $dbProvider, UserGroupManager $userGroupManager, UserIdentityLookup $userIdentityLookup)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
including( $x=null)
Whether the special page is being evaluated via transclusion.
This class is used to get a list of user.
Definition: UsersPager.php:46
Provide primary and replica IDatabase connections.