Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 92 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| SpecialCollabPad | |
0.00% |
0 / 92 |
|
0.00% |
0 / 7 |
156 | |
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 | |||
| getShortDescription | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |||
| getAssociatedNavigationLinks | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| execute | |
0.00% |
0 / 78 |
|
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 getShortDescription( string $path = '' ): string { |
| 56 | switch ( $path ) { |
| 57 | case 'CollabPad': |
| 58 | return $this->msg( 'collabpad' )->text(); |
| 59 | default: |
| 60 | return implode( '/', array_slice( explode( '/', $path ), 1 ) ); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * @inheritDoc |
| 66 | */ |
| 67 | public function getAssociatedNavigationLinks() { |
| 68 | $thisTitle = $this->getSkin()->getTitle()->getFullText(); |
| 69 | $title = SpecialPage::getTitleFor( 'CollabPad' )->getFullText(); |
| 70 | $links = [ $title ]; |
| 71 | if ( $title !== $thisTitle ) { |
| 72 | $links[] = $thisTitle; |
| 73 | } |
| 74 | return $links; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * @inheritDoc |
| 79 | */ |
| 80 | public function execute( $subPage ) { |
| 81 | $this->setHeaders(); |
| 82 | |
| 83 | $output = $this->getOutput(); |
| 84 | |
| 85 | $output->addJsConfigVars( 'collabPadPageName', $subPage ); |
| 86 | $output->addModuleStyles( 'ext.visualEditor.collabTarget.init.styles' ); |
| 87 | $output->addModuleStyles( 'oojs-ui.styles.icons-editing-core' ); |
| 88 | $output->addModuleStyles( 'oojs-ui.styles.icons-content' ); |
| 89 | |
| 90 | $output->addModules( 'ext.visualEditor.collabTarget.init' ); |
| 91 | |
| 92 | $output->enableOOUI(); |
| 93 | |
| 94 | $documentNameFieldset = new FieldsetLayout( [ |
| 95 | 'label' => $this->msg( 'visualeditor-rebase-client-document-create-edit' )->text(), |
| 96 | 'icon' => 'edit', |
| 97 | 'items' => [ |
| 98 | new ActionFieldLayout( |
| 99 | new TextInputWidget( [ |
| 100 | 'classes' => [ 've-init-mw-collabTarget-nameInput' ], |
| 101 | 'placeholder' => $this->msg( 'visualeditor-rebase-client-document-name' )->text(), |
| 102 | 'autofocus' => true, |
| 103 | 'infusable' => true |
| 104 | ] ), |
| 105 | new ButtonWidget( [ |
| 106 | 'classes' => [ 've-init-mw-collabTarget-nameButton' ], |
| 107 | 'label' => $this->msg( 'visualeditor-rebase-client-document-create-edit' )->text(), |
| 108 | 'flags' => [ 'primary', 'progressive' ], |
| 109 | // Only enable once JS has loaded |
| 110 | 'disabled' => true, |
| 111 | 'infusable' => true |
| 112 | ] ), |
| 113 | [ |
| 114 | 'align' => 'top', |
| 115 | 'classes' => [ 've-init-mw-collabTarget-nameField' ], |
| 116 | 'infusable' => true |
| 117 | ] |
| 118 | ) |
| 119 | ] |
| 120 | ] ); |
| 121 | $importFieldset = new FieldsetLayout( [ |
| 122 | 'label' => $this->msg( 'visualeditor-rebase-client-import' )->text(), |
| 123 | 'icon' => 'download', |
| 124 | 'items' => [ |
| 125 | new ActionFieldLayout( |
| 126 | new TitleInputWidget( [ |
| 127 | 'classes' => [ 've-init-mw-collabTarget-importInput' ], |
| 128 | 'placeholder' => $this->msg( 'visualeditor-rebase-client-import-name' )->text(), |
| 129 | 'infusable' => true, |
| 130 | ] ), |
| 131 | new ButtonWidget( [ |
| 132 | 'classes' => [ 've-init-mw-collabTarget-importButton' ], |
| 133 | 'label' => $this->msg( 'visualeditor-rebase-client-import' )->text(), |
| 134 | 'flags' => [ 'progressive' ], |
| 135 | // Only enable once JS has loaded |
| 136 | 'disabled' => true, |
| 137 | 'infusable' => true |
| 138 | ] ), |
| 139 | [ |
| 140 | 'align' => 'top', |
| 141 | 'classes' => [ 've-init-mw-collabTarget-importField' ], |
| 142 | 'infusable' => true |
| 143 | ] |
| 144 | ) |
| 145 | ] |
| 146 | ] ); |
| 147 | |
| 148 | $form = new FormLayout( [ |
| 149 | 'classes' => [ 've-init-mw-collabTarget-form' ], |
| 150 | 'items' => [ |
| 151 | $documentNameFieldset, |
| 152 | $importFieldset |
| 153 | ], |
| 154 | 'infusable' => true |
| 155 | ] ); |
| 156 | |
| 157 | $progressBar = new ProgressBarWidget( [ |
| 158 | 'classes' => [ 've-init-mw-collabTarget-loading' ], |
| 159 | 'infusable' => true |
| 160 | ] ); |
| 161 | |
| 162 | if ( $subPage ) { |
| 163 | $title = Title::newFromText( $subPage ); |
| 164 | $output->setPageTitleMsg( $this->msg( 'collabpad-doctitle', $title->getPrefixedText() ) ); |
| 165 | $form->addClasses( [ 'oo-ui-element-hidden' ] ); |
| 166 | } else { |
| 167 | // Scripts only, styles already added above |
| 168 | $output->addModules( 'ext.visualEditor.collabTarget' ); |
| 169 | $progressBar->addClasses( [ 'oo-ui-element-hidden' ] ); |
| 170 | } |
| 171 | $output->addHTML( $progressBar . $form ); |
| 172 | } |
| 173 | } |