https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114471
Revision: 114471
Author: jeroendedauw
Date: 2012-03-24 05:11:10 +0000 (Sat, 24 Mar 2012)
Log Message:
-----------
work on special:educationprogram
Modified Paths:
--------------
trunk/extensions/EducationProgram/EducationProgram.i18n.php
trunk/extensions/EducationProgram/actions/EditCourseAction.php
trunk/extensions/EducationProgram/actions/ViewCourseAction.php
trunk/extensions/EducationProgram/actions/ViewOrgAction.php
trunk/extensions/EducationProgram/specials/SpecialEducationProgram.php
Modified: trunk/extensions/EducationProgram/EducationProgram.i18n.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-03-24
01:26:26 UTC (rev 114470)
+++ trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-03-24
05:11:10 UTC (rev 114471)
@@ -214,13 +214,21 @@
'ep-course-status-planned' => 'Planned',
// Special:EducationProgram
- 'ep-summary-table-header' => 'Education Program summary',
+ 'ep-summary-table-header' => 'Education Program totals',
'specialeducationprogram-summary-org-count' => 'Number of
[[Special:Institutions|institutions]]',
'specialeducationprogram-summary-course-count' => 'Number of
[[Special:Courses|courses]]',
'specialeducationprogram-summary-student-count' => 'Number of
[[Special:Students|students]]',
'specialeducationprogram-summary-instructor-count' => 'Number of
instructors',
'specialeducationprogram-summary-ca-count' => 'Number of
[[Special:CampusAmbassadors|Campus Ambassadors]]',
'specialeducationprogram-summary-oa-count' => 'Number of
[[Special:OnlineAmbassadors|Online Ambassadors]]',
+ 'ep-educationprogram-by-term' => 'Totals per term',
+ 'ep-educationprogram-courses' => 'Number of courses',
+ 'ep-educationprogram-students' => 'Number of students',
+ 'ep-educationprogram-instructors' => 'Number of instructors',
+ 'ep-educationprogram-oas' => 'Number of Online Ambassadors',
+ 'ep-educationprogram-cas' => 'Number of Campus Ambassadors',
+ 'ep-educationprogram-orgs' => 'Number of institutions',
+ 'ep-educationprogram-articles' => 'Number of articles',
// Special:Institutions
'ep-institutions-noresults' => 'There are no institutions to list.',
Modified: trunk/extensions/EducationProgram/actions/EditCourseAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EditCourseAction.php
2012-03-24 01:26:26 UTC (rev 114470)
+++ trunk/extensions/EducationProgram/actions/EditCourseAction.php
2012-03-24 05:11:10 UTC (rev 114471)
@@ -170,10 +170,13 @@
} ,
);
+ $fieldFields = $this->table->selectFields( 'term', array(),
array( 'DISTINCT' ) );
+ $fieldFields = array_merge( array( '' => '' ), $fieldFields );
$fields['term'] = array (
- 'type' => 'text',
+ 'class' => 'EPHTMLCombobox',
'label-message' => 'ep-course-edit-term',
'required' => true,
+ 'options' => array_combine( $fieldFields, $fieldFields
),
);
$fields['start'] = array (
Modified: trunk/extensions/EducationProgram/actions/ViewCourseAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/ViewCourseAction.php
2012-03-24 01:26:26 UTC (rev 114470)
+++ trunk/extensions/EducationProgram/actions/ViewCourseAction.php
2012-03-24 05:11:10 UTC (rev 114471)
@@ -228,8 +228,7 @@
return array_merge( array(
$user->isAllowed( 'ep-course' ),
- $user->isAllowed( 'ep-bulkdelcourses' ),
- $user->getOption( 'ep_bulkdelcourses' ),
+ $user->isAllowed( 'ep-bulkdelcourses' ) &&
$user->getOption( 'ep_bulkdelcourses' ),
), parent::getCacheKey() );
}
Modified: trunk/extensions/EducationProgram/actions/ViewOrgAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/ViewOrgAction.php 2012-03-24
01:26:26 UTC (rev 114470)
+++ trunk/extensions/EducationProgram/actions/ViewOrgAction.php 2012-03-24
05:11:10 UTC (rev 114471)
@@ -115,8 +115,7 @@
return array_merge( array(
$user->isAllowed( 'ep-org' ),
$user->isAllowed( 'ep-course' ),
- $user->isAllowed( 'ep-bulkdelcourses' ),
- $user->getOption( 'ep_bulkdelcourses' ),
+ $user->isAllowed( 'ep-bulkdelcourses' ) &&
$user->getOption( 'ep_bulkdelcourses' ),
), parent::getCacheKey() );
}
Modified: trunk/extensions/EducationProgram/specials/SpecialEducationProgram.php
===================================================================
--- trunk/extensions/EducationProgram/specials/SpecialEducationProgram.php
2012-03-24 01:26:26 UTC (rev 114470)
+++ trunk/extensions/EducationProgram/specials/SpecialEducationProgram.php
2012-03-24 05:11:10 UTC (rev 114471)
@@ -32,12 +32,14 @@
public function execute( $subPage ) {
parent::execute( $subPage );
- $this->startCache( 3600 );
+ $this->startCache( 1 );
$this->displayNavigation();
$this->addCachedHTML( array( $this, 'displaySummaryTable' ) );
+ $this->addCachedHTML( array( $this, 'displayByTerm' ) );
+
$this->saveCache();
}
@@ -48,7 +50,7 @@
*
* @return string
*/
- protected function displaySummaryTable() {
+ public function displaySummaryTable() {
$html = Html::openElement( 'table', array( 'class' =>
'wikitable ep-summary' ) );
$html .= '<tr>' . Html::element( 'th', array( 'colspan' => 2 ),
wfMsg( 'ep-summary-table-header' ) ) . '</tr>';
@@ -93,4 +95,94 @@
return $data;
}
+ public function displayByTerm() {
+ $terms = $this->getTermData();
+
+ $html = Html::element( 'h2', array(), $this->msgTxt( 'by-term'
) );
+
+ $html .= Html::openElement( 'table', array( 'class' =>
'wikitable ep-termbreakdown' ) );
+
+ $term = array_shift( $terms );
+ $rows = array_keys( $term );
+ array_unshift( $terms, $term );
+
+ array_unshift( $rows, 'header' );
+
+ foreach ( $rows as $row ) {
+ $isHeader = $row === 'header';
+
+ $html .= '<tr>';
+
+ $html .= Html::element( 'th', array(), $isHeader ? '' :
$this->msgTxt( $row ) );
+
+ foreach ( $terms as $termName => $term ) {
+ $html .= Html::element( $isHeader ? 'th' :
'td', array(), $isHeader ? $termName : $term[$row] );
+ }
+
+ $html .= '</tr>';
+ }
+
+ $html .= Html::closeElement( 'table' );
+
+ return $html;
+ }
+
+ protected function getTermData() {
+ $termNames = EPCourses::singleton()->selectFields( 'term',
array(), array( 'DISTINCT' ) );
+ $terms = array();
+
+ foreach ( $termNames as $termName ) {
+ $courses = EPCourses::singleton()->select( null, array(
'term' => $termName ) );
+
+ $students = array();
+ $oas = array();
+ $cas = array();
+ $instructors = array();
+ $orgs = array();
+ $courseIds = array();
+
+ foreach ( $courses as /* EPCourse */ $course ) {
+ $students = array_merge( $students,
$course->getField( 'students' ) );
+ $oas = array_merge( $oas, $course->getField(
'online_ambs' ) );
+ $cas = array_merge( $cas, $course->getField(
'campus_ambs' ) );
+ $instructors = array_merge( $instructors,
$course->getField( 'instructors' ) );
+ $orgs[] = $course->getField( 'org_id' );
+ $courseIds[] = $course->getId();
+ }
+
+ $pageIds = EPArticles::singleton()->selectFields(
'page_id', array( 'course_id' => $courseIds ), array( 'DISTINCT' ) );
+ $pageIds = array_unique( $pageIds );
+
+ $students = array_unique( $students );
+ $oas = array_unique( $oas );
+ $cas = array_unique( $cas );
+ $instructors = array_unique( $instructors );
+ $orgs = array_unique( $orgs );
+
+ $term = array(
+ 'courses' => count( $courses ),
+ 'students' => count( $students ),
+ 'instructors' => count( $instructors ),
+ 'oas' => count( $oas ),
+ 'cas' => count( $cas ),
+ 'orgs' => count( $orgs ),
+ 'articles' => count( $pageIds ),
+ );
+
+ $terms[$termName] = $term;
+ }
+
+ return $terms;
+ }
+
+ protected function msgTxt() {
+ $args = func_get_args();
+ array_unshift( $args, $this->prefixKey( array_shift( $args ) )
);
+ return call_user_func_array( array( $this, 'msg' ), $args );
+ }
+
+ protected function prefixKey( $key ) {
+ return 'ep-' . strtolower( $this->mName ) . '-' . $key;
+ }
+
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs