Commit 8120609d authored by Damjan's avatar Damjan

[FEATURE] TinyMCE support (version 4.1.9 or higher).

Related: forge.typo3.org/issues/31889
parent 02b4c3c2
......@@ -29,6 +29,8 @@ namespace SGalinski\Lfeditor\Controller;
use SGalinski\Lfeditor\Exceptions\LFException;
use SGalinski\Lfeditor\Session\PhpSession;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
......@@ -219,6 +221,35 @@ abstract class AbstractController extends ActionController {
}
}
}
/**
* Prepares TinyMCE for use if it's selected as insertion method.
*
* @return void
*/
protected function prepareTinyMCEIfSelected() {
$tinyMCELoaded = ExtensionManagementUtility::isLoaded('tinymce');
$this->view->assign('tinyMCELoaded', $tinyMCELoaded);
if (!$tinyMCELoaded) {
return;
}
$tinyMCESelected = $this->session->getDataByKey('tinyMCESelected');
$this->view->assign('tinyMCESelected', $tinyMCESelected);
if (!$tinyMCESelected) {
return;
}
$pathTinyMCEConfig = PATH_site . ExtensionManagementUtility::siteRelPath(
'lfeditor'
Please register or sign in to reply
) . 'Resources/Public/Scripts/TinyMCEConfig.js';
require(ExtensionManagementUtility::extPath('tinymce') . 'class.tinymce.php');
$tinyMCE = $this->objectManager->get('tinyMCE');
$tinyMCE->loadConfiguration($pathTinyMCEConfig);
/** @var PageRenderer $pageRenderer */
$pageRenderer = $this->objectManager->get('TYPO3\CMS\Core\Page\PageRenderer');
$tinyMCE->loadJsViaPageRenderer($pageRenderer);
}
}
?>
\ No newline at end of file
......@@ -46,6 +46,8 @@ class AddConstantController extends AbstractBackendController {
public function addConstantAction() {
try {
$this->view->assign('controllerName', 'AddConstant');
$this->prepareTinyMCEIfSelected();
$extensionOptions = $this->configurationService->menuExtList();
$this->prepareExtensionAndLangFileOptions($extensionOptions);
$this->prepareAddConstantViewMainSectionContent();
......
......@@ -47,6 +47,7 @@ class DeleteConstantController extends AbstractBackendController {
public function deleteConstantAction() {
try {
$this->view->assign('controllerName', 'DeleteConstant');
$extensionOptions = $this->configurationService->menuExtList();
$this->prepareExtensionAndLangFileOptions($extensionOptions);
$this->configurationService->initFileObject(
......
......@@ -27,9 +27,6 @@ namespace SGalinski\Lfeditor\Controller;
***************************************************************/
use SGalinski\Lfeditor\Exceptions\LFException;
use SGalinski\Lfeditor\Utility\Functions;
use SGalinski\Lfeditor\Utility\SgLib;
use SGalinski\Lfeditor\Utility\Typo3Lib;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
......@@ -53,6 +50,7 @@ class EditConstantController extends AbstractBackendController {
public function editConstantAction() {
try {
$this->view->assign('controllerName', 'EditConstant');
$this->prepareTinyMCEIfSelected();
$extensionOptions = $this->configurationService->menuExtList();
$this->prepareExtensionAndLangFileOptions($extensionOptions);
......
......@@ -52,6 +52,7 @@ class EditFileController extends AbstractBackendController {
public function editFileAction($buttonType = 0) {
try {
$this->view->assign('controllerName', 'EditFile');
$this->prepareTinyMCEIfSelected();
$extensionOptions = $this->configurationService->menuExtList();
$this->prepareExtensionAndLangFileOptions($extensionOptions);
......
......@@ -61,8 +61,10 @@ class GeneralController extends AbstractBackendController {
* @return void
*/
public function generalAction() {
$this->view->assign('controllerName', 'General');
try {
$this->view->assign('controllerName', 'General');
$this->prepareTinyMCEIfSelected();
$extensionOptions = $this->configurationService->menuExtList();
$this->prepareExtensionAndLangFileOptions($extensionOptions);
if (!$this->session->getDataByKey('languageFileSelection')) {
......@@ -192,11 +194,23 @@ class GeneralController extends AbstractBackendController {
* Prepares parameters for redirection to viewTreeAction.
*
* @param string $language
* @return void
*/
protected function prepareLanguageForTreeAction($language) {
$this->session->setDataByKey('languageSelection', $language);
$this->redirect('viewTree', 'ViewTree');
}
/**
* Switches between insert modes: TinyMCE and normal.
*
* @param int $tinyMCE says is TinyMCE insert mode is selected.
* @return void
*/
protected function switchInsertModeAction($tinyMCE = 0) {
$this->session->setDataByKey('tinyMCESelected', $tinyMCE !== 0);
$this->indexAction();
}
}
?>
\ No newline at end of file
......@@ -70,6 +70,8 @@ class ManageBackupsController extends AbstractBackendController {
public function manageBackupsAction($fileName = '', $langFile = '', $showDiff = FALSE) {
try {
$this->view->assign('controllerName', 'ManageBackups');
$this->prepareTinyMCEIfSelected();
$extensionOptions = $this->configurationService->menuExtList();
$this->assignViewWidthMenuVariables('extension', $extensionOptions);
......
......@@ -47,6 +47,7 @@ class RenameConstantController extends AbstractBackendController {
public function renameConstantAction() {
try {
$this->view->assign('controllerName', 'RenameConstant');
$extensionOptions = $this->configurationService->menuExtList();
$this->prepareExtensionAndLangFileOptions($extensionOptions);
$this->configurationService->initFileObject(
......
......@@ -45,6 +45,7 @@ class SearchConstantController extends AbstractBackendController {
public function searchConstantAction($searchDone = FALSE) {
try {
$this->view->assign('controllerName', 'SearchConstant');
$extensionOptions = $this->configurationService->menuExtList();
$this->prepareExtensionAndLangFileOptions($extensionOptions);
$this->prepareSearchConstantViewMainSectionContent($searchDone);
......
......@@ -50,6 +50,7 @@ class ViewTreeController extends AbstractBackendController {
public function viewTreeAction() {
try {
$this->view->assign('controllerName', 'ViewTree');
$extensionOptions = $this->configurationService->menuExtList();
$this->prepareExtensionAndLangFileOptions($extensionOptions);
$this->configurationService->initFileObject(
......
......@@ -2,7 +2,14 @@
<lfe:addJavaScriptFile javaScriptFile="{f:uri.resource(path: 'Scripts/FormUtility.js')}" />
<lfe:addJavaScriptFile javaScriptFile="{f:uri.resource(path: 'Scripts/Lfeditor.js')}" />
<lfe:addJavaScriptFile javaScriptFile="{f:uri.resource(path: 'Scripts/textareaResize.js')}" />
<f:if condition="{tinyMCESelected}">
<f:then>
<lfe:addJavaScriptFile javaScriptFile="{f:uri.resource(path: 'Scripts/TinyMCEConfig.js')}" />
</f:then>
<f:else>
<lfe:addJavaScriptFile javaScriptFile="{f:uri.resource(path: 'Scripts/textareaResize.js')}" />
</f:else>
</f:if>
<lfe:addCssFile cssFile="{f:uri.resource(path: 'StyleSheets/Lfeditor.css')}" />
......@@ -41,6 +48,34 @@
controller="ManageBackups"
action="manageBackups" />
</f:be.menus.actionMenu>
<f:if condition="{tinyMCELoaded}">
<f:be.menus.actionMenu>
<f:if condition="{tinyMCESelected}">
<f:then>
<f:be.menus.actionMenuItem label="{f:translate(key:'select.insertMode.normal')}"
controller="General"
action="switchInsertMode"
arguments="{tinyMCE: 0}" />
<f:be.menus.actionMenuItem label="{f:translate(key:'select.insertMode.tinyMCE')}"
controller="General"
action="switchInsertMode"
arguments="{tinyMCE: 1}"
additionalAttributes="{selected: 'selected'}" />
</f:then>
<f:else>
<f:be.menus.actionMenuItem label="{f:translate(key:'select.insertMode.normal')}"
controller="General"
action="switchInsertMode"
arguments="{tinyMCE: 0}"
additionalAttributes="{selected: 'selected'}" />
<f:be.menus.actionMenuItem label="{f:translate(key:'select.insertMode.tinyMCE')}"
controller="General"
action="switchInsertMode"
arguments="{tinyMCE: 1}" />
</f:else>
</f:if>
</f:be.menus.actionMenu>
</f:if>
</div>
</div>
</div>
......
......@@ -53,7 +53,7 @@ $EM_CONF[$_EXTKEY] = array(
'conflicts' => array(
),
'suggests' => array(
'tinymce' => '4.0.0-4.0.99',
'tinymce' => '4.1.9',
),
),
'suggests' => array(
......
......@@ -11,7 +11,7 @@ if (TYPO3_MODE == 'BE') {
'LFEditor',
'',
[
'General' => 'index, general, changeSelection, generalSave, prepareLanguageForTree',
'General' => 'index, general, changeSelection, generalSave, prepareLanguageForTree, switchInsertMode',
'EditFile' => 'editFile, changeSelection, editFileSave',
'EditConstant' => 'editConstant, changeSelection, editConstantSave, prepareEditConstant',
'AddConstant' => 'addConstant, changeSelection, addConstantSave',
......
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