r53238 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53237‎ | r53238 | r53239 >
Date:16:01, 14 July 2009
Author:werdna
Status:deferred
Tags:
Comment:
Another missing file :)
Modified paths:
  • /trunk/extensions/LiquidThreads/pages/SpecialSplitThread.php (added) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/pages/SpecialSplitThread.php
@@ -0,0 +1,87 @@
 2+<?php
 3+
 4+// TODO access control
 5+class SpecialSplitThread extends ThreadActionPage {
 6+
 7+ function getFormFields() {
 8+ $splitForm = array(
 9+ 'subject' =>
 10+ array(
 11+ 'type' => 'text',
 12+ 'label-message' => 'lqt-thread-split-subject',
 13+ ),
 14+ 'reason' =>
 15+ array(
 16+ 'label-message' => 'movereason',
 17+ 'type' => 'text',
 18+ ),
 19+ );
 20+
 21+ return $splitForm;
 22+ }
 23+
 24+ /**
 25+ * @see SpecialPage::getDescription
 26+ */
 27+ function getDescription() {
 28+ wfLoadExtensionMessages( 'LiquidThreads' );
 29+ return wfMsg( 'lqt_split_thread' );
 30+ }
 31+
 32+ function trySubmit( $data ) {
 33+ // Load data
 34+ $newSubject = $data['subject'];
 35+ $reason = $data['reason'];
 36+
 37+ $this->recursiveSet( $this->mThread, $newSubject, $this->mThread, $reason, 'first' );
 38+
 39+ $title = clone $this->mThread->article()->getTitle();
 40+ $title->setFragment( '#'.$this->mThread->getAnchorName() );
 41+
 42+ $link = $this->user->getSkin()->link( $title, $this->mThread->subject() );
 43+
 44+ global $wgOut;
 45+ $wgOut->addHTML( wfMsgExt( 'lqt-split-success', array( 'parseinline', 'replaceafter' ),
 46+ $link ) );
 47+
 48+ return true;
 49+ }
 50+
 51+ function recursiveSet( $thread, $subject, $ancestor, $reason, $first = false ) {
 52+ $thread->setSubject( $subject );
 53+ $thread->setAncestor( $ancestor->id() );
 54+
 55+ if ($first) {
 56+ $thread->setSuperThread( null );
 57+ }
 58+
 59+ $thread->commitRevision( Threads::CHANGE_SPLIT, null, $reason );
 60+
 61+ foreach( $thread->replies() as $subThread ) {
 62+ $this->recursiveSet( $subThread, $subject, $ancestor, $reason );
 63+ }
 64+ }
 65+
 66+ function validateSubject( $target ) {
 67+ if (!$target) {
 68+ return wfMsgExt( 'lqt_split_nosubject', 'parseinline' );
 69+ }
 70+
 71+ $title = Title::newFromText( $target );
 72+
 73+ if ( !$title ) {
 74+ return wfMsgExt( 'lqt_split_badsubject', 'parseinline' );
 75+ }
 76+
 77+ return true;
 78+ }
 79+
 80+ function getPageName() {
 81+ return 'SplitThread';
 82+ }
 83+
 84+ function getSubmitText() {
 85+ wfLoadExtensionMessages( 'LiquidThreads' );
 86+ return wfMsg( 'lqt-split-submit' );
 87+ }
 88+}

Status & tagging log