https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114023

Revision: 114023
Author:   jeroendedauw
Date:     2012-03-16 16:59:04 +0000 (Fri, 16 Mar 2012)
Log Message:
-----------
work on special:studentactivity and adding frank his images

Modified Paths:
--------------
    trunk/extensions/EducationProgram/EducationProgram.i18n.php
    trunk/extensions/EducationProgram/EducationProgram.php
    trunk/extensions/EducationProgram/EducationProgram.settings.php
    trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php

Added Paths:
-----------
    trunk/extensions/EducationProgram/includes/EPStudentActivityPager.php
    trunk/extensions/EducationProgram/resources/images/flag_brazil.png
    trunk/extensions/EducationProgram/resources/images/flag_canada.png
    trunk/extensions/EducationProgram/resources/images/flag_egypt.png
    trunk/extensions/EducationProgram/resources/images/flag_germany.png
    trunk/extensions/EducationProgram/resources/images/flag_india.png
    trunk/extensions/EducationProgram/resources/images/flag_israel.png
    trunk/extensions/EducationProgram/resources/images/flag_mexico.png
    trunk/extensions/EducationProgram/resources/images/flag_sweden.png
    trunk/extensions/EducationProgram/resources/images/flag_tchech republic.png
    trunk/extensions/EducationProgram/resources/images/flag_unitedkingdom.png
    trunk/extensions/EducationProgram/resources/images/flag_unitedstates.png
    
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-0.png
    
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-10.png
    
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-20.png
    
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-30.png
    
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-40.png
    
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-5.png
    
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-50.png
    
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-60.png

Modified: trunk/extensions/EducationProgram/EducationProgram.i18n.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-03-16 
16:22:44 UTC (rev 114022)
+++ trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-03-16 
16:59:04 UTC (rev 114023)
@@ -775,6 +775,9 @@
        'epca-profile-saved' => 'Your profile has been saved',
        'epca-profile-invalid-bio' => 'Your bio needs to be at least contain $1 
{{PLURAL:$1|character|characters}}.',
        'epca-visible' => 'Publicly list me as Campus Ambassador',
+
+       // Special:StudentActivity
+       'ep-studentactivity-count' => 'There {{PLURAL:$1|is|are}} currently $1 
{{PLURAL:$1|student|students}} that where active in the last 24 hours.',
 );
 
 /** Message documentation (Message documentation)

Modified: trunk/extensions/EducationProgram/EducationProgram.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.php      2012-03-16 
16:22:44 UTC (rev 114022)
+++ trunk/extensions/EducationProgram/EducationProgram.php      2012-03-16 
16:59:04 UTC (rev 114023)
@@ -123,6 +123,7 @@
 $wgAutoloadClasses['EPInstructors']                            = dirname( 
__FILE__ ) . '/includes/EPInstructors.php';
 $wgAutoloadClasses['EPRevisions']                                      = 
dirname( __FILE__ ) . '/includes/EPRevisions.php';
 $wgAutoloadClasses['EPArticles']                                       = 
dirname( __FILE__ ) . '/includes/EPArticles.php';
+$wgAutoloadClasses['EPStudentActivityPager']           = dirname( __FILE__ ) . 
'/includes/EPStudentActivityPager.php';
 
 $wgAutoloadClasses['CoursePage']                                       = 
dirname( __FILE__ ) . '/pages/CoursePage.php';
 $wgAutoloadClasses['EPPage']                                           = 
dirname( __FILE__ ) . '/pages/EPPage.php';

Modified: trunk/extensions/EducationProgram/EducationProgram.settings.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.settings.php     
2012-03-16 16:22:44 UTC (rev 114022)
+++ trunk/extensions/EducationProgram/EducationProgram.settings.php     
2012-03-16 16:59:04 UTC (rev 114023)
@@ -27,6 +27,11 @@
         * @return array
         */
        protected static function getDefaultSettings() {
+               global $wgExtensionAssetsPath, $wgScriptPath;
+
+               $resourceDir = $egSWLScriptPath = $wgExtensionAssetsPath === 
false ? $wgScriptPath . '/extensions' : $wgExtensionAssetsPath;
+               $resourceDir .= '/EducationProgram/resources/';
+
                return array(
                        'enableTopLink' => true,
                        'ambassadorPictureDomains' => array(
@@ -35,7 +40,9 @@
                        'ambassadorCommonsUrl' => 
'https://commons.wikimedia.org/wiki/Special:UploadWizard',
                        'citylessCountries' => array( 'BT', 'BV', 'IO', 'VG', 
'TD', 'CX', 'CC', 'KM', 'DJ', 'GQ', 'FK', 'FX', 'TF', 'GW', 'HM', 'KI', 'YT', 
'MS', 'NR', 'NU', 'NF', 'PN', 'SH', 'PM', 'WS', 'SC', 'GS', 'SJ', 'TK', 'TP', 
'TV', 'UM', 'VU', 'EH' ),
                        'ambassadorImgWidth' => 140,
-                       'recentActivityLimit' => 24 * 60 * 60,
+                       'recentActivityLimit' => 17 * 60 * 60,
+                       'resourceDir' => $resourceDir,
+                       'imageDir' => $resourceDir . 'images/',
                );
        }
 

Added: trunk/extensions/EducationProgram/includes/EPStudentActivityPager.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPStudentActivityPager.php       
                        (rev 0)
+++ trunk/extensions/EducationProgram/includes/EPStudentActivityPager.php       
2012-03-16 16:59:04 UTC (rev 114023)
@@ -0,0 +1,239 @@
+<?php
+
+/**
+ * Student pager, primarily for Special:Students.
+ *
+ * @since 0.1
+ *
+ * @file EPStudentPager.php
+ * @ingroup EductaionProgram
+ *
+ * @licence GNU GPL v3 or later
+ * @author Jeroen De Dauw < [email protected] >
+ */
+class EPStudentActivityPager extends EPPager {
+
+       /**
+        * List of user ids mapped to user names and real names, set in 
doBatchLookups.
+        * The real names will just hold the user name when no real name is set.
+        * user id => array( user name, real name )
+        *
+        * @since 0.1
+        * @var array
+        */
+       protected $userNames = array();
+
+       /**
+        * List of course ids mapped to their title names.
+        * course id => course name
+        *
+        * @since 0.1
+        * @var array
+        */
+       protected $courseNames = array();
+
+       /**
+        * List of course ids pointing to the id of their org.
+        * course id => org id
+        *
+        * @since 0.1
+        * @var array
+        */
+       protected $courseOrgs = array();
+
+       /**
+        * List of org ids mapped to their title names.
+        * org id => org name
+        *
+        * @since 0.1
+        * @var array
+        */
+       protected $orgNames = array();
+
+       /**
+        * Constructor.
+        *
+        * @param IContextSource $context
+        * @param array $conds
+        */
+       public function __construct( IContextSource $context, array $conds = 
array() ) {
+               $this->mDefaultDirection = true;
+               parent::__construct( $context, $conds, EPStudents::singleton() 
);
+       }
+
+       /**
+        * (non-PHPdoc)
+        * @see EPPager::getFields()
+        */
+       public function getFields() {
+               return array(
+                       'id',
+                       'user_id',
+                       'last_course',
+                       'last_active',
+               );
+       }
+
+       /**
+        * (non-PHPdoc)
+        * @see TablePager::getRowClass()
+        */
+       function getRowClass( $row ) {
+               return 'ep-studentactivity-row';
+       }
+
+       /**
+        * (non-PHPdoc)
+        * @see TablePager::getTableClass()
+        */
+       public function getTableClass() {
+               return 'TablePager ep-studentactivity';
+       }
+
+       /**
+        * (non-PHPdoc)
+        * @see EPPager::getFormattedValue()
+        */
+       protected function getFormattedValue( $name, $value ) {
+               switch ( $name ) {
+                       case 'user_id':
+                               if ( array_key_exists( $value, $this->userNames 
) ) {
+                                       list( $userName, $realName ) = 
$this->userNames[$value];
+                                       $value = Linker::userLink( $value, 
$userName, $realName ) . Linker::userToolLinks( $value, $userName );
+                               }
+                               else {
+                                       wfWarn( 'User id not in 
$this->userNames in ' . __METHOD__ );
+                               }
+                               break;
+                       case 'last_active':
+                               $value = htmlspecialchars( 
$this->getLanguage()->timeanddate( $value ) );
+                               break;
+                       case 'last_course':
+                               if ( array_key_exists( $value, 
$this->courseNames ) ) {
+                                       $value = 
EPCourses::singleton()->getLinkFor( $this->courseNames[$value] );
+                               }
+                               else {
+                                       wfWarn( 'Course id not in 
$this->courseNames in ' . __METHOD__ );
+                               }
+                               break;
+                       case 'org_id':
+                               $courseId = $this->currentObject->getField( 
'last_course' );
+
+                               if ( array_key_exists( $courseId, 
$this->courseOrgs ) ) {
+                                       $orgId = $this->courseOrgs[$courseId];
+
+                                       if ( array_key_exists( $orgId, 
$this->orgNames ) ) {
+                                               $value = 
EPOrgs::singleton()->getLinkFor( $this->orgNames[$orgId] );
+                                       }
+                                       else {
+                                               wfWarn( 'Org id not in 
$this->orgNames in ' . __METHOD__ );
+                                       }
+                               }
+                               else {
+                                       wfWarn( 'Course id not in 
$this->courseOrgs in ' . __METHOD__ );
+                               }
+                               break;
+               }
+
+               return $value;
+       }
+
+       /**
+        * (non-PHPdoc)
+        * @see EPPager::getSortableFields()
+        */
+       protected function getSortableFields() {
+               return array(
+               );
+       }
+
+       /**
+        * (non-PHPdoc)
+        * @see EPPager::hasActionsColumn()
+        */
+       protected function hasActionsColumn() {
+               return false;
+       }
+
+       /**
+        * (non-PHPdoc)
+        * @see IndexPager::getDefaultSort()
+        */
+       function getDefaultSort() {
+               return 'last_active';
+       }
+
+       /**
+        * (non-PHPdoc)
+        * @see EPPager::getFieldNames()
+        */
+       public function getFieldNames() {
+               $fields = parent::getFieldNames();
+
+               unset( $fields['id'] );
+
+               $fields = wfArrayInsertAfter( $fields, array( 'org_id' => 
'org-id' ), 'user_id' );
+
+               return $fields;
+       }
+
+       /**
+        * (non-PHPdoc)
+        * @see IndexPager::doBatchLookups()
+        */
+       protected function doBatchLookups() {
+               $userIds = array();
+               $courseIds = array();
+
+               $userField = $this->table->getPrefixedField( 'user_id' );
+               $courseField = $this->table->getPrefixedField( 'last_course' );
+
+               while( $student = $this->mResult->fetchObject() ) {
+                       $userIds[] = (int)$student->$userField;
+                       $courseIds[] = (int)$student->$courseField;
+               }
+
+               if ( !empty( $userIds ) ) {
+                       $result = wfGetDB( DB_SLAVE )->select(
+                               'user',
+                               array( 'user_id', 'user_name', 'user_real_name' 
),
+                               array( 'user_id' => $userIds ),
+                               __METHOD__
+                       );
+
+                       while( $user = $result->fetchObject() ) {
+                               $real = $user->user_real_name === '' ? 
$user->user_name : $user->user_real_name;
+                               $this->userNames[$user->user_id] = array( 
$user->user_name, $real );
+                       }
+               }
+
+               if ( !empty( $courseIds ) ) {
+                       $courses = EPCourses::singleton()->selectFields(
+                               array( 'id', 'name', 'org_id' ),
+                               array( 'id' => array_unique( $courseIds ) )
+                       );
+
+                       $orgIds = array();
+
+                       foreach ( $courses as $courseData ) {
+                               $this->courseNames[$courseData['id']] = 
$courseData['name'];
+                               $orgIds[] = $courseData['org_id'];
+                               $this->courseOrgs[$courseData['id']] = 
$courseData['org_id'];
+                       }
+
+                       $this->orgNames = EPOrgs::singleton()->selectFields(
+                               array( 'id', 'name' ),
+                               array( 'id' => array_unique( $orgIds ) )
+                       );
+               }
+       }
+
+       /**
+        * (non-PHPdoc)
+        * @see EPPager::getMsg()
+        */
+       protected function getMsg( $messageKey ) {
+               return wfMsg( strtolower( get_called_class() ) . '-' . 
str_replace( '_', '-', $messageKey ) );
+       }
+
+}
\ No newline at end of file

Added: trunk/extensions/EducationProgram/resources/images/flag_brazil.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/flag_brazil.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/extensions/EducationProgram/resources/images/flag_canada.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/flag_canada.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/extensions/EducationProgram/resources/images/flag_egypt.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/flag_egypt.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/extensions/EducationProgram/resources/images/flag_germany.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/flag_germany.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/extensions/EducationProgram/resources/images/flag_india.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/flag_india.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/extensions/EducationProgram/resources/images/flag_israel.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/flag_israel.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/extensions/EducationProgram/resources/images/flag_mexico.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/flag_mexico.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/extensions/EducationProgram/resources/images/flag_sweden.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/flag_sweden.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/extensions/EducationProgram/resources/images/flag_tchech 
republic.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/flag_tchech republic.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/extensions/EducationProgram/resources/images/flag_unitedkingdom.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/flag_unitedkingdom.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/extensions/EducationProgram/resources/images/flag_unitedstates.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/flag_unitedstates.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-0.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-0.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-10.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-10.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-20.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-20.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-30.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-30.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-40.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-40.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-5.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-5.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-50.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-50.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-60.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/extensions/EducationProgram/resources/images/student-o-meter_morethan-60.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php
===================================================================
--- trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php       
2012-03-16 16:22:44 UTC (rev 114022)
+++ trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php       
2012-03-16 16:59:04 UTC (rev 114023)
@@ -34,9 +34,15 @@
 
                $this->displayNavigation();
 
+               $conds = array( 'last_active > ' . wfGetDB( DB_SLAVE 
)->addQuotes(
+                       wfTimestamp( TS_MW, time() - ( EPSettings::get( 
'recentActivityLimit' ) ) )
+               ) );
+
+               $this->showStudentMeter( $conds );
+
                $out = $this->getOutput();
 
-               $pager = new EPStudentActivityPager( $this->getContext(), 
array() );
+               $pager = new EPStudentActivityPager( $this->getContext(), 
$conds );
 
                if ( $pager->getNumRows() ) {
                        $out->addHTML(
@@ -53,250 +59,23 @@
                }
        }
 
-}
+       public function showStudentMeter( array $conds ) {
+               $studentCount = EPStudents::singleton()->count( $conds );
 
-
-/**
- * Student pager, primarily for Special:Students.
- *
- * @since 0.1
- *
- * @file EPStudentPager.php
- * @ingroup EductaionProgram
- *
- * @licence GNU GPL v3 or later
- * @author Jeroen De Dauw < [email protected] >
- */
-class EPStudentActivityPager extends EPPager {
-
-       /**
-        * List of user ids mapped to user names and real names, set in 
doBatchLookups.
-        * The real names will just hold the user name when no real name is set.
-        * user id => array( user name, real name )
-        *
-        * @since 0.1
-        * @var array
-        */
-       protected $userNames = array();
-
-       /**
-        * List of course ids mapped to their title names.
-        * course id => course name
-        *
-        * @since 0.1
-        * @var array
-        */
-       protected $courseNames = array();
-
-       /**
-        * List of course ids pointing to the id of their org.
-        * course id => org id
-        *
-        * @since 0.1
-        * @var array
-        */
-       protected $courseOrgs = array();
-
-       /**
-        * List of org ids mapped to their title names.
-        * org id => org name
-        *
-        * @since 0.1
-        * @var array
-        */
-       protected $orgNames = array();
-
-       /**
-        * Constructor.
-        *
-        * @param IContextSource $context
-        * @param array $conds
-        */
-       public function __construct( IContextSource $context, array $conds = 
array() ) {
-               $this->mDefaultDirection = true;
-
-               $conds[] = 'last_active > ' . wfGetDB( DB_SLAVE )->addQuotes(
-                       wfTimestamp( TS_MW, time() - ( EPSettings::get( 
'recentActivityLimit' ) ) )
-               );
-
-               parent::__construct( $context, $conds, EPStudents::singleton() 
);
-       }
-
-       /**
-        * (non-PHPdoc)
-        * @see EPPager::getFields()
-        */
-       public function getFields() {
-               return array(
-                       'id',
-                       'user_id',
-                       'last_course',
-                       'last_active',
-               );
-       }
-
-       /**
-        * (non-PHPdoc)
-        * @see TablePager::getRowClass()
-        */
-       function getRowClass( $row ) {
-               return 'ep-studentactivity-row';
-       }
-
-       /**
-        * (non-PHPdoc)
-        * @see TablePager::getTableClass()
-        */
-       public function getTableClass() {
-               return 'TablePager ep-studentactivity';
-       }
-
-       /**
-        * (non-PHPdoc)
-        * @see EPPager::getFormattedValue()
-        */
-       protected function getFormattedValue( $name, $value ) {
-               switch ( $name ) {
-                       case 'user_id':
-                               if ( array_key_exists( $value, $this->userNames 
) ) {
-                                       list( $userName, $realName ) = 
$this->userNames[$value];
-                                       $value = Linker::userLink( $value, 
$userName, $realName ) . Linker::userToolLinks( $value, $userName );
-                               }
-                               else {
-                                       wfWarn( 'User id not in 
$this->userNames in ' . __METHOD__ );
-                               }
-                               break;
-                       case 'last_active':
-                               $value = htmlspecialchars( 
$this->getLanguage()->timeanddate( $value ) );
-                               break;
-                       case 'last_course':
-                               if ( array_key_exists( $value, 
$this->courseNames ) ) {
-                                       $value = 
EPCourses::singleton()->getLinkFor( $this->courseNames[$value] );
-                               }
-                               else {
-                                       // TODO: enable
-                                       //wfWarn( 'Course id not in 
$this->courseNames in ' . __METHOD__ );
-                               }
-                               break;
-                       case 'org_id':
-                               $courseId = $this->currentObject->getField( 
'last_course' );
-
-                               if ( array_key_exists( $courseId, 
$this->courseOrgs ) ) {
-                                       $orgId = $this->courseOrgs[$courseId];
-
-                                       if ( array_key_exists( $orgId, 
$this->orgNames ) ) {
-                                               $value = 
EPOrgs::singleton()->getLinkFor( $this->orgNames[$orgId] );
-                                       }
-                                       else {
-                                               wfWarn( 'Org id not in 
$this->orgNames in ' . __METHOD__ );
-                                       }
-                               }
-                               else {
-                                       // TODO: enable
-                                       //wfWarn( 'Course id not in 
$this->courseOrgs in ' . __METHOD__ );
-                               }
-                               break;
+               if ( $studentCount < 10 ) {
+                       $image = $studentCount < 5 ? 0 : 5;
                }
-
-               return $value;
-       }
-
-       /**
-        * (non-PHPdoc)
-        * @see EPPager::getSortableFields()
-        */
-       protected function getSortableFields() {
-               return array(
-               );
-       }
-
-       /**
-        * (non-PHPdoc)
-        * @see EPPager::hasActionsColumn()
-        */
-       protected function hasActionsColumn() {
-               return false;
-       }
-
-       /**
-        * (non-PHPdoc)
-        * @see IndexPager::getDefaultSort()
-        */
-       function getDefaultSort() {
-               return 'last_active';
-       }
-
-       /**
-        * (non-PHPdoc)
-        * @see EPPager::getFieldNames()
-        */
-       public function getFieldNames() {
-               $fields = parent::getFieldNames();
-
-               unset( $fields['id'] );
-
-               $fields = wfArrayInsertAfter( $fields, array( 'org_id' => 
'org-id' ), 'user_id' );
-
-               return $fields;
-       }
-
-       /**
-        * (non-PHPdoc)
-        * @see IndexPager::doBatchLookups()
-        */
-       protected function doBatchLookups() {
-               $userIds = array();
-               $courseIds = array();
-
-               $userField = $this->table->getPrefixedField( 'user_id' );
-               $courseField = $this->table->getPrefixedField( 'last_course' );
-
-               while( $student = $this->mResult->fetchObject() ) {
-                       $userIds[] = (int)$student->$userField;
-                       $courseIds[] = (int)$student->$courseField;
+               else {
+                       $image = floor( $studentCount / 10 );
                }
 
-               if ( !empty( $userIds ) ) {
-                       $result = wfGetDB( DB_SLAVE )->select(
-                               'user',
-                               array( 'user_id', 'user_name', 'user_real_name' 
),
-                               array( 'user_id' => $userIds ),
-                               __METHOD__
-                       );
+               $message = $this->msg( 'ep-studentactivity-count', 
$studentCount )->escaped();
 
-                       while( $user = $result->fetchObject() ) {
-                               $real = $user->user_real_name === '' ? 
$user->user_name : $user->user_real_name;
-                               $this->userNames[$user->user_id] = array( 
$user->user_name, $real );
-                       }
-               }
-
-               if ( !empty( $courseIds ) ) {
-                       $courses = EPCourses::singleton()->selectFields(
-                               array( 'id', 'name', 'org_id' ),
-                               array( 'id' => array_unique( $courseIds ) )
-                       );
-
-                       $orgIds = array();
-
-                       foreach ( $courses as $courseData ) {
-                               $this->courseNames[$courseData['id']] = 
$courseData['name'];
-                               $orgIds[] = $courseData['org_id'];
-                               $this->courseOrgs[$courseData['id']] = 
$courseData['org_id'];
-                       }
-
-                       $this->orgNames = EPOrgs::singleton()->selectFields(
-                               array( 'id', 'name' ),
-                               array( 'id' => array_unique( $orgIds ) )
-                       );
-               }
+               $this->getOutput()->addElement( 'img', array(
+                       'src' => EPSettings::get( 'imageDir' ) . 
'student-o-meter_morethan-' . $image . '.png',
+                       'alt' => $message,
+                       'title' => $message,
+               ) );
        }
 
-       /**
-        * (non-PHPdoc)
-        * @see EPPager::getMsg()
-        */
-       protected function getMsg( $messageKey ) {
-               return wfMsg( strtolower( get_called_class() ) . '-' . 
str_replace( '_', '-', $messageKey ) );
-       }
-
-}
\ No newline at end of file
+}


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to