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

Revision: 114186
Author:   jeroendedauw
Date:     2012-03-19 21:16:19 +0000 (Mon, 19 Mar 2012)
Log Message:
-----------
work on special:student

Modified Paths:
--------------
    trunk/extensions/EducationProgram/EducationProgram.i18n.php
    trunk/extensions/EducationProgram/actions/ViewOrgAction.php
    trunk/extensions/EducationProgram/includes/EPCourse.php
    trunk/extensions/EducationProgram/includes/EPOrg.php
    trunk/extensions/EducationProgram/specials/SpecialCourses.php
    trunk/extensions/EducationProgram/specials/SpecialStudent.php

Modified: trunk/extensions/EducationProgram/EducationProgram.i18n.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-03-19 
21:09:37 UTC (rev 114185)
+++ trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-03-19 
21:16:19 UTC (rev 114186)
@@ -589,6 +589,7 @@
        'specialstudent-summary-first-enroll' => 'First enrollment',
        'specialstudent-summary-user' => 'User',
        'ep-student-courses' => 'Courses this student has enrolled in',
+       'ep-student-articles' => 'Articles this student is working on',
 
        // Special:Enroll
        'ep-enroll-title' => 'Enroll for $1 at $2',

Modified: trunk/extensions/EducationProgram/actions/ViewOrgAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/ViewOrgAction.php 2012-03-19 
21:09:37 UTC (rev 114185)
+++ trunk/extensions/EducationProgram/actions/ViewOrgAction.php 2012-03-19 
21:16:19 UTC (rev 114186)
@@ -45,7 +45,7 @@
 
                $out->addElement( 'h2', array(), wfMsg( 
'ep-institution-courses' ) );
 
-               EPCourse::displayPager( $this->getContext(), array( 'org_id' => 
$org->getId() ) );
+               $out->addHTML( EPCourse::displayPager( $this->getContext(), 
array( 'org_id' => $org->getId() ) ) );
 
                if ( $this->getUser()->isAllowed( 'ep-course' ) ) {
                        $out->addElement( 'h2', array(), wfMsg( 
'ep-institution-add-course' ) );

Modified: trunk/extensions/EducationProgram/includes/EPCourse.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPCourse.php     2012-03-19 
21:09:37 UTC (rev 114185)
+++ trunk/extensions/EducationProgram/includes/EPCourse.php     2012-03-19 
21:16:19 UTC (rev 114186)
@@ -45,7 +45,7 @@
         */
        protected $oas = false;
        
-               /**
+       /**
         * Field for caching the campus ambassaords.
         *
         * @since 0.1
@@ -259,26 +259,29 @@
         * @param boolean $readOnlyMode
         * @param string|false $filterPrefix
         */
-       public static function displayPager( IContextSource $context, array 
$conditions = array(), $readOnlyMode = false, $filterPrefix = false ) {
+       public static function getPager( IContextSource $context, array 
$conditions = array(), $readOnlyMode = false, $filterPrefix = false ) {
                $pager = new EPCoursePager( $context, $conditions, 
$readOnlyMode );
 
                if ( $filterPrefix !== false ) {
                        $pager->setFilterPrefix( $filterPrefix );
                }
+
+               $html = '';
                
                if ( $pager->getNumRows() ) {
-                       $context->getOutput()->addHTML(
+                       $html .=
                                $pager->getFilterControl() .
                                $pager->getNavigationBar() .
                                $pager->getBody() .
                                $pager->getNavigationBar() .
-                               $pager->getMultipleItemControl()
-                       );
+                               $pager->getMultipleItemControl();
                }
                else {
-                       $context->getOutput()->addHTML( 
$pager->getFilterControl( true ) );
-                       $context->getOutput()->addWikiMsg( 
'ep-courses-noresults' );
+                       $html .= $pager->getFilterControl( true );
+                       $html .= $context->msg( 'ep-courses-noresults' 
)->escaped();
                }
+
+               return $html;
        }
 
        /**

Modified: trunk/extensions/EducationProgram/includes/EPOrg.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPOrg.php        2012-03-19 
21:09:37 UTC (rev 114185)
+++ trunk/extensions/EducationProgram/includes/EPOrg.php        2012-03-19 
21:16:19 UTC (rev 114186)
@@ -210,7 +210,7 @@
                }
                else {
                        return $pager->getFilterControl( true ) .
-                               $context->msg( 'ep-institutions-noresults' );
+                               $context->msg( 'ep-institutions-noresults' 
)->escaped();
                }
        }
 

Modified: trunk/extensions/EducationProgram/specials/SpecialCourses.php
===================================================================
--- trunk/extensions/EducationProgram/specials/SpecialCourses.php       
2012-03-19 21:09:37 UTC (rev 114185)
+++ trunk/extensions/EducationProgram/specials/SpecialCourses.php       
2012-03-19 21:16:19 UTC (rev 114186)
@@ -35,8 +35,15 @@
 
                if ( $this->subPage === '' ) {
                        $this->displayNavigation();
-                       EPCourse::displayAddNewRegion( $this->getContext() );
-                       EPCourse::displayPager( $this->getContext() );
+
+                       $this->addCachedHTML(
+                               function( IContextSource $context ) {
+                                       return
+                                               EPCourse::getAddNewRegion( 
$context ) . // FIXME
+                                               EPCourse::getPager( $context );
+                               },
+                               $this->getContext()
+                       );
                }
                else {
                        $this->getOutput()->redirect( Title::newFromText( 
$this->subPage, EP_NS_COURSE )->getLocalURL() );

Modified: trunk/extensions/EducationProgram/specials/SpecialStudent.php
===================================================================
--- trunk/extensions/EducationProgram/specials/SpecialStudent.php       
2012-03-19 21:09:37 UTC (rev 114185)
+++ trunk/extensions/EducationProgram/specials/SpecialStudent.php       
2012-03-19 21:16:19 UTC (rev 114186)
@@ -59,34 +59,64 @@
                        }
                        else {
                                $out->setPageTitle( wfMsgExt( 
'ep-student-title', 'parsemag', $student->getName() ) );
+                               $this->addCachedHTML( array( $this, 
'getPageHTML' ), $student );
+                       }
 
-                               $this->addCachedHTML( array( $this, 
'getSummary' ), $student );
+                       $this->saveCache();
+               }
+       }
 
-                               $this->addCachedHTML( function( EPStudent 
$student ) {
-                                       $courseIds = array_map(
-                                               function( EPCourse $course ) {
-                                                       return $course->getId();
-                                               },
-                                               $student->getCourses( 'id' )
-                                       );
+       /**
+        * Builds the HTML for the page and returns it.
+        *
+        * @since 0.1
+        *
+        * @param EPStudent $student
+        *
+        * @return string
+        */
+       protected function getPageHTML( EPStudent $student ) {
+               $courseIds = array_map(
+                       function( EPCourse $course ) {
+                               return $course->getId();
+                       },
+                       $student->getCourses( 'id' )
+               );
 
-                                       $html = '';
+               $html = $this->getSummary( $student );
 
-                                       if ( empty( $courseIds ) ) {
-                                               // TODO: high
-                                       }
-                                       else {
-                                               $html .= Html::element( 'h2', 
array(), wfMsg( 'ep-student-courses' ) );
-                                               $html .= ''; // TODO
-                                                       // 
EPCourse::displayPager( $this->getContext(), array( 'id' => $courseIds ) );
-                                       }
+               if ( empty( $courseIds ) ) {
+                       // TODO: high
+               }
+               else {
+                       $html .= Html::element( 'h2', array(), wfMsg( 
'ep-student-courses' ) );
 
-                                       return $html;
-                               }, $student );
+                       $html .= EPCourse::getPager( $this->getContext(), 
array( 'id' => $courseIds ) );
+
+                       $pager = new EPArticleTable(
+                               $this->getContext(),
+                               array( 'user_id' => $this->getUser()->getId() ),
+                               array(
+                                       'course_id' => $courseIds,
+                                       'user_id' => $this->getUser()->getId(),
+                               )
+                       );
+
+                       $pager->setShowStudents( false );
+
+                       if ( $pager->getNumRows() ) {
+                               $html .= Html::element( 'h2', array(), wfMsg( 
'ep-student-articles' ) );
+
+                               $html .=
+                                       $pager->getFilterControl() .
+                                               $pager->getNavigationBar() .
+                                               $pager->getBody() .
+                                               $pager->getNavigationBar() .
+                                               
$pager->getMultipleItemControl();
                        }
+               }
 
-                       $this->saveCache();
-               }
+               return $html;
        }
 
        /**


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

Reply via email to