MediaWiki  1.23.1
showSiteStats.php
Go to the documentation of this file.
1 <?php
2 
32 require_once __DIR__ . '/Maintenance.php';
33 
39 class ShowSiteStats extends Maintenance {
40  public function __construct() {
41  parent::__construct();
42  $this->mDescription = "Show the cached statistics";
43  }
44  public function execute() {
45  $fields = array(
46  'ss_total_views' => 'Total views',
47  'ss_total_edits' => 'Total edits',
48  'ss_good_articles' => 'Number of articles',
49  'ss_total_pages' => 'Total pages',
50  'ss_users' => 'Number of users',
51  'ss_active_users' => 'Active users',
52  'ss_images' => 'Number of images',
53  );
54 
55  // Get cached stats from slave database
56  $dbr = wfGetDB( DB_SLAVE );
57  $stats = $dbr->selectRow( 'site_stats', '*', '', __METHOD__ );
58 
59  // Get maximum size for each column
60  $max_length_value = $max_length_desc = 0;
61  foreach ( $fields as $field => $desc ) {
62  $max_length_value = max( $max_length_value, strlen( $stats->$field ) );
63  $max_length_desc = max( $max_length_desc, strlen( $desc ) );
64  }
65 
66  // Show them
67  foreach ( $fields as $field => $desc ) {
68  $this->output( sprintf( "%-{$max_length_desc}s: %{$max_length_value}d\n", $desc, $stats->$field ) );
69  }
70  }
71 }
72 
73 $maintClass = "ShowSiteStats";
74 require_once RUN_MAINTENANCE_IF_MAIN;
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
$maintClass
$maintClass
Definition: showSiteStats.php:73
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3650
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
$dbr
$dbr
Definition: testCompression.php:48
ShowSiteStats\__construct
__construct()
Default constructor.
Definition: showSiteStats.php:40
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
ShowSiteStats\execute
execute()
Do the actual work.
Definition: showSiteStats.php:44
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
ShowSiteStats
Maintenance script to show the cached statistics.
Definition: showSiteStats.php:39