r98675 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98674‎ | r98675 | r98676 >
Date:16:03, 2 October 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on welcome page
Modified paths:
  • /trunk/extensions/Contest/Contest.i18n.php (modified) (history)
  • /trunk/extensions/Contest/Contest.sql (modified) (history)
  • /trunk/extensions/Contest/includes/Contest.class.php (modified) (history)
  • /trunk/extensions/Contest/resources/contest.special.welcome.js (added) (history)
  • /trunk/extensions/Contest/specials/SpecialContestWelcome.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialEditContest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.i18n.php
@@ -79,6 +79,8 @@
8080 'editcontest-legend' => 'Contest',
8181 'contest-edit-name' => 'Contest name',
8282 'contest-edit-status' => 'Contest status',
 83+ 'contest-edit-intro' => 'Introduction page',
 84+ 'contest-edit-oppertunities' => 'Oppertunities page',
8385 'contest-edit-rulespage' => 'Rules page',
8486 'contest-edit-exists-already' => 'Note: you are editing an already existing contest, not creating a new one.',
8587 'contest-edit-submit' => 'Submit',
@@ -93,6 +95,8 @@
9496
9597 // Special:ContestWelcome
9698 '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',
97101
98102 // Special:ContestSignup & Special:ContestSubmission
99103 'contest-signup-unknown' => 'There is no contest with the provided name.',
Index: trunk/extensions/Contest/specials/SpecialContestWelcome.php
@@ -59,31 +59,80 @@
6060 $out->setPageTitle( $contest->getField( 'name' ) );
6161
6262 $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 );
6666 $this->showSignupLinks( $contest );
 67+
 68+ $out->addModules( '' );
6769 }
6870 }
6971
7072 protected function showIntro( Contest $contest ) {
71 -
 73+ $this->getOutput()->addWikiText( $this->getArticleContent( $contest->getField( 'intro' ) ) );
7274 }
7375
74 - protected function showChallanges( array /* of ContestChallange */ $challanges ) {
 76+ protected function showChallanges( Contest $contest ) {
 77+ $out = $this->getOutput();
7578
 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+ }
7689 }
7790
78 - protected function showOpportunities() {
79 -
 91+ protected function showOpportunities( Contest $contest ) {
 92+ $this->getOutput()->addWikiText( $this->getArticleContent( $contest->getField( 'oppertunities' ) ) );
8093 }
8194
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' ) );
8498 }
8599
86100 protected function showSignupLinks( Contest $contest ) {
 101+ $out = $this->getOutput();
87102
 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+ ) );
88112 }
89113
 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+
90139 }
\ No newline at end of file
Index: trunk/extensions/Contest/specials/SpecialEditContest.php
@@ -175,6 +175,16 @@
176176 'options' => Contest::getStatusMessages()
177177 );
178178
 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+
179189 $fields['rules_page'] = array (
180190 'type' => 'text',
181191 'label-message' => 'contest-edit-rulespage',
Index: trunk/extensions/Contest/includes/Contest.class.php
@@ -92,6 +92,8 @@
9393 'status' => 'int',
9494 'submission_count' => 'int',
9595 'rules_page' => 'str',
 96+ 'oppertunities' => 'str',
 97+ 'intro' => 'str',
9698 );
9799 }
98100
@@ -107,7 +109,9 @@
108110 'name' => '',
109111 'status' => self::STATUS_DRAFT,
110112 'submission_count' => 0,
111 - 'rules_page' => '',
 113+ 'rules_page' => 'MediaWiki:',
 114+ 'oppertunities' => 'MediaWiki:',
 115+ 'intro' => 'MediaWiki:',
112116 );
113117 }
114118
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
121 + native
Index: trunk/extensions/Contest/Contest.sql
@@ -7,8 +7,10 @@
88 contest_id SMALLINT unsigned NOT NULL auto_increment PRIMARY KEY,
99 contest_name VARCHAR(255) NOT NULL, -- String indentifier for the contest
1010 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
1315 ) /*$wgDBTableOptions*/;
1416
1517 -- Contestants
@@ -28,7 +30,7 @@
2931 contestant_volunteer TINYINT unsigned NOT NULL, -- If the user is interested in voluneer oportunities
3032 contestant_wmf TINYINT unsigned NOT NULL, -- If the user is interested in a WMF job
3133
32 - contestant_submission INT(10) unsigned NOT NULL -- TODO: file shizzle
 34+ contestant_submission TINYBLOB NOT NULL -- URL to the users submission
3335 ) /*$wgDBTableOptions*/;
3436
3537 -- Challanges

Follow-up revisions

RevisionCommit summaryAuthorDate
r98677follow up to r98675; added docs and module registrationjeroendedauw16:10, 2 October 2011

Status & tagging log