Commit 732efdd0 authored by sgalinsk's avatar sgalinsk

Initial Import

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/tinymce/trunk@12350 735d13b6-9817-0410-8766-e36946ffe9aa
parent e9e137e9

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

For Mozilla and Firefox the functionality of
"copy and Paste" are disabled by default. If you
wish your Typo3-User are able to use this, the User
must have the "user.js" with it contents in his
Mozilla Userdir. On Windows XP is this the following:
C:\Documents and Settings\[User Name]\Application Data\Mozilla\Firefox\Profiles\
See also here:
http://www.mozilla.org/editor/midasdemo/securityprefs.html
Regards
Thomas
user_pref("capability.policy.policynames", "allowclipboard");
user_pref("capability.policy.allowclipboard.sites", "http://localhost");
user_pref("capability.policy.allowclipboard.Clipboard.cutcopy", "allAccess");
user_pref("capability.policy.allowclipboard.Clipboard.paste", "allAccess");
\ No newline at end of file
--- Used Versions ---
* tinyMCE - 2.1.1.1
* PHP compressor - 1.1.0
* PHP spellchecker - 1.0.5
* Languages - 08.07.2007 (dd.mm.yyyy)
--- TODO ---
* FileBrowser enhancements like in tinyRTE (?)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2005-2007 Stefan Galinski (stefan.galinski@gmail.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* tinyMCE initialisation class
*
* $Id$
*
* @author Stefan Galinski <stefan.galinski@gmail.com>
*/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*
*/
/** @var boolean initialisation flag to prevent multiple init code */
$tinyMCEInitFlag = false;
/**
* tinyMCE initialisation class
*
* @author Stefan Galinski <stefan.galinski@gmail.com>
* @package Typo3
* @subpackage tx_tinymce
*/
class tinyMCE
{
/**
* @var array configuration
* @see prepareConfig()
*/
var $extConfig = array();
/**@+
/** @var array configuration */
var $config = array();
var $GZconfig = array();
/**#@-*/
/**
* Constructor
* loads the tinyMCE configuration
*
* @param string configuration file or string (optional ... default is basic configuration)
* @param string gzip configuration file or string (optional ... default is basic configuration)
* @param boolean set to false if you dont want the automatic language replacement (default true)
* @return void
*/
function tinyMCE($config='', $GZconfig='', $autoLang=true)
{
// prepare extension and given tinyMCE configurations
$this->prepareConfig();
$this->prepareTinyMCEConfig($config, false);
$this->prepareTinyMCEConfig($GZconfig, true);
// language replacement
if($autoLang)
{
// get main object
if(TYPO3_MODE == 'FE')
$lang =& $GLOBALS['TSFE'];
else
$lang =& $GLOBALS['LANG'];
// language conversion from TLD to iso631
if(array_key_exists($this->extConfig['lang'], $lang->csConvObj->isoArray))
$this->extConfig['lang'] = $lang->csConvObj->isoArray[$this->extConfig['lang']];
if(!is_file(PATH_site . t3lib_extMgm::siteRelPath('tinymce') .
'tinyMCE/langs/' . $this->extConfig['lang'] . '.js'))
$this->extConfig['lang'] = 'en';
// language replacement
$this->replaceInConfig(array('language' => $this->extConfig['lang']));
if($this->extConfig['compressed'])
$this->replaceInConfig(array('languages' => $this->extConfig['lang']), true);
}
// activate disk cache
if($this->extConfig['compressed'] && $this->extConfig['diskCache'])
$this->replaceInConfig(array('disk_cache' => 'true'), true);
elseif($this->extConfig['compressed'] && !$this->extConfig['diskCache'])
$this->replaceInConfig(array('disk_cache', 'false'), true);
}
/**
* Generates a configuration string from the array informations
*
* @param boolean set to true if the options should be set into the gzip config
* @return string generated configuration
*/
function buildConfigString($gzip)
{
$curConfig = ($gzip) ? $this->GZconfig : $this->config;
// generate configuration strings from array
$config = $curConfig['preJS'];
$config .= (($gzip) ? 'tinyMCE_GZ' : 'tinyMCE') . '.init({' . "\n";
$configOptions = array();
if (count($curConfig)) {
foreach($curConfig as $option => $value) {
if ($option == 'preJS' || $option == 'postJS')
continue;
if ($value != 'false' && $value != 'true')
$value = '\'' . $value . '\'';
$configOptions[] = "\t" . $option . ' : ' . $value;
}
}
$config .= implode(",\n", $configOptions);
$config .= "\n" . '});';
$config .= $curConfig['postJS'];
return $config;
}
/**
* generates and returns the needed javascript inclusion code
*
* Note: this function can only be called one time
*
* @return string generated javascript inclusion code
*/
function getJS()
{
// check init flag
if($GLOBALS['tinyMCEInitFlag'])
return '';
$GLOBALS['tinyMCEInitFlag'] = true;
// build configuration strings
$config = $this->buildConfigString(false);
$GZconfig = $this->buildConfigString(true);
// return javascript
return '<script type="text/javascript" src="' . $GLOBALS['BACK_PATH'] .
t3lib_extMgm::extRelPath('tinymce') . 'tinyMCE/' .
($this->extConfig['compressed'] ? 'tiny_mce_gzip.js' : 'tiny_mce.js') . '"></script>
<script type="text/javascript">' . "\n" . $GZconfig . "\n" . '</script>
<script type="text/javascript">' . "\n" . $config . "\n" . '</script>';
}
/**
* Prepares a tinyMCE configuration
* All options, post and pre javascript is saved into the config or GZconfig array
*
* @param string file reference or configuration string
* @param boolean set to true if the options should be set into the gzip config
* @return void
*/
function prepareTinyMCEConfig($config, $gzip)
{
// get file contents if necessary
if(is_file($config))
$config = t3lib_div::getURL($config);
// get config variable
if ($gzip)
$curConfig =& $this->GZconfig;
else
$curConfig =& $this->config;
// split config into first and last javascript parts (applied later again into the config variables)
// additionaly the config part is matched to get the options
$start = '(.*)((tinyMCE|tinyMCE_GZ)\.init.*?\(.*?\{.*?';
$end = '.*?\}.*?\).*?;)(.*)';
$pattern = '/' . $start . $end . '/is';
preg_match($pattern, $config, $matches);
// add preJS and postJS
$curConfig['preJS'] = $matches[1];
$curConfig['postJS'] = $matches[4];
// split options into an array (first time strings and the second call splits bool values)
$pattern = '([[:print:]]+?)[\s]*?:[\s]*["|\']{1}(.*?)["|\']{1}[,|\n|}]{1}.*?';
preg_match_all('/' . $pattern . '/i', $matches[2], $options);
for ($i = 0; $i < count($options[1]); ++$i)
$configOptions[$options[1][$i]] = $options[2][$i];
$options = array();
$boolPattern = '([[:print:]]+?)[\s]*?:[\s]*(false|true)[,|\n|}]{1}.*?';
preg_match_all('/' . $boolPattern . '/i', $matches[2], $options);
for ($i = 0; $i < count($options[1]); ++$i)
$configOptions[$options[1][$i]] = $options[2][$i];
// add config options
if (is_array($configOptions))
$curConfig = array_merge($curConfig, $configOptions);