diff --git a/etemplate/inc/class.bo_tracking.inc.php b/etemplate/inc/class.bo_tracking.inc.php
index 122adf7e11..c0b0df26f6 100644
--- a/etemplate/inc/class.bo_tracking.inc.php
+++ b/etemplate/inc/class.bo_tracking.inc.php
@@ -120,12 +120,6 @@ class bo_tracking
* @var int
*/
var $tz_offset_s;
- /**
- * Reference to the html class
- *
- * @var html
- */
- var $html;
/**
* Should the class allow html content (for notifications)
*
@@ -140,7 +134,7 @@ class bo_tracking
*/
function bo_tracking()
{
- $this->html =& html::singleton();
+
}
/**
@@ -629,7 +623,7 @@ class bo_tracking
if ($html_mail)
{
- if (!$this->html_content_allow) $line = $this->html->htmlspecialchars($line); // XSS
+ if (!$this->html_content_allow) $line = html::htmlspecialchars($line); // XSS
$color = $modified ? 'red' : false;
$size = '110%';
@@ -682,7 +676,7 @@ class bo_tracking
{
// the link is often too long for html boxes
// chunk-split allows to break lines if needed
- $content .= $this->html->a_href(chunk_split($link,40,''),$link,'','target="_blank"');
+ $content .= html::a_href(chunk_split($link,40,''),$link,'','target="_blank"');
}
else
{
diff --git a/notifications/inc/class.notifications_email.inc.php b/notifications/inc/class.notifications_email.inc.php
index 1b7ccadb1a..409bd9d359 100644
--- a/notifications/inc/class.notifications_email.inc.php
+++ b/notifications/inc/class.notifications_email.inc.php
@@ -54,13 +54,6 @@ class notifications_email implements notifications_iface {
*/
private $mail;
- /**
- * holds html object to render elements
- *
- * @var object
- */
- private $html;
-
/**
* constructor of notifications_email
*
@@ -80,7 +73,6 @@ class notifications_email implements notifications_iface {
{
$this->mail = new send();
}
- $this->html = html::singleton();
}
/**
@@ -131,12 +123,12 @@ class notifications_email implements notifications_iface {
if(is_null($_render_html)) { $_render_html = false; }
if(is_null($_render_external)) { $_render_external = true; }
$newline = $_render_html ? "
" : "\n";
- $hruler = $_render_html ? $this->html->hr() : '';
+ $hruler = $_render_html ? html::hr() : '';
$rendered_links = array();
foreach($_links as $link) {
if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; }
- $url = $this->html->link('/index.php', $link->view);
+ $url = html::link('/index.php', $link->view);
// do not expose sensitive data
$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',$url);
// complete missing protocol and domain part if needed
@@ -144,7 +136,7 @@ class notifications_email implements notifications_iface {
$url = ($_SERVER['HTTPS'] || $GLOBALS['egw_info']['server']['enforce_ssl'] ? 'https://' : 'http://').
($GLOBALS['egw_info']['server']['hostname'] ? $GLOBALS['egw_info']['server']['hostname'] : $_SERVER['HTTP_HOST']).$url;
}
- $rendered_links[] = $_render_html ? $this->html->a_href($link->text, $url, false, 'target="_blank"') : $url;
+ $rendered_links[] = $_render_html ? html::a_href($link->text, $url, false, 'target="_blank"') : $url;
}
return $hruler.$newline.lang('Linked entries:').$newline.implode($newline,$rendered_links);
diff --git a/notifications/inc/class.notifications_popup.inc.php b/notifications/inc/class.notifications_popup.inc.php
index 016b77cbf2..7b5e89bed4 100644
--- a/notifications/inc/class.notifications_popup.inc.php
+++ b/notifications/inc/class.notifications_popup.inc.php
@@ -77,13 +77,6 @@ class notifications_popup implements notifications_iface {
*/
private $db;
- /**
- * holds html object to render elements
- *
- * @var object
- */
- private $html;
-
/**
* constructor of notifications_egwpopup
*
@@ -100,8 +93,6 @@ class notifications_popup implements notifications_iface {
$this->config = $_config;
$this->preferences = $_preferences;
$this->db = &$GLOBALS['egw']->db;
- $this->db->set_app( self::_appname );
- $this->html = html::singleton();
}
/**
@@ -123,9 +114,9 @@ class notifications_popup implements notifications_iface {
if ( empty($user_sessions) ) throw new Exception("User {$this->recipient->account_lid} isn't online. Can't send notification via popup");
$message = $this->render_infos($_subject)
- .$this->html->hr()
+ .html::hr()
.$_messages['html']
- .$this->html->hr()
+ .html::hr()
.$this->render_links($_links);
$this->save( $message, $user_sessions );
@@ -143,7 +134,7 @@ class notifications_popup implements notifications_iface {
'account_id' => $this->recipient->account_id,
'session_id' => $user_session,
'message' => $_message
- ), false,__LINE__,__FILE__);
+ ), false,__LINE__,__FILE__,self::_appname);
}
if ($result === false) throw new Exception("Can't save notification into SQL table");
}
@@ -163,27 +154,27 @@ class notifications_popup implements notifications_iface {
foreach($_links as $link) {
if(!$link->popup) { $link->view['no_popup'] = 1; }
- $url = $this->html->link('/index.php', $link->view);
+ $url = html::link('/index.php', $link->view);
// do not expose sensitive data
$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',$url);
// extract application-icon from menuaction
if($link->view['menuaction']) {
$menuaction_arr = explode('.',$link->view['menuaction']);
$application = $menuaction_arr[0];
- $image = $application ? $this->html->image($application,'navbar',$link->text,'align="middle" style="width: 24px; margin-right: 0.5em;"') : '';
+ $image = $application ? html::image($application,'navbar',$link->text,'align="middle" style="width: 24px; margin-right: 0.5em;"') : '';
} else {
$image = '';
}
if($link->popup) {
$dimensions = explode('x', $link->popup);
- $rendered_links[] = $this->html->div($image.$link->text,'onclick="'.$this->jspopup($url, '_blank', $dimensions[0], $dimensions[1]).'"','link');
+ $rendered_links[] = html::div($image.$link->text,'onclick="'.$this->jspopup($url, '_blank', $dimensions[0], $dimensions[1]).'"','link');
} else {
- $rendered_links[] = $this->html->div($this->html->a_href($image.$link->text, $url, false, 'target="_blank"'),'','link');
+ $rendered_links[] = html::div(html::a_href($image.$link->text, $url, false, 'target="_blank"'),'','link');
}
}
if(count($rendered_links) > 0) {
- return $this->html->bold(lang('Linked entries:')).$newline.implode($newline,$rendered_links);
+ return html::bold(lang('Linked entries:')).$newline.implode($newline,$rendered_links);
}
}
@@ -214,7 +205,7 @@ class notifications_popup implements notifications_iface {
$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
$infos[] = lang('Message from').': '.$sender;
- if(!empty($_subject)) { $infos[] = $this->html->bold($_subject); }
+ if(!empty($_subject)) { $infos[] = html::bold($_subject); }
return implode($newline,$infos);
}
}
diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php
index db6316c15e..3af2e0d67c 100644
--- a/phpgwapi/inc/class.html.inc.php
+++ b/phpgwapi/inc/class.html.inc.php
@@ -1,21 +1,22 @@
complete rewrite in 6/2006 and earlier modifications
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
+ * @author RalfBecker-AT-outdoor-training.de
+ * @copyright 2001-2008 by RalfBecker@outdoor-training.de
+ * @package api
+ * @subpackage html
* @version $Id$
*/
/**
- * generates html with methods representing html-tags or higher widgets
+ * Generates html with methods representing html-tags or higher widgets
+ *
+ * The class has only static methods now, so there's no need to instanciate the object anymore!
*
- * @package api
- * @subpackage html
- * @access public
- * @author RalfBecker-AT-outdoor-training.de
- * @license GPL
*/
class html
{
@@ -23,56 +24,57 @@ class html
* user-agent: 'mozilla','msie','konqueror', 'safari', 'opera'
* @var string
*/
- var $user_agent;
+ static $user_agent;
/**
* version of user-agent as specified by browser
* @var string
*/
- var $ua_version;
+ static $ua_version;
/**
* what attribute to use for the title of an image: 'title' for everything but netscape4='alt'
* @var string
*/
- var $prefered_img_title;
+ static $netscape4;
+ static private $prefered_img_title;
/**
* charset used by the page, as returned by $GLOBALS['egw']->translation->charset()
* @var string
*/
- var $charset;
+ static $charset;
/**
* URL (NOT path) of the js directory in the api
* @var string
*/
- var $phpgwapi_js_url;
+ static $api_js_url;
/**
* do we need to set the wz_tooltip class, to be included at the end of the page
* @var boolean
*/
- var $wz_tooltip_included = False;
+ static private $wz_tooltip_included = False;
/**
- * Constructor: initialised the class-vars
+ * initialise our static vars
*/
- function html()
+ static function _init_static()
{
// 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))
+ if (!preg_match('/(Safari)\/([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts) &&
+ !preg_match('/compatible; ([a-z_]+)[\/ ]+([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts))
{
- eregi('^([a-z_]+)/([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts);
+ preg_match('/^([a-z_]+)\/([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts);
}
- list(,$this->user_agent,$this->ua_version) = $parts;
- $this->user_agent = strtolower($this->user_agent);
+ list(,self::$user_agent,self::$ua_version) = $parts;
+ self::$user_agent = strtolower(self::$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"; + self::$netscape4 = self::$user_agent == 'mozilla' && self::$ua_version < 5; + self::$prefered_img_title = self::$netscape4 ? 'alt' : 'title'; + //echo "HTTP_USER_AGENT='$_SERVER[HTTP_USER_AGENT]', UserAgent: 'self::$user_agent', Version: 'self::$ua_version', img_title: 'self::$prefered_img_title'
\n"; if ($GLOBALS['egw']->translation) { - $this->charset = $GLOBALS['egw']->translation->charset(); + self::$charset = $GLOBALS['egw']->translation->charset(); } - $this->phpgwapi_js_url = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js'; + self::$api_js_url = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js'; } /** @@ -85,13 +87,13 @@ class html * @param string $title tooltip/title for the picker-activation-icon * @return string the html */ - function inputColor($name,$value='',$title='') + static 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 ' '. + $onclick = "javascript:window.open('".self::$api_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 ' '. ''. - '"; + '"; } /** @@ -105,17 +107,17 @@ class html * @param array $options 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
' + * @return string to be included in any tag, like 'Ralf').'>Text with tooltip
' */ - function tooltip($text,$do_lang=False,$options=False) + static function tooltip($text,$do_lang=False,$options=False) { - if (!$this->wz_tooltip_included) + if (!self::$wz_tooltip_included) { if (strpos($GLOBALS['egw_info']['flags']['need_footer'],'wz_tooltip')===false) { - $GLOBALS['egw_info']['flags']['need_footer'] .= ''."\n"; + $GLOBALS['egw_info']['flags']['need_footer'] .= ''."\n"; } - $this->wz_tooltip_included = True; + self::$wz_tooltip_included = True; } if ($do_lang) $text = lang($text); @@ -139,8 +141,10 @@ class html * @param string $content text containing URLs * @return string html with activated links */ - function activate_links($content) + static function activate_links($content) { + if (!$content || strlen($content) < 20) return $content; // performance + // Exclude everything which is already a link $NotAnchor = '(?$2$3$4", $result ); // Now match things beginning with www. - $NotHTTP = '(?)'; // avoid running again on http://www links already handled above $Domain = 'www(\.[\w-.]+)'; $Subdir = '([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?'; $Expr = '/' . $NotAnchor . $NotHTTP . $Domain . $Subdir . '/i'; @@ -177,10 +181,10 @@ class html * @param string $str string to escape * @return string */ - function htmlspecialchars($str) + static function htmlspecialchars($str) { // add @ by lkneschke to supress warning about unknown charset - $str = @htmlspecialchars($str,ENT_COMPAT,$this->charset); + $str = @htmlspecialchars($str,ENT_COMPAT,self::$charset); // we need '' unchanged, so we translate it back $str = str_replace(array('&#',' ','<','>'),array('',' ','<','>'),$str); @@ -199,7 +203,7 @@ class html * @param int $multiple number of lines for a multiselect, default 0 = no multiselect, < 0 sets size without multiple * @return string to set for a template or to echo into html page */ - function select($name, $key, $arr=0,$no_lang=false,$options='',$multiple=0) + static function select($name, $key, $arr=0,$no_lang=false,$options='',$multiple=0) { if (!is_array($arr)) { @@ -228,7 +232,7 @@ class html { if (!is_array($data) || count($data) == 2 && isset($data['label']) && isset($data['title'])) { - $out .= $this->select_option($k,is_array($data)?$data['label']:$data,$key,$no_lang, + $out .= self::select_option($k,is_array($data)?$data['label']:$data,$key,$no_lang, is_array($data)?$data['title']:''); } else @@ -238,11 +242,11 @@ class html $k = $data['lable']; unset($data['lable']); } - $out .= '