r106955 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106954‎ | r106955 | r106956 >
Date:16:22, 21 December 2011
Author:jeroendedauw
Status:deferred
Tags:educationprogram 
Comment:
some initial work on control and navigation links in pagers, will follow up later with the rest
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrgPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPPager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php
@@ -108,5 +108,22 @@
109109 ),
110110 );
111111 }
 112+
 113+ /**
 114+ * (non-PHPdoc)
 115+ * @see EPPager::getControlLinks()
 116+ */
 117+ protected function getControlLinks( EPDBObject $item ) {
 118+ $links = parent::getControlLinks( $item );
 119+
 120+ $links[] = $value = Linker::linkKnown(
 121+ SpecialPage::getTitleFor( 'EditInstitution', $item->getField( 'name' ) ),
 122+ wfMsg( 'edit' )
 123+ );
 124+
 125+ // TODO
 126+
 127+ return $links;
 128+ }
112129
113130 }
Index: trunk/extensions/EducationProgram/includes/EPPager.php
@@ -106,8 +106,32 @@
107107 */
108108 function formatRow( $row ) {
109109 $c = $this->className; // Yeah, this is needed in PHP 5.3 >_>
110 - $this->currentReview = $c::newFromDBResult( $row );
111 - return parent::formatRow( $row );
 110+ $this->currentObject = $c::newFromDBResult( $row );
 111+
 112+ $cells = array();
 113+
 114+ foreach ( $this->getFieldNames() as $field => $name ) {
 115+ $value = isset( $row->$field ) ? $row->$field : null;
 116+ $formatted = strval( $this->formatValue( $field, $value ) );
 117+
 118+ if ( $formatted == '' ) {
 119+ $formatted = ' ';
 120+ }
 121+
 122+ $cells[] = Html::rawElement( 'td', $this->getCellAttrs( $field, $value ), $formatted );
 123+ }
 124+
 125+ $links = $this->getControlLinks( $this->currentObject );
 126+
 127+ if ( count( $links ) > 0 ) {
 128+ $cells[] = Html::rawElement(
 129+ 'td',
 130+ $this->getCellAttrs( $field, $value ),
 131+ Html::rawElement( 'p', array(), $this->getLanguage()->pipeList( $links ) )
 132+ );
 133+ }
 134+
 135+ return Html::rawElement( 'tr', $this->getRowAttrs( $row ), implode( '', $cells ) ) . "\n";
112136 }
113137
114138 /**
@@ -334,11 +358,26 @@
335359 /**
336360 * Similar to TablePager::formatValue, but passes along the name of the field without prefix.
337361 *
 362+ * @since 0.1
 363+ *
338364 * @param string $name
339365 * @param string $value
340366 *
341367 * @return string
342368 */
343369 protected abstract function getFormattedValue( $name, $value );
 370+
 371+ /**
 372+ * Returns a list of (escaped, html) links to add in an adittional column.
 373+ *
 374+ * @since 0.1
 375+ *
 376+ * @param EPDBObject $item
 377+ *
 378+ * @return array
 379+ */
 380+ protected function getControlLinks( EPDBObject $item ) {
 381+ return array();
 382+ }
344383
345384 }
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -135,7 +135,7 @@
136136
137137 // Special:EditTerm
138138 'editterm-add-legend' => 'Add term',
139 - 'ep-term-edit-legend' => 'Edit term',
 139+ 'editterm-edit-legend' => 'Edit term',
140140 'ep-term-edit-year' => 'Year',
141141 'ep-term-edit-course' => 'Course',
142142 'ep-term-edit-start' => 'Start date',

Follow-up revisions

RevisionCommit summaryAuthorDate
r106958Follow up to r106955; added hack to have a colum for the links and added edit...jeroendedauw17:12, 21 December 2011

Status & tagging log