MediaWiki
REL1_19
|
00001 <?php 00026 require_once( dirname( __FILE__ ) . '/Maintenance.php' ); 00027 00028 class InitStats extends Maintenance { 00029 public function __construct() { 00030 parent::__construct(); 00031 $this->mDescription = "Re-initialise the site statistics tables"; 00032 $this->addOption( 'update', 'Update the existing statistics (preserves the ss_total_views field)' ); 00033 $this->addOption( 'noviews', "Don't update the page view counter" ); 00034 $this->addOption( 'active', 'Also update active users count' ); 00035 $this->addOption( 'use-master', 'Count using the master database' ); 00036 } 00037 00038 public function execute() { 00039 $this->output( "Refresh Site Statistics\n\n" ); 00040 $counter = new SiteStatsInit( $this->hasOption( 'use-master' ) ); 00041 00042 $this->output( "Counting total edits..." ); 00043 $edits = $counter->edits(); 00044 $this->output( "{$edits}\nCounting number of articles..." ); 00045 00046 $good = $counter->articles(); 00047 $this->output( "{$good}\nCounting total pages..." ); 00048 00049 $pages = $counter->pages(); 00050 $this->output( "{$pages}\nCounting number of users..." ); 00051 00052 $users = $counter->users(); 00053 $this->output( "{$users}\nCounting number of images..." ); 00054 00055 $image = $counter->files(); 00056 $this->output( "{$image}\n" ); 00057 00058 if ( !$this->hasOption( 'noviews' ) ) { 00059 $this->output( "Counting total page views..." ); 00060 $views = $counter->views(); 00061 $this->output( "{$views}\n" ); 00062 } 00063 00064 if ( $this->hasOption( 'active' ) ) { 00065 $this->output( "Counting active users..." ); 00066 $active = SiteStatsUpdate::cacheUpdate( wfGetDB( DB_MASTER ) ); 00067 $this->output( "{$active}\n" ); 00068 } 00069 00070 $this->output( "\nUpdating site statistics..." ); 00071 00072 if ( $this->hasOption( 'update' ) ) { 00073 $counter->update(); 00074 } else { 00075 $counter->refresh(); 00076 } 00077 00078 $this->output( "done.\n" ); 00079 } 00080 } 00081 00082 $maintClass = "InitStats"; 00083 require_once( RUN_MAINTENANCE_IF_MAIN );