Index: trunk/extensions/Storyboard/storyboard.sql |
— | — | @@ -3,11 +3,11 @@ |
4 | 4 | CREATE TABLE /*$wgDBprefix*/storyboard ( |
5 | 5 | story_id INT(8) unsigned NOT NULL auto_increment PRIMARY KEY, |
6 | 6 | story_author_id INT unsigned NULL, |
7 | | - story_author_name VARCHAR(100) NOT NULL, |
8 | | - story_author_location VARCHAR(150) NOT NULL, |
9 | | - story_author_occupation VARCHAR(100) NOT NULL, |
10 | | - story_author_image VARCHAR(50) NULL, -- TODO: find out if this is an acceptible way to refer to an image |
11 | | - story_hit_count INT(8) unsigned NOT NULL, |
| 7 | + story_author_name VARCHAR(255) NOT NULL, |
| 8 | + story_author_location VARCHAR(255) NOT NULL, |
| 9 | + story_author_occupation VARCHAR(255) NOT NULL, |
| 10 | + story_author_image VARCHAR(255) NULL, -- TODO: find out if this is an acceptible way to refer to an image |
| 11 | + story_hit_count INT(8) unsigned NOT NULL, default '0', |
12 | 12 | story_title VARCHAR(255) NOT NULL, |
13 | 13 | story_text MEDIUMBLOB NOT NULL, |
14 | 14 | story_modified CHAR(14) binary NOT NULL default '', |
Index: trunk/extensions/Storyboard/Storyboard.i18n.php |
— | — | @@ -34,6 +34,7 @@ |
35 | 35 | 'storyboard-story' => "Your story", |
36 | 36 | 'storyboard-photo' => 'Have a photo of yourself? Why not share it?', |
37 | 37 | 'storyboard-contact' => 'Your E-mail address or telephone number', |
| 38 | + 'storyboard-storytitle' => 'A short, descriptive title', |
38 | 39 | 'storyboard-agreement' => 'I agree with the publication of this story.', |
39 | 40 | 'storyboard-charsleft' => '($1 {{PLURAL:$1|character|characters}} left)', |
40 | 41 | 'storyboard-cannotbelonger' => 'Your story is <b>$1</b> {{PLURAL:$1|character|characters}} to long!', |
Index: trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php |
— | — | @@ -40,9 +40,11 @@ |
41 | 41 | * @param $parser |
42 | 42 | * @param array $args |
43 | 43 | * @return HTML |
| 44 | + * |
| 45 | + * TODO: any sort of client side validation? |
44 | 46 | */ |
45 | 47 | private static function getFrom( $parser, array $args ) { |
46 | | - global $wgOut, $wgUser, $wgJsMimeType, $wgSc, $egStoryboardScriptPath, $egStorysubmissionWidth, $egStoryboardMaxStoryLen, $egStoryboardMinStoryLen; |
| 48 | + global $wgOut, $wgUser, $wgJsMimeType, $egStoryboardScriptPath, $egStorysubmissionWidth, $egStoryboardMaxStoryLen, $egStoryboardMinStoryLen; |
47 | 49 | |
48 | 50 | $wgOut->addStyle( $egStoryboardScriptPath . '/tags/Storysubmission/storysubmission.css' ); |
49 | 51 | $wgOut->addScriptFile( $egStoryboardScriptPath . '/tags/Storysubmission/storysubmission.js' ); |
— | — | @@ -57,6 +59,7 @@ |
58 | 60 | |
59 | 61 | $formBody = "<table width='$width'>"; |
60 | 62 | |
| 63 | + // TODO: if logged in, use real name as default, or username when not available |
61 | 64 | $formBody .= '<tr>' . |
62 | 65 | Html::element( 'td', array('width' => '100%'), wfMsg( 'storyboard-yourname' ) ) . |
63 | 66 | '<td>' . |
— | — | @@ -77,6 +80,11 @@ |
78 | 81 | Html::element( 'td', array('width' => '100%'), wfMsg( 'storyboard-contact' ) ) . |
79 | 82 | '<td>' . Html::input('contact' ,'', 'text', array( 'size' => $fieldSize ) |
80 | 83 | ) . '</td></tr>'; |
| 84 | + |
| 85 | + $formBody .= '<tr>' . |
| 86 | + Html::element( 'td', array('width' => '100%'), wfMsg( 'storyboard-storytitle' ) ) . |
| 87 | + '<td>' . Html::input('storytitle' ,'', 'text', array( 'size' => $fieldSize ) |
| 88 | + ) . '</td></tr>'; |
81 | 89 | |
82 | 90 | $formBody .= '<tr><td colspan="2">' . |
83 | 91 | wfMsg( 'storyboard-story' ) . |
— | — | @@ -89,7 +97,8 @@ |
90 | 98 | Html::element( |
91 | 99 | 'textarea', |
92 | 100 | array( |
93 | | - 'id' => 'story', |
| 101 | + 'id' => 'storytext', |
| 102 | + 'name' => 'storytext', |
94 | 103 | 'rows' => 7, |
95 | 104 | 'onkeyup' => "stbValidateStory( this, $minLen, $maxLen, 'storysubmission-charlimitinfo', 'storysubmission-button' )", |
96 | 105 | ), |
— | — | @@ -111,7 +120,7 @@ |
112 | 121 | |
113 | 122 | $formBody .= Html::hidden( 'wpEditToken', $wgUser->editToken() ); |
114 | 123 | |
115 | | - $formHtml = Html::rawElement( |
| 124 | + return Html::rawElement( |
116 | 125 | 'form', |
117 | 126 | array( |
118 | 127 | 'id' => 'storyform', |
— | — | @@ -122,11 +131,6 @@ |
123 | 132 | ), |
124 | 133 | $formBody |
125 | 134 | ); |
126 | | - |
127 | | - // Disable the submission button when JS is enabled. |
128 | | - $formJs = "<script type='$wgJsMimeType'>/*<![CDATA[*/ document.getElementById( 'storysubmission-button' ).disabled = true; /*]]>*/</script>"; |
129 | | - |
130 | | - return $formHtml . $formJs; |
131 | 135 | } |
132 | 136 | |
133 | 137 | /** |
— | — | @@ -136,7 +140,25 @@ |
137 | 141 | global $wgRequest, $wgUser; |
138 | 142 | |
139 | 143 | $dbw = wfGetDB( DB_MASTER ); |
140 | | - $dbw->insert( 'storyboard' ); // TODO |
| 144 | + |
| 145 | + // TODO: some sort of validation? |
| 146 | + |
| 147 | + $story = array( |
| 148 | + 'story_author_name' => $dbw->addQuotes( $wgRequest->getText( 'name' ) ), |
| 149 | + 'story_author_location' => $dbw->addQuotes( $wgRequest->getText( 'location' ) ), |
| 150 | + 'story_author_occupation' => $dbw->addQuotes( $wgRequest->getText( 'occupation' ) ), |
| 151 | + 'story_title' => $dbw->addQuotes( $wgRequest->getText( 'storytitle' ) ), |
| 152 | + 'story_text' => $dbw->addQuotes( $wgRequest->getText( 'storytext' ) ), |
| 153 | + // TODO: add other fields |
| 154 | + ); |
| 155 | + |
| 156 | + // TODO: Add user id to $story if user is logged in |
| 157 | + |
| 158 | + $dbw->insert( 'storyboard', $story ); |
| 159 | + |
| 160 | + $responseHtml = ''; // TODO: create html response |
| 161 | + |
| 162 | + return $responseHtml; |
141 | 163 | } |
142 | 164 | |
143 | 165 | } |
\ No newline at end of file |
Index: trunk/extensions/Storyboard/tags/Storysubmission/storysubmission.js |
— | — | @@ -33,4 +33,8 @@ |
34 | 34 | alert( 'You need to agree to the publication of your story to submit it.' ); // TODO: i18n |
35 | 35 | } |
36 | 36 | return agreementValid; |
37 | | -} |
\ No newline at end of file |
| 37 | +} |
| 38 | + |
| 39 | +addOnloadHook( function() { |
| 40 | + document.getElementById( 'storysubmission-button' ).disabled = true; |
| 41 | +} ); |
\ No newline at end of file |