Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 35
0.00% covered (danger)
0.00%
0 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
SpecialSplitThread
0.00% covered (danger)
0.00%
0 / 35
0.00% covered (danger)
0.00%
0 / 7
90
0.00% covered (danger)
0.00%
0 / 1
 getFormFields
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 1
2
 getDescription
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRightRequirement
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 trySubmit
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 validateSubject
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
12
 getPageName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getSubmitText
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3use MediaWiki\Message\Message;
4
5// TODO access control
6class SpecialSplitThread extends ThreadActionPage {
7    public function getFormFields() {
8        $splitForm = [
9            'src' => [
10                'type' => 'info',
11                'label-message' => 'lqt-thread-split-thread',
12                'default' => LqtView::permalink( $this->mThread ),
13                'raw' => 1,
14            ],
15            'subject' => [
16                'type' => 'text',
17                'label-message' => 'lqt-thread-split-subject',
18            ],
19            'reason' => [
20                'label-message' => 'movereason',
21                'type' => 'text',
22            ],
23        ];
24
25        return $splitForm;
26    }
27
28    /**
29     * @see SpecialPage::getDescription
30     * @return Message
31     */
32    public function getDescription() {
33        return $this->msg( 'lqt_split_thread' );
34    }
35
36    protected function getRightRequirement() {
37        return 'lqt-split';
38    }
39
40    public function trySubmit( $data ) {
41        // Load data
42        $newSubject = $data['subject'];
43        $reason = $data['reason'];
44
45        $this->mThread->split( $newSubject, $reason );
46
47        $link = LqtView::linkInContext( $this->mThread );
48
49        $this->getOutput()->addWikiMsg( 'lqt-split-success', Message::rawParam( $link ) );
50
51        return true;
52    }
53
54    public function validateSubject( $target ) {
55        if ( !$target ) {
56            return $this->msg( 'lqt_split_nosubject' )->parse();
57        }
58
59        $title = null;
60        $article = $this->mThread->article();
61
62        $ok = Thread::validateSubject( $target, $this->getUser(), $title, null, $article );
63
64        if ( !$ok ) {
65            return $this->msg( 'lqt_split_badsubject' )->parse();
66        }
67
68        return true;
69    }
70
71    public function getPageName() {
72        return 'SplitThread';
73    }
74
75    public function getSubmitText() {
76        return $this->msg( 'lqt-split-submit' )->text();
77    }
78}