r110710 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110709‎ | r110710 | r110711 >
Date:22:53, 4 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
get rid of duplicate code and added min width
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPCAPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOAPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialAmbassadorProfile.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialAmbassadorProfile.php
@@ -70,9 +70,9 @@
7171 'default' => $ambassador->getField( 'bio' ),
7272 );
7373
74 - $lang = $this->getLanguage();
75 -
76 - $prefix = $this->getMsgPrefix();
 74+// $lang = $this->getLanguage();
 75+//
 76+// $prefix = $this->getMsgPrefix();
7777 $fields['photo'] = array(
7878 'type' => 'text',
7979 'label-message' => $this->getMsgPrefix() . 'profile-photo',
Index: trunk/extensions/EducationProgram/includes/EPCAPager.php
@@ -11,7 +11,7 @@
1212 * @licence GNU GPL v3 or later
1313 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
1414 */
15 -class EPCAPager extends EPPager {
 15+class EPCAPager extends EPOAPager {
1616 /**
1717 * Constructor.
1818 *
@@ -25,18 +25,6 @@
2626
2727 /**
2828 * (non-PHPdoc)
29 - * @see EPPager::getFields()
30 - */
31 - public function getFields() {
32 - return array(
33 - 'photo',
34 - 'user_id',
35 - 'bio',
36 - );
37 - }
38 -
39 - /**
40 - * (non-PHPdoc)
4129 * @see TablePager::getRowClass()
4230 */
4331 function getRowClass( $row ) {
@@ -51,91 +39,4 @@
5240 return 'TablePager ep-cas';
5341 }
5442
55 - /**
56 - * (non-PHPdoc)
57 - * @see EPPager::getFormattedValue()
58 - */
59 - protected function getFormattedValue( $name, $value ) {
60 - switch ( $name ) {
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 - 'width' => '200px',
86 - )
87 - );
88 - break;
89 - }
90 - }
91 - }
92 - }
93 - break;
94 - case 'user_id':
95 - $ca = $this->currentObject;
96 - $value = Linker::userLink( $value, $ca->getName() ) . Linker::userToolLinks( $value, $ca->getName() );
97 - break;
98 - case 'bio':
99 - $value = $this->getOutput()->parseInline( $value );
100 - break;
101 - case '_courses':
102 - $oa = $this->currentObject;
103 - $value = $this->getLanguage()->listToText( array_map(
104 - function( EPCourse $course ) {
105 - return $course->getLink();
106 - },
107 - $oa->getCoursesWithState( 'current', 'name' )
108 - ) );
109 - break;
110 - }
111 -
112 - return $value;
113 - }
114 -
115 - /**
116 - * (non-PHPdoc)
117 - * @see EPPager::getSortableFields()
118 - */
119 - protected function getSortableFields() {
120 - return array(
121 - );
122 - }
123 -
124 - /**
125 - * (non-PHPdoc)
126 - * @see EPPager::hasActionsColumn()
127 - */
128 - protected function hasActionsColumn() {
129 - return false;
130 - }
131 -
132 - /**
133 - * (non-PHPdoc)
134 - * @see EPPager::getFieldNames()
135 - */
136 - public function getFieldNames() {
137 - $fields = parent::getFieldNames();
138 - $fields['_courses'] = 'courses';
139 - return $fields;
140 - }
141 -
14243 }
Index: trunk/extensions/EducationProgram/includes/EPOAPager.php
@@ -12,6 +12,7 @@
1313 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
1414 */
1515 class EPOAPager extends EPPager {
 16+
1617 /**
1718 * Constructor.
1819 *
@@ -51,6 +52,16 @@
5253 return 'TablePager ep-oas';
5354 }
5455
 56+ function getCellAttrs( $field, $value ) {
 57+ $attr = parent::getCellAttrs( $field, $value );
 58+
 59+ if ( in_array( $field, array( 'user_id', '_courses' ) ) ) {
 60+ $attr['style'] = 'min-width: 200px';
 61+ }
 62+
 63+ return $attr;
 64+ }
 65+
5566 /**
5667 * (non-PHPdoc)
5768 * @see EPPager::getFormattedValue()

Status & tagging log