Skip to content
Code-Schnipsel Gruppen Projekte

Revisionen vergleichen

Änderungen werden so angezeigt, als ob die Quellrevision mit der Zielrevision zusammengeführt würde. Erfahre mehr über den Vergleich von Revisionen.

Quelle

Zielprojekt auswählen
No results found

Ziel

Zielprojekt auswählen
  • quiqqer/ckeditor4
1 Ergebnis
Änderungen anzeigen
Commits auf Quelle (6)
checklist.md5
\ No newline at end of file
tools/
phpstan.neon
.phpunit.result.cache
phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="^1.10.67" installed="1.10.67" location="./tools/phpstan" copy="false"/>
</phive>
......@@ -2,18 +2,17 @@
/**
* Activates the plugin
*
* @param pluginName
*
*/
use QUI\Ckeditor\Plugins\Manager;
QUI::$Ajax->registerFunction(
'package_quiqqer_ckeditor4_ajax_activatePlugin',
function ($pluginName) {
$PluginManager = new \QUI\Ckeditor\Plugins\Manager();
$PluginManager = new Manager();
$PluginManager->activate($pluginName);
},
array('pluginName'),
['pluginName'],
"quiqqer.editors.ckeditor.plugins.toggle"
);
......@@ -2,18 +2,17 @@
/**
* Deactivates the plugin
*
* @param pluginName
*
*/
use QUI\Ckeditor\Plugins\Manager;
QUI::$Ajax->registerFunction(
'package_quiqqer_ckeditor4_ajax_deactivatePlugin',
function ($pluginName) {
$PluginManager = new \QUI\Ckeditor\Plugins\Manager();
$PluginManager = new Manager();
$PluginManager->deactivate($pluginName);
},
array('pluginName'),
['pluginName'],
"quiqqer.editors.ckeditor.plugins.toggle"
);
......@@ -9,11 +9,11 @@ QUI::$Ajax->registerFunction(
function ($brickId) {
try {
$Brick = QUI\Bricks\Manager::init()->getBrickById($brickId);
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
return '';
}
return '#'.$Brick->getAttribute('id').' - '.$Brick->getAttribute('title');
return '#' . $Brick->getAttribute('id') . ' - ' . $Brick->getAttribute('title');
},
['brickId']
);
<?php
use QUI\Ckeditor\Plugins\Manager;
QUI::$Ajax->registerFunction(
'package_quiqqer_ckeditor4_ajax_getEditorConfig',
function () {
$config = array();
$Pluginmanager = new \QUI\Ckeditor\Plugins\Manager();
$config = [];
$PluginManager = new Manager();
$PackageConfig = QUI::getPackage("quiqqer/ckeditor4")->getConfig();
$config['plugins'] = $Pluginmanager->getActivePlugins();
$config['pluginPath'] = $Pluginmanager->getPluginUrlPath();
$config['plugins'] = $PluginManager->getActivePlugins();
$config['pluginPath'] = $PluginManager->getPluginUrlPath();
$config['disableNativeSpellChecker'] = $PackageConfig->get("general", "disablenativeSpellcheck");
return $config;
},
array()
}
);
......@@ -8,11 +8,10 @@
QUI::$Ajax->registerFunction(
'package_quiqqer_ckeditor4_ajax_getPermissions',
function () {
$result = array(
$result = [
'toggle' => false,
'upload' => false
);
];
if (QUI::getUserBySession()->getId() === 0) {
return $result;
......@@ -36,6 +35,5 @@ QUI::$Ajax->registerFunction(
}
return $result;
},
array()
}
);
......@@ -8,23 +8,21 @@
* 'plugins' => array('plugin1','plugin2','plugin3'...),
* 'pluginpath' => 'path/to/plugins'
* )
*
* @param pluginName
*
*/
use QUI\Cache\Manager;
QUI::$Ajax->registerFunction(
'package_quiqqer_ckeditor4_ajax_getPluginData',
function () {
if (QUI::getUserBySession()->getId() === 0) {
throw new \QUI\Exception("Invalid external function call. Caller must be logged in!");
}
try {
return \QUI\Cache\Manager::get("quiqqer/ckeditor/plugins/data");
} catch (\Exception $Exception) {
return Manager::get("quiqqer/ckeditor/plugins/data");
} catch (Exception) {
}
......@@ -32,22 +30,19 @@ QUI::$Ajax->registerFunction(
// Build the web reachable path for the plugin directory
$pluginPath = QUI::getPackage("quiqqer/ckeditor4")->getVarDir() . "plugins";
$varParent = dirname(VAR_DIR);
$varParent = dirname(VAR_DIR);
# Parse the URL directory
$pluginUrlPath = str_replace($varParent, "", $pluginPath);
$data = array(
'plugins' => $Manager->getActivePlugins(),
$data = [
'plugins' => $Manager->getActivePlugins(),
'pluginPath' => $pluginUrlPath
);
\QUI\Cache\Manager::set("quiqqer/ckeditor/plugins/data", $data);
];
Manager::set("quiqqer/ckeditor/plugins/data", $data);
return $data;
},
array()
}
);
......@@ -4,17 +4,17 @@
* Gets all plugins and their state
*/
use QUI\Ckeditor\Plugins\Manager;
QUI::$Ajax->registerFunction(
'package_quiqqer_ckeditor4_ajax_getPlugins',
function () {
if (QUI::getUserBySession()->getId() === 0) {
throw new \QUI\Exception("Invalid external function call. Caller must be logged in!");
}
$Pluginmanager = new \QUI\Ckeditor\Plugins\Manager();
$PluginManager = new Manager();
return $Pluginmanager->getAllPlugins();
},
array()
return $PluginManager->getAllPlugins();
}
);
<?php
use QUI\Ckeditor\Plugins\Manager;
use QUI\System\Log;
QUI::$Ajax->registerFunction(
'package_quiqqer_ckeditor4_ajax_uploadComplete',
function ($File) {
$filePath = $File->getAttribute('filepath');
$Manager = new Manager();
$Manager = new \QUI\Ckeditor\Plugins\Manager();
try {
$Manager->installPlugin($filePath);
} catch (\Exception $Exception) {
QUI::getMessagesHandler()->addError($Exception->getMessage());
\QUI\System\Log::addError($Exception->getMessage());
Log::addError($Exception->getMessage());
}
},
array('File'),
['File'],
"quiqqer.editors.ckeditor.plugins.upload"
);
{
"name": "quiqqer\/ckeditor4",
"name": "quiqqer/ckeditor4",
"type": "quiqqer-module",
"description": "CKEditor for the QUIQQER CMS - enable the ckeditor for quiqqer",
"license": "GPL-2.0-or-later",
......@@ -7,7 +7,7 @@
{
"name": "Henning Leutz",
"email": "leutz@pcsg.de",
"homepage": "http:\/\/www.pcsg.de",
"homepage": "https://www.pcsg.de",
"role": "Developer"
}
],
......@@ -15,14 +15,14 @@
"email": "support@pcsg.de"
},
"require": {
"quiqqer\/quiqqer": "*",
"quiqqer\/qui": ">=1|*@dev",
"ckeditor\/ckeditor": ">=4.16.0 <4.22.0"
"quiqqer/core": "^2",
"quiqqer/qui": "^1",
"ckeditor/ckeditor": ">=4.16.0 <4.22.0"
},
"autoload": {
"psr-4": {
"QUI\\Ckeditor\\": "src\/QUI\/Ckeditor\/",
"QUI\\Ckeditor\\Plugins\\": "src\/QUI\/Ckeditor\/Plugins\/"
"QUI\\Ckeditor\\": "src/QUI/Ckeditor/",
"QUI\\Ckeditor\\Plugins\\": "src/QUI/Ckeditor/Plugins/"
}
}
}
<?xml version="1.0"?>
<ruleset>
<!-- Use PSR-12 ruleset -->
<rule ref="PSR12"/>
<!-- Only scan *.php files -->
<arg name="extensions" value="php"/>
<!-- Ignore warnings -->
<arg name="warning-severity" value="0"/>
<!-- Process 64 (or number of CPU cores) files in parallel -->
<arg name="parallel" value="64"/>
<!-- Output relative file paths, by setting the current folder as the basepath -->
<arg name="basepath" value="."/>
<!-- Show colored output -->
<arg name="colors"/>
<!-- Scan everything in the current folder -->
<file>.</file>
</ruleset>
includes:
- phpstan-baseline.neon
parameters:
level: 1
paths:
- src
- ajax
bootstrapFiles:
- tests/phpstan-bootstrap.php
......@@ -39,7 +39,7 @@ class Manager
*
* @var array
*/
protected $blacklist = array(
protected $blacklist = [
"ckawesome",
"copyformatting",
"crossreference",
......@@ -48,7 +48,7 @@ class Manager
"enhancedcolorbutton",
"footnotes",
"textselection"
);
];
/**
* Manager constructor.
......@@ -57,8 +57,8 @@ class Manager
{
$Package = QUI::getPackage("quiqqer/ckeditor4");
$this->activePluginDir = $Package->getVarDir()."/plugins/bin";
$this->installedPluginDir = $Package->getVarDir()."/plugins/installed";
$this->activePluginDir = $Package->getVarDir() . "/plugins/bin";
$this->installedPluginDir = $Package->getVarDir() . "/plugins/installed";
if (!is_dir($this->activePluginDir)) {
mkdir($this->activePluginDir, 0755, true);
......@@ -78,11 +78,11 @@ class Manager
*/
public function updatePlugins()
{
$srcDirs = array(
OPT_DIR."ckeditor/ckeditor/plugins",
OPT_DIR."quiqqer/ckeditor4/plugins/quiqqer",
OPT_DIR."quiqqer/ckeditor4/plugins/ckeditor4"
);
$srcDirs = [
OPT_DIR . "ckeditor/ckeditor/plugins",
OPT_DIR . "quiqqer/ckeditor4/plugins/quiqqer",
OPT_DIR . "quiqqer/ckeditor4/plugins/ckeditor4"
];
foreach ($srcDirs as $srcDir) {
if (!is_dir($srcDir)) {
......@@ -94,7 +94,7 @@ class Manager
continue;
}
if (!is_dir($srcDir."/".$entry)) {
if (!is_dir($srcDir . "/" . $entry)) {
continue;
}
......@@ -105,10 +105,10 @@ class Manager
}
# Check if/where the plugin is installed
$targetDir = $this->installedPluginDir."/".$pluginName;
$targetDir = $this->installedPluginDir . "/" . $pluginName;
if (is_dir($this->activePluginDir."/".$pluginName)) {
$targetDir = $this->activePluginDir."/".$pluginName;
if (is_dir($this->activePluginDir . "/" . $pluginName)) {
$targetDir = $this->activePluginDir . "/" . $pluginName;
}
if (is_dir($targetDir)) {
......@@ -116,7 +116,7 @@ class Manager
}
File::dircopy(
$srcDir."/".$entry,
$srcDir . "/" . $entry,
$targetDir
);
}
......@@ -129,17 +129,17 @@ class Manager
*/
public function installPluginsFromSource()
{
$srcDirs = array(
OPT_DIR."ckeditor/ckeditor/plugins",
OPT_DIR."quiqqer/ckeditor4/plugins/quiqqer",
OPT_DIR."quiqqer/ckeditor4/plugins/ckeditor4"
);
$srcDirs = [
OPT_DIR . "ckeditor/ckeditor/plugins",
OPT_DIR . "quiqqer/ckeditor4/plugins/quiqqer",
OPT_DIR . "quiqqer/ckeditor4/plugins/ckeditor4"
];
$activePlugins = array();
$defaultStateFile = dirname(dirname(dirname(dirname(dirname(__FILE__)))))."/plugins/activePlugins.json";
$activePlugins = [];
$defaultStateFile = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/plugins/activePlugins.json";
if (file_exists($defaultStateFile)) {
$json = file_get_contents($defaultStateFile);
$json = file_get_contents($defaultStateFile);
$activePlugins = json_decode($json, true);
}
......@@ -165,15 +165,15 @@ class Manager
$targetDir = $this->activePluginDir;
}
if (!is_dir($srcDir."/".$entry)) {
if (!is_dir($srcDir . "/" . $entry)) {
continue;
}
if (is_dir($this->installedPluginDir."/".$pluginName)) {
if (is_dir($this->installedPluginDir . "/" . $pluginName)) {
continue;
}
if (is_dir($this->activePluginDir."/".$pluginName)) {
if (is_dir($this->activePluginDir . "/" . $pluginName)) {
continue;
}
......@@ -181,21 +181,20 @@ class Manager
continue;
}
$this->copyDir(
$srcDir."/".$entry,
$targetDir."/".$pluginName
$srcDir . "/" . $entry,
$targetDir . "/" . $pluginName
);
}
}
if (file_exists(OPT_DIR."quiqqer/ckeditor4/plugins/dependencies.json")) {
if (file_exists(OPT_DIR . "quiqqer/ckeditor4/plugins/dependencies.json")) {
copy(
OPT_DIR."quiqqer/ckeditor4/plugins/dependencies.json",
$this->getPluginDir()."/dependencies.json"
OPT_DIR . "quiqqer/ckeditor4/plugins/dependencies.json",
$this->getPluginDir() . "/dependencies.json"
);
}
#File::deleteDir(OPT_DIR . "ckeditor/ckeditor/plugins");
}
......@@ -206,12 +205,12 @@ class Manager
*/
public function getInstalledPlugins()
{
$result = array();
$result = [];
$content = scandir($this->installedPluginDir);
if ($content === false) {
return array();
return [];
}
foreach ($content as $entry) {
......@@ -219,7 +218,7 @@ class Manager
continue;
}
$fullpath = $this->installedPluginDir."/".$entry;
$fullpath = $this->installedPluginDir . "/" . $entry;
if (!is_dir($fullpath)) {
continue;
......@@ -242,29 +241,29 @@ class Manager
{
# Check if file exists
if (!file_exists($pluginpath)) {
throw new Exception(array("quiqqer/ckeditor4", "exception.install.file.not.found"));
throw new Exception(["quiqqer/ckeditor4", "exception.install.file.not.found"]);
}
$tmpDir = QUI::getTemp()->createFolder();
copy(
$pluginpath,
$tmpDir."/archive.zip"
$tmpDir . "/archive.zip"
);
$Zip = new \ZipArchive();
if ($Zip->open($tmpDir."/archive.zip") === false) {
throw new Exception(array("quiqqer/ckeditor4", "exception.install.file.invalid.format"));
if ($Zip->open($tmpDir . "/archive.zip") === false) {
throw new Exception(["quiqqer/ckeditor4", "exception.install.file.invalid.format"]);
}
if ($Zip->extractTo($tmpDir."/content") === false) {
throw new Exception(array("quiqqer/ckeditor4", "exception.install.file.extract.failed"));
if ($Zip->extractTo($tmpDir . "/content") === false) {
throw new Exception(["quiqqer/ckeditor4", "exception.install.file.extract.failed"]);
}
// Scan dir and remove '.' and '..'
$contents = scandir($tmpDir."/content");
$contents = scandir($tmpDir . "/content");
foreach (array_keys($contents, ".", true) as $key) {
unset($contents[$key]);
}
......@@ -276,10 +275,10 @@ class Manager
// Check if the zip contains only one folder
if (count($contents) !== 1) {
throw new Exception(array(
throw new Exception([
"quiqqer/ckeditor4",
"exception.plugin.install.wrong.format"
));
]);
}
......@@ -289,17 +288,17 @@ class Manager
continue;
}
if (is_dir($this->installedPluginDir."/".$entry)) {
throw new Exception(array("quiqqer/ckeditor4", "exception.install.file.exists"));
if (is_dir($this->installedPluginDir . "/" . $entry)) {
throw new Exception(["quiqqer/ckeditor4", "exception.install.file.exists"]);
}
if (is_dir($this->activePluginDir."/".$entry)) {
throw new Exception(array("quiqqer/ckeditor4", "exception.install.file.exists"));
if (is_dir($this->activePluginDir . "/" . $entry)) {
throw new Exception(["quiqqer/ckeditor4", "exception.install.file.exists"]);
}
rename(
$tmpDir."/content/".$entry,
$this->installedPluginDir."/".$entry
$tmpDir . "/content/" . $entry,
$this->installedPluginDir . "/" . $entry
);
}
......@@ -330,24 +329,24 @@ class Manager
$pluginName = str_replace("/", "", $pluginName);
if (in_array($pluginName, $this->blacklist)) {
throw new Exception(array(
throw new Exception([
"quiqqer/ckeditor4",
"exception.plugin.activate.blacklisted"
));
]);
}
if (!is_dir($this->installedPluginDir."/".$pluginName)) {
throw new Exception(array(
if (!is_dir($this->installedPluginDir . "/" . $pluginName)) {
throw new Exception([
"quiqqer/ckeditor4",
"exception.plugin.activate.plugin.not.found"
));
]);
}
if (is_dir($this->activePluginDir."/".$pluginName)) {
throw new Exception(array(
if (is_dir($this->activePluginDir . "/" . $pluginName)) {
throw new Exception([
"quiqqer/ckeditor4",
"exception.plugin.already.active"
));
]);
}
$deps = $this->getDependencies($pluginName);
......@@ -360,8 +359,8 @@ class Manager
}
rename(
$this->installedPluginDir."/".$pluginName,
$this->activePluginDir."/".$pluginName
$this->installedPluginDir . "/" . $pluginName,
$this->activePluginDir . "/" . $pluginName
);
QUI\Cache\Manager::clear("quiqqer/ckeditor/plugins/data");
......@@ -379,15 +378,15 @@ class Manager
$pluginName = Orthos::clearPath($pluginName);
$pluginName = str_replace("/", "", $pluginName);
if (!is_dir($this->activePluginDir."/".$pluginName)) {
throw new Exception(array(
if (!is_dir($this->activePluginDir . "/" . $pluginName)) {
throw new Exception([
"quiqqer/ckeditor4",
"exception.plugin.activate.plugin.not.active"
));
]);
}
if (is_dir($this->installedPluginDir."/".$pluginName)) {
File::deleteDir($this->activePluginDir."/".$pluginName);
if (is_dir($this->installedPluginDir . "/" . $pluginName)) {
File::deleteDir($this->activePluginDir . "/" . $pluginName);
return;
}
......@@ -400,8 +399,8 @@ class Manager
}
rename(
$this->activePluginDir."/".$pluginName,
$this->installedPluginDir."/".$pluginName
$this->activePluginDir . "/" . $pluginName,
$this->installedPluginDir . "/" . $pluginName
);
QUI\Cache\Manager::clear("quiqqer/ckeditor/plugins/data");
......@@ -414,11 +413,11 @@ class Manager
*/
public function getActivePlugins()
{
$result = array();
$result = [];
$content = scandir($this->activePluginDir);
if ($content === false) {
return array();
return [];
}
foreach ($content as $entry) {
......@@ -426,7 +425,7 @@ class Manager
continue;
}
$fullpath = $this->activePluginDir."/".$entry;
$fullpath = $this->activePluginDir . "/" . $entry;
if (!is_dir($fullpath)) {
continue;
......@@ -459,10 +458,10 @@ class Manager
return false;
}
$result = array();
$result = [];
if (!isset($this->dependencies[$pluginName])) {
return array();
return [];
}
$deps = $this->dependencies[$pluginName];
......@@ -471,7 +470,7 @@ class Manager
$result[] = $dep;
$subDeps = $this->getDependencies($dep);
$result = array_merge($result, $subDeps);
$result = array_merge($result, $subDeps);
}
$result = array_unique($result);
......@@ -489,7 +488,7 @@ class Manager
*/
public function getDependentPlugins($pluginName)
{
$result = array();
$result = [];
try {
$this->loadDependencies();
......@@ -519,13 +518,13 @@ class Manager
return;
}
if (!file_exists($this->getPluginDir()."/dependencies.json")) {
Log::addWarning("Missing dependency file: ".$this->getPluginDir()."/dependencies.json");
if (!file_exists($this->getPluginDir() . "/dependencies.json")) {
Log::addWarning("Missing dependency file: " . $this->getPluginDir() . "/dependencies.json");
throw new Exception("missing.dependency.file");
}
$json = file_get_contents($this->getPluginDir()."/dependencies.json");
$json = file_get_contents($this->getPluginDir() . "/dependencies.json");
$deps = json_decode($json, true);
if (json_last_error() !== JSON_ERROR_NONE) {
......@@ -553,20 +552,20 @@ class Manager
*/
public function getAllPlugins()
{
$result = array();
$result = [];
foreach ($this->getActivePlugins() as $plugin) {
$result[] = array(
'name' => $plugin,
$result[] = [
'name' => $plugin,
'state' => 1
);
];
}
foreach ($this->getInstalledPlugins() as $plugin) {
$result[] = array(
'name' => $plugin,
$result[] = [
'name' => $plugin,
'state' => 0
);
];
}
return $result;
......@@ -579,7 +578,7 @@ class Manager
*/
public function getPluginDir()
{
return QUI::getPackage("quiqqer/ckeditor4")->getVarDir()."/plugins";
return QUI::getPackage("quiqqer/ckeditor4")->getVarDir() . "/plugins";
}
/**
......@@ -601,14 +600,14 @@ class Manager
continue;
}
$fullpath = $src."/".$entry;
$fullpath = $src . "/" . $entry;
if (is_dir($fullpath)) {
$this->copyDir($fullpath, $target."/".$entry);
$this->copyDir($fullpath, $target . "/" . $entry);
continue;
}
copy($fullpath, $target."/".$entry);
copy($fullpath, $target . "/" . $entry);
}
}
......@@ -620,8 +619,8 @@ class Manager
public function getPluginUrlPath()
{
// Build the web reachable path for the plugin directory
$pluginPath = QUI::getPackage("quiqqer/ckeditor4")->getVarDir()."plugins";
$varParent = dirname(VAR_DIR);
$pluginPath = QUI::getPackage("quiqqer/ckeditor4")->getVarDir() . "plugins";
$varParent = dirname(VAR_DIR);
# Parse the URL directory
$pluginUrlPath = str_replace($varParent, "", $pluginPath);
......
<?php
if (!defined('QUIQQER_SYSTEM')) {
define('QUIQQER_SYSTEM', true);
}
if (!defined('QUIQQER_AJAX')) {
define('QUIQQER_AJAX', true);
}
putenv("QUIQQER_OTHER_AUTOLOADERS=KEEP");
require_once __DIR__ . '/../../../../bootstrap.php';