Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tinymce
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TYPO3
tinymce
Commits
d8cb4ed9
Commit
d8cb4ed9
authored
10 years ago
by
Stefan Galinski
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] New minimum version requirement is TYPO3 6.2 now
parent
17a651f7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Loader.php
+32
-86
32 additions, 86 deletions
Classes/Loader.php
ext_emconf.php
+2
-12
2 additions, 12 deletions
ext_emconf.php
with
34 additions
and
98 deletions
c
lass
.tinymce
.php
→
C
lass
es/Loader
.php
+
32
−
86
View file @
d8cb4ed9
<?php
<?php
namespace
SGalinski\Tinymce
;
/***************************************************************
/***************************************************************
* Copyright notice
* Copyright notice
*
*
...
@@ -24,13 +26,19 @@
...
@@ -24,13 +26,19 @@
* This copyright notice MUST APPEAR in all copies of the script!
* 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
* tinyMCE initialisation class
*
*
* Usage:
* Usage:
* $tinyM
CE = t3lib_div::makeInstance('tinyMCE
');
* $tinyM
ceLoader = GeneralUtility::makeInstance('\SGalinski\Tinymce\Loader
');
* $tinyM
CE
->loadConfiguration($configuration);
* $tinyM
ceLoader
->loadConfiguration($configuration
File
);
* $javascript = $tinyM
CE->getJS
();
* $javascript = $tinyM
ceLoader->loadJsViaPageRenderer
();
*
*
* Basic Configuration:
* Basic Configuration:
*
*
...
@@ -38,7 +46,7 @@
...
@@ -38,7 +46,7 @@
* selector: 'textarea'
* selector: 'textarea'
* });
* });
*/
*/
class
tinyMCE
{
class
Loader
{
/**
/**
* TinyMCE configuration
* TinyMCE configuration
*
*
...
@@ -72,36 +80,29 @@ class tinyMCE {
...
@@ -72,36 +80,29 @@ class tinyMCE {
* @return void
* @return void
*/
*/
protected
function
setLanguage
()
{
protected
function
setLanguage
()
{
/** @var $languageInstance
l
anguage */
/** @var $languageInstance
L
anguage
Service
*/
$languageInstance
=
(
TYPO3_MODE
===
'FE'
?
$GLOBALS
[
'TSFE'
]
:
$GLOBALS
[
'LANG'
]);
$languageInstance
=
(
TYPO3_MODE
===
'FE'
?
$GLOBALS
[
'TSFE'
]
:
$GLOBALS
[
'LANG'
]);
$languageKey
=
$languageInstance
->
lang
;
$languageKey
=
$languageInstance
->
lang
;
if
(
TYPO3_MODE
===
'BE'
)
{
if
(
TYPO3_MODE
===
'BE'
)
{
$groupOrUserProps
=
t3lib_BEfunc
::
getModTSconfig
(
''
,
'tx_tinyMCE'
);
$groupOrUserProps
=
BackendUtility
::
getModTSconfig
(
''
,
'tx_tinyMCE'
);
if
(
trim
(
$groupOrUserProps
[
'properties'
][
'prefLang'
])
!==
''
)
{
if
(
trim
(
$groupOrUserProps
[
'properties'
][
'prefLang'
])
!==
''
)
{
$languageKey
=
$groupOrUserProps
[
'properties'
][
'prefLang'
];
$languageKey
=
$groupOrUserProps
[
'properties'
][
'prefLang'
];
}
}
}
}
// language conversion from TLD to iso631
// language conversion from TLD to iso631
if
(
class_exists
(
'\TYPO3\CMS\Core\Localization\Locales'
))
{
/** @var $locales \TYPO3\CMS\Core\Localization\Locales */
/** @var $locales \TYPO3\CMS\Core\Localization\Locales */
$locales
=
GeneralUtility
::
makeInstance
(
'\TYPO3\CMS\Core\Localization\Locales'
);
$locales
=
t3lib_div
::
makeInstance
(
'\TYPO3\CMS\Core\Localization\Locales'
);
$locales
->
initialize
();
$locales
->
initialize
();
$isoArray
=
$locales
->
getIsoMapping
();
$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
;
}
if
(
array_key_exists
(
$languageKey
,
$isoArray
))
{
if
(
array_key_exists
(
$languageKey
,
$isoArray
))
{
$languageKey
=
$isoArray
[
$languageKey
];
$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
))
{
if
(
!
is_file
(
$languageFile
))
{
$languageKey
=
'en'
;
$languageKey
=
'en'
;
}
}
...
@@ -110,42 +111,12 @@ class tinyMCE {
...
@@ -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
* @param bool $loadConfigurationWithTimer useful in relation with AJAX
* @return string
* @return string
*/
*/
protected
function
getConfiguration
(
$loadConfigurationWithTimer
=
FALSE
)
{
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
=
$this
->
tinymceConfiguration
[
'preJS'
];
$configuration
.
=
'
$configuration
.
=
'
var executeTinymceInit = function() {
var executeTinymceInit = function() {
...
@@ -168,7 +139,7 @@ class tinyMCE {
...
@@ -168,7 +139,7 @@ class tinyMCE {
$file
=
PATH_site
.
'typo3temp/'
.
$filename
;
$file
=
PATH_site
.
'typo3temp/'
.
$filename
;
if
(
!
is_file
(
$file
))
{
if
(
!
is_file
(
$file
))
{
file_put_contents
(
$file
,
$configuration
);
file_put_contents
(
$file
,
$configuration
);
t3lib_div
::
fixPermissions
(
$file
);
GeneralUtility
::
fixPermissions
(
$file
);
}
}
return
$this
->
getPath
(
$file
,
TRUE
);
return
$this
->
getPath
(
$file
,
TRUE
);
...
@@ -186,7 +157,8 @@ class tinyMCE {
...
@@ -186,7 +157,8 @@ class tinyMCE {
$output
=
''
;
$output
=
''
;
if
(
!
self
::
$init
)
{
if
(
!
self
::
$init
)
{
self
::
$init
=
TRUE
;
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>'
;
$output
=
'<script type="text/javascript" src="'
.
$script
.
'"></script>'
;
$script
=
$this
->
getConfiguration
(
$loadConfigurationWithTimer
);
$script
=
$this
->
getConfiguration
(
$loadConfigurationWithTimer
);
...
@@ -199,17 +171,17 @@ class tinyMCE {
...
@@ -199,17 +171,17 @@ class tinyMCE {
/**
/**
* Loads the required javascript via the given page renderer instance
* Loads the required javascript via the given page renderer instance
*
*
* @param
t3lib_
PageRenderer $pageRenderer
* @param PageRenderer $pageRenderer
* @param bool $loadConfigurationWithTimer
* @param bool $loadConfigurationWithTimer
* @return void
* @return void
*/
*/
public
function
loadJsViaPageRenderer
(
t3lib_
PageRenderer
$pageRenderer
,
$loadConfigurationWithTimer
=
FALSE
)
{
public
function
loadJsViaPageRenderer
(
PageRenderer
$pageRenderer
,
$loadConfigurationWithTimer
=
FALSE
)
{
if
(
self
::
$init
)
{
if
(
self
::
$init
)
{
return
;
return
;
}
}
self
::
$init
=
TRUE
;
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
);
$pageRenderer
->
addJsLibrary
(
'tinymce'
,
$script
,
'text/javascript'
,
FALSE
,
TRUE
,
''
,
TRUE
);
$script
=
$this
->
getConfiguration
(
$loadConfigurationWithTimer
);
$script
=
$this
->
getConfiguration
(
$loadConfigurationWithTimer
);
...
@@ -219,10 +191,6 @@ class tinyMCE {
...
@@ -219,10 +191,6 @@ class tinyMCE {
/**
/**
* Parses and processes the tinyMCE configuration
* 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
* @param string $configuration file reference or configuration string
* @return array
* @return array
*/
*/
...
@@ -230,7 +198,7 @@ class tinyMCE {
...
@@ -230,7 +198,7 @@ class tinyMCE {
$configurationArray
=
array
();
$configurationArray
=
array
();
// try to resolve a potential TYPO3 file path
// try to resolve a potential TYPO3 file path
$configurationFile
=
t3lib_div
::
getFileAbsFileName
(
$configuration
);
$configurationFile
=
GeneralUtility
::
getFileAbsFileName
(
$configuration
);
if
(
is_file
(
$configurationFile
))
{
if
(
is_file
(
$configurationFile
))
{
$configuration
=
file_get_contents
(
$configurationFile
);
$configuration
=
file_get_contents
(
$configurationFile
);
}
}
...
@@ -245,28 +213,6 @@ class tinyMCE {
...
@@ -245,28 +213,6 @@ class tinyMCE {
$configurationArray
[
'configurationData'
]
=
trim
(
$matches
[
2
]);
$configurationArray
[
'configurationData'
]
=
trim
(
$matches
[
2
]);
$configurationArray
[
'postJS'
]
=
trim
(
$matches
[
3
]);
$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
;
return
$configurationArray
;
}
}
...
@@ -301,8 +247,8 @@ class tinyMCE {
...
@@ -301,8 +247,8 @@ class tinyMCE {
protected
function
replaceTypo3Paths
(
$configuration
)
{
protected
function
replaceTypo3Paths
(
$configuration
)
{
$replacementFunction
=
function
(
$value
)
{
$replacementFunction
=
function
(
$value
)
{
// getPath should be used, but this causes a php exception with PHP 5.3 as $this isn't set there
// 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'
)
.
return
'\''
.
GeneralUtility
::
getIndpEnv
(
'TYPO3_SITE_URL'
)
.
str_replace
(
PATH_site
,
''
,
t3lib_div
::
getFileAbsFileName
(
$value
[
1
]))
.
'\''
;
str_replace
(
PATH_site
,
''
,
GeneralUtility
::
getFileAbsFileName
(
$value
[
1
]))
.
'\''
;
};
};
return
preg_replace_callback
(
'/["\'](EXT:[^"\']*)["\']/is'
,
$replacementFunction
,
$configuration
);
return
preg_replace_callback
(
'/["\'](EXT:[^"\']*)["\']/is'
,
$replacementFunction
,
$configuration
);
...
@@ -317,9 +263,9 @@ class tinyMCE {
...
@@ -317,9 +263,9 @@ class tinyMCE {
* @return string
* @return string
*/
*/
protected
function
getPath
(
$relativePath
,
$returnWithDomain
=
FALSE
)
{
protected
function
getPath
(
$relativePath
,
$returnWithDomain
=
FALSE
)
{
$finalPath
=
$absolutePath
=
t3lib_div
::
getFileAbsFileName
(
$relativePath
);
$finalPath
=
$absolutePath
=
GeneralUtility
::
getFileAbsFileName
(
$relativePath
);
if
(
$returnWithDomain
)
{
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
;
return
$finalPath
;
}
}
...
...
This diff is collapsed.
Click to expand it.
ext_emconf.php
+
2
−
12
View file @
d8cb4ed9
<?php
<?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
(
$EM_CONF
[
$_EXTKEY
]
=
array
(
'title'
=>
'tinyMCE'
,
'title'
=>
'tinyMCE'
,
'description'
=>
'TinyMCE sources including a small PHP API'
,
'description'
=>
'TinyMCE sources including a small PHP API'
,
...
@@ -26,8 +16,8 @@ $EM_CONF[$_EXTKEY] = array (
...
@@ -26,8 +16,8 @@ $EM_CONF[$_EXTKEY] = array (
array
(
array
(
'depends'
=>
'depends'
=>
array
(
array
(
'php'
=>
'5.
2
.0-5.
5
.99'
,
'php'
=>
'5.
3
.0-5.
6
.99'
,
'typo3'
=>
'
4.5
.0-6.2.99'
,
'typo3'
=>
'
6.2
.0-6.2.99'
,
),
),
'conflicts'
=>
'conflicts'
=>
array
(
array
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment