Changeset 1652 for branches/3.0/framework/Web/UI/WebControls/THtmlArea.php
- Timestamp:
- 01/24/2007 09:08:32 PM (23 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/framework/Web/UI/WebControls/THtmlArea.php
r1397 r1652 99 99 'is' => 'is', 100 100 'it' => 'it', 101 'ja' => 'ja ',101 'ja' => 'ja_utf-8', 102 102 'ko' => 'ko', 103 103 'nb' => 'nb', 104 104 'nl' => 'nl', 105 'nn' => 'nn', 105 106 'pl' => 'pl', 106 107 'pt' => 'pt', 107 108 'pt_BR' => 'pt_br', 108 'ru' => 'ru_UTF-8', 109 'ro' => 'ro', 110 'ru' => 'ru', 109 111 'si' => 'si', 110 112 'sk' => 'sk', 111 'sv' => 'sv', 113 'sq' => 'sq', 114 'sr' => 'sr', 115 'sv' => 'sv_utf8', 112 116 'th' => 'th', 113 117 'tr' => 'tr', … … 120 124 121 125 /** 126 * @var array list of default plugins to load, override using getAvailablePlugins(); 127 */ 128 private static $_plugins = array( 129 'style', 130 'layer', 131 'table', 132 'save', 133 'advhr', 134 // 'advimage', 135 // 'advlink', 136 'emotions', 137 'iespell', 138 'insertdatetime', 139 'preview', 140 'media', 141 'searchreplace', 142 'print', 143 'contextmenu', 144 'paste', 145 'directionality', 146 'fullscreen', 147 'noneditable', 148 'visualchars', 149 'nonbreaking', 150 'xhtmlxtras' 151 ); 152 153 /** 154 * @var array default themes to load 155 */ 156 private static $_themes = array( 157 'simple', 158 'advanced' 159 ); 160 161 /** 122 162 * Constructor. 123 163 * Sets default width and height. … … 125 165 public function __construct() 126 166 { 127 $this->setWidth('4 50px');167 $this->setWidth('470px'); 128 168 $this->setHeight('250px'); 129 169 } … … 210 250 { 211 251 $this->setViewState('Options', $value, ''); 252 } 253 254 /** 255 * @param string path to custom plugins to be copied. 256 */ 257 public function setCustomPluginPath($value) 258 { 259 $this->setViewState('CustomPluginPath', $value); 260 } 261 262 /** 263 * @return string path to custom plugins to be copied. 264 */ 265 public function getCustomPluginPath() 266 { 267 return $this->getViewState('CustomPluginPath'); 268 } 269 270 public function onPreRender($param) 271 { 272 $this->preLoadCompressedScript(); 212 273 } 213 274 … … 229 290 230 291 /** 231 * Registers the editor javascript file and code to initialize the editor. 232 */ 233 protected function registerEditorClientScript($writer) 292 * Returns a list of plugins to be loaded. 293 * Override this method to customize. 294 * @return array list of plugins to be loaded 295 */ 296 public function getAvailablePlugins() 297 { 298 return self::$_plugins; 299 } 300 301 /** 302 * @return array list of available themese 303 */ 304 public function getAvailableThemes() 305 { 306 return self::$_themes; 307 } 308 309 protected function preLoadCompressedScript() 234 310 { 235 311 $scripts = $this->getPage()->getClientScript(); 236 312 if(!$scripts->isScriptFileRegistered('prado:THtmlArea')) 237 313 $scripts->registerScriptFile('prado:THtmlArea', $this->getScriptUrl()); 314 $key = 'prado:THtmlArea:compressed'; 315 if(!$scripts->isBeginScriptRegistered($key)) 316 { 317 $options['plugins'] = implode(',', $this->getAvailablePlugins()); 318 $options['themes'] = implode(',', $this->getAvailableThemes()); 319 $options['languages'] = $this->getLanguageSuffix($this->getCulture()); 320 $options['disk_cache'] = true; 321 $options['debug'] = false; 322 $js = TJavaScript::encode($options); 323 $script = "if(typeof(tinyMCE_GZ)!='undefined'){ tinyMCE_GZ.init({$js}); }"; 324 $scripts->registerBeginScript($key, $script); 325 } 326 } 327 328 /** 329 * Registers the editor javascript file and code to initialize the editor. 330 */ 331 protected function registerEditorClientScript($writer) 332 { 333 $scripts = $this->getPage()->getClientScript(); 238 334 $options = TJavaScript::encode($this->getEditorOptions()); 239 $script = "if(t inyMCE){ tinyMCE.init($options); }";335 $script = "if(typeof(tinyMCE)!='undefined'){ tinyMCE.init($options); }"; 240 336 $scripts->registerEndScript('prado:THtmlArea'.$this->ClientID,$script); 241 337 } … … 246 342 protected function getScriptUrl() 247 343 { 248 return $this->getScriptDeploymentPath().'/tiny_mce/tiny_mce_gzip. php';344 return $this->getScriptDeploymentPath().'/tiny_mce/tiny_mce_gzip.js'; 249 345 } 250 346 … … 259 355 if($tarfile===null || $md5sum===null) 260 356 throw new TConfigurationException('htmlarea_tarfile_invalid'); 261 return $this->getApplication()->getAssetManager()->publishTarFile($tarfile, $md5sum); 357 $url = $this->getApplication()->getAssetManager()->publishTarFile($tarfile, $md5sum); 358 $this->copyCustomPlugins($url); 359 return $url; 360 } 361 362 protected function copyCustomPlugins($url) 363 { 364 if($plugins = $this->getCustomPluginPath()) 365 { 366 $assets = $this->getApplication()->getAssetManager(); 367 $path = is_dir($plugins) ? $plugins : Prado::getPathOfNameSpace($plugins); 368 $dest = $assets->getBasePath().'/'.basename($url).'/tiny_mce/plugins/'; 369 if(!is_dir($dest) || $this->getApplication()->getMode()!==TApplicationMode::Performance) 370 $assets->copyDirectory($path, $dest); 371 } 262 372 } 263 373 … … 296 406 { 297 407 $options = array(); 298 $substrings = preg_split('/ \n|,\n/', trim($string));408 $substrings = preg_split('/,\s*\n|\n/', trim($string)); 299 409 foreach($substrings as $bits) 300 410 { 301 $option = explode(":",$bits); 411 $option = explode(":",$bits,2); 412 302 413 if(count($option) == 2) 303 414 $options[trim($option[0])] = trim(preg_replace('/\'|"/','', $option[1])); … … 326 437 return 'en'; 327 438 } 439 440 /** 441 * Gets the name of the javascript class responsible for performing postback for this control. 442 * This method overrides the parent implementation. 443 * @return string the javascript class name 444 */ 445 protected function getClientClassName() 446 { 447 return 'Prado.WebUI.THtmlArea'; 448 } 328 449 } 329 450
