2016-10-25 20:44:26 +00:00
|
|
|
<?php
|
2018-03-28 19:47:04 +00:00
|
|
|
/**
|
|
|
|
* CollabPad special page
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
|
|
|
* @copyright 2011-2018 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license MIT
|
|
|
|
*/
|
|
|
|
|
2016-10-25 20:44:26 +00:00
|
|
|
class SpecialCollabPad extends SpecialPage {
|
|
|
|
private $prefixes = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var null|Title
|
|
|
|
*/
|
|
|
|
private $title = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var null|ParserOutput
|
|
|
|
*/
|
|
|
|
private $output = null;
|
|
|
|
|
2017-12-30 22:29:40 +00:00
|
|
|
public function __construct() {
|
2016-10-25 20:44:26 +00:00
|
|
|
parent::__construct( 'CollabPad' );
|
|
|
|
}
|
|
|
|
|
2018-03-28 19:47:04 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2016-10-25 20:44:26 +00:00
|
|
|
protected function getGroupName() {
|
|
|
|
return 'wiki';
|
|
|
|
}
|
|
|
|
|
2018-03-28 19:47:04 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2016-10-25 20:44:26 +00:00
|
|
|
public function userCanExecute( User $user ) {
|
|
|
|
global $wgVisualEditorRebaserURL;
|
|
|
|
return !!$wgVisualEditorRebaserURL && parent::userCanExecute( $user );
|
|
|
|
}
|
|
|
|
|
2018-03-28 19:47:04 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2018-01-02 01:00:08 +00:00
|
|
|
public function isListed() {
|
2016-10-25 20:44:26 +00:00
|
|
|
global $wgVisualEditorRebaserURL;
|
|
|
|
return !!$wgVisualEditorRebaserURL;
|
|
|
|
}
|
|
|
|
|
2018-03-28 19:47:04 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2017-12-30 22:29:40 +00:00
|
|
|
public function execute( $par ) {
|
2016-10-25 20:44:26 +00:00
|
|
|
$this->setHeaders();
|
|
|
|
$this->checkPermissions();
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
|
|
|
|
$output = $this->getOutput();
|
|
|
|
|
|
|
|
$output->addJsConfigVars( 'collabPadPageName', $par );
|
|
|
|
$output->addModuleStyles( 'ext.visualEditor.collabTarget.init.styles' );
|
|
|
|
$output->addModules( 'ext.visualEditor.collabTarget.init' );
|
|
|
|
|
|
|
|
$output->enableOOUI();
|
2017-05-20 19:22:44 +00:00
|
|
|
|
|
|
|
$documentNameField = new OOUI\ActionFieldLayout(
|
|
|
|
new OOUI\TextInputWidget( [
|
|
|
|
'classes' => [ 've-init-mw-collabTarget-nameInput' ],
|
|
|
|
'placeholder' => $this->msg( 'visualeditor-rebase-client-document-name' )->text(),
|
|
|
|
'autofocus' => true,
|
|
|
|
'infusable' => true
|
|
|
|
] ),
|
|
|
|
new OOUI\ButtonWidget( [
|
|
|
|
'classes' => [ 've-init-mw-collabTarget-nameButton' ],
|
|
|
|
'label' => $this->msg( 'visualeditor-rebase-client-document-create-edit' )->text(),
|
|
|
|
// Only enable once JS has loaded
|
|
|
|
'disabled' => true,
|
|
|
|
'infusable' => true
|
|
|
|
] ),
|
|
|
|
[
|
|
|
|
'classes' => [ 've-init-mw-collabTarget-nameField' ],
|
|
|
|
'infusable' => true
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$progressBar = new OOUI\ProgressBarWidget( [
|
|
|
|
'classes' => [ 've-init-mw-collabTarget-loading' ],
|
|
|
|
'infusable' => true
|
|
|
|
] );
|
|
|
|
|
2016-10-25 20:44:26 +00:00
|
|
|
if ( $par ) {
|
|
|
|
$title = Title::newFromText( $par );
|
|
|
|
$output->setPageTitle( 'CollabPad: ' . $title->getPrefixedText() );
|
2017-05-20 19:22:44 +00:00
|
|
|
$documentNameField->addClasses( [ 'oo-ui-element-hidden' ] );
|
2016-10-25 20:44:26 +00:00
|
|
|
} else {
|
|
|
|
// Scripts only, styles already added above
|
|
|
|
$output->addModules( 'ext.visualEditor.collabTarget' );
|
2017-05-20 19:22:44 +00:00
|
|
|
$progressBar->addClasses( [ 'oo-ui-element-hidden' ] );
|
2016-10-25 20:44:26 +00:00
|
|
|
}
|
2017-05-20 19:22:44 +00:00
|
|
|
$output->addHTML( $progressBar . $documentNameField );
|
2016-10-25 20:44:26 +00:00
|
|
|
}
|
|
|
|
}
|