| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
namespace MediaWiki\Extension\ReplaceText; |
| 23 |
|
| 24 |
use MediaWiki\Config\Config; |
| 25 |
use MediaWiki\Hook\SpecialMovepageAfterMoveHook; |
| 26 |
use MediaWiki\SpecialPage\SpecialPageFactory; |
| 27 |
use MediaWiki\Specials\SpecialMovePage; |
| 28 |
use MediaWiki\Title\Title; |
| 29 |
use MediaWiki\User\Hook\UserGetReservedNamesHook; |
| 30 |
|
| 31 |
class Hooks implements |
| 32 |
SpecialMovepageAfterMoveHook, |
| 33 |
UserGetReservedNamesHook |
| 34 |
{ |
| 35 |
|
| 36 |
|
| 37 |
private $config; |
| 38 |
|
| 39 |
|
| 40 |
private $specialPageFactory; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
public function __construct( |
| 47 |
Config $config, |
| 48 |
SpecialPageFactory $specialPageFactory |
| 49 |
) { |
| 50 |
$this->config = $config; |
| 51 |
$this->specialPageFactory = $specialPageFactory; |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
public function onSpecialMovepageAfterMove( $form, $ot, $nt ) { |
| 65 |
if ( !$form->getUser()->isAllowed( 'replacetext' ) ) { |
| 66 |
return; |
| 67 |
} |
| 68 |
$out = $form->getOutput(); |
| 69 |
$page = $this->specialPageFactory->getPage( 'ReplaceText' ); |
| 70 |
$pageLink = $form->getLinkRenderer()->makeLink( $page->getPageTitle() ); |
| 71 |
$out->addHTML( $form->msg( 'replacetext_reminder' ) |
| 72 |
->rawParams( $pageLink )->parseAsBlock() ); |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
public function onUserGetReservedNames( &$names ) { |
| 80 |
$replaceTextUser = $this->config->get( 'ReplaceTextUser' ); |
| 81 |
if ( $replaceTextUser !== null ) { |
| 82 |
$names[] = $replaceTextUser; |
| 83 |
} |
| 84 |
} |
| 85 |
} |