Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
TYPO3
tinymce
Commits
d8cb4ed9
Commit
d8cb4ed9
authored
Feb 21, 2015
by
Stefan Galinski
🎮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TASK] New minimum version requirement is TYPO3 6.2 now
parent
17a651f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
98 deletions
+34
-98
Classes/Loader.php
Classes/Loader.php
+32
-86
ext_emconf.php
ext_emconf.php
+2
-12
No files found.
c
lass
.tinymce
.php
→
C
lass
es/Loader
.php
View file @
d8cb4ed9
<?php
namespace
SGalinski\Tinymce
;
/***************************************************************
* Copyright notice
*
...
...
@@ -24,13 +26,19 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use
TYPO3\CMS\Backend\Utility\BackendUtility
;
use
TYPO3\CMS\Core\Page\PageRenderer
;
use
TYPO3\CMS\Core\Utility\ExtensionManagementUtility
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
use
TYPO3\CMS\Lang\LanguageService
;
/**
* tinyMCE initialisation class
*
* Usage:
* $tinyM
CE = t3lib_div::makeInstance('tinyMCE
');
* $tinyM
CE
->loadConfiguration($configuration);
* $javascript = $tinyM
CE->getJS
();
* $tinyM
ceLoader = GeneralUtility::makeInstance('\SGalinski\Tinymce\Loader
');
* $tinyM
ceLoader
->loadConfiguration($configuration
File
);
* $javascript = $tinyM
ceLoader->loadJsViaPageRenderer
();
*
* Basic Configuration:
*
...
...
@@ -38,7 +46,7 @@
* selector: 'textarea'
* });
*/
class
tinyMCE
{
class
Loader
{
/**
* TinyMCE configuration
*
...
...
@@ -72,36 +80,29 @@ class tinyMCE {
* @return void
*/
protected
function
setLanguage
()
{
/** @var $languageInstance
l
anguage */
/** @var $languageInstance
L
anguage
Service
*/
$languageInstance
=
(
TYPO3_MODE
===
'FE'
?
$GLOBALS
[
'TSFE'
]
:
$GLOBALS
[
'LANG'
]);
$languageKey
=
$languageInstance
->
lang
;
if
(
TYPO3_MODE
===
'BE'
)
{
$groupOrUserProps
=
t3lib_BEfunc
::
getModTSconfig
(
''
,
'tx_tinyMCE'
);
$groupOrUserProps
=
BackendUtility
::
getModTSconfig
(
''
,
'tx_tinyMCE'
);
if
(
trim
(
$groupOrUserProps
[
'properties'
][
'prefLang'
])
!==
''
)
{
$languageKey
=
$groupOrUserProps
[
'properties'
][
'prefLang'
];
}
}
// language conversion from TLD to iso631
if
(
class_exists
(
'\TYPO3\CMS\Core\Localization\Locales'
))
{
/** @var $locales \TYPO3\CMS\Core\Localization\Locales */
$locales
=
t3lib_div
::
makeInstance
(
'\TYPO3\CMS\Core\Localization\Locales'
);
$locales
->
initialize
();
$isoArray
=
$locales
->
getIsoMapping
();
}
elseif
(
class_exists
(
't3lib_l10n_Locales'
))
{
/** @var $locales t3lib_l10n_Locales */
$locales
=
t3lib_div
::
makeInstance
(
't3lib_l10n_Locales'
);
$isoArray
=
$locales
->
getIsoMapping
();
}
else
{
$isoArray
=
$languageInstance
->
csConvObj
->
isoArray
;
}
/** @var $locales \TYPO3\CMS\Core\Localization\Locales */
$locales
=
GeneralUtility
::
makeInstance
(
'\TYPO3\CMS\Core\Localization\Locales'
);
$locales
->
initialize
();
$isoArray
=
$locales
->
getIsoMapping
();
if
(
array_key_exists
(
$languageKey
,
$isoArray
))
{
$languageKey
=
$isoArray
[
$languageKey
];
}
$languageFile
=
PATH_site
.
t3lib_extMgm
::
siteRelPath
(
'tinymce'
)
.
'tinymce/langs/'
.
$languageKey
.
'.js'
;
$languageFile
=
PATH_site
.
ExtensionManagementUtility
::
siteRelPath
(
'tinymce'
)
.
'tinymce/langs/'
.
$languageKey
.
'.js'
;
if
(
!
is_file
(
$languageFile
))
{
$languageKey
=
'en'
;
}
...
...
@@ -110,42 +111,12 @@ class tinyMCE {
}
/**
* Returns a file that contains the tiny
mce
configuration
* Returns a file that contains the tiny
MCE
configuration
*
* @param bool $loadConfigurationWithTimer useful in relation with AJAX
* @return string
*/
protected
function
getConfiguration
(
$loadConfigurationWithTimer
=
FALSE
)
{
// $configurationOptions = array();
// foreach ($this->tinymceConfiguration['strings'] as $option => $value) {
// $value = '\'' . str_replace('\'', '\\\'', $value) . '\'';
// $configurationOptions[] = "\t" . $option . ': ' . $value;
// }
//
// foreach ($this->tinymceConfiguration['boolAndInt'] as $option => $value) {
// if (is_numeric($value)) {
// if (strpos($value, '.')) {
// $value = (float) $value;
// } else {
// $value = (int) $value;
// }
// }
// $configurationOptions[] = "\t" . $option . ': ' . $value;
// }
//
// foreach ($this->tinymceConfiguration['arrays'] as $option => $value) {
// $configurationOptions[] = "\t" . $option . ': ' . $value;
// }
//
// foreach ($this->tinymceConfiguration['objects'] as $option => $value) {
// $configurationOptions[] = "\t" . $option . ': ' . $value;
// }
//
// foreach ($this->tinymceConfiguration['functions'] as $option => $value) {
// $configurationOptions[] = "\t" . $option . ': ' . $value;
// }
// $configuration .= implode(",\n", $configurationOptions);
$configuration
=
$this
->
tinymceConfiguration
[
'preJS'
];
$configuration
.
=
'
var executeTinymceInit = function() {
...
...
@@ -168,7 +139,7 @@ class tinyMCE {
$file
=
PATH_site
.
'typo3temp/'
.
$filename
;
if
(
!
is_file
(
$file
))
{
file_put_contents
(
$file
,
$configuration
);
t3lib_div
::
fixPermissions
(
$file
);
GeneralUtility
::
fixPermissions
(
$file
);
}
return
$this
->
getPath
(
$file
,
TRUE
);
...
...
@@ -186,7 +157,8 @@ class tinyMCE {
$output
=
''
;
if
(
!
self
::
$init
)
{
self
::
$init
=
TRUE
;
$script
=
$GLOBALS
[
'BACK_PATH'
]
.
t3lib_extMgm
::
extRelPath
(
'tinymce'
)
.
'tinymce/tinymce.min.js'
;
$script
=
$GLOBALS
[
'BACK_PATH'
]
.
ExtensionManagementUtility
::
extRelPath
(
'tinymce'
)
.
'tinymce/tinymce.min.js'
;
$output
=
'<script type="text/javascript" src="'
.
$script
.
'"></script>'
;
$script
=
$this
->
getConfiguration
(
$loadConfigurationWithTimer
);
...
...
@@ -199,17 +171,17 @@ class tinyMCE {
/**
* Loads the required javascript via the given page renderer instance
*
* @param
t3lib_
PageRenderer $pageRenderer
* @param PageRenderer $pageRenderer
* @param bool $loadConfigurationWithTimer
* @return void
*/
public
function
loadJsViaPageRenderer
(
t3lib_
PageRenderer
$pageRenderer
,
$loadConfigurationWithTimer
=
FALSE
)
{
public
function
loadJsViaPageRenderer
(
PageRenderer
$pageRenderer
,
$loadConfigurationWithTimer
=
FALSE
)
{
if
(
self
::
$init
)
{
return
;
}
self
::
$init
=
TRUE
;
$script
=
$GLOBALS
[
'BACK_PATH'
]
.
t3lib_extMgm
::
extRelPath
(
'tinymce'
)
.
'tinymce/tinymce.min.js'
;
$script
=
$GLOBALS
[
'BACK_PATH'
]
.
ExtensionManagementUtility
::
extRelPath
(
'tinymce'
)
.
'tinymce/tinymce.min.js'
;
$pageRenderer
->
addJsLibrary
(
'tinymce'
,
$script
,
'text/javascript'
,
FALSE
,
TRUE
,
''
,
TRUE
);
$script
=
$this
->
getConfiguration
(
$loadConfigurationWithTimer
);
...
...
@@ -219,10 +191,6 @@ class tinyMCE {
/**
* Parses and processes the tinyMCE configuration
*
* Note: Unfortunately we didn't solved the riddle how to parse object and function blocks. So we can't parse
* the configuration in detail. Also the regexp has some other possible minor flaws. Recursion (?R) could be a
* possible way.
*
* @param string $configuration file reference or configuration string
* @return array
*/
...
...
@@ -230,7 +198,7 @@ class tinyMCE {
$configurationArray
=
array
();
// try to resolve a potential TYPO3 file path
$configurationFile
=
t3lib_div
::
getFileAbsFileName
(
$configuration
);
$configurationFile
=
GeneralUtility
::
getFileAbsFileName
(
$configuration
);
if
(
is_file
(
$configurationFile
))
{
$configuration
=
file_get_contents
(
$configurationFile
);
}
...
...
@@ -245,28 +213,6 @@ class tinyMCE {
$configurationArray
[
'configurationData'
]
=
trim
(
$matches
[
2
]);
$configurationArray
[
'postJS'
]
=
trim
(
$matches
[
3
]);
// split options into an array (four value types: values in quotes, int/booleans, arrays, objects, functions)
// $pattern = '([^:\[\(\{]+?)\s*:\s*(?:(\[.*?\])|(\{.*\})|(function.*\})|["\']([^"\']*)["|\']\s*|([^,\n]*))[,\n]\n?';
// preg_match_all('/' . $pattern . '/is', $matches[2] . "\n", $options);
// for ($i = 0; $i < count($options[1]); ++$i) {
// if (trim($options[2][$i]) !== '') {
// // array
// $configurationArray['arrays'][trim($options[1][$i])] = trim($options[2][$i]);
// } elseif (trim($options[3][$i]) !== '') {
// // object
// $configurationArray['objects'][trim($options[1][$i])] = trim($options[3][$i]);
// } elseif (trim($options[4][$i]) !== '') {
// // function
// $configurationArray['functions'][trim($options[1][$i])] = trim($options[4][$i]);
// } elseif (trim($options[6][$i]) !== '') {
// // int/bool
// $configurationArray['boolAndInt'][trim($options[1][$i])] = trim($options[6][$i]);
// } else {
// // quoted value (value can be empty)
// $configurationArray['strings'][trim($options[1][$i])] = trim($options[5][$i]);
// }
// }
return
$configurationArray
;
}
...
...
@@ -301,8 +247,8 @@ class tinyMCE {
protected
function
replaceTypo3Paths
(
$configuration
)
{
$replacementFunction
=
function
(
$value
)
{
// getPath should be used, but this causes a php exception with PHP 5.3 as $this isn't set there
return
'\''
.
t3lib_div
::
getIndpEnv
(
'TYPO3_SITE_URL'
)
.
str_replace
(
PATH_site
,
''
,
t3lib_div
::
getFileAbsFileName
(
$value
[
1
]))
.
'\''
;
return
'\''
.
GeneralUtility
::
getIndpEnv
(
'TYPO3_SITE_URL'
)
.
str_replace
(
PATH_site
,
''
,
GeneralUtility
::
getFileAbsFileName
(
$value
[
1
]))
.
'\''
;
};
return
preg_replace_callback
(
'/["\'](EXT:[^"\']*)["\']/is'
,
$replacementFunction
,
$configuration
);
...
...
@@ -317,9 +263,9 @@ class tinyMCE {
* @return string
*/
protected
function
getPath
(
$relativePath
,
$returnWithDomain
=
FALSE
)
{
$finalPath
=
$absolutePath
=
t3lib_div
::
getFileAbsFileName
(
$relativePath
);
$finalPath
=
$absolutePath
=
GeneralUtility
::
getFileAbsFileName
(
$relativePath
);
if
(
$returnWithDomain
)
{
$finalPath
=
t3lib_div
::
getIndpEnv
(
'TYPO3_SITE_URL'
)
.
str_replace
(
PATH_site
,
''
,
$absolutePath
);
$finalPath
=
GeneralUtility
::
getIndpEnv
(
'TYPO3_SITE_URL'
)
.
str_replace
(
PATH_site
,
''
,
$absolutePath
);
}
return
$finalPath
;
}
...
...
ext_emconf.php
View file @
d8cb4ed9
<?php
/***************************************************************
* Extension Manager/Repository config file for ext "tinymce".
*
* Auto generated 05-08-2014 22:42
*
* Manual updates:
* Only the data in the array - everything else is removed by next
* writing. "version" and "dependencies" must not be touched!
***************************************************************/
$EM_CONF
[
$_EXTKEY
]
=
array
(
'title'
=>
'tinyMCE'
,
'description'
=>
'TinyMCE sources including a small PHP API'
,
...
...
@@ -26,8 +16,8 @@ $EM_CONF[$_EXTKEY] = array (
array
(
'depends'
=>
array
(
'php'
=>
'5.
2
.0-5.
5
.99'
,
'typo3'
=>
'
4.5
.0-6.2.99'
,
'php'
=>
'5.
3
.0-5.
6
.99'
,
'typo3'
=>
'
6.2
.0-6.2.99'
,
),
'conflicts'
=>
array
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment