Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
PageViewAction | |
0.00% |
0 / 22 |
|
0.00% |
0 / 1 |
72 | |
0.00% |
0 / 1 |
show | |
0.00% |
0 / 22 |
|
0.00% |
0 / 1 |
72 |
1 | <?php |
2 | |
3 | namespace ProofreadPage\Page; |
4 | |
5 | use MediaWiki\Revision\RevisionRecord; |
6 | use ProofreadPage\Context; |
7 | use ViewAction; |
8 | |
9 | /** |
10 | * @license GPL-2.0-or-later |
11 | * |
12 | * ViewAction for a Page: page |
13 | */ |
14 | class PageViewAction extends ViewAction { |
15 | |
16 | /** |
17 | * @see FormlessAction::show() |
18 | */ |
19 | public function show() { |
20 | $out = $this->getOutput(); |
21 | $title = $this->getTitle(); |
22 | $context = Context::getDefaultContext(); |
23 | |
24 | if ( !$title->inNamespace( $context->getPageNamespaceId() ) || |
25 | $out->isPrintable() || $this->getContext()->getRequest()->getCheck( 'diff' ) |
26 | ) { |
27 | $this->getArticle()->view(); |
28 | |
29 | return; |
30 | } |
31 | |
32 | $wikiPage = $this->getWikiPage(); |
33 | $content = $wikiPage->getContent( RevisionRecord::FOR_THIS_USER, $this->getUser() ); |
34 | if ( $content === null || $content->getModel() !== CONTENT_MODEL_PROOFREAD_PAGE || |
35 | $content->isRedirect() |
36 | ) { |
37 | $this->getArticle()->view(); |
38 | |
39 | return; |
40 | } |
41 | $pageDisplayHandler = new PageDisplayHandler( $context ); |
42 | |
43 | // render HTML |
44 | $out->addHTML( $pageDisplayHandler->buildPageContainerBegin() ); |
45 | $this->getArticle()->view(); |
46 | $out->addHTML( $pageDisplayHandler->buildPageContainerEnd( $title ) ); |
47 | |
48 | // add modules |
49 | $out->addModules( 'ext.proofreadpage.ve.pageTarget.init' ); |
50 | $out->addModuleStyles( [ 'ext.proofreadpage.base', 'ext.proofreadpage.page' ] ); |
51 | |
52 | // custom CSS |
53 | $css = $pageDisplayHandler->getCustomCss( $title ); |
54 | if ( $css !== '' ) { |
55 | $out->addInlineStyle( $css ); |
56 | } |
57 | } |
58 | } |