2021-03-25 20:35:15 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class CKEditorPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|
|
|
{
|
|
|
|
const
|
|
|
|
NAME = 'CKEditor',
|
2021-08-17 21:14:55 +08:00
|
|
|
VERSION = '2.2',
|
|
|
|
RELEASE = '2021-08-17',
|
|
|
|
REQUIRED = '2.6.2',
|
2021-03-25 20:35:15 +08:00
|
|
|
DESCRIPTION = 'Use CKEditor instead of Squire as WYSIWYG';
|
|
|
|
|
|
|
|
public function Init() : void
|
|
|
|
{
|
|
|
|
$path = APP_VERSION_ROOT_PATH . 'static/ckeditor';
|
|
|
|
|
|
|
|
// Apache AH00037: Symbolic link not allowed or link target not accessible
|
|
|
|
// That's why we clone the source
|
|
|
|
if (!\is_dir($path)/* && !\is_link($path)*/) {
|
2021-10-22 23:42:58 +08:00
|
|
|
$old_mask = umask(0022);
|
2021-03-25 20:35:15 +08:00
|
|
|
// $active = \symlink(__DIR__ . '/src', $path);
|
|
|
|
\mkdir($path, 0755);
|
|
|
|
$iterator = new \RecursiveIteratorIterator(
|
|
|
|
new \RecursiveDirectoryIterator(__DIR__ . '/src', \RecursiveDirectoryIterator::SKIP_DOTS),
|
|
|
|
\RecursiveIteratorIterator::SELF_FIRST
|
|
|
|
);
|
|
|
|
foreach ($iterator as $item) {
|
|
|
|
if ($item->isDir()) {
|
|
|
|
\mkdir($path . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
|
|
|
} else {
|
|
|
|
\copy($item, $path . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
|
|
|
}
|
|
|
|
}
|
2021-10-22 23:42:58 +08:00
|
|
|
umask($old_mask);
|
2021-03-25 20:35:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (\is_file("{$path}/ckeditor.js")) {
|
2021-08-30 15:43:18 +08:00
|
|
|
$this->addCss('style.css');
|
2021-03-25 20:35:15 +08:00
|
|
|
$this->addJs('ckeditor.js');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|