r63851 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63850‎ | r63851 | r63852 >
Date:00:52, 17 March 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r63850
* Added query to update a story after submitting the edit form
Modified paths:
  • /trunk/extensions/Storyboard/specials/Story/Story_body.php (modified) (history)
  • /trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php
@@ -160,7 +160,7 @@
161161 'story_author_name' => $wgRequest->getText( 'name' ),
162162 'story_author_location' => $wgRequest->getText( 'location' ),
163163 'story_author_occupation' => $wgRequest->getText( 'occupation' ),
164 - 'story_author_contact' => $wgRequest->getText( 'storyboard-contact' ),
 164+ 'story_author_contact' => $wgRequest->getText( 'contact' ),
165165 'story_title' => $wgRequest->getText( 'storytitle' ),
166166 'story_text' => $wgRequest->getText( 'storytext' ),
167167 'story_created' => $dbw->timestamp( time() ),
Index: trunk/extensions/Storyboard/specials/Story/Story_body.php
@@ -22,14 +22,12 @@
2323 public function execute( $title ) {
2424 wfProfileIn( __METHOD__ );
2525
26 - global $wgOut, $wgRequest;
 26+ global $wgOut, $wgRequest, $wgUser;
2727
28 - $action = $wgRequest->getVal( 'action' );
29 -
30 - if ( $action == 'save' ) {
 28+ if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
3129 $this->saveStoryAndShowResult();
3230 } else if ( trim( $title ) != '' || $wgRequest->getIntOrNull( 'id' ) ) {
33 - $this->queryAndShowStory( $title, $action );
 31+ $this->queryAndShowStory( $title );
3432 } else {
3533 $wgOut->addWikiMsg( 'storyboard-nostorytitle' );
3634 }
@@ -40,7 +38,7 @@
4139 /**
4240 * Queries for the requested story and shows it in either display or edit mode when it's found.
4341 */
44 - private function queryAndShowStory( $title, $action ) {
 42+ private function queryAndShowStory( $title ) {
4543 global $wgOut, $wgRequest;
4644
4745 if ( trim( $title ) != '' ) {
@@ -75,7 +73,7 @@
7674 );
7775
7876 if ( $story ) {
79 - if ( $action == 'edit' ) {
 77+ if ( $wgRequest->getVal( 'action' ) == 'edit' ) {
8078 $this->showStoryForm( $story );
8179 } else {
8280 if ( $story->story_is_published == 1 ) {
@@ -122,6 +120,10 @@
123121 * Outputs a form to edit the story with. Code based on <storysubmission>.
124122 *
125123 * @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
126128 */
127129 private function showStoryForm( $story ) {
128130 global $wgOut, $wgRequest, $wgUser, $wgJsMimeType, $egStoryboardScriptPath, $egStorysubmissionWidth, $egStoryboardMaxStoryLen, $egStoryboardMinStoryLen;
@@ -139,9 +141,6 @@
140142 $minLen = $wgRequest->getVal( 'minlength' );
141143 if ( !is_int( $minLen ) ) $minLen = $egStoryboardMinStoryLen;
142144
143 - //$submissionUrl = $wgParser->getTitle()->getLocalURL( 'action=save' );
144 - $submissionUrl = ''; // TODO: get title
145 -
146145 $formBody = "<table width='$width'>";
147146
148147 $defaultName = '';
@@ -199,6 +198,7 @@
200199 $formBody .= '</table>';
201200
202201 $formBody .= Html::hidden( 'wpEditToken', $wgUser->editToken() );
 202+ $formBody .= Html::hidden( 'storyId', $story->story_id );
203203
204204 $formBody = Html::rawElement(
205205 'form',
@@ -206,7 +206,7 @@
207207 'id' => 'storyform',
208208 'name' => 'storyform',
209209 'method' => 'post',
210 - 'action' => $submissionUrl,
 210+ 'action' => $this->getTitle()->getLocalURL(),
211211 ),
212212 $formBody
213213 );
@@ -216,12 +216,30 @@
217217
218218 /**
219219 * Saves the story after a story edit form has been submitted and shows a result.
 220+ *
 221+ * TODO: add permission check
220222 */
221223 private function saveStoryAndShowResult() {
222 - global $wgOut;
 224+ global $wgOut, $wgRequest, $wgUser;
223225
224 - // TODO: save story
 226+ $dbw = wfGetDB( DB_MASTER );
225227
 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+
226244 $wgOut->addHTML( '' ); // TODO: add output
227245 }
228246 }
\ No newline at end of file

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r63850* Added regular story view and put existing data into the edit form of Specia...jeroendedauw00:25, 17 March 2010

Status & tagging log