Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 84 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
SpecialCollabPad | |
0.00% |
0 / 84 |
|
0.00% |
0 / 5 |
56 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
userCanExecute | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
isListed | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 79 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | /** |
3 | * CollabPad special page |
4 | * |
5 | * @file |
6 | * @ingroup Extensions |
7 | * @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt |
8 | * @license MIT |
9 | */ |
10 | |
11 | namespace MediaWiki\Extension\VisualEditor; |
12 | |
13 | use MediaWiki\SpecialPage\SpecialPage; |
14 | use MediaWiki\Title\Title; |
15 | use MediaWiki\User\User; |
16 | use MediaWiki\Widget\TitleInputWidget; |
17 | use OOUI\ActionFieldLayout; |
18 | use OOUI\ButtonWidget; |
19 | use OOUI\FieldsetLayout; |
20 | use OOUI\FormLayout; |
21 | use OOUI\ProgressBarWidget; |
22 | use OOUI\TextInputWidget; |
23 | |
24 | class SpecialCollabPad extends SpecialPage { |
25 | |
26 | public function __construct() { |
27 | parent::__construct( 'CollabPad' ); |
28 | } |
29 | |
30 | /** |
31 | * @inheritDoc |
32 | */ |
33 | protected function getGroupName() { |
34 | return 'wiki'; |
35 | } |
36 | |
37 | /** |
38 | * @inheritDoc |
39 | */ |
40 | public function userCanExecute( User $user ) { |
41 | return $this->getConfig()->get( 'VisualEditorRebaserURL' ) && |
42 | parent::userCanExecute( $user ); |
43 | } |
44 | |
45 | /** |
46 | * @inheritDoc |
47 | */ |
48 | public function isListed() { |
49 | return (bool)$this->getConfig()->get( 'VisualEditorRebaserURL' ); |
50 | } |
51 | |
52 | /** |
53 | * @inheritDoc |
54 | */ |
55 | public function execute( $subPage ) { |
56 | $this->setHeaders(); |
57 | $this->checkPermissions(); |
58 | |
59 | $output = $this->getOutput(); |
60 | |
61 | $output->addJsConfigVars( 'collabPadPageName', $subPage ); |
62 | $output->addModuleStyles( 'ext.visualEditor.collabTarget.init.styles' ); |
63 | $output->addModuleStyles( 'oojs-ui.styles.icons-editing-core' ); |
64 | $output->addModuleStyles( 'oojs-ui.styles.icons-content' ); |
65 | |
66 | $output->addModules( 'ext.visualEditor.collabTarget.init' ); |
67 | |
68 | $output->enableOOUI(); |
69 | |
70 | $documentNameFieldset = new FieldsetLayout( [ |
71 | 'label' => $this->msg( 'visualeditor-rebase-client-document-create-edit' )->text(), |
72 | 'icon' => 'edit', |
73 | 'items' => [ |
74 | new ActionFieldLayout( |
75 | new TextInputWidget( [ |
76 | 'classes' => [ 've-init-mw-collabTarget-nameInput' ], |
77 | 'placeholder' => $this->msg( 'visualeditor-rebase-client-document-name' )->text(), |
78 | 'autofocus' => true, |
79 | 'infusable' => true |
80 | ] ), |
81 | new ButtonWidget( [ |
82 | 'classes' => [ 've-init-mw-collabTarget-nameButton' ], |
83 | 'label' => $this->msg( 'visualeditor-rebase-client-document-create-edit' )->text(), |
84 | 'flags' => [ 'primary', 'progressive' ], |
85 | // Only enable once JS has loaded |
86 | 'disabled' => true, |
87 | 'infusable' => true |
88 | ] ), |
89 | [ |
90 | 'align' => 'top', |
91 | 'classes' => [ 've-init-mw-collabTarget-nameField' ], |
92 | 'infusable' => true |
93 | ] |
94 | ) |
95 | ] |
96 | ] ); |
97 | $importFieldset = new FieldsetLayout( [ |
98 | 'label' => $this->msg( 'visualeditor-rebase-client-import' )->text(), |
99 | 'icon' => 'download', |
100 | 'items' => [ |
101 | new ActionFieldLayout( |
102 | new TitleInputWidget( [ |
103 | 'classes' => [ 've-init-mw-collabTarget-importInput' ], |
104 | 'placeholder' => $this->msg( 'visualeditor-rebase-client-import-name' )->text(), |
105 | 'infusable' => true, |
106 | ] ), |
107 | new ButtonWidget( [ |
108 | 'classes' => [ 've-init-mw-collabTarget-importButton' ], |
109 | 'label' => $this->msg( 'visualeditor-rebase-client-import' )->text(), |
110 | 'flags' => [ 'progressive' ], |
111 | // Only enable once JS has loaded |
112 | 'disabled' => true, |
113 | 'infusable' => true |
114 | ] ), |
115 | [ |
116 | 'align' => 'top', |
117 | 'classes' => [ 've-init-mw-collabTarget-importField' ], |
118 | 'infusable' => true |
119 | ] |
120 | ) |
121 | ] |
122 | ] ); |
123 | |
124 | $form = new FormLayout( [ |
125 | 'classes' => [ 've-init-mw-collabTarget-form' ], |
126 | 'items' => [ |
127 | $documentNameFieldset, |
128 | $importFieldset |
129 | ], |
130 | 'infusable' => true |
131 | ] ); |
132 | |
133 | $progressBar = new ProgressBarWidget( [ |
134 | 'classes' => [ 've-init-mw-collabTarget-loading' ], |
135 | 'infusable' => true |
136 | ] ); |
137 | |
138 | if ( $subPage ) { |
139 | $title = Title::newFromText( $subPage ); |
140 | $output->setPageTitleMsg( $this->msg( 'collabpad-doctitle', $title->getPrefixedText() ) ); |
141 | $form->addClasses( [ 'oo-ui-element-hidden' ] ); |
142 | } else { |
143 | // Scripts only, styles already added above |
144 | $output->addModules( 'ext.visualEditor.collabTarget' ); |
145 | $progressBar->addClasses( [ 'oo-ui-element-hidden' ] ); |
146 | } |
147 | $output->addHTML( $progressBar . $form ); |
148 | } |
149 | } |