Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 28
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
Sandbox
0.00% covered (danger)
0.00%
0 / 28
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getGroupName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 26
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Graph;
4
5use MediaWiki\Html\Html;
6use MediaWiki\SpecialPage\SpecialPage;
7
8class Sandbox extends SpecialPage {
9
10    public const PAGENAME = 'GraphSandbox';
11
12    public function __construct() {
13        parent::__construct( self::PAGENAME );
14    }
15
16    /**
17     * @inheritDoc
18     */
19    protected function getGroupName() {
20        return 'wiki';
21    }
22
23    /**
24     * Main execution function
25     * @param string|null $par Parameters passed to the page
26     */
27    public function execute( $par ) {
28        $out = $this->getContext()->getOutput();
29
30        $this->setHeaders();
31        $this->addHelpLink( 'Extension:Graph/Guide' );
32        $out->addModules( 'ext.graph.sandbox' );
33        $out->addModuleStyles( [
34            'ext.graph.sandbox.styles',
35            'ext.graph.styles'
36        ] );
37        // Tell CodeEditor that this page is JSON (T143165)
38        $out->addJsConfigVars( 'wgCodeEditorCurrentLanguage', 'json' );
39
40        $attr = ParserTag::buildDivAttributes( 'always' );
41        $attr['id'] = 'mw-graph-image';
42        $graphHtml = Html::rawElement( 'div', $attr, '' );
43
44        // FIXME: make this textarea readonly (but text should be selectable)
45        $specHtml = '<div><textarea tabindex="1" accesskey="," id="wpTextbox1" cols="80" rows="40"' .
46            ' style="" lang="en" dir="ltr" name="wpTextbox1" class="webfonts-changed"></textarea>' .
47            '</div>';
48        $jsonHtml = '<div><textarea id="mw-graph-json"></textarea></div>';
49
50        $out->addHTML(
51            Html::errorBox(
52                $out->msg( 'graph-sandbox-requires-js' )->text(),
53                '',
54                'mw-graph-sandbox-nojs'
55            )
56        );
57        $out->addHTML( Html::rawElement( 'div', [ 'id' => 'mw-graph-sandbox' ],
58            Html::rawElement( 'div', [ 'id' => 'mw-graph-left' ], $graphHtml . $jsonHtml ) .
59            Html::rawElement( 'div', [ 'id' => 'mw-graph-right' ], $specHtml ) ) );
60    }
61}