Index: trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php |
— | — | @@ -160,7 +160,7 @@ |
161 | 161 | 'story_author_name' => $wgRequest->getText( 'name' ), |
162 | 162 | 'story_author_location' => $wgRequest->getText( 'location' ), |
163 | 163 | 'story_author_occupation' => $wgRequest->getText( 'occupation' ), |
164 | | - 'story_author_contact' => $wgRequest->getText( 'storyboard-contact' ), |
| 164 | + 'story_author_contact' => $wgRequest->getText( 'contact' ), |
165 | 165 | 'story_title' => $wgRequest->getText( 'storytitle' ), |
166 | 166 | 'story_text' => $wgRequest->getText( 'storytext' ), |
167 | 167 | 'story_created' => $dbw->timestamp( time() ), |
Index: trunk/extensions/Storyboard/specials/Story/Story_body.php |
— | — | @@ -22,14 +22,12 @@ |
23 | 23 | public function execute( $title ) { |
24 | 24 | wfProfileIn( __METHOD__ ); |
25 | 25 | |
26 | | - global $wgOut, $wgRequest; |
| 26 | + global $wgOut, $wgRequest, $wgUser; |
27 | 27 | |
28 | | - $action = $wgRequest->getVal( 'action' ); |
29 | | - |
30 | | - if ( $action == 'save' ) { |
| 28 | + if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
31 | 29 | $this->saveStoryAndShowResult(); |
32 | 30 | } else if ( trim( $title ) != '' || $wgRequest->getIntOrNull( 'id' ) ) { |
33 | | - $this->queryAndShowStory( $title, $action ); |
| 31 | + $this->queryAndShowStory( $title ); |
34 | 32 | } else { |
35 | 33 | $wgOut->addWikiMsg( 'storyboard-nostorytitle' ); |
36 | 34 | } |
— | — | @@ -40,7 +38,7 @@ |
41 | 39 | /** |
42 | 40 | * Queries for the requested story and shows it in either display or edit mode when it's found. |
43 | 41 | */ |
44 | | - private function queryAndShowStory( $title, $action ) { |
| 42 | + private function queryAndShowStory( $title ) { |
45 | 43 | global $wgOut, $wgRequest; |
46 | 44 | |
47 | 45 | if ( trim( $title ) != '' ) { |
— | — | @@ -75,7 +73,7 @@ |
76 | 74 | ); |
77 | 75 | |
78 | 76 | if ( $story ) { |
79 | | - if ( $action == 'edit' ) { |
| 77 | + if ( $wgRequest->getVal( 'action' ) == 'edit' ) { |
80 | 78 | $this->showStoryForm( $story ); |
81 | 79 | } else { |
82 | 80 | if ( $story->story_is_published == 1 ) { |
— | — | @@ -122,6 +120,10 @@ |
123 | 121 | * Outputs a form to edit the story with. Code based on <storysubmission>. |
124 | 122 | * |
125 | 123 | * @param $story |
| 124 | + * |
| 125 | + * TODO: add options to publish/unpublish, hide/unhide and delete the story |
| 126 | + * TODO: confirm with erik that author info should be editable here |
| 127 | + * TODO: add permission check |
126 | 128 | */ |
127 | 129 | private function showStoryForm( $story ) { |
128 | 130 | global $wgOut, $wgRequest, $wgUser, $wgJsMimeType, $egStoryboardScriptPath, $egStorysubmissionWidth, $egStoryboardMaxStoryLen, $egStoryboardMinStoryLen; |
— | — | @@ -139,9 +141,6 @@ |
140 | 142 | $minLen = $wgRequest->getVal( 'minlength' ); |
141 | 143 | if ( !is_int( $minLen ) ) $minLen = $egStoryboardMinStoryLen; |
142 | 144 | |
143 | | - //$submissionUrl = $wgParser->getTitle()->getLocalURL( 'action=save' ); |
144 | | - $submissionUrl = ''; // TODO: get title |
145 | | - |
146 | 145 | $formBody = "<table width='$width'>"; |
147 | 146 | |
148 | 147 | $defaultName = ''; |
— | — | @@ -199,6 +198,7 @@ |
200 | 199 | $formBody .= '</table>'; |
201 | 200 | |
202 | 201 | $formBody .= Html::hidden( 'wpEditToken', $wgUser->editToken() ); |
| 202 | + $formBody .= Html::hidden( 'storyId', $story->story_id ); |
203 | 203 | |
204 | 204 | $formBody = Html::rawElement( |
205 | 205 | 'form', |
— | — | @@ -206,7 +206,7 @@ |
207 | 207 | 'id' => 'storyform', |
208 | 208 | 'name' => 'storyform', |
209 | 209 | 'method' => 'post', |
210 | | - 'action' => $submissionUrl, |
| 210 | + 'action' => $this->getTitle()->getLocalURL(), |
211 | 211 | ), |
212 | 212 | $formBody |
213 | 213 | ); |
— | — | @@ -216,12 +216,30 @@ |
217 | 217 | |
218 | 218 | /** |
219 | 219 | * Saves the story after a story edit form has been submitted and shows a result. |
| 220 | + * |
| 221 | + * TODO: add permission check |
220 | 222 | */ |
221 | 223 | private function saveStoryAndShowResult() { |
222 | | - global $wgOut; |
| 224 | + global $wgOut, $wgRequest, $wgUser; |
223 | 225 | |
224 | | - // TODO: save story |
| 226 | + $dbw = wfGetDB( DB_MASTER ); |
225 | 227 | |
| 228 | + $dbw->update( |
| 229 | + 'storyboard', |
| 230 | + array( |
| 231 | + 'story_author_name' => $wgRequest->getText( 'name' ), |
| 232 | + 'story_author_location' => $wgRequest->getText( 'location' ), |
| 233 | + 'story_author_occupation' => $wgRequest->getText( 'occupation' ), |
| 234 | + 'story_author_contact' => $wgRequest->getText( 'contact' ), |
| 235 | + 'story_title' => $wgRequest->getText( 'storytitle' ), |
| 236 | + 'story_text' => $wgRequest->getText( 'storytext' ), |
| 237 | + 'story_modified' => $dbw->timestamp( time() ), |
| 238 | + ), |
| 239 | + array( |
| 240 | + 'story_id' => $wgRequest->getText( 'storyId' ), |
| 241 | + ) |
| 242 | + ); |
| 243 | + |
226 | 244 | $wgOut->addHTML( '' ); // TODO: add output |
227 | 245 | } |
228 | 246 | } |
\ No newline at end of file |