Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -322,7 +322,8 @@ |
323 | 323 | if( $edit_type == 'editExisting' && $e->didSave ) { |
324 | 324 | $subject = $this->request->getVal('lqt_subject_field', ''); |
325 | 325 | if ( $subject && $subject != $thread->subjectWithoutIncrement() ) { |
326 | | - $this->renameThread($thread, $subject); |
| 326 | + $reason = $this->request->getVal("wpSummary", ""); |
| 327 | + $this->renameThread($thread, $subject, $reason); |
327 | 328 | } |
328 | 329 | // this is unrelated to the subject change and is for all edits: |
329 | 330 | $thread->setRootRevision( Revision::newFromTitle($thread->root()->getTitle()) ); |
— | — | @@ -330,11 +331,11 @@ |
331 | 332 | } |
332 | 333 | } |
333 | 334 | |
334 | | - function renameThread($t,$s) { |
335 | | - $this->simplePageMove($t->root()->getTitle(),$s); |
| 335 | + function renameThread($t,$s,$reason) { |
| 336 | + $this->simplePageMove($t->root()->getTitle(),$s, $reason); |
336 | 337 | // TODO here create a redirect from old page to new. |
337 | 338 | foreach( $t->subthreads() as $st ) { |
338 | | - $this->renameThread($st, $s); |
| 339 | + $this->renameThread($st, $s, $reason); |
339 | 340 | } |
340 | 341 | } |
341 | 342 | |
— | — | @@ -361,7 +362,7 @@ |
362 | 363 | } |
363 | 364 | |
364 | 365 | /* Adapted from MovePageForm::doSubmit in SpecialMovepage.php. */ |
365 | | - function simplePageMove( $old_title, $new_subject ) { |
| 366 | + function simplePageMove( $old_title, $new_subject, $reason ) { |
366 | 367 | if ( $this->user->pingLimiter( 'move' ) ) { |
367 | 368 | $this->out->rateLimited(); |
368 | 369 | return false; |
— | — | @@ -380,7 +381,7 @@ |
381 | 382 | return false; |
382 | 383 | } |
383 | 384 | |
384 | | - $error = $ot->moveTo( $nt, true, "changed thread subject" ); |
| 385 | + $error = $ot->moveTo( $nt, true, "Changed thread subject: $reason" ); |
385 | 386 | if ( $error !== true ) { |
386 | 387 | var_dump($error); |
387 | 388 | echo "something bad happened trying to rename the thread."; // TODO |
— | — | @@ -1123,17 +1124,22 @@ |
1124 | 1125 | function handleGet() { |
1125 | 1126 | $thread_name = $this->thread->title()->getPrefixedText(); |
1126 | 1127 | $article_name = $this->thread->article()->getTitle()->getTalkPage()->getPrefixedText(); |
| 1128 | + $edit_url = LqtView::permalinkUrl($this->thread, 'edit', $this->thread); |
1127 | 1129 | $this->output->addHTML(<<<HTML |
1128 | 1130 | <p>Moving <b>$thread_name</b>. |
1129 | 1131 | This thread is part of <b>$article_name</b>.</p> |
| 1132 | + <p>To rename this thread, <a href="$edit_url">edit it</a> and change the 'Subject' field.</p> |
1130 | 1133 | <form id="lqt_move_thread_form" action="{$this->title->getLocalURL()}" method="POST"> |
1131 | 1134 | <table> |
1132 | 1135 | <tr> |
1133 | 1136 | <td><label for="lqt_move_thread_target_title">Title of destination talkpage:</label></td> |
1134 | | - <td><input id="lqt_move_thread_target_title" name="lqt_move_thread_target_title" tabindex="100" /></td> |
| 1137 | + <td><input id="lqt_move_thread_target_title" name="lqt_move_thread_target_title" tabindex="100" size="40" /></td> |
1135 | 1138 | </tr><tr> |
| 1139 | + <td><label for="lqt_move_thread_reason">Reason:</label></td> |
| 1140 | + <td><input id="lqt_move_thread_reason" name="lqt_move_thread_reason" tabindex="200" size="40" /></td> |
| 1141 | + </tr><tr> |
1136 | 1142 | <td> </td> |
1137 | | - <td><input type="submit" value="Move" style="float:right;" tabindex="200" /></td> |
| 1143 | + <td><input type="submit" value="Move" style="float:right;" tabindex="300" /></td> |
1138 | 1144 | </tr> |
1139 | 1145 | </table> |
1140 | 1146 | </form> |
— | — | @@ -1177,14 +1183,22 @@ |
1178 | 1184 | $this->redisplayForm(array('lqt_move_thread_target_title'), "You must specify a destination."); |
1179 | 1185 | return; |
1180 | 1186 | } |
1181 | | - |
1182 | 1187 | $newtitle = Title::newFromText( $tmp )->getSubjectPage(); |
1183 | 1188 | |
| 1189 | + $reason = $this->request->getVal('lqt_move_thread_reason', "No reason given."); |
| 1190 | + |
1184 | 1191 | // TODO no status code from this method. |
1185 | | - $this->thread->moveToSubjectPage( $newtitle, true ); |
| 1192 | + $this->thread->moveToSubjectPage( $newtitle, $reason, true ); |
1186 | 1193 | |
1187 | | - |
| 1194 | + $this->showSuccessMessage( $newtitle->getTalkPage() ); |
1188 | 1195 | } |
| 1196 | + |
| 1197 | + function showSuccessMessage( $target_title ) { |
| 1198 | + $this->output->addHTML(<<<HTML |
| 1199 | + The thread was moved to <a href="{$target_title->getFullURL()}">{$target_title->getPrefixedText()}</a>. |
| 1200 | +HTML |
| 1201 | + ); |
| 1202 | + } |
1189 | 1203 | |
1190 | 1204 | function execute( $par = null ) { |
1191 | 1205 | global $wgOut, $wgRequest, $wgTitle, $wgUser; |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -242,7 +242,7 @@ |
243 | 243 | // $revisionId ); |
244 | 244 | } |
245 | 245 | |
246 | | - function moveToSubjectPage($title, $leave_trace) { |
| 246 | + function moveToSubjectPage($title, $reason, $leave_trace) { |
247 | 247 | $dbr =& wfGetDB( DB_MASTER ); |
248 | 248 | |
249 | 249 | if( $title->exists() ) { |
— | — | @@ -273,11 +273,11 @@ |
274 | 274 | $this->commitRevision(); |
275 | 275 | |
276 | 276 | if($leave_trace) { |
277 | | - $this->leaveTrace(); |
| 277 | + $this->leaveTrace($reason); |
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | | - function leaveTrace() { |
| 281 | + function leaveTrace($reason) { |
282 | 282 | /* Adapted from Title::moveToNewTitle. But now the new title exists on the old talkpage. */ |
283 | 283 | $dbw =& wfGetDB( DB_MASTER ); |
284 | 284 | |
— | — | @@ -288,14 +288,14 @@ |
289 | 289 | $newid = $redirectArticle->insertOn( $dbw ); |
290 | 290 | $redirectRevision = new Revision( array( |
291 | 291 | 'page' => $newid, |
292 | | - 'comment' => "page moved from here", |
| 292 | + 'comment' => $reason, |
293 | 293 | 'text' => $redirectText ) ); |
294 | 294 | $redirectRevision->insertOn( $dbw ); |
295 | 295 | $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); |
296 | 296 | |
297 | 297 | # Log the move |
298 | 298 | $log = new LogPage( 'move' ); |
299 | | - $log->addEntry( 'move', $this->double->title(), "page moved from here", array( 1 => $this->title()->getPrefixedText()) ); |
| 299 | + $log->addEntry( 'move', $this->double->title(), $reason, array( 1 => $this->title()->getPrefixedText()) ); |
300 | 300 | |
301 | 301 | # Purge caches as per article creation |
302 | 302 | Article::onArticleCreate( $redirectArticle->getTitle() ); |