r106958 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106957‎ | r106958 | r106959 >
Date:17:12, 21 December 2011
Author:jeroendedauw
Status:deferred
Tags:educationprogram 
Comment:
Follow up to r106955; added hack to have a colum for the links and added edit links
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPCoursePager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrgPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPTermPager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php
@@ -31,11 +31,14 @@
3232 * @see TablePager::getFieldNames()
3333 */
3434 public function getFieldNames() {
35 - return parent::getFieldNameList( array(
 35+ $fields = parent::getFieldNameList( array(
3636 'name',
3737 'city',
3838 'country',
39 - ) );
 39+ ) );
 40+
 41+ $fields[0] = ''; // This is a hack to get an extra colum for the control links.
 42+ return $fields;
4043 }
4144
4245 /**
Index: trunk/extensions/EducationProgram/includes/EPTermPager.php
@@ -31,13 +31,16 @@
3232 * @see TablePager::getFieldNames()
3333 */
3434 public function getFieldNames() {
35 - return parent::getFieldNameList( array(
 35+ $fields = parent::getFieldNameList( array(
3636 'id',
3737 'course_id',
3838 'year',
3939 'start',
4040 'end',
41 - ) );
 41+ ) );
 42+
 43+ $fields[0] = ''; // This is a hack to get an extra colum for the control links.
 44+ return $fields;
4245 }
4346
4447 /**
@@ -130,5 +133,22 @@
131134 ),
132135 );
133136 }
 137+
 138+ /**
 139+ * (non-PHPdoc)
 140+ * @see EPPager::getControlLinks()
 141+ */
 142+ protected function getControlLinks( EPDBObject $item ) {
 143+ $links = parent::getControlLinks( $item );
 144+
 145+ $links[] = $value = Linker::linkKnown(
 146+ SpecialPage::getTitleFor( 'EditTerm', $item->getId() ),
 147+ wfMsg( 'edit' )
 148+ );
 149+
 150+ // TODO
 151+
 152+ return $links;
 153+ }
134154
135155 }
Index: trunk/extensions/EducationProgram/includes/EPPager.php
@@ -111,7 +111,13 @@
112112 $cells = array();
113113
114114 foreach ( $this->getFieldNames() as $field => $name ) {
115 - $value = isset( $row->$field ) ? $row->$field : null;
 115+ if ( $field === 0 ) {
 116+ $value = $this->getLanguage()->pipeList( $this->getControlLinks( $this->currentObject ) );
 117+ }
 118+ else {
 119+ $value = isset( $row->$field ) ? $row->$field : null;
 120+ }
 121+
116122 $formatted = strval( $this->formatValue( $field, $value ) );
117123
118124 if ( $formatted == '' ) {
@@ -123,14 +129,6 @@
124130
125131 $links = $this->getControlLinks( $this->currentObject );
126132
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 -
135133 return Html::rawElement( 'tr', $this->getRowAttrs( $row ), implode( '', $cells ) ) . "\n";
136134 }
137135
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php
@@ -31,10 +31,13 @@
3232 * @see TablePager::getFieldNames()
3333 */
3434 public function getFieldNames() {
35 - return parent::getFieldNameList( array(
 35+ $fields = parent::getFieldNameList( array(
3636 'name',
3737 'org_id',
38 - ) );
 38+ ) );
 39+
 40+ $fields[0] = ''; // This is a hack to get an extra colum for the control links.
 41+ return $fields;
3942 }
4043
4144 /**
@@ -109,5 +112,22 @@
110113 ),
111114 );
112115 }
 116+
 117+ /**
 118+ * (non-PHPdoc)
 119+ * @see EPPager::getControlLinks()
 120+ */
 121+ protected function getControlLinks( EPDBObject $item ) {
 122+ $links = parent::getControlLinks( $item );
 123+
 124+ $links[] = $value = Linker::linkKnown(
 125+ SpecialPage::getTitleFor( 'EditCourse', $item->getField( 'name' ) ),
 126+ wfMsg( 'edit' )
 127+ );
 128+
 129+ // TODO
 130+
 131+ return $links;
 132+ }
113133
114134 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r106955some initial work on control and navigation links in pagers, will follow up l...jeroendedauw16:22, 21 December 2011

Status & tagging log