forked from thelia-modules/Tinymce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTinymce.php
84 lines (72 loc) · 2.97 KB
/
Tinymce.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : [email protected] */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Tinymce;
use Propel\Runtime\Connection\ConnectionInterface;
use Symfony\Component\Filesystem\Filesystem;
use Thelia\Action\Document;
use Thelia\Model\ConfigQuery;
use Thelia\Module\BaseModule;
class Tinymce extends BaseModule
{
/** The module domain for internationalisation */
const MODULE_DOMAIN = 'tinymce';
private $jsPath;
private $webJsPath;
private $webMediaPath;
public function __construct()
{
$this->jsPath = __DIR__ . DS .'Resources' . DS . 'js' . DS . 'tinymce';
$this->webJsPath = THELIA_WEB_DIR . 'tinymce';
$this->webMediaPath = THELIA_WEB_DIR . 'media';
}
/**
* @inheritdoc
*/
public function postActivation(ConnectionInterface $con = null)
{
$fileSystem = new Filesystem();
// Create symbolic links or hard copy in the web directory
// (according to \Thelia\Action\Document::CONFIG_DELIVERY_MODE),
// to make the TinyMCE code available.
if (false === $fileSystem->exists($this->webJsPath)) {
if (ConfigQuery::read(Document::CONFIG_DELIVERY_MODE) === 'symlink') {
$fileSystem->symlink($this->jsPath, $this->webJsPath);
} else {
$fileSystem->mirror($this->jsPath, $this->webJsPath);
}
}
// Create the media directory in the web root, if required
if (false === $fileSystem->exists($this->webMediaPath)) {
$fileSystem->mkdir($this->webMediaPath . DS . 'upload');
$fileSystem->mkdir($this->webMediaPath . DS . 'thumbs');
}
}
/**
* @inheritdoc
*/
public function postDeactivation(ConnectionInterface $con = null)
{
$fileSystem = new Filesystem();
$fileSystem->remove($this->webJsPath);
}
/**
* @inheritdoc
*/
public function destroy(ConnectionInterface $con = null, $deleteModuleData = false)
{
// If we have to delete module data, remove the media directory.
if ($deleteModuleData) {
$fileSystem = new Filesystem();
$fileSystem->remove($this->webMediaPath);
}
}
}