2006-12-11 00:44:18 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2011-08-31 09:50:28 +02:00
|
|
|
* EGroupware API - framework baseclass
|
2008-07-21 16:40:54 +02:00
|
|
|
*
|
2006-12-11 00:44:18 +01:00
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> rewrite in 12/2006
|
|
|
|
* @author Pim Snel <pim@lingewoud.nl> author of the idots template set
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package api
|
|
|
|
* @subpackage framework
|
|
|
|
* @access public
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
2016-03-13 15:08:31 +01:00
|
|
|
use EGroupware\Api;
|
|
|
|
|
2006-12-11 00:44:18 +01:00
|
|
|
/**
|
2016-04-07 22:42:06 +02:00
|
|
|
* Framework: virtual base class for all template sets
|
2008-07-21 16:40:54 +02:00
|
|
|
*
|
2016-04-07 22:42:06 +02:00
|
|
|
* @deprecated use Api\Framework
|
2006-12-11 00:44:18 +01:00
|
|
|
*/
|
2016-04-07 22:42:06 +02:00
|
|
|
abstract class egw_framework extends Api\Framework
|
2006-12-11 00:44:18 +01:00
|
|
|
{
|
2013-10-05 15:33:28 +02:00
|
|
|
/**
|
|
|
|
* Set/get Content-Security-Policy attributes for script-src: 'unsafe-eval' and/or 'unsafe-inline'
|
|
|
|
*
|
|
|
|
* Using CK-Editor currently requires both to be set :(
|
|
|
|
*
|
|
|
|
* Old pre-et2 apps might need to call egw_framework::csp_script_src_attrs(array('unsafe-eval','unsafe-inline'))
|
|
|
|
*
|
|
|
|
* EGroupware itself currently still requires 'unsafe-eval'!
|
|
|
|
*
|
2016-03-13 15:08:31 +01:00
|
|
|
* @param string|array $set =null 'unsafe-eval' and/or 'unsafe-inline' (without quotes!) or URL (incl. protocol!)
|
|
|
|
* @deprecated use Api\Header\ContentSecurityPolicy::add('script-src', $set);
|
2013-10-05 15:33:28 +02:00
|
|
|
*/
|
|
|
|
public static function csp_script_src_attrs($set=null)
|
|
|
|
{
|
2016-03-13 15:08:31 +01:00
|
|
|
Api\Header\ContentSecurityPolicy::add('script-src', $set);
|
2013-10-05 15:33:28 +02:00
|
|
|
}
|
|
|
|
|
2014-09-04 11:58:48 +02:00
|
|
|
/**
|
|
|
|
* Set/get Content-Security-Policy attributes for style-src: 'unsafe-inline'
|
|
|
|
*
|
|
|
|
* EGroupware itself currently still requires 'unsafe-inline'!
|
|
|
|
*
|
2016-03-13 15:08:31 +01:00
|
|
|
* @param string|array $set =null 'unsafe-inline' (without quotes!) and/or URL (incl. protocol!)
|
|
|
|
* @deprecated use Api\Header\ContentSecurityPolicy::add('style-src', $set);
|
2014-09-04 11:58:48 +02:00
|
|
|
*/
|
|
|
|
public static function csp_style_src_attrs($set=null)
|
|
|
|
{
|
2016-03-13 15:08:31 +01:00
|
|
|
Api\Header\ContentSecurityPolicy::add('style-src', $set);
|
2014-09-04 11:58:48 +02:00
|
|
|
}
|
|
|
|
|
2014-10-09 22:32:59 +02:00
|
|
|
/**
|
|
|
|
* Set/get Content-Security-Policy attributes for connect-src:
|
|
|
|
*
|
|
|
|
* @param string|array $set =array() URL (incl. protocol!)
|
2016-03-13 15:08:31 +01:00
|
|
|
* @deprecated use Api\Header\ContentSecurityPolicy::add('connect-src', $set);
|
2014-10-09 22:32:59 +02:00
|
|
|
*/
|
|
|
|
public static function csp_connect_src_attrs($set=null)
|
|
|
|
{
|
2016-03-13 15:08:31 +01:00
|
|
|
Api\Header\ContentSecurityPolicy::add('connect-src', $set);
|
2014-10-09 22:32:59 +02:00
|
|
|
}
|
|
|
|
|
2015-02-21 14:29:10 +01:00
|
|
|
/**
|
|
|
|
* Set/get Content-Security-Policy attributes for frame-src:
|
|
|
|
*
|
|
|
|
* Calling this method with an empty array sets no frame-src, but "'self'"!
|
|
|
|
*
|
2016-03-13 15:08:31 +01:00
|
|
|
* @param string|array $set =null URL (incl. protocol!)
|
|
|
|
* @deprecated use Api\Header\ContentSecurityPolicy::add('frame-src', $set);
|
2015-02-21 14:29:10 +01:00
|
|
|
*/
|
|
|
|
public static function csp_frame_src_attrs($set=null)
|
2014-02-21 18:06:11 +01:00
|
|
|
{
|
2016-03-13 15:08:31 +01:00
|
|
|
Api\Header\ContentSecurityPolicy::add('frame-src', $set);
|
2014-02-21 18:06:11 +01:00
|
|
|
}
|
|
|
|
|
2013-10-05 15:33:28 +02:00
|
|
|
/**
|
2016-04-07 22:42:06 +02:00
|
|
|
* Get the (depricated) application footer
|
2008-07-21 16:40:54 +02:00
|
|
|
*
|
2016-04-07 22:42:06 +02:00
|
|
|
* @deprecated
|
|
|
|
* @return string html
|
2006-12-11 00:44:18 +01:00
|
|
|
*/
|
2016-04-07 22:42:06 +02:00
|
|
|
protected static function _get_app_footer()
|
2006-12-11 00:44:18 +01:00
|
|
|
{
|
2016-04-07 22:42:06 +02:00
|
|
|
ob_start();
|
|
|
|
// Include the apps footer files if it exists
|
|
|
|
if (EGW_APP_INC != EGW_API_INC && // this prevents an endless inclusion on the homepage
|
|
|
|
// (some apps set currentapp in hook_home => it's not releyable)
|
|
|
|
(file_exists (EGW_APP_INC . '/footer.inc.php') || isset($_GET['menuaction'])) &&
|
2016-05-01 11:57:48 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['currentapp'] != 'api' &&
|
2016-04-07 22:42:06 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['currentapp'] != 'login' &&
|
|
|
|
$GLOBALS['egw_info']['flags']['currentapp'] != 'logout' &&
|
|
|
|
!@$GLOBALS['egw_info']['flags']['noappfooter'])
|
2006-12-11 00:44:18 +01:00
|
|
|
{
|
2016-04-07 22:42:06 +02:00
|
|
|
list(, $class) = explode('.',(string)$_GET['menuaction']);
|
|
|
|
if ($class && is_object($GLOBALS[$class]) && is_array($GLOBALS[$class]->public_functions) &&
|
|
|
|
isset($GLOBALS[$class]->public_functions['footer']))
|
|
|
|
{
|
|
|
|
$GLOBALS[$class]->footer();
|
|
|
|
}
|
|
|
|
elseif(file_exists(EGW_APP_INC.'/footer.inc.php'))
|
|
|
|
{
|
|
|
|
include(EGW_APP_INC . '/footer.inc.php');
|
|
|
|
}
|
2006-12-11 00:44:18 +01:00
|
|
|
}
|
2016-04-07 22:42:06 +02:00
|
|
|
$content = ob_get_contents();
|
|
|
|
ob_end_clean();
|
2016-03-24 09:40:43 +01:00
|
|
|
|
2016-04-07 22:42:06 +02:00
|
|
|
return $content;
|
2013-08-20 14:06:41 +02:00
|
|
|
}
|
|
|
|
|
2013-09-05 13:53:25 +02:00
|
|
|
/**
|
2016-04-07 22:42:06 +02:00
|
|
|
* Sets an onLoad action for a page
|
2013-09-05 13:53:25 +02:00
|
|
|
*
|
2016-04-07 22:42:06 +02:00
|
|
|
* @param string $code ='' javascript to be used
|
|
|
|
* @param boolean $replace =false false: append to existing, true: replace existing tag
|
|
|
|
* @deprecated since 14.1 use app.js et2_ready method instead to execute code or bind a handler (CSP will stop onXXX attributes!)
|
|
|
|
* @return string content of onXXX tag after adding code
|
2013-09-05 13:53:25 +02:00
|
|
|
*/
|
2016-04-07 22:42:06 +02:00
|
|
|
static function set_onload($code='',$replace=false)
|
2013-09-05 13:53:25 +02:00
|
|
|
{
|
2016-04-15 17:12:27 +02:00
|
|
|
if ($replace || empty(self::$body_tags['onLoad']))
|
|
|
|
{
|
|
|
|
self::$body_tags['onLoad'] = $code;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self::$body_tags['onLoad'] .= $code;
|
|
|
|
}
|
|
|
|
return self::$body_tags['onLoad'];
|
2013-09-05 13:53:25 +02:00
|
|
|
}
|
|
|
|
|
2014-06-18 15:57:15 +02:00
|
|
|
/**
|
2016-04-07 22:42:06 +02:00
|
|
|
* Sets an onUnload action for a page
|
2014-06-18 15:57:15 +02:00
|
|
|
*
|
2016-04-07 22:42:06 +02:00
|
|
|
* @param string $code ='' javascript to be used
|
|
|
|
* @param boolean $replace =false false: append to existing, true: replace existing tag
|
|
|
|
* @deprecated since 14.1 use app.js et2_ready method instead to execute code or bind a handler (CSP will stop onXXX attributes!)
|
|
|
|
* @return string content of onXXX tag after adding code
|
2014-06-18 15:57:15 +02:00
|
|
|
*/
|
2016-04-07 22:42:06 +02:00
|
|
|
static function set_onunload($code='',$replace=false)
|
2014-06-18 15:57:15 +02:00
|
|
|
{
|
2016-04-15 17:12:27 +02:00
|
|
|
if ($replace || empty(self::$body_tags['onUnload']))
|
|
|
|
{
|
|
|
|
self::$body_tags['onUnload'] = $code;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self::$body_tags['onUnload'] .= $code;
|
|
|
|
}
|
|
|
|
return self::$body_tags['onUnload'];
|
2014-06-18 15:57:15 +02:00
|
|
|
}
|
|
|
|
|
2013-08-20 14:06:41 +02:00
|
|
|
/**
|
2016-04-07 22:42:06 +02:00
|
|
|
* Sets an onBeforeUnload action for a page
|
2013-08-26 12:24:11 +02:00
|
|
|
*
|
2016-04-07 22:42:06 +02:00
|
|
|
* @param string $code ='' javascript to be used
|
|
|
|
* @param boolean $replace =false false: append to existing, true: replace existing tag
|
|
|
|
* @deprecated since 14.1 use app.js et2_ready method instead to execute code or bind a handler (CSP will stop onXXX attributes!)
|
|
|
|
* @return string content of onXXX tag after adding code
|
2013-08-20 15:25:36 +02:00
|
|
|
*/
|
2016-04-07 22:42:06 +02:00
|
|
|
static function set_onbeforeunload($code='',$replace=false)
|
2013-08-20 15:25:36 +02:00
|
|
|
{
|
2016-04-15 17:12:27 +02:00
|
|
|
if ($replace || empty(self::$body_tags['onBeforeUnload']))
|
|
|
|
{
|
|
|
|
self::$body_tags['onBeforeUnload'] = $code;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self::$body_tags['onBeforeUnload'] .= $code;
|
|
|
|
}
|
|
|
|
return self::$body_tags['onBeforeUnload'];
|
2013-08-20 15:25:36 +02:00
|
|
|
}
|
|
|
|
|
2013-12-05 00:28:31 +01:00
|
|
|
/**
|
2016-04-07 22:42:06 +02:00
|
|
|
* Sets an onResize action for a page
|
2013-12-05 00:28:31 +01:00
|
|
|
*
|
2016-04-07 22:42:06 +02:00
|
|
|
* @param string $code ='' javascript to be used
|
|
|
|
* @param boolean $replace =false false: append to existing, true: replace existing tag
|
|
|
|
* @deprecated since 14.1 use app.js et2_ready method instead to execute code or bind a handler (CSP will stop onXXX attributes!)
|
|
|
|
* @return string content of onXXX tag after adding code
|
2013-12-05 00:28:31 +01:00
|
|
|
*/
|
2016-04-07 22:42:06 +02:00
|
|
|
static function set_onresize($code='',$replace=false)
|
2013-12-05 00:28:31 +01:00
|
|
|
{
|
2016-04-15 17:12:27 +02:00
|
|
|
if ($replace || empty(self::$body_tags['onResize']))
|
|
|
|
{
|
|
|
|
self::$body_tags['onResize'] = $code;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self::$body_tags['onResize'] .= $code;
|
|
|
|
}
|
|
|
|
return self::$body_tags['onResize'];
|
2013-12-05 00:28:31 +01:00
|
|
|
}
|
|
|
|
|
2014-03-10 16:20:27 +01:00
|
|
|
/**
|
2016-04-07 22:42:06 +02:00
|
|
|
* Checks to make sure a valid package and file name is provided
|
|
|
|
*
|
|
|
|
* @param string $package package or complete path (relative to EGW_SERVER_ROOT) to be included
|
|
|
|
* @param string|array $file =null file to be included - no ".js" on the end or array with get params
|
|
|
|
* @param string $app ='phpgwapi' application directory to search - default = phpgwapi
|
|
|
|
* @param boolean $append =true should the file be added
|
|
|
|
* @deprecated use Api\Framework::includeJS($package, $file=null, $app='api')
|
|
|
|
*/
|
|
|
|
static function validate_file($package, $file=null, $app='api')
|
2014-03-10 16:20:27 +01:00
|
|
|
{
|
2016-04-07 22:42:06 +02:00
|
|
|
self::includeJS($package, $file, $app);
|
2014-03-10 16:20:27 +01:00
|
|
|
}
|
|
|
|
|
2013-08-20 14:06:41 +02:00
|
|
|
/**
|
2016-04-07 22:42:06 +02:00
|
|
|
* Include favorites when generating the page server-side
|
2013-08-20 14:06:41 +02:00
|
|
|
*
|
2016-04-07 22:42:06 +02:00
|
|
|
* @param string $app application, needed to find preferences
|
|
|
|
* @param string $default =null preference name for default favorite, default "nextmatch-$app.index.rows-favorite"
|
|
|
|
* @deprecated use Api\Framework\Favorites::favorite_list
|
|
|
|
* @return array with a single sidebox menu item (array) containing html for favorites
|
2013-08-20 14:06:41 +02:00
|
|
|
*/
|
2016-04-07 22:42:06 +02:00
|
|
|
public static function favorite_list($app, $default=null)
|
2013-08-20 14:06:41 +02:00
|
|
|
{
|
2016-04-07 22:42:06 +02:00
|
|
|
return Api\Framework\Favorites::list_favorites($app, $default);
|
2015-05-28 16:40:33 +02:00
|
|
|
}
|
2006-12-11 00:44:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Public functions to be compatible with the exiting eGW framework
|
|
|
|
*/
|
|
|
|
if (!function_exists('parse_navbar'))
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* echo's out the navbar
|
|
|
|
*
|
2010-10-18 12:46:47 +02:00
|
|
|
* @deprecated use $GLOBALS['egw']->framework->navbar() or $GLOBALS['egw']->framework::render()
|
2006-12-11 00:44:18 +01:00
|
|
|
*/
|
|
|
|
function parse_navbar()
|
|
|
|
{
|
|
|
|
echo $GLOBALS['egw']->framework->navbar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!function_exists('display_sidebox'))
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* echo's out a sidebox menu
|
|
|
|
*
|
2013-05-10 18:39:42 +02:00
|
|
|
* @deprecated use $GLOBALS['egw']->framework->sidebox()
|
2006-12-11 00:44:18 +01:00
|
|
|
*/
|
2014-10-09 22:32:59 +02:00
|
|
|
function display_sidebox($appname,$menu_title,$_file)
|
2006-12-11 00:44:18 +01:00
|
|
|
{
|
2014-10-09 22:32:59 +02:00
|
|
|
$file = str_replace('preferences.uisettings.index', 'preferences.preferences_settings.index', $_file);
|
2006-12-11 00:44:18 +01:00
|
|
|
$GLOBALS['egw']->framework->sidebox($appname,$menu_title,$file);
|
|
|
|
}
|
2007-01-09 23:42:01 +01:00
|
|
|
}
|