r110705 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110704‎ | r110705 | r110706 >
Date:21:38, 4 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on ambassador pagers
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCA.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCAPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOAPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialCAs.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialOAs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialOAs.php
@@ -34,12 +34,10 @@
3535
3636 if ( $this->subPage === '' ) {
3737 $this->displayNavigation();
38 - // TODO
39 - // EPMentor::displayPager( $this->getContext() );
 38+ EPOA::displayPager( $this->getContext() );
4039 }
4140 else {
42 - // TODO
43 - // $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Institution', $this->subPage )->getLocalURL() );
 41+ $this->getOutput()->redirect( SpecialPage::getTitleFor( 'OnlineAmbassador', $this->subPage )->getLocalURL() );
4442 }
4543 }
4644
Index: trunk/extensions/EducationProgram/specials/SpecialCAs.php
@@ -34,12 +34,10 @@
3535
3636 if ( $this->subPage === '' ) {
3737 $this->displayNavigation();
38 - // TODO
39 - // EPMentor::displayPager( $this->getContext() );
 38+ EPCA::displayPager( $this->getContext() );
4039 }
4140 else {
42 - // TODO
43 - // $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Institution', $this->subPage )->getLocalURL() );
 41+ $this->getOutput()->redirect( SpecialPage::getTitleFor( 'CampusAmbassador', $this->subPage )->getLocalURL() );
4442 }
4543 }
4644
Index: trunk/extensions/EducationProgram/includes/EPOAPager.php
@@ -29,8 +29,9 @@
3030 */
3131 public function getFields() {
3232 return array(
33 - 'id',
 33+ 'photo',
3434 'user_id',
 35+ 'bio',
3536 );
3637 }
3738
@@ -56,15 +57,45 @@
5758 */
5859 protected function getFormattedValue( $name, $value ) {
5960 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+ }
6292 break;
6393 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() );
6896 break;
 97+ case 'bio':
 98+ $value = $this->getOutput()->parseInline( $value );
 99+ break;
69100 }
70101
71102 return $value;
@@ -76,7 +107,6 @@
77108 */
78109 protected function getSortableFields() {
79110 return array(
80 - 'id',
81111 );
82112 }
83113
Index: trunk/extensions/EducationProgram/includes/EPCA.php
@@ -50,7 +50,7 @@
5151 * @param array $conditions
5252 */
5353 public static function displayPager( IContextSource $context, array $conditions = array() ) {
54 - $pager = new EPOAPager( $context, $conditions );
 54+ $pager = new EPCAPager( $context, $conditions );
5555
5656 if ( $pager->getNumRows() ) {
5757 $context->getOutput()->addHTML(
Index: trunk/extensions/EducationProgram/includes/EPCAPager.php
@@ -29,8 +29,9 @@
3030 */
3131 public function getFields() {
3232 return array(
33 - 'id',
 33+ 'photo',
3434 'user_id',
 35+ 'bio',
3536 );
3637 }
3738
@@ -56,15 +57,45 @@
5758 */
5859 protected function getFormattedValue( $name, $value ) {
5960 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+ }
6292 break;
6393 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() );
6896 break;
 97+ case 'bio':
 98+ $value = $this->getOutput()->parseInline( $value );
 99+ break;
69100 }
70101
71102 return $value;
@@ -76,7 +107,6 @@
77108 */
78109 protected function getSortableFields() {
79110 return array(
80 - 'id',
81111 );
82112 }
83113
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -233,10 +233,14 @@
234234 'epstudentpager-no' => 'No',
235235
236236 // 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',
238240
239241 // 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',
241245
242246 // Institution editing
243247 'editinstitution-text' => 'Enter the institution details below and click submit to save your changes.',

Status & tagging log