Index: trunk/extensions/EducationProgram/specials/SpecialOAs.php |
— | — | @@ -34,12 +34,10 @@ |
35 | 35 | |
36 | 36 | if ( $this->subPage === '' ) { |
37 | 37 | $this->displayNavigation(); |
38 | | - // TODO |
39 | | - // EPMentor::displayPager( $this->getContext() ); |
| 38 | + EPOA::displayPager( $this->getContext() ); |
40 | 39 | } |
41 | 40 | else { |
42 | | - // TODO |
43 | | - // $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Institution', $this->subPage )->getLocalURL() ); |
| 41 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'OnlineAmbassador', $this->subPage )->getLocalURL() ); |
44 | 42 | } |
45 | 43 | } |
46 | 44 | |
Index: trunk/extensions/EducationProgram/specials/SpecialCAs.php |
— | — | @@ -34,12 +34,10 @@ |
35 | 35 | |
36 | 36 | if ( $this->subPage === '' ) { |
37 | 37 | $this->displayNavigation(); |
38 | | - // TODO |
39 | | - // EPMentor::displayPager( $this->getContext() ); |
| 38 | + EPCA::displayPager( $this->getContext() ); |
40 | 39 | } |
41 | 40 | else { |
42 | | - // TODO |
43 | | - // $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Institution', $this->subPage )->getLocalURL() ); |
| 41 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'CampusAmbassador', $this->subPage )->getLocalURL() ); |
44 | 42 | } |
45 | 43 | } |
46 | 44 | |
Index: trunk/extensions/EducationProgram/includes/EPOAPager.php |
— | — | @@ -29,8 +29,9 @@ |
30 | 30 | */ |
31 | 31 | public function getFields() { |
32 | 32 | return array( |
33 | | - 'id', |
| 33 | + 'photo', |
34 | 34 | 'user_id', |
| 35 | + 'bio', |
35 | 36 | ); |
36 | 37 | } |
37 | 38 | |
— | — | @@ -56,15 +57,45 @@ |
57 | 58 | */ |
58 | 59 | protected function getFormattedValue( $name, $value ) { |
59 | 60 | switch ( $name ) { |
60 | | - case 'id': |
61 | | - $value = $value; |
| 61 | + case 'photo': |
| 62 | + $title = Title::newFromText( $value, NS_FILE ); |
| 63 | + $value = ''; |
| 64 | + |
| 65 | + if ( is_object( $title ) ) { |
| 66 | + $api = new ApiMain( new FauxRequest( array( |
| 67 | + 'action' => 'query', |
| 68 | + 'format' => 'json', |
| 69 | + 'prop' => 'imageinfo', |
| 70 | + 'iiprop' => 'url', |
| 71 | + 'titles' => $title->getFullText(), |
| 72 | + 'iiurlwidth' => 200 |
| 73 | + ), true ), true ); |
| 74 | + |
| 75 | + $api->execute(); |
| 76 | + $result = $api->getResultData(); |
| 77 | + |
| 78 | + if ( array_key_exists( 'query', $result ) && array_key_exists( 'pages', $result['query'] ) ) { |
| 79 | + foreach ( $result['query']['pages'] as $page ) { |
| 80 | + foreach ( $page['imageinfo'] as $imageInfo ) { |
| 81 | + $value = Html::element( |
| 82 | + 'img', |
| 83 | + array( |
| 84 | + 'src' => $imageInfo['thumburl'] |
| 85 | + ) |
| 86 | + ); |
| 87 | + break; |
| 88 | + } |
| 89 | + } |
| 90 | + } |
| 91 | + } |
62 | 92 | break; |
63 | 93 | case 'user_id': |
64 | | - $user = User::newFromId( $value ); |
65 | | - $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName(); |
66 | | - |
67 | | - $value = Linker::userLink( $value, $name ) . Linker::userToolLinks( $value, $name ); |
| 94 | + $oa = EPOA::newFromUserId( $value ); |
| 95 | + $value = Linker::userLink( $value, $oa->getName() ) . Linker::userToolLinks( $value, $oa->getName() ); |
68 | 96 | break; |
| 97 | + case 'bio': |
| 98 | + $value = $this->getOutput()->parseInline( $value ); |
| 99 | + break; |
69 | 100 | } |
70 | 101 | |
71 | 102 | return $value; |
— | — | @@ -76,7 +107,6 @@ |
77 | 108 | */ |
78 | 109 | protected function getSortableFields() { |
79 | 110 | return array( |
80 | | - 'id', |
81 | 111 | ); |
82 | 112 | } |
83 | 113 | |
Index: trunk/extensions/EducationProgram/includes/EPCA.php |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | * @param array $conditions |
52 | 52 | */ |
53 | 53 | public static function displayPager( IContextSource $context, array $conditions = array() ) { |
54 | | - $pager = new EPOAPager( $context, $conditions ); |
| 54 | + $pager = new EPCAPager( $context, $conditions ); |
55 | 55 | |
56 | 56 | if ( $pager->getNumRows() ) { |
57 | 57 | $context->getOutput()->addHTML( |
Index: trunk/extensions/EducationProgram/includes/EPCAPager.php |
— | — | @@ -29,8 +29,9 @@ |
30 | 30 | */ |
31 | 31 | public function getFields() { |
32 | 32 | return array( |
33 | | - 'id', |
| 33 | + 'photo', |
34 | 34 | 'user_id', |
| 35 | + 'bio', |
35 | 36 | ); |
36 | 37 | } |
37 | 38 | |
— | — | @@ -56,15 +57,45 @@ |
57 | 58 | */ |
58 | 59 | protected function getFormattedValue( $name, $value ) { |
59 | 60 | switch ( $name ) { |
60 | | - case 'id': |
61 | | - $value = $value; |
| 61 | + case 'photo': |
| 62 | + $title = Title::newFromText( $value, NS_FILE ); |
| 63 | + $value = ''; |
| 64 | + |
| 65 | + if ( is_object( $title ) ) { |
| 66 | + $api = new ApiMain( new FauxRequest( array( |
| 67 | + 'action' => 'query', |
| 68 | + 'format' => 'json', |
| 69 | + 'prop' => 'imageinfo', |
| 70 | + 'iiprop' => 'url', |
| 71 | + 'titles' => $title->getFullText(), |
| 72 | + 'iiurlwidth' => 200 |
| 73 | + ), true ), true ); |
| 74 | + |
| 75 | + $api->execute(); |
| 76 | + $result = $api->getResultData(); |
| 77 | + |
| 78 | + if ( array_key_exists( 'query', $result ) && array_key_exists( 'pages', $result['query'] ) ) { |
| 79 | + foreach ( $result['query']['pages'] as $page ) { |
| 80 | + foreach ( $page['imageinfo'] as $imageInfo ) { |
| 81 | + $value = Html::element( |
| 82 | + 'img', |
| 83 | + array( |
| 84 | + 'src' => $imageInfo['thumburl'] |
| 85 | + ) |
| 86 | + ); |
| 87 | + break; |
| 88 | + } |
| 89 | + } |
| 90 | + } |
| 91 | + } |
62 | 92 | break; |
63 | 93 | case 'user_id': |
64 | | - $user = User::newFromId( $value ); |
65 | | - $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName(); |
66 | | - |
67 | | - $value = Linker::userLink( $value, $name ) . Linker::userToolLinks( $value, $name ); |
| 94 | + $oa = EPOA::newFromUserId( $value ); |
| 95 | + $value = Linker::userLink( $value, $oa->getName() ) . Linker::userToolLinks( $value, $oa->getName() ); |
68 | 96 | break; |
| 97 | + case 'bio': |
| 98 | + $value = $this->getOutput()->parseInline( $value ); |
| 99 | + break; |
69 | 100 | } |
70 | 101 | |
71 | 102 | return $value; |
— | — | @@ -76,7 +107,6 @@ |
77 | 108 | */ |
78 | 109 | protected function getSortableFields() { |
79 | 110 | return array( |
80 | | - 'id', |
81 | 111 | ); |
82 | 112 | } |
83 | 113 | |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -233,10 +233,14 @@ |
234 | 234 | 'epstudentpager-no' => 'No', |
235 | 235 | |
236 | 236 | // Campus ambassador pager |
237 | | - 'eppager-header-user-id' => 'User', |
| 237 | + 'epcapager-header-photo' => 'Photo', |
| 238 | + 'epcapager-header-user-id' => 'User', |
| 239 | + 'epcapager-header-bio' => 'Profile', |
238 | 240 | |
239 | 241 | // Online ambassador pager |
240 | | - 'epstudentpager-header-user-id' => 'User', |
| 242 | + 'epoapager-header-photo' => 'Photo', |
| 243 | + 'epoapager-header-user-id' => 'User', |
| 244 | + 'epoapager-header-bio' => 'Profile', |
241 | 245 | |
242 | 246 | // Institution editing |
243 | 247 | 'editinstitution-text' => 'Enter the institution details below and click submit to save your changes.', |