Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 46 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
PageActions | |
0.00% |
0 / 46 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
getPageActionsDirector | |
0.00% |
0 / 41 |
|
0.00% |
0 / 1 |
30 |
1 | <?php |
2 | /** |
3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @file |
19 | */ |
20 | |
21 | namespace MediaWiki\Minerva\Menu\PageActions; |
22 | |
23 | use MediaWiki\Config\ServiceOptions; |
24 | use MediaWiki\Context\IContextSource; |
25 | use MediaWiki\Minerva\LanguagesHelper; |
26 | use MediaWiki\Minerva\Permissions\IMinervaPagePermissions; |
27 | use MediaWiki\Minerva\Permissions\MinervaPagePermissions; |
28 | use MediaWiki\Minerva\SkinOptions; |
29 | use MediaWiki\Minerva\Skins\SkinUserPageHelper; |
30 | use MediaWiki\SpecialPage\SpecialPage; |
31 | use MediaWiki\Watchlist\WatchlistManager; |
32 | |
33 | class PageActions { |
34 | |
35 | private LanguagesHelper $languagesHelper; |
36 | private IMinervaPagePermissions $permissions; |
37 | private SkinOptions $skinOptions; |
38 | private SkinUserPageHelper $skinUserPageHelper; |
39 | private WatchlistManager $watchlistManager; |
40 | |
41 | public function __construct( |
42 | LanguagesHelper $languagesHelper, |
43 | MinervaPagePermissions $permissions, |
44 | SkinOptions $skinOptions, |
45 | SkinUserPageHelper $skinUserPageHelper, |
46 | WatchlistManager $watchlistManager |
47 | ) { |
48 | $this->languagesHelper = $languagesHelper; |
49 | $this->permissions = $permissions; |
50 | $this->skinOptions = $skinOptions; |
51 | $this->skinUserPageHelper = $skinUserPageHelper; |
52 | $this->watchlistManager = $watchlistManager; |
53 | } |
54 | |
55 | public function getPageActionsDirector( IContextSource $context ): PageActionsDirector { |
56 | $title = $context->getTitle(); |
57 | if ( !$title ) { |
58 | $title = SpecialPage::getTitleFor( 'Badtitle' ); |
59 | } |
60 | $user = $context->getUser(); |
61 | |
62 | $this->skinUserPageHelper |
63 | ->setContext( $context ) |
64 | ->setTitle( $title->inNamespace( NS_USER_TALK ) ? |
65 | $context->getSkin()->getRelevantTitle()->getSubjectPage() : |
66 | $title |
67 | ); |
68 | |
69 | $toolbarBuilder = new ToolbarBuilder( |
70 | $title, |
71 | $user, |
72 | $context, |
73 | $this->permissions, |
74 | $this->skinOptions, |
75 | $this->skinUserPageHelper, |
76 | $this->languagesHelper, |
77 | new ServiceOptions( ToolbarBuilder::CONSTRUCTOR_OPTIONS, |
78 | $context->getConfig() ), |
79 | $this->watchlistManager |
80 | ); |
81 | if ( $this->skinOptions->get( SkinOptions::TOOLBAR_SUBMENU ) ) { |
82 | $overflowBuilder = $this->skinUserPageHelper->isUserPage() ? |
83 | new UserNamespaceOverflowBuilder( |
84 | $title, |
85 | $context, |
86 | $this->permissions, |
87 | $this->languagesHelper |
88 | ) : |
89 | new DefaultOverflowBuilder( |
90 | $title, |
91 | $context, |
92 | $this->permissions |
93 | ); |
94 | } else { |
95 | $overflowBuilder = new EmptyOverflowBuilder(); |
96 | } |
97 | |
98 | return new PageActionsDirector( |
99 | $toolbarBuilder, |
100 | $overflowBuilder, |
101 | $context |
102 | ); |
103 | } |
104 | |
105 | } |