r106863 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106862‎ | r106863 | r106864 >
Date:21:23, 20 December 2011
Author:jeroendedauw
Status:deferred
Tags:educationprogram 
Comment:
work on term management
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPStudentPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEPFormPage.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEditTerm.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialTerms.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialEPFormPage.php
@@ -116,7 +116,7 @@
117117 }
118118 }
119119 else {
120 - $object = $c::selectRow( null, array( 'name' => $this->subPage ) );
 120+ $object = $c::selectRow( null, $this->getTitleConditions() );
121121 }
122122
123123 if ( $object === false ) {
@@ -182,6 +182,17 @@
183183 protected function getNewData() {
184184 return array( 'name' => $this->getRequest()->getVal( 'newname' ) );
185185 }
 186+
 187+ /**
 188+ * Get the query conditions to obtain the item based on the page title.
 189+ *
 190+ * @since 0.1
 191+ *
 192+ * @return array
 193+ */
 194+ protected function getTitleConditions() {
 195+ return array( 'name' => $this->subPage );
 196+ }
186197
187198 /**
188199 * (non-PHPdoc)
Index: trunk/extensions/EducationProgram/specials/SpecialTerms.php
@@ -116,7 +116,7 @@
117117 $select->addOptions( EPCourse::getCourseOptions( $courses ) );
118118 $out->addHTML( $select->getHTML() );
119119
120 - $out->addHTML( Xml::inputLabel( wfMsg( 'ep-terms-newyear' ), 'newyear', 'newyear' ) );
 120+ $out->addHTML( ' ' . Xml::inputLabel( wfMsg( 'ep-terms-newyear' ), 'newyear', 'newyear' ) );
121121
122122 $out->addHTML( ' ' . Html::input(
123123 'addnewterm',
Index: trunk/extensions/EducationProgram/specials/SpecialEditTerm.php
@@ -1 +1,77 @@
22 <?php
 3+
 4+/**
 5+ * Adittion and modification interface for terms.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file SpecialEditTerm.php
 10+ * @ingroup EducationProgram
 11+ *
 12+ * @licence GNU GPL v3 or later
 13+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 14+ */
 15+class SpecialEditTerm extends SpecialEPFormPage {
 16+
 17+ /**
 18+ * Constructor.
 19+ *
 20+ * @since 0.1
 21+ */
 22+ public function __construct() {
 23+ parent::__construct( 'EditTerm', 'epmentor', 'EPTerm', 'Terms' );
 24+ }
 25+
 26+ /**
 27+ * (non-PHPdoc)
 28+ * @see SpecialEPFormPage::getFormFields()
 29+ * @return array
 30+ */
 31+ protected function getFormFields() {
 32+ $fields = parent::getFormFields();
 33+
 34+ $courseOptions = EPCourse::getCourseOptions( EPCourse::getEditableCourses( $this->getUser() ) );
 35+
 36+ $fields['course_id'] = array (
 37+ 'type' => 'select',
 38+ 'label-message' => 'ep-term-edit-course',
 39+ 'required' => true,
 40+ 'options' => $courseOptions,
 41+ 'validation-callback' => function ( $value, array $alldata = null ) use ( $courseOptions ) {
 42+ return in_array( (int)$value, array_values( $courseOptions ) ) ? true : wfMsg( 'ep-term-invalid-course' );
 43+ },
 44+ 'default' => array_shift( $courseOptions )
 45+ );
 46+
 47+ $fields['year'] = array (
 48+ 'type' => 'text',
 49+ 'label-message' => 'ep-term-edit-year',
 50+ 'required' => true,
 51+ 'validation-callback' => function ( $value, array $alldata = null ) {
 52+ return ctype_digit( $value ) ? true : wfMsg( 'ep-term-invalid-year' );
 53+ },
 54+ );
 55+
 56+ return $this->processFormFields( $fields );
 57+ }
 58+
 59+ /**
 60+ * (non-PHPdoc)
 61+ * @see SpecialEPFormPage::getTitleConditions()
 62+ */
 63+ protected function getTitleConditions() {
 64+ return array( 'id' => $this->subPage );
 65+ }
 66+
 67+ /**
 68+ * (non-PHPdoc)
 69+ * @see SpecialEPFormPage::getNewData()
 70+ */
 71+ protected function getNewData() {
 72+ return array(
 73+ 'course_id' => $this->getRequest()->getVal( 'newcourse' ),
 74+ 'year' => $this->getRequest()->getVal( 'newyear' ),
 75+ );
 76+ }
 77+
 78+}
Index: trunk/extensions/EducationProgram/includes/EPStudentPager.php
@@ -54,9 +54,9 @@
5555
5656 /**
5757 * (non-PHPdoc)
58 - * @see TablePager::formatValue()
 58+ * @see EPPager::getFormattedValue()
5959 */
60 - public function formatValue( $name, $value ) {
 60+ protected function getFormattedValue( $name, $value ) {
6161 switch ( $name ) {
6262 case '': // TODO
6363 $value = $value;
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -124,6 +124,11 @@
125125 'ep-course-invalid-description' => 'This description is to short. It needs to be at least contain $1 {{PLURAL:$1|character|characters}}.',
126126 'ep-course-invalid-org' => 'This institution does not exist',
127127
 128+ // Special:EditTerm
 129+ 'editterm-add-legend' => 'Add term',
 130+ 'ep-term-edit-legend' => 'Edit term',
 131+ 'ep-term-edit-year' => 'Year',
 132+ 'ep-term-edit-course' => 'Course',
128133 );
129134
130135 /** Message documentation (Message documentation)

Status & tagging log