[eGroupWare-svn] r55758 - in /trunk: egroupware/api/src/Framework.php phpgwapi/inc/class.egw_framework.inc.php

[email protected]
Newsgroups gmane.comp.web.egroupware.cvs
Message-ID <[email protected]>
Author: ralfbecker
Date: Fri Apr 15 17:12:27 2016
New Revision: 55758

URL: http://svn.stylite.de/viewvc/egroupware?rev=55758&view=rev
Log:
cant completly remove egw_framework::set_on* methods, as they are still in use

Modified:
    trunk/egroupware/api/src/Framework.php
    trunk/phpgwapi/inc/class.egw_framework.inc.php

Modified: trunk/egroupware/api/src/Framework.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/src/Framework.php?rev=55758&r1=55757&r2=55758&view=diff
==============================================================================
--- trunk/egroupware/api/src/Framework.php (original)
+++ trunk/egroupware/api/src/Framework.php Fri Apr 15 17:12:27 2016
@@ -360,6 +360,40 @@
 	}
 
 	/**
+	 * Body tags for onLoad, onUnload and onResize
+	 *
+	 * @deprecated since 14.1 use app.js et2_ready method instead to execute code or bind a handler (CSP will stop onXXX attributes!)
+	 * @var array
+	 */
+	protected static $body_tags = array();
+
+	/**
+	 * Adds on(Un)Load= attributes to the body tag of a page
+	 *
+	 * Can only be set via egw_framework::set_on* methods.
+	 *
+	 * @deprecated since 14.1 use app.js et2_ready method instead to execute code or bind a handler (CSP will stop onXXX attributes!)
+	 * @returns string the attributes to be used
+	 */
+	static public function _get_body_attribs()
+	{
+		$js = '';
+		foreach(self::$body_tags as $what => $data)
+		{
+			if (!empty($data))
+			{
+				if($what == 'onLoad')
+				{
+					$js .= 'onLoad="egw_LAB.wait(function() {'. htmlspecialchars($data).'})"';
+					continue;
+				}
+				$js .= ' '.$what.'="' . htmlspecialchars($data) . '"';
+			}
+		}
+		return $js;
+	}
+
+	/**
 	 * Get header as array to eg. set as vars for a template (from idots' head.inc.php)
 	 *
 	 * @param array $extra =array() extra attributes passed as data-attribute to egw.js
@@ -419,6 +453,7 @@
 			'lang_code'			=> $lang_code,
 			'charset'       	=> Translation::charset(),
 			'website_title' 	=> $site_title,
+			'body_tags'         => self::_get_body_attribs(),
 			'java_script'   	=> self::_get_js($extra),
 			'meta_robots'		=> $robots,
 			'dir_code'			=> lang('language_direction_rtl') != 'rtl' ? '' : ' dir="rtl"',

Modified: trunk/phpgwapi/inc/class.egw_framework.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/phpgwapi/inc/class.egw_framework.inc.php?rev=55758&r1=55757&r2=55758&view=diff
==============================================================================
--- trunk/phpgwapi/inc/class.egw_framework.inc.php (original)
+++ trunk/phpgwapi/inc/class.egw_framework.inc.php Fri Apr 15 17:12:27 2016
@@ -120,7 +120,15 @@
 	 */
 	static function set_onload($code='',$replace=false)
 	{
-		unset($code, $replace);
+		if ($replace || empty(self::$body_tags['onLoad']))
+		{
+			self::$body_tags['onLoad'] = $code;
+		}
+		else
+		{
+			self::$body_tags['onLoad'] .= $code;
+		}
+		return self::$body_tags['onLoad'];
 	}
 
 	/**
@@ -133,7 +141,15 @@
 	 */
 	static function set_onunload($code='',$replace=false)
 	{
-		unset($code, $replace);
+		if ($replace || empty(self::$body_tags['onUnload']))
+		{
+			self::$body_tags['onUnload'] = $code;
+		}
+		else
+		{
+			self::$body_tags['onUnload'] .= $code;
+		}
+		return self::$body_tags['onUnload'];
 	}
 
 	/**
@@ -146,7 +162,15 @@
 	 */
 	static function set_onbeforeunload($code='',$replace=false)
 	{
-		unset($code, $replace);
+		if ($replace || empty(self::$body_tags['onBeforeUnload']))
+		{
+			self::$body_tags['onBeforeUnload'] = $code;
+		}
+		else
+		{
+			self::$body_tags['onBeforeUnload'] .= $code;
+		}
+		return self::$body_tags['onBeforeUnload'];
 	}
 
 	/**
@@ -159,7 +183,15 @@
 	 */
 	static function set_onresize($code='',$replace=false)
 	{
-		unset($code, $replace);
+		if ($replace || empty(self::$body_tags['onResize']))
+		{
+			self::$body_tags['onResize'] = $code;
+		}
+		else
+		{
+			self::$body_tags['onResize'] .= $code;
+		}
+		return self::$body_tags['onResize'];
 	}
 
 	/**


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.