cant completly remove egw_framework::set_on* methods, as they are still in use

This commit is contained in:
Ralf Becker 2016-04-15 15:12:27 +00:00
parent 2c40992428
commit aa2275ace8
2 changed files with 71 additions and 4 deletions

View File

@ -359,6 +359,40 @@ abstract class Framework extends Framework\Extra
return $var;
}
/**
* 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)
*
@ -419,6 +453,7 @@ abstract class Framework extends Framework\Extra
'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"',

View File

@ -120,7 +120,15 @@ abstract class egw_framework extends Api\Framework
*/
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 @@ abstract class egw_framework extends Api\Framework
*/
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 @@ abstract class egw_framework extends Api\Framework
*/
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 @@ abstract class egw_framework extends Api\Framework
*/
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'];
}
/**