r98312 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98311‎ | r98312 | r98313 >
Date:14:37, 28 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added ContestChallange class
Modified paths:
  • /trunk/extensions/Contest/Contest.php (modified) (history)
  • /trunk/extensions/Contest/includes/Contest.class.php (modified) (history)
  • /trunk/extensions/Contest/includes/ContestChallange.php (added) (history)

Diff [purge]

Index: trunk/extensions/Contest/includes/Contest.class.php
@@ -1,11 +1,11 @@
22 <?php
33
44 /**
5 - * Abstract base class for representing objects that are stored in some DB table.
65 *
 6+ *
77 * @since 0.1
88 *
9 - * @file ContestDBObject.php
 9+ * @file Contest.class.php
1010 * @ingroup Contest
1111 *
1212 * @licence GNU GPL v3 or later
@@ -39,6 +39,8 @@
4040
4141 /**
4242 * Get a new instance of the class from an array.
 43+ * This method ought to be in the basic class and
 44+ * return a new static(), but this requires LSB/PHP>=5.3.
4345 *
4446 * @since 0.1
4547 *
@@ -150,9 +152,10 @@
151153 * @return array of ContestChallange
152154 */
153155 public function getChallanges() {
154 - // TODO
155 -
156 - return array();
 156+ return ContestChallange::s()->select(
 157+ null,
 158+ array( 'contest_id' => $this->getId() )
 159+ );
157160 }
158161
159162 }
\ No newline at end of file
Index: trunk/extensions/Contest/includes/ContestChallange.php
@@ -0,0 +1,103 @@
 2+<?php
 3+
 4+/**
 5+ * Contest challange object.
 6+ * Each contest (can) has a list of associated challanges.
 7+ *
 8+ * @since 0.1
 9+ *
 10+ * @file ContestChallange.php
 11+ * @ingroup Contest
 12+ *
 13+ * @licence GNU GPL v3 or later
 14+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 15+ */
 16+class ContestChallange extends ContestDBObject {
 17+
 18+ /**
 19+ * Method to get an instance so methods that ought to be static,
 20+ * but can't be due to PHP 5.2 not having LSB, can be called on
 21+ * it. This also allows easy identifying of code that needs to
 22+ * be changed once PHP 5.3 becomes an acceptable requirement.
 23+ *
 24+ * @since 0.1
 25+ *
 26+ * @return ContestDBObject
 27+ */
 28+ public static function s() {
 29+ static $instance = false;
 30+
 31+ if ( $instance === false ) {
 32+ $instance = new self( array() );
 33+ }
 34+
 35+ return $instance;
 36+ }
 37+
 38+ /**
 39+ * Get a new instance of the class from an array.
 40+ * This method ought to be in the basic class and
 41+ * return a new static(), but this requires LSB/PHP>=5.3.
 42+ *
 43+ * @since 0.1
 44+ *
 45+ * @param array $data
 46+ * @param boolean $loadDefaults
 47+ *
 48+ * @return ContestDBObject
 49+ */
 50+ public function newFromArray( array $data, $loadDefaults = false ) {
 51+ return new self( $data, $loadDefaults );
 52+ }
 53+
 54+ /**
 55+ * @see parent::getFieldTypes
 56+ *
 57+ * @since 0.1
 58+ *
 59+ * @return string
 60+ */
 61+ public function getDBTable() {
 62+ return 'contest_challanges';
 63+ }
 64+
 65+ /**
 66+ * @see parent::getFieldTypes
 67+ *
 68+ * @since 0.1
 69+ *
 70+ * @return string
 71+ */
 72+ protected function getFieldPrefix() {
 73+ return 'challange_';
 74+ }
 75+
 76+ /**
 77+ * @see parent::getFieldTypes
 78+ *
 79+ * @since 0.1
 80+ *
 81+ * @return array
 82+ */
 83+ protected function getFieldTypes() {
 84+ return array(
 85+ 'id' => 'id',
 86+ 'contest_id' => 'id',
 87+ 'text' => 'str',
 88+ );
 89+ }
 90+
 91+ /**
 92+ * @see parent::getDefaults
 93+ *
 94+ * @since 0.1
 95+ *
 96+ * @return array
 97+ */
 98+ public function getDefaults() {
 99+ return array(
 100+ 'text' => '',
 101+ );
 102+ }
 103+
 104+}
Property changes on: trunk/extensions/Contest/includes/ContestChallange.php
___________________________________________________________________
Added: svn:eol-style
1105 + native
Index: trunk/extensions/Contest/Contest.php
@@ -52,6 +52,9 @@
5353 $wgAutoloadClasses['ApiDeleteContest'] = dirname( __FILE__ ) . '/api/ApiDeleteContest.php';
5454
5555 $wgAutoloadClasses['Contest'] = dirname( __FILE__ ) . '/includes/Contest.class.php';
 56+$wgAutoloadClasses['ContestChallange'] = dirname( __FILE__ ) . '/includes/ContestChallange.php';
 57+$wgAutoloadClasses['ContestComment'] = dirname( __FILE__ ) . '/includes/ContestComment.php';
 58+$wgAutoloadClasses['ContestContestant'] = dirname( __FILE__ ) . '/includes/ContestContestant.php';
5659 $wgAutoloadClasses['ContestDBObject'] = dirname( __FILE__ ) . '/includes/ContestDBObject.php';
5760
5861 $wgAutoloadClasses['SpecialContest'] = dirname( __FILE__ ) . '/specials/SpecialContest.php';

Status & tagging log