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/UI/WebControls/THtmlArea.php | 39 +++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'framework/Web/UI') 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