From 290efbe4d33905b5ca006ac4f3db005421a0a4cf Mon Sep 17 00:00:00 2001 From: wei <> Date: Wed, 15 Nov 2006 23:54:00 +0000 Subject: add custom plugin path for THtmlArea --- framework/Web/TAssetManager.php | 2 +- framework/Web/UI/WebControls/THtmlArea.php | 39 +++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/framework/Web/TAssetManager.php b/framework/Web/TAssetManager.php index 4382aee1..04933bfa 100644 --- a/framework/Web/TAssetManager.php +++ b/framework/Web/TAssetManager.php @@ -219,7 +219,7 @@ class TAssetManager extends TModule * @param string the destination directory * @todo a generic solution to ignore certain directories and files */ - protected function copyDirectory($src,$dst) + public function copyDirectory($src,$dst) { if(!is_dir($dst)) { diff --git a/framework/Web/UI/WebControls/THtmlArea.php b/framework/Web/UI/WebControls/THtmlArea.php index 94b3152b..6729c6dc 100644 --- a/framework/Web/UI/WebControls/THtmlArea.php +++ b/framework/Web/UI/WebControls/THtmlArea.php @@ -124,7 +124,7 @@ class THtmlArea extends TTextBox */ public function __construct() { - $this->setWidth('450px'); + $this->setWidth('470px'); $this->setHeight('250px'); } @@ -211,6 +211,22 @@ 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'); + } + /** * Adds attribute name-value pairs to renderer. * This method overrides the parent implementation by registering @@ -258,7 +274,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 +325,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])); } -- cgit v1.2.3