Changeset 5334
- Timestamp:
- 01/10/12 09:21:05 (13 years ago)
- Location:
- trunk
- Files:
-
- 3 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpgwapi/inc/class.html.inc.php
r5281 r5334 214 214 { 215 215 return "<textarea name=\"$name\" $options>".$this->htmlspecialchars($value)."</textarea>\n"; 216 }217 218 /*!219 @function htmlarea_avalible220 @author ralfbecker221 @abstract Checks if HTMLarea (or an other richtext editor) is availible for the used browser222 */223 function htmlarea_availible()224 {225 switch($this->user_agent)226 {227 case 'msie':228 return $this->ua_version >= 5.5;229 case 'mozilla':230 return $this->ua_version >= 1.3;231 default:232 return False;233 }234 }235 236 /**237 * creates a textarea inputfield for the htmlarea js-widget (returns the necessary html and js)238 *239 * Please note: it need to be called before the call to phpgw_header() !!!240 * @author ralfbecker241 * @param $name string name and id of the input-field242 * @param $content string of the htmlarea (will be run through htmlspecialchars !!!), default ''243 * @param $style string inline styles, eg. dimension of textarea element244 * @param $base_href string set a base href to get relative image-pathes working245 * @param $plugins string plugins to load seperated by comma's, eg 'TableOperations,ContextMenu'246 * (htmlarea breaks when a plugin calls a nonexisiting lang file)247 * @return the necessary html for the textarea248 */249 function htmlarea($name,$content='',$style='',$base_href='',$plugins='')250 {251 if (!$style) $style = 'width:100%; min-width:500px; height:300px;';252 // check if htmlarea is availible for the browser and use a textarea if not253 if (!$this->htmlarea_availible())254 {255 return $this->textarea($name,$content,'style="'.$style.'"');256 }257 if (!$plugins) $plugins = 'ContextMenu,TableOperations,SpellChecker';258 259 if (!is_object($GLOBALS['phpgw']->js))260 {261 $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');262 }263 if (!strstr($GLOBALS['phpgw_info']['flags']['java_script'],'htmlarea'))264 {265 $GLOBALS['phpgw']->js->validate_file('htmlarea','htmlarea');266 $GLOBALS['phpgw']->js->validate_file('htmlarea','dialog');267 $lang = $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'];268 if ($lang == 'en') // other lang-files are utf-8 only and incomplete (crashes htmlarea as of 3.0beta)269 {270 $GLOBALS['phpgw']->js->validate_file('htmlarea',"lang/$lang");271 }272 else273 {274 $GLOBALS['phpgw_info']['flags']['java_script'] .=275 '<script type="text/javascript" src="'.ereg_replace('[?&]*click_history=[0-9a-f]*','',276 $GLOBALS['phpgw']->link('/phpgwapi/inc/htmlarea-lang.php',array('lang'=>$lang))).'"></script>'."\n";277 }278 279 $GLOBALS['phpgw_info']['flags']['java_script_thirst'] .=280 '<style type="text/css">@import url(' . $this->phpgwapi_js_url . '/htmlarea/htmlarea.css);</style>281 <script type="text/javascript">282 283 _editor_url = "'."$this->phpgwapi_js_url/htmlarea/".'";284 // var htmlareaConfig = new HTMLArea.Config();285 // htmlareaConfig.editorURL = '."'$this->phpgwapi_js_url/htmlarea/';286 </script>\n";287 288 // set a base href to get relative image-pathes working289 if ($base_href && $this->user_agent != 'msie') // HTMLarea does not work in IE with base href set !!!290 {291 $GLOBALS['phpgw_info']['flags']['java_script_thirst'] .= '<base href="'.292 ($base_href[0] != '/' && substr($base_href,0,4) != 'http' ? $GLOBALS['phpgw_info']['server']['webserver_url'].'/' : '').293 $base_href.'" />'."\n";294 }295 296 297 if (!empty($plugins))298 {299 foreach(explode(',',$plugins) as $plg_name)300 {301 $plg_name = trim($plg_name);302 $plg_dir = PHPGW_SERVER_ROOT.'/phpgwapi/js/htmlarea/plugins/'.$plg_name;303 if (!@is_dir($plg_dir) || !@file_exists($plg_lang_script="$plg_dir/lang/lang.php") && !@file_exists($plg_lang_file="$plg_dir/lang/$lang.js"))304 {305 //echo "$plg_dir or $plg_lang_file not found !!!";306 continue; // else htmlarea fails with js errors307 }308 $script_name = strtolower(preg_replace('/([A-Z][a-z]+)([A-Z][a-z]+)/','\\1-\\2',$plg_name));309 $GLOBALS['phpgw']->js->validate_file('htmlarea',"plugins/$plg_name/$script_name");310 if ($lang == 'en' || !@file_exists($plg_lang_script)) // other lang-files are utf-8 only and incomplete (crashes htmlarea as of 3.0beta)311 {312 $GLOBALS['phpgw']->js->validate_file('htmlarea',"plugins/$plg_name/lang/$lang");313 }314 else315 {316 $GLOBALS['phpgw_info']['flags']['java_script'] .=317 '<script type="text/javascript" src="'.ereg_replace('[?&]*click_history=[0-9a-f]*','',318 $GLOBALS['phpgw']->link("/phpgwapi/js/htmlarea/plugins/$plg_name/lang/lang.php",array('lang'=>$lang))).'"></script>'."\n";319 }320 //$load_plugin_string .= 'HTMLArea.loadPlugin("'.$plg_name.'");'."\n";321 $register_plugin_string .= 'ret_editor = editor.registerPlugin("'.$plg_name.'");'."\n";322 }323 }324 325 $GLOBALS['phpgw_info']['flags']['java_script'] .=326 '<script type="text/javascript">327 328 /** Replacement for the replace-helperfunction to make it possible to include plugins. */329 HTMLArea.replace = function(id, config)330 {331 var ta = HTMLArea.getElementById("textarea", id);332 333 if(ta)334 {335 editor = new HTMLArea(ta, config);336 '.$register_plugin_string.'337 ret_editor = editor.generate();338 return ret_editor;339 }340 else341 {342 return null;343 }344 };345 346 '.$load_plugin_string.'347 348 var htmlareaConfig = new HTMLArea.Config();349 htmlareaConfig.editorURL = '."'$this->phpgwapi_js_url/htmlarea/';";350 351 $GLOBALS['phpgw_info']['flags']['java_script'] .="</script>\n";352 }353 $id = str_replace(array('[',']'),array('_',''),$name); // no brakets in the id allowed by js354 355 $GLOBALS['phpgw']->js->set_onload("HTMLArea.replace('$id',htmlareaConfig);");356 357 if (!empty($style)) $style = " style=\"$style\"";358 359 return "<textarea name=\"$name\" id=\"$id\"$style>".$this->htmlspecialchars($content)."</textarea>\n";360 216 } 361 217
Note: See TracChangeset
for help on using the changeset viewer.