Commit 5525bc6d authored by Tino Goratsch's avatar Tino Goratsch

- added some missing directories after the SVN to Git conversion

- reworked the process of getting all available WYSIWYG editors
parent 5e998975
......@@ -8,4 +8,6 @@
/uploads/categories/*
/uploads/files/*
/uploads/gallery/*
/uploads/logs/*
\ No newline at end of file
/uploads/logs/*
!.gitignore
\ No newline at end of file
......@@ -38,15 +38,20 @@ class WYSIWYG extends AbstractFunction
{
$params['id'] = !empty($params['id']) ? $params['id'] : $params['name'];
$serviceId = 'core.wysiwyg.' . $this->container->get('core.config')->getSettings('system')['wysiwyg'];
$serviceId = $this->container->get('core.config')->getSettings('system')['wysiwyg'];
if ($this->container->has($serviceId) === true) {
/** @var Core\WYSIWYG\AbstractWYSIWYG $wysiwyg */
$wysiwyg = $this->container->get($serviceId);
$wysiwyg->setParameters($params);
return $wysiwyg->display();
} else {
throw new \InvalidArgumentException('Can not find wysiwyg service ' . $serviceId);
if ($wysiwyg instanceof Core\WYSIWYG\AbstractWYSIWYG) {
$wysiwyg->setParameters($params);
return $wysiwyg->display();
}
throw new \InvalidArgumentException(get_class($wysiwyg) . ' has to extend the AbstractWYSIWYG class');
}
throw new \InvalidArgumentException('Can not find wysiwyg service ' . $serviceId);
}
}
}
\ No newline at end of file
......@@ -44,4 +44,11 @@ abstract class AbstractWYSIWYG
* @return string
*/
abstract public function display();
/**
* Returns the name of the WYSIWYG Editor
*
* @return string
*/
abstract public function getFriendlyName();
}
......@@ -40,6 +40,14 @@ class CKEditor extends Textarea
$this->view = $view;
}
/**
* @inheritdoc
*/
public function getFriendlyName()
{
return 'CKEditor';
}
/**
* @param \ACP3\Modules\ACP3\Emoticons\Model $emoticonsModel
*
......@@ -208,7 +216,7 @@ class CKEditor extends Textarea
$info = simplexml_load_file(LIBRARIES_DIR . 'ckeditor/info.xml');
$out .= "<script type=\"text/javascript\" src=\"" . $basePath . 'ckeditor.js?v=' . ((string) $info->version) . "\"></script>\n";
$out .= "<script type=\"text/javascript\" src=\"" . $basePath . 'ckeditor.js?v=' . ((string)$info->version) . "\"></script>\n";
return $out;
}
......
......@@ -27,6 +27,14 @@ class Textarea extends AbstractWYSIWYG
$this->modules = $modules;
}
/**
* @inheritdoc
*/
public function getFriendlyName()
{
return 'Textarea';
}
/**
* @param $emoticonsHelpers
*
......
......@@ -34,6 +34,14 @@ class TinyMCE extends Textarea
$this->view = $view;
}
/**
* @inheritdoc
*/
public function getFriendlyName()
{
return 'TinyMCE';
}
/**
* @inheritdoc
*/
......
......@@ -60,18 +60,20 @@ class Index extends Core\Modules\Controller\Admin
$this->view->assign('entries', $this->get('core.helpers.forms')->recordsPerPage($systemSettings['entries']));
// WYSIWYG-Editoren
$editors = array_diff(scandir(CLASSES_DIR . 'WYSIWYG'), ['.', '..', 'AbstractWYSIWYG.php']);
// WYSIWYG editors
$services = $this->container->getServiceIds();
$wysiwyg = [];
foreach ($editors as $editor) {
$editor = substr($editor, 0, strrpos($editor, '.php'));
if (!empty($editor)) {
$wysiwyg[] = [
'value' => $editor,
'selected' => $this->get('core.helpers.forms')->selectEntry('wysiwyg', $editor, $systemSettings['wysiwyg']),
'lang' => $editor
];
foreach ($services as $service) {
if (strpos($service, 'core.wysiwyg') === 0) {
$editor = $this->container->get($service);
if ($editor instanceof Core\WYSIWYG\AbstractWYSIWYG) {
$wysiwyg[] = [
'value' => $service,
'selected' => $this->get('core.helpers.forms')->selectEntry('wysiwyg', $service, $systemSettings['wysiwyg']),
'lang' => $editor->getFriendlyName()
];
}
}
}
$this->view->assign('wysiwyg', $wysiwyg);
......
......@@ -11,7 +11,7 @@ use ACP3\Core\Modules;
class Installer extends Modules\AbstractInstaller
{
const MODULE_NAME = 'system';
const SCHEMA_VERSION = 53;
const SCHEMA_VERSION = 54;
/**
* @var array
......@@ -313,6 +313,11 @@ class Installer extends Modules\AbstractInstaller
return $result;
}
],
54 => [
'UPDATE `{pre}settings` SET `value` = "core.wyiswyg.ckeditor" WHERE `module_id` = ' . $this->getModuleId() . ' AND `name` = "wysiwyg" AND `value` = "CKEditor";',
'UPDATE `{pre}settings` SET `value` = "core.wyiswyg.textarea" WHERE `module_id` = ' . $this->getModuleId() . ' AND `name` = "wysiwyg" AND `value` = "Textarea";',
'UPDATE `{pre}settings` SET `value` = "core.wyiswyg.tinymce" WHERE `module_id` = ' . $this->getModuleId() . ' AND `name` = "wysiwyg" AND `value` = "TinyMCE";',
]
];
}
......
......@@ -247,7 +247,7 @@
<item key="select_cache_images">Bitte wählen Sie aus, ob Bilder gecached werden sollen.</item>
<item key="select_date">Bitte vervollständigen Sie die Angaben zum Veröffentlichungsdatum bzw. dem Enddatum dieses Eintrages.</item>
<item key="select_date_format">Bitte wählen Sie aus, ob das lange oder das kurze Datumsformat verwendet werden soll.</item>
<item key="select_editor">Bitte wählen Sie aus, mit welchen Editor Sie Ihre Einträge erstellen wollen.</item>
<item key="select_editor">Bitte wählen Sie aus, mit welchem Editor Sie Ihre Einträge erstellen wollen.</item>
<item key="select_export_type">Bitte wählen Sie die Exportart aus.</item>
<item key="select_language">Bitte wählen Sie aus, in welcher Sprache Sie die Website angezeigt bekommen möchten.</item>
<item key="select_menu_item">Bitte wählen Sie einen der oben stehenden Menüpunkte aus, um zur gewünschten Aktion zu gelangen.</item>
......
......@@ -2,6 +2,7 @@
namespace ACP3\Modules\ACP3\System;
use ACP3\Core;
use Symfony\Component\DependencyInjection\Container;
/**
* Class Validator
......@@ -21,26 +22,33 @@ class Validator extends Core\Validator\AbstractValidator
* @var Core\Validator\Rules\Router
*/
protected $routerValidator;
/**
* @var \Symfony\Component\DependencyInjection\Container
*/
protected $container;
/**
* @param Core\Lang $lang
* @param Core\Validator\Rules\Misc $validate
* @param Core\Validator\Rules\Date $dateValidator
* @param Core\Validator\Rules\Mime $mimeValidator
* @param Core\Validator\Rules\Router $routerValidator
* @param \ACP3\Core\Lang $lang
* @param \ACP3\Core\Validator\Rules\Misc $validate
* @param \ACP3\Core\Validator\Rules\Date $dateValidator
* @param \ACP3\Core\Validator\Rules\Mime $mimeValidator
* @param \ACP3\Core\Validator\Rules\Router $routerValidator
* @param \Symfony\Component\DependencyInjection\Container $container
*/
public function __construct(
Core\Lang $lang,
Core\Validator\Rules\Misc $validate,
Core\Validator\Rules\Date $dateValidator,
Core\Validator\Rules\Mime $mimeValidator,
Core\Validator\Rules\Router $routerValidator
Core\Validator\Rules\Router $routerValidator,
Container $container
) {
parent::__construct($lang, $validate);
$this->dateValidator = $dateValidator;
$this->mimeValidator = $mimeValidator;
$this->routerValidator = $routerValidator;
$this->container = $container;
}
/**
......@@ -62,7 +70,9 @@ class Validator extends Core\Validator\AbstractValidator
if ($this->validate->isNumber($formData['flood']) === false) {
$this->errors['flood'] = $this->lang->t('system', 'type_in_flood_barrier');
}
if (preg_match('=/=', $formData['wysiwyg']) || is_file(CLASSES_DIR . 'WYSIWYG/' . $formData['wysiwyg'] . '.php') === false) {
if (empty($formData['wysiwyg']) ||
!$this->container->has($formData['wysiwyg']) ||
!($this->container->get($formData['wysiwyg']) instanceof Core\WYSIWYG\AbstractWYSIWYG)) {
$this->errors['wysiwyg'] = $this->lang->t('system', 'select_editor');
}
if ($this->lang->languagePackExists($formData['language']) === false) {
......
......@@ -30,7 +30,7 @@ services:
system.validator:
class: %system.validator.fqdn%
arguments: ['@core.lang', '@core.validator.rules.misc', '@core.validator.rules.date', '@core.validator.rules.mime', '@core.validator.rules.router']
arguments: ['@core.lang', '@core.validator.rules.misc', '@core.validator.rules.date', '@core.validator.rules.mime', '@core.validator.rules.router', '@service_container']
system.installer:
class: %system.installer.fqdn%
......
......@@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "0c1c2ed77b20f35e6a87ebbafd3a781d",
"hash": "c4d6b0b26c1349951dccbfd00e104a69",
"packages": [
{
"name": "doctrine/annotations",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment