r98694 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98693‎ | r98694 | r98695 >
Date:17:29, 2 October 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on contest landing page
Modified paths:
  • /trunk/extensions/Contest/Contest.php (modified) (history)
  • /trunk/extensions/Contest/resources/contest.special.welcome.css (added) (history)
  • /trunk/extensions/Contest/specials/SpecialContest.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestSignup.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestWelcome.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/specials/SpecialContestWelcome.php
@@ -90,14 +90,26 @@
9191 $out = $this->getOutput();
9292
9393 foreach ( $contest->getChallanges() as /* ContestChallange */ $challange ) {
94 - $out->addHTML( Html::rawElement(
95 - 'fieldset',
 94+ $out->addHTML( '<fieldset>' );
 95+
 96+ $out->addHTML( Html::element( 'legend', array(), $challange->getField( 'title' ) ) );
 97+
 98+ $out->addHTML( '<div class="contest-challange">' );
 99+
 100+ $out->addHTML( Html::element(
 101+ 'button',
96102 array(
97 - 'data-contest-target' => $this->getSignupLink( $challange->getId() )
 103+ 'class' => 'contest-signup challange-signup',
 104+ 'data-contest-target' => $this->getSignupLink( $contest->getField( 'name' ), $challange->getId() )
98105 ),
99 - Html::element( 'legend', array(), $challange->getField( 'title' ) )
100 - . htmlspecialchars( $challange->getField( 'text' ) )
 106+ wfMsg( 'contest-welcome-signup' )
101107 ) );
 108+
 109+ $out->addHTML( Html::element( 'p', array(), $challange->getField( 'text' ) ) );
 110+
 111+ $out->addHTML( '</div>' );
 112+
 113+ $out->addHTML( '</fieldset>' );
102114 }
103115 }
104116
@@ -158,6 +170,10 @@
159171 * @return string
160172 */
161173 protected function getSignupLink( $contestName, $challangeId = false ) {
 174+ if ( $challangeId !== false ) {
 175+ $contestName .= '/' . $challangeId;
 176+ }
 177+
162178 $signupitle = SpecialPage::getTitleFor( 'ContestSignup', $contestName );
163179
164180 if ( $this->getUser()->isLoggedIn() ) {
Index: trunk/extensions/Contest/specials/SpecialContest.php
@@ -103,7 +103,15 @@
104104 return $stats;
105105 }
106106
107 - // TODO: list scores and comment counts as well
 107+ /**
 108+ * Show a paged list of the contestants foe this contest.
 109+ *
 110+ * @since 0.1
 111+ *
 112+ * @param Contest $contest
 113+ *
 114+ * TODO: list scores and comment counts as well
 115+ */
108116 protected function showContestants( Contest $contest ) {
109117 $out = $this->getOutput();
110118
Index: trunk/extensions/Contest/specials/SpecialContestSignup.php
@@ -77,11 +77,15 @@
7878 *
7979 * @since 0.1
8080 *
81 - * @param string $contestName
 81+ * @param string $subPage
8282 */
83 - protected function showPage( $contestName ) {
 83+ protected function showPage( $subPage ) {
8484 $out = $this->getOutput();
8585
 86+ $subPage = explode( '/', $subPage );
 87+ $contestName = $subPage[0];
 88+ $challangeId = count( $subPage ) > 1 ? $subPage[1] : false;
 89+
8690 $contest = Contest::s()->selectRow( null, array( 'name' => $contestName ) );
8791
8892 if ( $contest === false ) {
@@ -92,7 +96,7 @@
9397 else {
9498 switch ( $contest->getField( 'status' ) ) {
9599 case Contest::STATUS_ACTIVE:
96 - $this->showEnabledPage( $contest );
 100+ $this->showEnabledPage( $contest, $challangeId );
97101 break;
98102 case Contest::STATUS_DRAFT:
99103 // TODO
@@ -112,8 +116,9 @@
113117 * @since 0.1
114118 *
115119 * @param Contest $contest
 120+ * @param integer|false $challangeId
116121 */
117 - protected function showEnabledPage( Contest $contest ) {
 122+ protected function showEnabledPage( Contest $contest, $challangeId ) {
118123 $out = $this->getOutput();
119124
120125 // Check if the user is already a contestant in this contest.
@@ -131,7 +136,7 @@
132137 $out->setPageTitle( $contest->getField( 'name' ) );
133138 $out->addWikiMsg( 'contest-signup-header', $contest->getField( 'name' ) );
134139
135 - $this->showSignupForm( $contest );
 140+ $this->showSignupForm( $contest, $challangeId );
136141 }
137142 else {
138143 $out->redirect( SpecialPage::getTitleFor( 'ContestSubmission', $contest->getField( 'name' ) )->getLocalURL() );
@@ -144,9 +149,10 @@
145150 * @since 0.1
146151 *
147152 * @param Contest $contest
 153+ * @param integer|false $challangeId
148154 */
149 - protected function showSignupForm( Contest $contest ) {
150 - $form = new HTMLForm( $this->getFormFields( $contest ), $this->getContext() );
 155+ protected function showSignupForm( Contest $contest, $challangeId = false ) {
 156+ $form = new HTMLForm( $this->getFormFields( $contest, $challangeId ), $this->getContext() );
151157
152158 $form->setSubmitCallback( array( __CLASS__, 'handleSubmission' ) );
153159 $form->setSubmitText( wfMsg( 'contest-signup-submit' ) );
@@ -175,8 +181,9 @@
176182 * @since 0.1
177183 *
178184 * @param Contest $contest
 185+ * @param integer|false $challangeId
179186 */
180 - protected function getFormFields( Contest $contest ) {
 187+ protected function getFormFields( Contest $contest, $challangeId ) {
181188 $fields = array();
182189
183190 $user = $this->getUser();
@@ -218,6 +225,10 @@
219226 'required' => true,
220227 );
221228
 229+ if ( $challangeId !== false ) {
 230+ $fields['contestant-challangeid']['default'] = $challangeId;
 231+ }
 232+
222233 $fields['contestant-volunteer'] = array(
223234 'type' => 'check',
224235 'default' => '0',
Index: trunk/extensions/Contest/Contest.php
@@ -154,8 +154,11 @@
155155
156156 $wgResourceModules['contest.special.welcome'] = $moduleTemplate + array(
157157 'scripts' => array(
158 - 'contest.special.welcome.js'
 158+ 'contest.special.welcome.js',
159159 ),
 160+ 'styles' => array(
 161+ 'contest.special.welcome.css',
 162+ ),
160163 'messages' => array(
161164 ),
162165 'dependencies' => array(
Index: trunk/extensions/Contest/resources/contest.special.welcome.css
@@ -0,0 +1,16 @@
 2+/**
 3+ * CSS for the Contest MediaWiki extension.
 4+ * @see https://secure.wikimedia.org/wikipedia/mediawiki/wiki/Extension:Contest
 5+ *
 6+ * @licence GNU GPL v3 or later
 7+ * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
 8+ */
 9+
 10+button.challange-signup {
 11+ position: absolute;
 12+ right: 5px;
 13+}
 14+
 15+div.contest-challange {
 16+ position: relative;
 17+}
\ No newline at end of file
Property changes on: trunk/extensions/Contest/resources/contest.special.welcome.css
___________________________________________________________________
Added: svn:eol-style
118 + native

Status & tagging log