| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Specials; |
| 4 |
|
| 5 |
use MediaWiki\Html\TemplateParser; |
| 6 |
use MediaWiki\MainConfigNames; |
| 7 |
use MediaWiki\SpecialPage\IncludableSpecialPage; |
| 8 |
use MediaWiki\Specials\Contribute\ContributeFactory; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
class SpecialContribute extends IncludableSpecialPage { |
| 24 |
|
| 25 |
public function __construct() { |
| 26 |
parent::__construct( 'Contribute' ); |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
public function execute( $par ) { |
| 33 |
$this->setHeaders(); |
| 34 |
$this->outputHeader(); |
| 35 |
|
| 36 |
$out = $this->getOutput(); |
| 37 |
$out->setPageTitleMsg( $this->msg( 'contribute-title', $this->getUser()->getName() ) ); |
| 38 |
$out->addModuleStyles( [ |
| 39 |
'mediawiki.special' |
| 40 |
] ); |
| 41 |
$out->addHTML( $this->getContributePage() ); |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
private function getContributePage() { |
| 51 |
$contributeFactory = new ContributeFactory( |
| 52 |
$this->getContext(), |
| 53 |
$this->getHookRunner() |
| 54 |
); |
| 55 |
$cards = $contributeFactory->getCards(); |
| 56 |
$user = $this->getContext()->getUser(); |
| 57 |
|
| 58 |
$templateParser = new TemplateParser( __DIR__ . '/Contribute/Templates' ); |
| 59 |
$templateData = [ |
| 60 |
'cards' => $cards, |
| 61 |
]; |
| 62 |
$outputHTML = $templateParser->processTemplate( |
| 63 |
'SpecialContribute', |
| 64 |
$templateData |
| 65 |
); |
| 66 |
|
| 67 |
return $outputHTML; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
public function getShortDescription( string $path = '' ): string { |
| 74 |
return $this->msg( 'special-tab-contribute-short' )->text(); |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
public function getAssociatedNavigationLinks(): array { |
| 81 |
if ( $this->isShowable() ) { |
| 82 |
$user = $this->getUser(); |
| 83 |
return ContributeFactory::getAssociatedNavigationLinks( |
| 84 |
$user, |
| 85 |
$user |
| 86 |
); |
| 87 |
} |
| 88 |
return []; |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public function isShowable(): bool { |
| 98 |
return ContributeFactory::isEnabledOnCurrentSkin( |
| 99 |
$this->getSkin(), |
| 100 |
$this->getConfig()->get( MainConfigNames::SpecialContributeSkinsEnabled ) |
| 101 |
); |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
class_alias( SpecialContribute::class, 'SpecialContribute' ); |