r108914 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108913‎ | r108914 | r108915 >
Date:16:07, 14 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
fix a bunch of todos
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrg.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPTerm.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEditCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEditTerm.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialTerm.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialEducationProgram.php
@@ -34,7 +34,7 @@
3535
3636 $out = $this->getOutput();
3737
38 - // TODO: AUTH
 38+ // TODO
3939 }
4040
4141 }
Index: trunk/extensions/EducationProgram/specials/SpecialEditCourse.php
@@ -40,7 +40,7 @@
4141 } ,
4242 );
4343
44 - $orgOptions = EPOrg::getOrgOptions( array() ); // TODO
 44+ $orgOptions = EPOrg::getOrgOptions();
4545
4646 $fields['org_id'] = array (
4747 'type' => 'select',
Index: trunk/extensions/EducationProgram/specials/SpecialTerm.php
@@ -109,7 +109,7 @@
110110 htmlspecialchars( $course )
111111 );
112112
113 - $stats['year'] = htmlspecialchars( $term->getField( 'year' ) ); // TODO: how to properly i18n this?
 113+ $stats['year'] = htmlspecialchars( $this->getLanguage()->formatNum( $term->getField( 'year' ), true ) );
114114 $stats['start'] = htmlspecialchars( $this->getLanguage()->timeanddate( $term->getField( 'start' ), true ) );
115115 $stats['end'] = htmlspecialchars( $this->getLanguage()->timeanddate( $term->getField( 'end' ), true ) );
116116
Index: trunk/extensions/EducationProgram/specials/SpecialEditTerm.php
@@ -32,7 +32,7 @@
3333 protected function getFormFields() {
3434 $fields = parent::getFormFields();
3535
36 - $courseOptions = EPCourse::getCourseOptions( array() ); // TODO
 36+ $courseOptions = EPCourse::getCourseOptions();
3737
3838 $fields['course_id'] = array (
3939 'type' => 'select',
Index: trunk/extensions/EducationProgram/includes/EPOrg.php
@@ -171,13 +171,17 @@
172172 *
173173 * @since 0.1
174174 *
175 - * @param array $orgs
 175+ * @param array|null $orgs
176176 *
177177 * @return array
178178 */
179 - public static function getOrgOptions( array /* EPOrg */ $orgs ) {
 179+ public static function getOrgOptions( array /* EPOrg */ $orgs = null ) {
180180 $options = array();
181181
 182+ if ( is_null( $orgs ) ) {
 183+ $orgs = EPOrg::select( array( 'name', 'id' ) );
 184+ }
 185+
182186 foreach ( $orgs as /* EPOrg */ $org ) {
183187 $options[$org->getField( 'name' )] = $org->getId();
184188 }
Index: trunk/extensions/EducationProgram/includes/EPTerm.php
@@ -364,7 +364,7 @@
365365 array_key_exists( 'course', $args ) ? $args['course'] : false
366366 );
367367
368 - $select->addOptions( EPCourse::getCourseOptions( array() ) ); // TODO
 368+ $select->addOptions( EPCourse::getCourseOptions() );
369369 $out->addHTML( $select->getHTML() );
370370
371371 $out->addHTML( ' ' . Xml::inputLabel( wfMsg( 'ep-terms-newyear' ), 'newyear', 'newyear', 10 ) );
@@ -392,9 +392,7 @@
393393 * @param array $args
394394 */
395395 public static function displayAddNewRegion( IContextSource $context, array $args = array() ) {
396 - $courses = array(); // TODO
397 -
398 - if ( count( $courses ) > 0 ) {
 396+ if ( EPCourse::has() ) {
399397 EPTerm::displayAddNewControl( $context, $args );
400398 }
401399 elseif ( $context->getUser()->isAllowed( 'ep-course' ) ) {
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -182,13 +182,17 @@
183183 *
184184 * @since 0.1
185185 *
186 - * @param array $courses
 186+ * @param array|null $courses
187187 *
188188 * @return array
189189 */
190 - public static function getCourseOptions( array /* EPCourse */ $courses ) {
 190+ public static function getCourseOptions( array /* EPCourse */ $courses = null ) {
191191 $options = array();
192192
 193+ if ( is_null( $courses ) ) {
 194+ $courses = EPCourse::select( array( 'name', 'id' ) );
 195+ }
 196+
193197 foreach ( $courses as /* EPCourse */ $course ) {
194198 $options[$course->getField( 'name' )] = $course->getId();
195199 }
@@ -238,7 +242,7 @@
239243 array_key_exists( 'org', $args ) ? $args['org'] : false
240244 );
241245
242 - $select->addOptions( EPOrg::getOrgOptions( array() ) ); // TODO
 246+ $select->addOptions( EPOrg::getOrgOptions() );
243247 $out->addHTML( $select->getHTML() );
244248
245249 $out->addHTML( ' ' );
@@ -276,15 +280,10 @@
277281 * @param array $args
278282 */
279283 public static function displayAddNewRegion( IContextSource $context, array $args = array() ) {
280 - $orgs = array(); // TODO
281 -
282 - if ( count( $orgs ) > 0 ) {
 284+ if ( EPOrg::has() ) {
283285 EPCourse::displayAddNewControl( $context, $args );
284286 }
285 - elseif ( $context->getUser()->isAllowed( 'epadmin' ) ) {
286 - $context->getOutput()->addWikiMsg( 'ep-courses-noorgs' );
287 - }
288 - elseif ( $context->getUser()->isAllowed( 'epmentor' ) ) {
 287+ elseif ( $context->getUser()->isAllowed( 'ep-org' ) ) {
289288 $context->getOutput()->addWikiMsg( 'ep-courses-addorgfirst' );
290289 }
291290 }

Status & tagging log