From e7f0d8a133fae30570069e8ba160ee23c78facaf Mon Sep 17 00:00:00 2001 From: Pim Snel Date: Thu, 7 Oct 2004 23:09:52 +0000 Subject: [PATCH] reorderded htmlarea so different htmlarea's can be configured seperately --- phpgwapi/inc/class.html.inc.php | 1142 ++++++++++++++++--------------- 1 file changed, 573 insertions(+), 569 deletions(-) diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 3c3c0015da..5aaf6ffbf6 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -1,693 +1,697 @@ * -* -------------------------------------------- * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 2 of the License, or (at your * -* option) any later version. * -\**************************************************************************/ + /**************************************************************************\ + * eGroupWare - HTML creation class * + * http://www.eGroupWare.org * + * Written and (c) by Ralf Becker * + * -------------------------------------------- * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; either version 2 of the License, or (at your * + * option) any later version. * + \**************************************************************************/ -/* $Id$ */ + /* $Id$ */ -class html -{ - var $user_agent,$ua_version; // 'mozilla','msie','konqueror' - var $prefered_img_title; - var $charset,$phpgwapi_js_url; - var $need_footer = False; // do we need to be called at the end of the page + class html + { + var $user_agent,$ua_version; // 'mozilla','msie','konqueror' + var $prefered_img_title; + var $charset,$phpgwapi_js_url; + var $need_footer = False; // do we need to be called at the end of the page - function html() - { - // should be Ok for all HTML 4 compatible browsers - if (!eregi('(Safari)/([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts) && - !eregi('compatible; ([a-z_]+)[/ ]+([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts)) - { + function html() + { + // should be Ok for all HTML 4 compatible browsers + if (!eregi('(Safari)/([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts) && + !eregi('compatible; ([a-z_]+)[/ ]+([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts)) + { eregi('^([a-z_]+)/([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts); - } - list(,$this->user_agent,$this->ua_version) = $parts; - $this->user_agent = strtolower($this->user_agent); + } + list(,$this->user_agent,$this->ua_version) = $parts; + $this->user_agent = strtolower($this->user_agent); - $this->netscape4 = $this->user_agent == 'mozilla' && $this->ua_version < 5; - $this->prefered_img_title = $this->netscape4 ? 'alt' : 'title'; - //echo "

HTTP_USER_AGENT='$_SERVER[HTTP_USER_AGENT]', UserAgent: '$this->user_agent', Version: '$this->ua_version', img_title: '$this->prefered_img_title'

\n"; + $this->netscape4 = $this->user_agent == 'mozilla' && $this->ua_version < 5; + $this->prefered_img_title = $this->netscape4 ? 'alt' : 'title'; + //echo "

HTTP_USER_AGENT='$_SERVER[HTTP_USER_AGENT]', UserAgent: '$this->user_agent', Version: '$this->ua_version', img_title: '$this->prefered_img_title'

\n"; - if ($GLOBALS['phpgw']->translation) - { + if ($GLOBALS['phpgw']->translation) + { $this->charset = $GLOBALS['phpgw']->translation->charset(); - } - $this->phpgwapi_js_url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/js'; - } + } + $this->phpgwapi_js_url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/js'; + } - /** - * Created an input-field with an attached tigra color-picker - * - * Please note: it need to be called before the call to phpgw_header() !!! - * - * @param $name string the name of the input-field - * @param $value string the actual value for the input-field, default '' - * @param $title string tooltip/title for the picker-activation-icon - */ - function inputColor($name,$value='',$title='') - { - $id = str_replace(array('[',']'),array('_',''),$name).'_colorpicker'; - $onclick = "javascript:window.open('".$this->phpgwapi_js_url.'/colorpicker/select_color.html?id='.urlencode($id)."&color='+document.getElementById('$id').value,'colorPicker','width=240,height=187,scrollbars=no,resizable=no,toolbar=no');"; - return ' '. - ''. + /** + * Created an input-field with an attached tigra color-picker + * + * Please note: it need to be called before the call to phpgw_header() !!! + * + * @param $name string the name of the input-field + * @param $value string the actual value for the input-field, default '' + * @param $title string tooltip/title for the picker-activation-icon + */ + function inputColor($name,$value='',$title='') + { + $id = str_replace(array('[',']'),array('_',''),$name).'_colorpicker'; + $onclick = "javascript:window.open('".$this->phpgwapi_js_url.'/colorpicker/select_color.html?id='.urlencode($id)."&color='+document.getElementById('$id').value,'colorPicker','width=240,height=187,scrollbars=no,resizable=no,toolbar=no');"; + return ' '. + ''. '"; - } + } - /** - * Handles tooltips via the wz_tooltip class from Walter Zorn - * - * Note: The wz_tooltip.js file gets automaticaly loaded at the end of the page - * - * @param $text string/boolean text or html for the tooltip, all chars allowed, they will be quoted approperiate - * Or if False the content (innerHTML) of the element itself is used. - * @param $do_lang boolean (default False) should the text be run though lang() - * @param $options array param/value pairs, eg. 'TITLE' => 'I am the title'. Some common parameters: - * title (string) gives extra title-row, width (int,'auto') , padding (int), above (bool), bgcolor (color), bgimg (URL) - * For a complete list and description see http://www.walterzorn.com/tooltip/tooltip_e.htm - * @return string to be included in any tag, like 'tooltip('Hello Ralf').'>Text with tooltip

' - */ - function tooltip($text,$do_lang=False,$options=False) - { - if (!$this->wz_tooltip_included) - { + /** + * Handles tooltips via the wz_tooltip class from Walter Zorn + * + * Note: The wz_tooltip.js file gets automaticaly loaded at the end of the page + * + * @param $text string/boolean text or html for the tooltip, all chars allowed, they will be quoted approperiate + * Or if False the content (innerHTML) of the element itself is used. + * @param $do_lang boolean (default False) should the text be run though lang() + * @param $options array param/value pairs, eg. 'TITLE' => 'I am the title'. Some common parameters: + * title (string) gives extra title-row, width (int,'auto') , padding (int), above (bool), bgcolor (color), bgimg (URL) + * For a complete list and description see http://www.walterzorn.com/tooltip/tooltip_e.htm + * @return string to be included in any tag, like 'tooltip('Hello Ralf').'>Text with tooltip

' + */ + function tooltip($text,$do_lang=False,$options=False) + { + if (!$this->wz_tooltip_included) + { if (!strstr('wz_tooltip',$GLOBALS['phpgw_info']['flags']['need_footer'])) { - $GLOBALS['phpgw_info']['flags']['need_footer'] .= ''."\n"; + $GLOBALS['phpgw_info']['flags']['need_footer'] .= ''."\n"; } $this->wz_tooltip_included = True; - } - if ($do_lang) $text = lang($text); + } + if ($do_lang) $text = lang($text); - $opt_out = 'this.T_WIDTH = 200;'; - if (is_array($options)) - { + $opt_out = 'this.T_WIDTH = 200;'; + if (is_array($options)) + { foreach($options as $option => $value) { - $opt_out .= 'this.T_'.strtoupper($option).'='.(is_numeric($value)?$value:"'$value'").'; '; + $opt_out .= 'this.T_'.strtoupper($option).'='.(is_numeric($value)?$value:"'$value'").'; '; } - } - if ($text === False) return ' onmouseover="'.$opt_out.'return escape(this.innerHTML);"'; + } + if ($text === False) return ' onmouseover="'.$opt_out.'return escape(this.innerHTML);"'; - return ' onmouseover="'.$opt_out.'return escape(\''.str_replace(array("\n","\r","'",'"'),array('','',"\\'",'"'),$text).'\')"'; - } + return ' onmouseover="'.$opt_out.'return escape(\''.str_replace(array("\n","\r","'",'"'),array('','',"\\'",'"'),$text).'\')"'; + } - function activate_links($content) - { - // Exclude everything which is already a link - $NotAnchor = '(?\\1 AT \\2 DOT \\3', - $content); + // spamsaver emailaddress + $result = preg_replace('/'.$NotAnchor.'mailto:([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i', + '\\1 AT \\2 DOT \\3', + $content); - // First match things beginning with http:// (or other protocols) - $Protocol = '(http|ftp|https):\/\/'; - $Domain = '([\w]+.[\w]+)'; - $Subdir = '([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?'; - $Expr = '/' . $NotAnchor . $Protocol . $Domain . $Subdir . '/i'; + // First match things beginning with http:// (or other protocols) + $Protocol = '(http|ftp|https):\/\/'; + $Domain = '([\w]+.[\w]+)'; + $Subdir = '([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?'; + $Expr = '/' . $NotAnchor . $Protocol . $Domain . $Subdir . '/i'; - $result = preg_replace( $Expr, "$2$3", $result ); + $result = preg_replace( $Expr, "$2$3", $result ); - // Now match things beginning with www. - $NotHTTP = '(?$0", $result ); - } + return preg_replace( $Expr, "$0", $result ); + } - function htmlspecialchars($str) - { - // add @ by lkneschke to supress warning about unknown charset - $str = @htmlspecialchars($str,ENT_COMPAT,$this->charset); - - // we need '&#' unchanged, so we translate it back - $str = str_replace('&#','&#',$str); + function htmlspecialchars($str) + { + // add @ by lkneschke to supress warning about unknown charset + $str = @htmlspecialchars($str,ENT_COMPAT,$this->charset); - return $str; - } + // we need '&#' unchanged, so we translate it back + $str = str_replace('&#','&#',$str); - /*! - @function select - @abstract allows to show and select one item from an array - @param $name string with name of the submitted var which holds the key of the selected item form array - @param $key key(s) of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys - @param $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe'); - @param $no_lang if !$no_lang send items through lang() - @param $options additional options (e.g. 'width') - @param $multiple number of lines for a multiselect, default 0 = no multiselect - @returns string to set for a template or to echo into html page - */ - function select($name, $key, $arr=0,$no_lang=0,$options='',$multiple=0) - { - // should be in class common.sbox - if (!is_array($arr)) - { + return $str; + } + + /*! + @function select + @abstract allows to show and select one item from an array + @param $name string with name of the submitted var which holds the key of the selected item form array + @param $key key(s) of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys + @param $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe'); + @param $no_lang if !$no_lang send items through lang() + @param $options additional options (e.g. 'width') + @param $multiple number of lines for a multiselect, default 0 = no multiselect + @returns string to set for a template or to echo into html page + */ + function select($name, $key, $arr=0,$no_lang=0,$options='',$multiple=0) + { + // should be in class common.sbox + if (!is_array($arr)) + { $arr = array('no','yes'); - } - if ((int)$multiple > 0) - { + } + if ((int)$multiple > 0) + { $options .= ' multiple="1" size="'.(int)$multiple.'"'; if (substr($name,-2) != '[]') { - $name .= '[]'; + $name .= '[]'; } - } - $out = "\n"; - if (!is_array($key)) - { - // explode on ',' only if multiple values expected and the key contains just numbers and commas - $key = $multiple && preg_match('/^[,0-9]+$/',$key) ? explode(',',$key) : array($key); - } - foreach($arr as $k => $text) - { - $out .= '