Index: trunk/extensions/Storyboard/storyboard.sql |
— | — | @@ -18,7 +18,6 @@ |
19 | 19 | story_image_hidden TINYINT NOT NULL default '0' |
20 | 20 | ) /*$wgDBTableOptions*/; |
21 | 21 | |
| 22 | +CREATE UNIQUE INDEX story_title ON /*$wgDBprefix*/storyboard (story_title); |
22 | 23 | CREATE INDEX story_published_modified ON /*$wgDBprefix*/storyboard (story_is_published, story_modified); |
23 | | -CREATE INDEX story_modified_id ON /*$wgDBprefix*/storyboard (story_modified, story_id); |
24 | | -CREATE INDEX story_title ON /*$wgDBprefix*/storyboard (story_title); |
25 | | -ALTER TABLE /*$wgDBprefix*/storyboard ADD UNIQUE (story_title) |
\ No newline at end of file |
| 24 | +CREATE INDEX story_modified_id ON /*$wgDBprefix*/storyboard (story_modified, story_id); |
\ No newline at end of file |
Index: trunk/extensions/Storyboard/Storyboard.i18n.php |
— | — | @@ -38,6 +38,9 @@ |
39 | 39 | 'storyboard-authorcontact' => 'Author contact information', |
40 | 40 | 'storyboard-thestory' => 'The story', |
41 | 41 | |
| 42 | + // Special:StorySubmission |
| 43 | + 'storyboard-submissioncomplete' => 'Submission complete', |
| 44 | + |
42 | 45 | // Story review |
43 | 46 | 'storyreview' => 'Story review', |
44 | 47 | 'storyboard-publish' => 'Publish', |
Index: trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php |
— | — | @@ -33,11 +33,7 @@ |
34 | 34 | |
35 | 35 | global $wgRequest, $wgUser; |
36 | 36 | |
37 | | - if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpStoryEditToken' ) ) ) { |
38 | | - $output = self::doSubmissionAndGetResult(); |
39 | | - } else { |
40 | | - $output = self::getFrom( $parser, $args ); |
41 | | - } |
| 37 | + $output = self::getFrom( $parser, $args ); |
42 | 38 | |
43 | 39 | wfProfileOut( __METHOD__ ); |
44 | 40 | |
— | — | @@ -76,8 +72,6 @@ |
77 | 73 | $maxLen = array_key_exists( 'maxlength', $args ) && is_int( $args['maxlength'] ) ? $args['maxlength'] : $egStoryboardMaxStoryLen; |
78 | 74 | $minLen = array_key_exists( 'minlength', $args ) && is_int( $args['minlength'] ) ? $args['minlength'] : $egStoryboardMinStoryLen; |
79 | 75 | |
80 | | - $submissionUrl = $parser->getTitle()->getLocalURL( 'action=purge' ); |
81 | | - |
82 | 76 | $formBody = "<table width='$width'>"; |
83 | 77 | |
84 | 78 | $defaultName = ''; |
— | — | @@ -151,6 +145,8 @@ |
152 | 146 | |
153 | 147 | $formBody .= Html::hidden( 'lang', $args['language'] ); |
154 | 148 | |
| 149 | + $submissionUrl = SpecialPage::getTitleFor( 'StorySubmission' )->getFullURL(); |
| 150 | + |
155 | 151 | return Html::rawElement( |
156 | 152 | 'form', |
157 | 153 | array( |
— | — | @@ -164,40 +160,6 @@ |
165 | 161 | ); |
166 | 162 | } |
167 | 163 | |
168 | | - /** |
169 | | - * Store the submitted story in the database, and return a page telling the user his story has been submitted. |
170 | | - */ |
171 | | - private static function doSubmissionAndGetResult() { |
172 | | - global $wgRequest, $wgUser; |
173 | | - |
174 | | - $dbw = wfGetDB( DB_MASTER ); |
175 | 164 | |
176 | | - $title = $wgRequest->getText( 'storytitle' ); |
177 | | - |
178 | | - $story = array( |
179 | | - 'story_lang_code' => $wgRequest->getText( 'lang' ), |
180 | | - 'story_author_name' => $wgRequest->getText( 'name' ), |
181 | | - 'story_author_location' => $wgRequest->getText( 'location' ), |
182 | | - 'story_author_occupation' => $wgRequest->getText( 'occupation' ), |
183 | | - 'story_author_contact' => $wgRequest->getText( 'contact' ), |
184 | | - 'story_title' => $title, |
185 | | - 'story_text' => $wgRequest->getText( 'storytext' ), |
186 | | - 'story_created' => $dbw->timestamp( time() ), |
187 | | - 'story_modified' => $dbw->timestamp( time() ), |
188 | | - ); |
189 | | - |
190 | | - // If the user is logged in, also store his user id. |
191 | | - if ( $wgUser->isLoggedIn() ) { |
192 | | - $story[ 'story_author_id' ] = $wgUser->getId(); |
193 | | - } |
194 | | - |
195 | | - // TODO: email confirmation would be nice |
196 | | - |
197 | | - $dbw->insert( 'storyboard', $story ); |
198 | | - |
199 | | - $storyboardLink = ''; // TODO: create html link to the page containing stories. |
200 | | - |
201 | | - return wfMsgExt( 'storyboard-createdsucessfully', 'parsemag', $storyboardLink ); |
202 | | - } |
203 | 165 | |
204 | 166 | } |
\ No newline at end of file |
Index: trunk/extensions/Storyboard/specials/StorySubmission/StorySubmission_body.php |
— | — | @@ -0,0 +1,75 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * File holding the SpecialStorySubmission class defining a special page to save submitted stories and display a success message. |
| 5 | + * |
| 6 | + * @file StorySubmission_body.php |
| 7 | + * @ingroup Storyboard |
| 8 | + * @ingroup SpecialPage |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +class SpecialStorySubmission extends UnlistedSpecialPage { |
| 18 | + |
| 19 | + public function __construct() { |
| 20 | + parent::__construct( 'StorySubmission' ); |
| 21 | + } |
| 22 | + |
| 23 | + public function execute( $title ) { |
| 24 | + global $wgOut, $wgRequest, $wgUser; |
| 25 | + |
| 26 | + if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpStoryEditToken' ) ) ) { |
| 27 | + $this->saveStory(); |
| 28 | + $this->displayResult(); |
| 29 | + } else { |
| 30 | + $wgOut->returnToMain(); |
| 31 | + } |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * Store the submitted story in the database, and return a page telling the user his story has been submitted. |
| 36 | + */ |
| 37 | + private function saveStory() { |
| 38 | + global $wgRequest, $wgUser; |
| 39 | + |
| 40 | + $dbw = wfGetDB( DB_MASTER ); |
| 41 | + |
| 42 | + $title = $wgRequest->getText( 'storytitle' ); |
| 43 | + |
| 44 | + $story = array( |
| 45 | + 'story_lang_code' => $wgRequest->getText( 'lang' ), |
| 46 | + 'story_author_name' => $wgRequest->getText( 'name' ), |
| 47 | + 'story_author_location' => $wgRequest->getText( 'location' ), |
| 48 | + 'story_author_occupation' => $wgRequest->getText( 'occupation' ), |
| 49 | + 'story_author_contact' => $wgRequest->getText( 'contact' ), |
| 50 | + 'story_title' => $title, |
| 51 | + 'story_text' => $wgRequest->getText( 'storytext' ), |
| 52 | + 'story_created' => $dbw->timestamp( time() ), |
| 53 | + 'story_modified' => $dbw->timestamp( time() ), |
| 54 | + ); |
| 55 | + |
| 56 | + // If the user is logged in, also store his user id. |
| 57 | + if ( $wgUser->isLoggedIn() ) { |
| 58 | + $story[ 'story_author_id' ] = $wgUser->getId(); |
| 59 | + } |
| 60 | + |
| 61 | + // TODO: email confirmation would be nice |
| 62 | + |
| 63 | + $dbw->insert( 'storyboard', $story ); |
| 64 | + } |
| 65 | + |
| 66 | + private function displayResult() { |
| 67 | + global $wgOut; |
| 68 | + |
| 69 | + $wgOut->setPageTitle( wfMsg( 'storyboard-submissioncomplete' ) ); |
| 70 | + |
| 71 | + $storyboardLink = ''; // TODO: create html link to the page containing stories. |
| 72 | + |
| 73 | + $wgOut->addWikiText( wfMsgExt( 'storyboard-createdsucessfully', 'parsemag', $storyboardLink ) ); |
| 74 | + } |
| 75 | + |
| 76 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/Storyboard/specials/StorySubmission/StorySubmission_body.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 77 | + native |
Index: trunk/extensions/Storyboard/Storyboard.php |
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | // Load classes |
45 | 45 | $wgAutoloadClasses['StoryboardUtils'] = $egStoryboardDir . 'Storyboard_Utils.php'; |
46 | 46 | $wgAutoloadClasses['SpecialStory'] = $egStoryboardDir . 'specials/Story/Story_body.php'; |
| 47 | +$wgAutoloadClasses['SpecialStorySubmission'] = $egStoryboardDir . 'specials/StorySubmission/StorySubmission_body.php'; |
47 | 48 | $wgAutoloadClasses['SpecialStoryReview'] = $egStoryboardDir . 'specials/StoryReview/StoryReview_body.php'; |
48 | 49 | $wgAutoloadClasses['TagStoryboard'] = $egStoryboardDir . 'tags/Storyboard/Storyboard_body.php'; |
49 | 50 | $wgAutoloadClasses['TagStorysubmission'] = $egStoryboardDir . 'tags/Storysubmission/Storysubmission_body.php'; |
— | — | @@ -52,6 +53,7 @@ |
53 | 54 | $wgSpecialPageGroups['StoryReview'] = 'contribution'; |
54 | 55 | $wgSpecialPages['Story'] = 'SpecialStory'; |
55 | 56 | $wgSpecialPageGroups['Story'] = 'contribution'; |
| 57 | +$wgSpecialPages['StorySubmission'] = 'SpecialStorySubmission'; |
56 | 58 | |
57 | 59 | // API |
58 | 60 | $wgAutoloadClasses['ApiStoryExists'] = "{$egStoryboardDir}api/ApiStoryExists.php"; |