r107217 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107216‎ | r107217 | r107218 >
Date:20:02, 24 December 2011
Author:jeroendedauw
Status:ok
Tags:educationprogram 
Comment:
initial work on showing item summaries
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEPPage.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialInstitution.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialInstitution.php
@@ -55,7 +55,7 @@
5656 }
5757 }
5858 else {
59 - $this->displayInfo( $org );
 59+ $this->displaySummary( $org );
6060
6161 $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-institution-courses' ) ) );
6262
@@ -65,16 +65,22 @@
6666 }
6767
6868 /**
69 - * Display the orgs info.
70 - *
 69+ * Gets the summary data.
 70+ *
7171 * @since 0.1
72 - *
 72+ *
7373 * @param EPOrg $org
 74+ *
 75+ * @return array
7476 */
75 - protected function displayInfo( EPOrg $org ) {
76 - $out = $this->getOutput();
77 -
78 -
 77+ protected function getSummaryData( EPDBObject $org ) {
 78+ $stats = array();
 79+
 80+ $stats['name'] = $org->getField( 'name' );
 81+ $stats['city'] = $org->getField( 'city' );
 82+ $stats['country'] = $org->getField( 'country' );
 83+
 84+ return $stats;
7985 }
8086
8187 }
Index: trunk/extensions/EducationProgram/specials/SpecialEPPage.php
@@ -166,5 +166,60 @@
167167
168168 return $items;
169169 }
 170+
 171+ /**
 172+ * Display the summary data.
 173+ *
 174+ * @since 0.1
 175+ *
 176+ * @param EPDBObject $item
 177+ * @param boolean $collapsed
 178+ */
 179+ protected function displaySummary( EPDBObject $item, $collapsed = true ) {
 180+ $out = $this->getOutput();
 181+
 182+ $class = 'wikitable ep-summary mw-collapsible';
 183+
 184+ if ( $collapsed ) {
 185+ $class.= ' mw-collapsed';
 186+ }
 187+
 188+ $out->addHTML( Html::openElement( 'table', array( 'class' => $class ) ) );
 189+
 190+ $out->addHTML( '<tr>' . Html::element( 'th', array( 'colspan' => 2 ), wfMsg( 'ep-item-summary' ) ) . '</tr>' );
 191+
 192+ foreach ( $this->getSummaryData( $item ) as $stat => $value ) {
 193+ $out->addHTML( '<tr>' );
170194
 195+ $out->addHTML( Html::element(
 196+ 'th',
 197+ array( 'class' => 'ep-summary-name' ),
 198+ wfMsg( strtolower( get_called_class() ) . '-summary-' . $stat )
 199+ ) );
 200+
 201+ $out->addHTML( Html::element(
 202+ 'td',
 203+ array( 'class' => 'ep-summary-value' ),
 204+ $value
 205+ ) );
 206+
 207+ $out->addHTML( '</tr>' );
 208+ }
 209+
 210+ $out->addHTML( Html::closeElement( 'table' ) );
 211+ }
 212+
 213+ /**
 214+ * Gets the summary data.
 215+ *
 216+ * @since 0.1
 217+ *
 218+ * @param EPDBObject $item
 219+ *
 220+ * @return array
 221+ */
 222+ protected function getSummaryData( EPDBObject $item ) {
 223+ return array();
 224+ }
 225+
171226 }
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -156,6 +156,9 @@
157157 'ep-institution-create' => 'There is no institution with name "$1" yet, but you can create it.',
158158 'ep-institution-title' => 'Institution: $1',
159159 'ep-institution-courses' => 'Courses',
 160+ 'specialinstitution-summary-name' => 'Name',
 161+ 'specialinstitution-summary-city' => 'City',
 162+ 'specialinstitution-summary-country' => 'Country',
160163
161164 // Special:Course
162165 'ep-course-title' => 'Course: $1',
@@ -174,6 +177,9 @@
175178 'ep-nav-courses' => 'Courses list',
176179 'ep-nav-terms' => 'Terms list',
177180 'ep-nav-mycourses' => 'My courses',
 181+
 182+ // Misc
 183+ 'ep-item-summary' => 'Summary',
178184 );
179185
180186 /** Message documentation (Message documentation)

Status & tagging log