Index: trunk/extensions/EducationProgram/specials/SpecialEPFormPage.php |
— | — | @@ -116,7 +116,7 @@ |
117 | 117 | } |
118 | 118 | } |
119 | 119 | else { |
120 | | - $object = $c::selectRow( null, array( 'name' => $this->subPage ) ); |
| 120 | + $object = $c::selectRow( null, $this->getTitleConditions() ); |
121 | 121 | } |
122 | 122 | |
123 | 123 | if ( $object === false ) { |
— | — | @@ -182,6 +182,17 @@ |
183 | 183 | protected function getNewData() { |
184 | 184 | return array( 'name' => $this->getRequest()->getVal( 'newname' ) ); |
185 | 185 | } |
| 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 | + } |
186 | 197 | |
187 | 198 | /** |
188 | 199 | * (non-PHPdoc) |
Index: trunk/extensions/EducationProgram/specials/SpecialTerms.php |
— | — | @@ -116,7 +116,7 @@ |
117 | 117 | $select->addOptions( EPCourse::getCourseOptions( $courses ) ); |
118 | 118 | $out->addHTML( $select->getHTML() ); |
119 | 119 | |
120 | | - $out->addHTML( Xml::inputLabel( wfMsg( 'ep-terms-newyear' ), 'newyear', 'newyear' ) ); |
| 120 | + $out->addHTML( ' ' . Xml::inputLabel( wfMsg( 'ep-terms-newyear' ), 'newyear', 'newyear' ) ); |
121 | 121 | |
122 | 122 | $out->addHTML( ' ' . Html::input( |
123 | 123 | 'addnewterm', |
Index: trunk/extensions/EducationProgram/specials/SpecialEditTerm.php |
— | — | @@ -1 +1,77 @@ |
2 | 2 | <?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 @@ |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * (non-PHPdoc) |
58 | | - * @see TablePager::formatValue() |
| 58 | + * @see EPPager::getFormattedValue() |
59 | 59 | */ |
60 | | - public function formatValue( $name, $value ) { |
| 60 | + protected function getFormattedValue( $name, $value ) { |
61 | 61 | switch ( $name ) { |
62 | 62 | case '': // TODO |
63 | 63 | $value = $value; |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -124,6 +124,11 @@ |
125 | 125 | 'ep-course-invalid-description' => 'This description is to short. It needs to be at least contain $1 {{PLURAL:$1|character|characters}}.', |
126 | 126 | 'ep-course-invalid-org' => 'This institution does not exist', |
127 | 127 | |
| 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', |
128 | 133 | ); |
129 | 134 | |
130 | 135 | /** Message documentation (Message documentation) |