MediaWiki  1.27.2
SpecialActiveusers.php
Go to the documentation of this file.
1 <?php
30 
34  public function __construct() {
35  parent::__construct( 'Activeusers' );
36  }
37 
43  public function execute( $par ) {
44  $days = $this->getConfig()->get( 'ActiveUserDays' );
45 
46  $this->setHeaders();
47  $this->outputHeader();
48 
49  $out = $this->getOutput();
50  $out->wrapWikiMsg( "<div class='mw-activeusers-intro'>\n$1\n</div>",
51  [ 'activeusers-intro', $this->getLanguage()->formatNum( $days ) ] );
52 
53  // Mention the level of cache staleness...
54  $dbr = wfGetDB( DB_SLAVE, 'recentchanges' );
55  $rcMax = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', '', __METHOD__ );
56  if ( $rcMax ) {
57  $cTime = $dbr->selectField( 'querycache_info',
58  'qci_timestamp',
59  [ 'qci_type' => 'activeusers' ],
60  __METHOD__
61  );
62  if ( $cTime ) {
63  $secondsOld = wfTimestamp( TS_UNIX, $rcMax ) - wfTimestamp( TS_UNIX, $cTime );
64  } else {
65  $rcMin = $dbr->selectField( 'recentchanges', 'MIN(rc_timestamp)' );
66  $secondsOld = time() - wfTimestamp( TS_UNIX, $rcMin );
67  }
68  if ( $secondsOld > 0 ) {
69  $out->addWikiMsg( 'cachedspecial-viewing-cached-ttl',
70  $this->getLanguage()->formatDuration( $secondsOld ) );
71  }
72  }
73 
74  $up = new ActiveUsersPager( $this->getContext(), null, $par );
75 
76  # getBody() first to check, if empty
77  $usersbody = $up->getBody();
78 
79  $out->addHTML( $up->getPageHeader() );
80  if ( $usersbody ) {
81  $out->addHTML(
82  $up->getNavigationBar() .
83  Html::rawElement( 'ul', [], $usersbody ) .
84  $up->getNavigationBar()
85  );
86  } else {
87  $out->addWikiMsg( 'activeusers-noresult' );
88  }
89  }
90 
91  protected function getGroupName() {
92  return 'users';
93  }
94 }
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:762
getContext()
Gets the context this SpecialPage is executed in.
This class is used to get a list of active users.
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
Definition: Html.php:210
__construct()
Constructor.
getOutput()
Get the OutputPage being used for this instance.
outputHeader($summaryMessageKey= '')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Parent class for all special pages.
Definition: SpecialPage.php:36
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
const DB_SLAVE
Definition: Defines.php:46
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
getConfig()
Shortcut to get main config object.
getLanguage()
Shortcut to get user's language.
execute($par)
Show the special page.
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.