Completed
Push — master ( a848da...37f5b2 )
by Henry
05:28
created

CodeEditor::install()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
namespace Redaxscript\Modules\CodeEditor;
3
4
use Redaxscript\Head;
5
use Redaxscript\Module;
6
use Redaxscript\Modules;
7
8
/**
9
 * publish content with perfect code
10
 *
11
 * @since 2.6.0
12
 *
13
 * @package Redaxscript
14
 * @category Modules
15
 * @author Henry Ruhs
16
 */
17
18
class CodeEditor extends Module\Module
19
{
20
	/**
21
	 * array of the module
22
	 *
23
	 * @var array
24
	 */
25
26
	protected static $_moduleArray =
27
	[
28
		'name' => 'Code Editor',
29
		'alias' => 'CodeEditor',
30
		'author' => 'Redaxmedia',
31
		'description' => 'Publish content with perfect code',
32
		'version' => '4.3.0'
33
	];
34
35
	/**
36
	 * renderStart
37
	 *
38
	 * @since 3.0.0
39
	 */
40
41
	public function renderStart() : void
42
	{
43
		if ($this->_registry->get('loggedIn') === $this->_registry->get('token'))
44
		{
45
			/* link */
46
47
			$link = Head\Link::getInstance();
48
			$link
49
				->init()
50
				->appendFile('modules/CodeEditor/dist/styles/ace.min.css');
51
52
			/* script */
53
54
			$script = Head\Script::getInstance();
55
			$script
56
				->init('foot')
57
				->appendFile(
58
				[
59
					'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/ace.js',
60
					'modules/CodeEditor/assets/scripts/init.js',
61
					'modules/CodeEditor/dist/scripts/code-editor.min.js'
62
				]);
63
		}
64
	}
65
66
	/**
67
	 * install the module
68
	 *
69
	 * @since 4.3.0
70
	 *
71
	 * @return bool
72
	 */
73
74
	public function install() : bool
75
	{
76
		$visualEditor = new Modules\VisualEditor\VisualEditor($this->_registry, $this->_request, $this->_language, $this->_config);
77
		return $visualEditor->uninstall() && parent::install();
78
	}
79
}
80