Commit 419b8db0 authored by Tino Goratsch's avatar Tino Goratsch

Merge commit 'c15623a6' as 'ACP3/Modules/ACP3/WYSIWYGTinyMCE'

parents 6e77c91f c15623a6
<?php
namespace ACP3\Modules\ACP3\WYSIWYGTinyMCE;
use ACP3\Core\Modules;
/**
* Class Installer
* @package ACP3\Modules\ACP3\WYSIWYGTinyMCE
*/
class Installer extends Modules\AbstractInstaller
{
const MODULE_NAME = 'wysiwygtinymce';
const SCHEMA_VERSION = 1;
/**
* @inheritdoc
*/
public function createTables()
{
return [];
}
/**
* @inheritdoc
*/
public function removeTables()
{
return [];
}
/**
* @inheritdoc
*/
public function settings()
{
return [];
}
/**
* @inheritdoc
*/
public function schemaUpdates()
{
return [];
}
}
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="wysiwygtinymce">TinyMCE (WYSIWYG-Editor)</item>
<item key="mod_description">Dieses Modul ermöglicht die Nutzung des TinyMCE WYSIWYG-Editors.</item>
</keys>
</language>
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="wysiwygtinymce">TinyMCE (WYSIWYG editor)</item>
<item key="mod_description">This module enables the usage of the TinyMCE WYSIWYG editor.</item>
</keys>
</language>
<?php
namespace ACP3\Modules\ACP3\WYSIWYGTinyMCE\WYSIWYG;
use ACP3\Core;
/**
* Implementation of the AbstractWYSIWYG class for TinyMCE
* @package ACP3\Modules\ACP3\WYSIWYGTinyMCE\WYSIWYG
*/
class TinyMCE extends Core\WYSIWYG\Textarea
{
/**
* @var \ACP3\Core\Assets
*/
private $assets;
/**
* @var \ACP3\Core\View
*/
private $view;
/**
* @var \ACP3\Modules\ACP3\Filemanager\Helpers
*/
protected $filemanagerHelpers;
/**
* @var bool
*/
private $initialized = false;
/**
* @param \ACP3\Core\Assets $assets
* @param \ACP3\Core\View $view
*/
public function __construct(
Core\Assets $assets,
Core\View $view
) {
$this->assets = $assets;
$this->view = $view;
}
/**
* @inheritdoc
*/
public function getFriendlyName()
{
return 'TinyMCE';
}
/**
* @param \ACP3\Modules\ACP3\Filemanager\Helpers $filemanagerHelpers
*
* @return $this
*/
public function setFilemanagerHelpers(\ACP3\Modules\ACP3\Filemanager\Helpers $filemanagerHelpers)
{
$this->filemanagerHelpers = $filemanagerHelpers;
return $this;
}
/**
* @inheritdoc
*/
public function setParameters(array $params = [])
{
parent::setParameters($params);
$this->config['toolbar'] = (isset($params['toolbar'])) ? $params['toolbar'] : '';
$this->config['height'] = ((isset($params['height'])) ? $params['height'] : 250) . 'px';
}
/**
* @inheritdoc
*/
public function display()
{
$editor = '';
if ($this->initialized === false) {
$this->initialized = true;
$editor .= '<script type="text/javascript" src="' . ROOT_DIR . 'vendor/tinymce/tinymce/tinymce.min.js"></script>';
}
$editor .= '<script type="text/javascript">' . "\n";
$editor .= 'tinymce.init(' . $this->_configure() . ');' . "\n";
$editor .= "</script>\n";
$wysiwyg = [
'id' => $this->id,
'name' => $this->name,
'value' => $this->value,
'js' => $editor,
'advanced' => $this->advanced,
];
if ($wysiwyg['advanced'] === true) {
$wysiwyg['advanced_replace_content'] = 'tinyMCE.execInstanceCommand(\'' . $this->id . '\',"mceInsertContent",false,text);';
}
$this->view->assign('wysiwyg', $wysiwyg);
return $this->view->fetchTemplate('system/wysiwyg.tpl');
}
/**
* @return string
*/
private function _configure()
{
$config = [
'selector' => 'textarea#' . $this->id,
'theme' => 'modern',
'height' => $this->config['height'],
'content_css' => $this->assets->buildMinifyLink('css')
];
// Basic editor
if (isset($this->config['toolbar']) && $this->config['toolbar'] === 'simple') {
$config['plugins'] = [
'advlist autolink lists link image charmap print preview anchor',
'searchreplace visualblocks code fullscreen',
'insertdatetime media table contextmenu paste'
];
$config['toolbar'] = 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image';
return json_encode($config);
} else { // Full editor
$config['plugins'] = [
'advlist autolink lists link image charmap print preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code fullscreen',
'insertdatetime media nonbreaking save table contextmenu directionality',
'emoticons template paste textcolor colorpicker'
];
$config['toolbar'] = 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media | forecolor backcolor emoticons';
$config['image_advtab'] = true;
if ($this->filemanagerHelpers instanceof \ACP3\Modules\ACP3\Filemanager\Helpers) {
// Filebrowser
$fileBrowserOptions = [
'file' => $this->filemanagerHelpers->getFilemanagerPath() . 'browse.php?opener=tinymce4&field= + field + &cms=acp3&type= + (type == "image" ? "gallery" : "files")',
'title' => 'KCFinder',
'width' => 700,
'height' => 500,
'inline' => true,
'close_previous' => false
];
$fileBrowserCallback = ",\"file_browser_callback\": function(field, url, type, win) {
tinyMCE.activeEditor.windowManager.open(" . json_encode($fileBrowserOptions) . ", {
window: win,
input: field
});
return false;
}";
}
// Ugly hack to prevent the callback function getting converted into a string
return substr(json_encode($config), 0, -1) . $fileBrowserCallback . '}';
}
}
}
{
"name": "acp3/module-wysiwyg-tinymce",
"type": "acp3-module",
"require": {
"acp3/composer-installer": "*",
"tinymce/tinymce": "4.1.9"
},
"extra": {
"installer-name": "ACP3/WYSIWYGTinyMCE"
}
}
\ No newline at end of file
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "541de309a93cdd8e8638ba27da2c6320",
"packages": [
{
"name": "acp3/composer-installer",
"version": "0.1.2",
"source": {
"type": "git",
"url": "https://github.com/ACP3/composer-installer.git",
"reference": "d44e0f2f68f6e6558fb3cede8aef059373351a85"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ACP3/composer-installer/zipball/d44e0f2f68f6e6558fb3cede8aef059373351a85",
"reference": "d44e0f2f68f6e6558fb3cede8aef059373351a85",
"shasum": ""
},
"require": {
"composer-plugin-api": "1.0.0"
},
"require-dev": {
"composer/composer": "1.0.*@dev"
},
"type": "composer-plugin",
"extra": {
"class": "ACP3\\Composer\\Installer\\Plugin"
},
"autoload": {
"psr-0": {
"ACP3\\Composer": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL"
],
"authors": [
{
"name": "Tino Goratsch",
"email": "mail@acp3-cms.net"
}
],
"description": "Adds a custom installer to Composer so that it can install ACP3 modules into the right location.",
"time": "2015-03-16 21:04:16"
},
{
"name": "tinymce/tinymce",
"version": "4.1.9",
"source": {
"type": "git",
"url": "https://github.com/tinymce/tinymce-dist.git",
"reference": "0c25116c95fe26532e04708c495ec047e7e5acc5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tinymce/tinymce-dist/zipball/0c25116c95fe26532e04708c495ec047e7e5acc5",
"reference": "0c25116c95fe26532e04708c495ec047e7e5acc5",
"shasum": ""
},
"type": "component",
"extra": {
"component": {
"scripts": [
"tinymce.js",
"plugins/*/plugin.js",
"themes/*/theme.js"
],
"files": [
"tinymce.min.js",
"plugins/*/plugin.min.js",
"themes/*/theme.min.js",
"skins/**"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1"
],
"description": "Web based JavaScript HTML WYSIWYG editor control.",
"homepage": "http://www.tinymce.com",
"keywords": [
"editor",
"html",
"javascript",
"richtext",
"tinymce",
"wysiwyg"
],
"time": "2015-03-10 12:20:06"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
<?xml version="1.0" encoding="UTF-8"?>
<module>
<info>
<name lang="true"/>
<description lang="true"/>
<author>Tino Goratsch</author>
<version core="true"/>
</info>
</module>
parameters:
wysiwygtinymce.installer.fqdn: 'ACP3\Modules\ACP3\WYSIWYGTinyMCE\Installer'
core.wysiwyg.tinymce.fqdn: 'ACP3\Modules\ACP3\WYSIWYGTinyMCE\WYSIWYG\TinyMCE'
services:
wysiwygtinymce.installer:
class: %wysiwygtinymce.installer.fqdn%
parent: core.modules.abstractInstaller
core.wysiwyg.tinymce:
class: %core.wysiwyg.tinymce.fqdn%
arguments: ['@core.assets', '@core.view']
calls:
- ['setFilemanagerHelpers', ['@?filemanager.helpers']]
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