From 30d123719a219e88c24b7f098f9a6eb14d312d6e Mon Sep 17 00:00:00 2001 From: wei <> Date: Thu, 25 Jan 2007 03:08:32 +0000 Subject: upgrade tinyMCE to 2.0.9 to fix #482 and #459 --- framework/3rdParty/TinyMCE/readme.txt | 13 --- framework/3rdParty/TinyMCE/tiny_mce.md5 | 2 +- framework/3rdParty/TinyMCE/tiny_mce.tar | Bin 3164160 -> 3502080 bytes framework/Web/UI/WebControls/THtmlArea.php | 143 ++++++++++++++++++++++++++--- 4 files changed, 133 insertions(+), 25 deletions(-) delete mode 100644 framework/3rdParty/TinyMCE/readme.txt (limited to 'framework') diff --git a/framework/3rdParty/TinyMCE/readme.txt b/framework/3rdParty/TinyMCE/readme.txt deleted file mode 100644 index e242d71a..00000000 --- a/framework/3rdParty/TinyMCE/readme.txt +++ /dev/null @@ -1,13 +0,0 @@ -TinyMCE Compressor 1.03 -------------------------- - -TinyMCE Compressor gzips all javascript files in TinyMCE to a single streamable file. -This makes the overall download sice 70% smaller and all requests are merged into a few requests. - -To enable this compressor simply place the tiny_mce_gzip.php in the tiny_mce directory where tiny_mce.js is located and switch your scripts form: - - - -to - - diff --git a/framework/3rdParty/TinyMCE/tiny_mce.md5 b/framework/3rdParty/TinyMCE/tiny_mce.md5 index 7e3ff1f8..b853cd60 100644 --- a/framework/3rdParty/TinyMCE/tiny_mce.md5 +++ b/framework/3rdParty/TinyMCE/tiny_mce.md5 @@ -1 +1 @@ -92380b28b827c8d569026439abb44142 tiny_mce.tar +dcd33d2779fc68523fe73ab54b9e1034 *tiny_mce.tar diff --git a/framework/3rdParty/TinyMCE/tiny_mce.tar b/framework/3rdParty/TinyMCE/tiny_mce.tar index 125ee624..ddbbd1ac 100644 Binary files a/framework/3rdParty/TinyMCE/tiny_mce.tar and b/framework/3rdParty/TinyMCE/tiny_mce.tar differ diff --git a/framework/Web/UI/WebControls/THtmlArea.php b/framework/Web/UI/WebControls/THtmlArea.php index a505732a..f70f8d25 100644 --- a/framework/Web/UI/WebControls/THtmlArea.php +++ b/framework/Web/UI/WebControls/THtmlArea.php @@ -98,17 +98,21 @@ class THtmlArea extends TTextBox 'hu' => 'hu', 'is' => 'is', 'it' => 'it', - 'ja' => 'ja', + 'ja' => 'ja_utf-8', 'ko' => 'ko', 'nb' => 'nb', 'nl' => 'nl', + 'nn' => 'nn', 'pl' => 'pl', 'pt' => 'pt', 'pt_BR' => 'pt_br', - 'ru' => 'ru_UTF-8', + 'ro' => 'ro', + 'ru' => 'ru', 'si' => 'si', 'sk' => 'sk', - 'sv' => 'sv', + 'sq' => 'sq', + 'sr' => 'sr', + 'sv' => 'sv_utf8', 'th' => 'th', 'tr' => 'tr', 'vi' => 'vi', @@ -118,13 +122,49 @@ class THtmlArea extends TTextBox 'zh_TW' => 'zh_tw_utf8' ); + /** + * @var array list of default plugins to load, override using getAvailablePlugins(); + */ + private static $_plugins = array( + 'style', + 'layer', + 'table', + 'save', + 'advhr', +// 'advimage', +// 'advlink', + 'emotions', + 'iespell', + 'insertdatetime', + 'preview', + 'media', + 'searchreplace', + 'print', + 'contextmenu', + 'paste', + 'directionality', + 'fullscreen', + 'noneditable', + 'visualchars', + 'nonbreaking', + 'xhtmlxtras' + ); + + /** + * @var array default themes to load + */ + private static $_themes = array( + 'simple', + 'advanced' + ); + /** * Constructor. * Sets default width and height. */ public function __construct() { - $this->setWidth('450px'); + $this->setWidth('470px'); $this->setHeight('250px'); } @@ -211,6 +251,27 @@ class THtmlArea extends TTextBox $this->setViewState('Options', $value, ''); } + /** + * @param string path to custom plugins to be copied. + */ + public function setCustomPluginPath($value) + { + $this->setViewState('CustomPluginPath', $value); + } + + /** + * @return string path to custom plugins to be copied. + */ + public function getCustomPluginPath() + { + return $this->getViewState('CustomPluginPath'); + } + + public function onPreRender($param) + { + $this->preLoadCompressedScript(); + } + /** * Adds attribute name-value pairs to renderer. * This method overrides the parent implementation by registering @@ -228,15 +289,50 @@ class THtmlArea extends TTextBox } /** - * Registers the editor javascript file and code to initialize the editor. + * Returns a list of plugins to be loaded. + * Override this method to customize. + * @return array list of plugins to be loaded */ - protected function registerEditorClientScript($writer) + public function getAvailablePlugins() + { + return self::$_plugins; + } + + /** + * @return array list of available themese + */ + public function getAvailableThemes() + { + return self::$_themes; + } + + protected function preLoadCompressedScript() { $scripts = $this->getPage()->getClientScript(); if(!$scripts->isScriptFileRegistered('prado:THtmlArea')) $scripts->registerScriptFile('prado:THtmlArea', $this->getScriptUrl()); + $key = 'prado:THtmlArea:compressed'; + if(!$scripts->isBeginScriptRegistered($key)) + { + $options['plugins'] = implode(',', $this->getAvailablePlugins()); + $options['themes'] = implode(',', $this->getAvailableThemes()); + $options['languages'] = $this->getLanguageSuffix($this->getCulture()); + $options['disk_cache'] = true; + $options['debug'] = false; + $js = TJavaScript::encode($options); + $script = "if(typeof(tinyMCE_GZ)!='undefined'){ tinyMCE_GZ.init({$js}); }"; + $scripts->registerBeginScript($key, $script); + } + } + + /** + * Registers the editor javascript file and code to initialize the editor. + */ + protected function registerEditorClientScript($writer) + { + $scripts = $this->getPage()->getClientScript(); $options = TJavaScript::encode($this->getEditorOptions()); - $script = "if(tinyMCE){ tinyMCE.init($options); }"; + $script = "if(typeof(tinyMCE)!='undefined'){ tinyMCE.init($options); }"; $scripts->registerEndScript('prado:THtmlArea'.$this->ClientID,$script); } @@ -245,7 +341,7 @@ class THtmlArea extends TTextBox */ protected function getScriptUrl() { - return $this->getScriptDeploymentPath().'/tiny_mce/tiny_mce_gzip.php'; + return $this->getScriptDeploymentPath().'/tiny_mce/tiny_mce_gzip.js'; } /** @@ -258,7 +354,21 @@ class THtmlArea extends TTextBox $md5sum = Prado::getPathOfNamespace('System.3rdParty.TinyMCE.tiny_mce', '.md5'); if($tarfile===null || $md5sum===null) throw new TConfigurationException('htmlarea_tarfile_invalid'); - return $this->getApplication()->getAssetManager()->publishTarFile($tarfile, $md5sum); + $url = $this->getApplication()->getAssetManager()->publishTarFile($tarfile, $md5sum); + $this->copyCustomPlugins($url); + return $url; + } + + protected function copyCustomPlugins($url) + { + if($plugins = $this->getCustomPluginPath()) + { + $assets = $this->getApplication()->getAssetManager(); + $path = is_dir($plugins) ? $plugins : Prado::getPathOfNameSpace($plugins); + $dest = $assets->getBasePath().'/'.basename($url).'/tiny_mce/plugins/'; + if(!is_dir($dest) || $this->getApplication()->getMode()!==TApplicationMode::Performance) + $assets->copyDirectory($path, $dest); + } } /** @@ -295,10 +405,11 @@ class THtmlArea extends TTextBox protected function parseEditorOptions($string) { $options = array(); - $substrings = preg_split('/\n|,\n/', trim($string)); + $substrings = preg_split('/,\s*\n|\n/', trim($string)); foreach($substrings as $bits) { - $option = explode(":",$bits); + $option = explode(":",$bits,2); + if(count($option) == 2) $options[trim($option[0])] = trim(preg_replace('/\'|"/','', $option[1])); } @@ -325,6 +436,16 @@ class THtmlArea extends TTextBox return 'en'; } + + /** + * Gets the name of the javascript class responsible for performing postback for this control. + * This method overrides the parent implementation. + * @return string the javascript class name + */ + protected function getClientClassName() + { + return 'Prado.WebUI.THtmlArea'; + } } ?> \ No newline at end of file -- cgit v1.2.3