Index: trunk/extensions/Contest/Contest.i18n.php |
— | — | @@ -79,6 +79,8 @@ |
80 | 80 | 'editcontest-legend' => 'Contest', |
81 | 81 | 'contest-edit-name' => 'Contest name', |
82 | 82 | 'contest-edit-status' => 'Contest status', |
| 83 | + 'contest-edit-intro' => 'Introduction page', |
| 84 | + 'contest-edit-oppertunities' => 'Oppertunities page', |
83 | 85 | 'contest-edit-rulespage' => 'Rules page', |
84 | 86 | 'contest-edit-exists-already' => 'Note: you are editing an already existing contest, not creating a new one.', |
85 | 87 | 'contest-edit-submit' => 'Submit', |
— | — | @@ -93,6 +95,8 @@ |
94 | 96 | |
95 | 97 | // Special:ContestWelcome |
96 | 98 | 'contest-welcome-unknown' => 'There is no contest with the provided name.', |
| 99 | + 'contest-welcome-rules' => 'In order to participate, you must agree to [[$1|the contest rules]].', |
| 100 | + 'contest-welcome-signup' => 'Signup now', |
97 | 101 | |
98 | 102 | // Special:ContestSignup & Special:ContestSubmission |
99 | 103 | 'contest-signup-unknown' => 'There is no contest with the provided name.', |
Index: trunk/extensions/Contest/specials/SpecialContestWelcome.php |
— | — | @@ -59,31 +59,80 @@ |
60 | 60 | $out->setPageTitle( $contest->getField( 'name' ) ); |
61 | 61 | |
62 | 62 | $this->showIntro( $contest ); |
63 | | - $this->showChallanges( $contest->getChallanges() ); |
64 | | - $this->showOpportunities(); |
65 | | - $this->showRules(); |
| 63 | + $this->showChallanges( $contest ); |
| 64 | + $this->showOpportunities( $contest ); |
| 65 | + $this->showRules( $contest ); |
66 | 66 | $this->showSignupLinks( $contest ); |
| 67 | + |
| 68 | + $out->addModules( '' ); |
67 | 69 | } |
68 | 70 | } |
69 | 71 | |
70 | 72 | protected function showIntro( Contest $contest ) { |
71 | | - |
| 73 | + $this->getOutput()->addWikiText( $this->getArticleContent( $contest->getField( 'intro' ) ) ); |
72 | 74 | } |
73 | 75 | |
74 | | - protected function showChallanges( array /* of ContestChallange */ $challanges ) { |
| 76 | + protected function showChallanges( Contest $contest ) { |
| 77 | + $out = $this->getOutput(); |
75 | 78 | |
| 79 | + foreach ( $contest->getChallanges() as /* ContestChallange */ $challange ) { |
| 80 | + $out->addHTML( Html::rawElement( |
| 81 | + 'fieldset', |
| 82 | + array( |
| 83 | + 'data-contest-target' => $this->getSignupLink( $challange->getId() ) |
| 84 | + ), |
| 85 | + Html::element( 'legend', array(), $challange->getField( 'title' ) ) |
| 86 | + . htmlspecialchars( $challange->getField( 'text' ) ) |
| 87 | + ) ); |
| 88 | + } |
76 | 89 | } |
77 | 90 | |
78 | | - protected function showOpportunities() { |
79 | | - |
| 91 | + protected function showOpportunities( Contest $contest ) { |
| 92 | + $this->getOutput()->addWikiText( $this->getArticleContent( $contest->getField( 'oppertunities' ) ) ); |
80 | 93 | } |
81 | 94 | |
82 | | - protected function showRules() { |
83 | | - |
| 95 | + protected function showRules( Contest $contest ) { |
| 96 | + // TODO: we might want to have a pop-up with the content here, instead of a link to the page. |
| 97 | + $this->getOutput()->addWikiMsgArray( 'contest-welcome-rules', $contest->getField( 'rules_page' ) ); |
84 | 98 | } |
85 | 99 | |
86 | 100 | protected function showSignupLinks( Contest $contest ) { |
| 101 | + $out = $this->getOutput(); |
87 | 102 | |
| 103 | + $out->addHTML( Html::element( |
| 104 | + 'button', |
| 105 | + array( |
| 106 | + 'id' => 'contest-signup', |
| 107 | + 'class' => 'contest-signup', |
| 108 | + 'data-contest-target' => $this->getSignupLink( $contest->getField( 'name' ) ) |
| 109 | + ), |
| 110 | + wfMsg( 'contest-welcome-signup' ) |
| 111 | + ) ); |
88 | 112 | } |
89 | 113 | |
| 114 | + protected function getSignupLink( $contestName, $challangeId = false ) { |
| 115 | + $signupitle = SpecialPage::getTitleFor( 'ContestSignup', $contestName ); |
| 116 | + |
| 117 | + if ( $this->getUser()->isLoggedIn() ) { |
| 118 | + return $signupitle->getLocalURL(); |
| 119 | + } |
| 120 | + else { |
| 121 | + return SpecialPage::getTitleFor( 'UserLogin' )->getLocalURL( array( |
| 122 | + //'type' => 'signup', |
| 123 | + 'returnto' => $signupitle->getFullText() |
| 124 | + ) ); |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + protected function getArticleContent( $pageName ) { |
| 129 | + $title = Title::newFromText( $pageName ); |
| 130 | + |
| 131 | + if ( is_null( $title ) ) { |
| 132 | + return ''; |
| 133 | + } |
| 134 | + |
| 135 | + $article = new Article( $title, 0 ); |
| 136 | + return $article->getContent(); |
| 137 | + } |
| 138 | + |
90 | 139 | } |
\ No newline at end of file |
Index: trunk/extensions/Contest/specials/SpecialEditContest.php |
— | — | @@ -175,6 +175,16 @@ |
176 | 176 | 'options' => Contest::getStatusMessages() |
177 | 177 | ); |
178 | 178 | |
| 179 | + $fields['intro'] = array ( |
| 180 | + 'type' => 'text', |
| 181 | + 'label-message' => 'contest-edit-intro', |
| 182 | + ); |
| 183 | + |
| 184 | + $fields['oppertunities'] = array ( |
| 185 | + 'type' => 'text', |
| 186 | + 'label-message' => 'contest-edit-oppertunities', |
| 187 | + ); |
| 188 | + |
179 | 189 | $fields['rules_page'] = array ( |
180 | 190 | 'type' => 'text', |
181 | 191 | 'label-message' => 'contest-edit-rulespage', |
Index: trunk/extensions/Contest/includes/Contest.class.php |
— | — | @@ -92,6 +92,8 @@ |
93 | 93 | 'status' => 'int', |
94 | 94 | 'submission_count' => 'int', |
95 | 95 | 'rules_page' => 'str', |
| 96 | + 'oppertunities' => 'str', |
| 97 | + 'intro' => 'str', |
96 | 98 | ); |
97 | 99 | } |
98 | 100 | |
— | — | @@ -107,7 +109,9 @@ |
108 | 110 | 'name' => '', |
109 | 111 | 'status' => self::STATUS_DRAFT, |
110 | 112 | 'submission_count' => 0, |
111 | | - 'rules_page' => '', |
| 113 | + 'rules_page' => 'MediaWiki:', |
| 114 | + 'oppertunities' => 'MediaWiki:', |
| 115 | + 'intro' => 'MediaWiki:', |
112 | 116 | ); |
113 | 117 | } |
114 | 118 | |
Index: trunk/extensions/Contest/resources/contest.special.welcome.js |
— | — | @@ -0,0 +1,19 @@ |
| 2 | +/** |
| 3 | + * JavasSript 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 | +(function( $, mw ) { |
| 11 | + |
| 12 | + $( document ).ready( function() { |
| 13 | + |
| 14 | + $( '#contest-signup' ).click( function() { |
| 15 | + |
| 16 | + } ); |
| 17 | + |
| 18 | + } ); |
| 19 | + |
| 20 | +})( window.jQuery, window.mediaWiki ); |
\ No newline at end of file |
Property changes on: trunk/extensions/Contest/resources/contest.special.welcome.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 21 | + native |
Index: trunk/extensions/Contest/Contest.sql |
— | — | @@ -7,8 +7,10 @@ |
8 | 8 | contest_id SMALLINT unsigned NOT NULL auto_increment PRIMARY KEY, |
9 | 9 | contest_name VARCHAR(255) NOT NULL, -- String indentifier for the contest |
10 | 10 | contest_status TINYINT unsigned NOT NULL default '0', -- Status of the contest |
11 | | - contest_submission_count SMALLINT unsigned NOT NULL, -- |
12 | | - contest_rules_page VARCHAR(255) NOT NULL |
| 11 | + contest_submission_count SMALLINT unsigned NOT NULL, -- Amount of submissions made to the contest |
| 12 | + contest_rules_page VARCHAR(255) NOT NULL, -- Name of the page with rules |
| 13 | + contest_oppertunities VARCHAR(255) NOT NULL, -- Name of the page with oppertunities |
| 14 | + contest_intro VARCHAR(255) NOT NULL -- Name of the page with the intro text |
13 | 15 | ) /*$wgDBTableOptions*/; |
14 | 16 | |
15 | 17 | -- Contestants |
— | — | @@ -28,7 +30,7 @@ |
29 | 31 | contestant_volunteer TINYINT unsigned NOT NULL, -- If the user is interested in voluneer oportunities |
30 | 32 | contestant_wmf TINYINT unsigned NOT NULL, -- If the user is interested in a WMF job |
31 | 33 | |
32 | | - contestant_submission INT(10) unsigned NOT NULL -- TODO: file shizzle |
| 34 | + contestant_submission TINYBLOB NOT NULL -- URL to the users submission |
33 | 35 | ) /*$wgDBTableOptions*/; |
34 | 36 | |
35 | 37 | -- Challanges |