2006-12-11 00:44:18 +01:00
< ? php
/**
* eGW API - framework
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 $
*/
/**
* eGW API - framework : virtual base class for all template sets
2008-07-21 16:40:54 +02:00
*
2006-12-11 00:44:18 +01:00
* This class creates / renders the eGW framework :
* a ) html header
* b ) navbar
* c ) sidebox menu
* d ) main application area
* e ) footer
* It replaces several methods in the common class and the diverse templates .
2008-07-21 16:40:54 +02:00
*
2009-10-12 11:41:46 +02:00
* Existing apps either set $GLOBALS [ 'egw_info' ][ 'flags' ][ 'noheader' ] and call common :: egw_header () and
2006-12-11 00:44:18 +01:00
* ( if $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ] is true ) parse_navbar () or it ' s done by the header . inc . php include .
* The app ' s hook_sidebox then calls the public function display_sidebox () .
2009-10-12 11:41:46 +02:00
* And the app calls common :: egw_footer () .
2008-07-21 16:40:54 +02:00
*
2006-12-11 00:44:18 +01:00
* This are the authors ( and their copyrights ) of the original egw_header , egw_footer methods of the common class :
* This file written by Dan Kuykendall < seek3r @ phpgroupware . org >
* and Joseph Engo < jengo @ phpgroupware . org >
* and Mark Peters < skeeter @ phpgroupware . org >
* and Lars Kneschke < lkneschke @ linux - at - work . de >
* Copyright ( C ) 2000 , 2001 Dan Kuykendall
* Copyright ( C ) 2003 Lars Kneschke
*/
2008-08-18 11:00:19 +02:00
abstract class egw_framework
2006-12-11 00:44:18 +01:00
{
/**
* Name of the template set , eg . 'idots'
*
* @ var string
*/
var $template ;
2010-06-02 11:20:55 +02:00
/**
* Path relative to EGW_SERVER_ROOT for the template directory
*
* @ var string
*/
var $template_dir ;
2010-01-17 04:20:45 +01:00
/**
* true if $this -> header () was called
*
* @ var boolean
*/
static $header_done = false ;
/**
* true if $this -> navbar () was called
*
* @ var boolean
*/
static $navbar_done = false ;
2006-12-11 00:44:18 +01:00
/**
* Constructor
2008-07-21 16:40:54 +02:00
*
2006-12-11 00:44:18 +01:00
* The constructor instanciates the class in $GLOBALS [ 'egw' ] -> framework , from where it should be used
*
* @ return egw_framework
*/
2010-06-01 23:38:00 +02:00
function __construct ( $template )
2006-12-11 00:44:18 +01:00
{
$this -> template = $template ;
2010-01-17 04:20:45 +01:00
if ( ! isset ( $GLOBALS [ 'egw' ] -> framework ))
2006-12-11 00:44:18 +01:00
{
2008-03-21 21:11:59 +01:00
$GLOBALS [ 'egw' ] -> framework = $this ;
2006-12-11 00:44:18 +01:00
}
2010-06-02 11:20:55 +02:00
$this -> template_dir = '/phpgwapi/templates/' . $template ;
2006-12-11 00:44:18 +01:00
}
2008-07-21 16:40:54 +02:00
2010-06-01 23:38:00 +02:00
/**
* PHP4 - Constructor
*
* The constructor instanciates the class in $GLOBALS [ 'egw' ] -> framework , from where it should be used
*
* @ deprecated use __construct ()
*/
function egw_framework ( $template )
{
self :: __construct ( $template );
}
2010-11-09 15:44:18 +01:00
2010-06-01 23:38:00 +02:00
/**
* Link url generator
*
* @ param string $string The url the link is for
* @ param string / array $extravars Extra params to be passed to the url
* @ return string The full url after processing
*/
static function link ( $url = '' , $extravars = '' )
{
return $GLOBALS [ 'egw' ] -> session -> link ( $url , $extravars );
}
/**
* Redirects direct to a generated link
*
* @ param string $string The url the link is for
* @ param string / array $extravars Extra params to be passed to the url
* @ return string The full url after processing
*/
static function redirect_link ( $url = '' , $extravars = '' )
{
egw :: redirect ( self :: link ( $url , $extravars ));
}
2006-12-11 00:44:18 +01:00
/**
* Renders an applicaton page with the complete eGW framework ( header , navigation and menu )
2008-07-21 16:40:54 +02:00
*
2006-12-11 00:44:18 +01:00
* This is the ( new ) prefered way to render a page in eGW !
*
* @ param string $content html of the main application area
* @ param string $app_header = null application header , default what 's set in $GLOBALS[' egw_info '][' flags '][' app_header ' ]
* @ param string $navbar = null show the navigation , default ! $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ], false gives a typical popu
2008-07-21 16:40:54 +02:00
*
2006-12-11 00:44:18 +01:00
*/
function render ( $content , $app_header = null , $navbar = null )
{
if ( ! is_null ( $app_header )) $GLOBALS [ 'egw_info' ][ 'flags' ][ 'app_header' ] = $app_header ;
if ( ! is_null ( $navbar )) $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ] = ! $navbar ;
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
echo $this -> header ();
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
if ( ! isset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ]) || ! $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ])
{
2007-01-05 15:06:34 +01:00
echo $this -> navbar ();
2006-12-11 00:44:18 +01:00
}
echo $content ;
2007-01-05 15:06:34 +01:00
2006-12-11 00:44:18 +01:00
echo $this -> footer ();
2007-01-05 15:06:34 +01:00
}
2006-12-11 00:44:18 +01:00
/**
* Returns the html - header incl . the opening body tag
*
* @ return string with html
*/
2008-08-18 11:00:19 +02:00
abstract function header ();
2006-12-11 00:44:18 +01:00
/**
* Returns the html from the body - tag til the main application area ( incl . opening div tag )
2010-11-09 15:44:18 +01:00
*
2010-10-18 12:46:47 +02:00
* If header has NOT been called , also return header content !
* No need to manually call header , this allows to postpone header so navbar / sidebox can include JS or CSS .
2006-12-11 00:44:18 +01:00
*
* @ return string with html
*/
2008-08-18 11:00:19 +02:00
abstract function navbar ();
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
/**
* Returns the content of one sidebox
*
* @ param string $appname
* @ param string $menu_title
* @ param array $file
*/
2008-08-18 11:00:19 +02:00
abstract function sidebox ( $appname , $menu_title , $file );
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
/**
* Returns the html from the closing div of the main application area to the closing html - tag
*
* @ return string
*/
2008-08-18 11:00:19 +02:00
abstract function footer ();
2008-07-21 16:40:54 +02:00
2006-12-25 12:05:44 +01:00
/**
* displays a login screen
*
* @ string $extra_vars for login url
* @ return string
*/
2008-08-18 11:00:19 +02:00
abstract function login_screen ( $extra_vars );
2008-07-21 16:40:54 +02:00
2006-12-25 12:05:44 +01:00
/**
* displays a login denied message
*
* @ return string
*/
2008-08-18 11:00:19 +02:00
abstract function denylogin_screen ();
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
/**
* Get footer as array to eg . set as vars for a template ( from idots ' head . inc . php )
*
* @ return array
*/
2008-08-18 11:00:19 +02:00
protected function _get_footer ()
2006-12-11 00:44:18 +01:00
{
$var = Array (
2010-06-03 00:43:41 +02:00
'img_root' => $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . $this -> template_dir . '/images' ,
2006-12-11 00:44:18 +01:00
'version' => $GLOBALS [ 'egw_info' ][ 'server' ][ 'versions' ][ 'phpgwapi' ]
);
2010-06-10 17:37:47 +02:00
$var [ 'page_generation_time' ] = '' ;
2006-12-11 00:44:18 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'show_generation_time' ])
{
2008-07-21 16:40:54 +02:00
$totaltime = sprintf ( '%4.2lf' , microtime ( true ) - $GLOBALS [ 'egw_info' ][ 'flags' ][ 'page_start_time' ]);
2006-12-11 00:44:18 +01:00
2008-03-22 17:22:11 +01:00
$var [ 'page_generation_time' ] = '<div id="divGenTime"><br/><span>' . lang ( 'Page was generated in %1 seconds' , $totaltime );
if ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'session_restore_time' ])
{
$var [ 'page_generation_time' ] .= ' ' . lang ( '(session restored in %1 seconds)' ,
sprintf ( '%4.2lf' , $GLOBALS [ 'egw_info' ][ 'flags' ][ 'session_restore_time' ]));
}
$var [ 'page_generation_time' ] .= '</span></div>' ;
2006-12-11 00:44:18 +01:00
}
2010-09-16 11:57:12 +02:00
$var [ 'powered_by' ] = lang ( 'Powered by' ) . ' <a href="http://www.stylite.de/" target="_blank">Stylite\'s</a>' .
' <a href="' . egw :: link ( '/about.php' , '' , 'about' ) . '">EGroupware</a>' .
' Community Version ' . $GLOBALS [ 'egw_info' ][ 'server' ][ 'versions' ][ 'phpgwapi' ];
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
return $var ;
}
/**
* Get the ( depricated ) application footer
*
* @ return string html
*/
2008-08-18 11:00:19 +02:00
protected static function _get_app_footer ()
2006-12-11 00:44:18 +01:00
{
ob_start ();
// Include the apps footer files if it exists
2008-07-21 16:40:54 +02:00
if ( EGW_APP_INC != EGW_API_INC && // this prevents an endless inclusion on the homepage
2006-12-11 00:44:18 +01:00
// (some apps set currentapp in hook_home => it's not releyable)
( file_exists ( EGW_APP_INC . '/footer.inc.php' ) || isset ( $_GET [ 'menuaction' ])) &&
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ] != 'home' &&
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ] != 'login' &&
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ] != 'logout' &&
!@ $GLOBALS [ 'egw_info' ][ 'flags' ][ 'noappfooter' ])
{
list ( $app , $class , $method ) = explode ( '.' ,( string ) $_GET [ 'menuaction' ]);
2008-07-21 16:40:54 +02:00
if ( $class && is_object ( $GLOBALS [ $class ]) && is_array ( $GLOBALS [ $class ] -> public_functions ) &&
2006-12-11 00:44:18 +01:00
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' );
}
}
$content = ob_get_contents ();
ob_end_clean ();
2008-07-21 16:40:54 +02:00
return $content ;
2006-12-11 00:44:18 +01:00
}
/**
* Get header as array to eg . set as vars for a template ( from idots ' head . inc . php )
*
* @ return array
*/
2008-08-18 11:00:19 +02:00
protected function _get_header ()
2006-12-11 00:44:18 +01:00
{
2010-02-13 03:57:22 +01:00
// get used language code (with a little xss check, if someone tries to sneak something in)
if ( preg_match ( '/^[a-z]{2}(-[a-z]{2})?$/' , $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'lang' ]))
{
$lang_code = $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'lang' ];
}
2010-11-10 11:49:16 +01:00
// IE specific fixes
if ( html :: $user_agent == 'msie' )
2006-12-11 00:44:18 +01:00
{
2010-11-10 11:49:16 +01:00
// tell IE to use it's own mode, not old compatibility modes (set eg. via group policy for all intranet sites)
// has to be before any other header tags, but meta and title!!!
$pngfix = '<meta http-equiv="X-UA-Compatible" content="IE=edge" />' . " \n " ;
// pngfix for IE6 defaults to yes
if ( ! $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'disable_pngfix' ] && html :: $ua_version < 7 )
{
$pngfix_src = $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . '/phpgwapi/templates/idots/js/pngfix.js' ;
$pngfix .= ' <!-- This solves the Internet Explorer PNG - transparency bug , but only for IE 5.5 - 6.0 and higher -->
<!-- [ if lt IE 7.0 ] >
< script src = " '. $pngfix_src .' " type = " text/javascript " >
</ script >
<! [ endif ] --> ' ;
}
2010-11-09 15:44:18 +01:00
}
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
if ( ! $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'disable_slider_effects' ])
{
$slider_effects_src = $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . '/phpgwapi/templates/idots/js/slidereffects.js' ;
$slider_effects = '<script src="' . $slider_effects_src . ' " type= " text / javascript " >
</ script > ' ;
}
else
{
$simple_show_hide_src = $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . '/phpgwapi/templates/idots/js/simple_show_hide.js' ;
$simple_show_hide = '<script src="' . $simple_show_hide_src . ' " type= " text / javascript " >
</ script > ' ;
}
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'app_header' ])
{
$app = $GLOBALS [ 'egw_info' ][ 'flags' ][ 'app_header' ];
}
else
{
$app = $GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ];
$app = isset ( $GLOBALS [ 'egw_info' ][ 'apps' ][ $app ]) ? $GLOBALS [ 'egw_info' ][ 'apps' ][ $app ][ 'title' ] : lang ( $app );
}
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
if ( $app != 'wiki' ) $robots = '<meta name="robots" content="none" />' ;
2009-05-13 16:33:36 +02:00
if ( substr ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'favicon_file' ], 0 , 4 ) == 'http' )
{
$var [ 'favicon_file' ] = $GLOBALS [ 'egw_info' ][ 'server' ][ 'favicon_file' ];
}
else
{
2009-10-12 11:41:46 +02:00
$var [ 'favicon_file' ] = common :: image ( 'phpgwapi' , $GLOBALS [ 'egw_info' ][ 'server' ][ 'favicon_file' ] ? $GLOBALS [ 'egw_info' ][ 'server' ][ 'favicon_file' ] : 'favicon.ico' );
2009-05-13 16:33:36 +02:00
}
2008-07-21 16:40:54 +02:00
2010-01-17 04:20:45 +01:00
$wz_tooltip = '/phpgwapi/js/wz_tooltip/wz_tooltip.js' ;
if ( file_exists ( EGW_SERVER_ROOT . $wz_tooltip ))
{
$include_wz_tooltip = '<script src="' . $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] .
$wz_tooltip . '?' . filemtime ( EGW_SERVER_ROOT . $wz_tooltip ) . '" type="text/javascript"></script>' ;
}
2006-12-17 14:14:16 +01:00
return $this -> _get_css () + array (
2009-05-13 16:33:36 +02:00
'img_icon' => $var [ 'favicon_file' ],
'img_shortcut' => $var [ 'favicon_file' ],
2006-12-11 00:44:18 +01:00
'pngfix' => $pngfix ,
'slider_effects' => $slider_effects ,
'simple_show_hide' => $simple_show_hide ,
'lang_code' => $lang_code ,
2009-10-12 11:41:46 +02:00
'charset' => translation :: charset (),
2006-12-11 00:44:18 +01:00
'website_title' => strip_tags ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'site_title' ] . ( $app ? " [ $app ] " : '' )),
2008-08-18 11:00:19 +02:00
'body_tags' => self :: _get_body_attribs (),
'java_script' => self :: _get_js (),
2006-12-11 00:44:18 +01:00
'meta_robots' => $robots ,
'dir_code' => lang ( 'language_direction_rtl' ) != 'rtl' ? '' : ' dir="rtl"' ,
2010-01-17 04:20:45 +01:00
'include_wz_tooltip' => $include_wz_tooltip ,
2010-06-02 10:10:43 +02:00
'webserver_url' => $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ],
2006-12-11 00:44:18 +01:00
);
}
/**
* Get navbar as array to eg . set as vars for a template ( from idots ' navbar . inc . php )
*
* @ param array $apps navbar apps from _get_navbar_apps
* @ return array
*/
2008-08-18 11:00:19 +02:00
protected function _get_navbar ( $apps )
2006-12-11 00:44:18 +01:00
{
$var [ 'img_root' ] = $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . '/phpgwapi/templates/' . $this -> template . '/images' ;
if ( isset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'app_header' ]))
{
$var [ 'current_app_title' ] = $GLOBALS [ 'egw_info' ][ 'flags' ][ 'app_header' ];
}
else
{
$var [ 'current_app_title' ] = $apps [ $GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ]][ 'title' ];
2009-11-18 21:00:26 +01:00
}
$var [ 'currentapp' ] = $GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ];
2007-01-10 00:14:21 +01:00
2006-12-11 00:44:18 +01:00
// current users for admins
2008-08-07 23:12:44 +02:00
$var [ 'current_users' ] = $this -> _current_users ();
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
// quick add selectbox
$var [ 'quick_add' ] = $this -> _get_quick_add ();
2007-01-05 15:06:34 +01:00
$var [ 'user_info' ] = $this -> _user_time_info ();
2010-11-09 15:44:18 +01:00
2010-09-22 11:48:27 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_lastpwd_change' ] == 0 )
2006-12-11 00:44:18 +01:00
{
$api_messages = lang ( 'You are required to change your password during your first login' ) . '<br />' .
2009-10-12 11:41:46 +02:00
lang ( 'Click this image on the navbar: %1' , '<img src="' . common :: image ( 'preferences' , 'navbar.gif' ) . '">' );
2006-12-11 00:44:18 +01:00
}
2010-09-22 11:48:27 +02:00
elseif ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'change_pwd_every_x_days' ] && $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_lastpwd_change' ] < time () - ( 86400 * $GLOBALS [ 'egw_info' ][ 'server' ][ 'change_pwd_every_x_days' ]))
2006-12-11 00:44:18 +01:00
{
2010-09-22 11:48:27 +02:00
$api_messages = lang ( 'it has been more then %1 days since you changed your password' , $GLOBALS [ 'egw_info' ][ 'server' ][ 'change_pwd_every_x_days' ]);
2006-12-11 00:44:18 +01:00
}
// This is gonna change
if ( isset ( $cd ))
{
$var [ 'messages' ] = $api_messages . '<br />' . checkcode ( $cd );
}
2010-06-02 23:28:07 +02:00
if ( substr ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_file' ], 0 , 4 ) == 'http' ||
$GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_file' ][ 0 ] == '/' )
2006-12-11 00:44:18 +01:00
{
$var [ 'logo_file' ] = $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_file' ];
}
else
{
2009-10-12 11:41:46 +02:00
$var [ 'logo_file' ] = common :: image ( 'phpgwapi' , $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_file' ] ? $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_file' ] : 'logo' );
2006-12-11 00:44:18 +01:00
}
$var [ 'logo_url' ] = $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_url' ] ? $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_url' ] : 'http://www.eGroupWare.org' ;
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
if ( substr ( $var [ 'logo_url' ], 0 , 4 ) != 'http' )
{
$var [ 'logo_url' ] = 'http://' . $var [ 'logo_url' ];
}
$var [ 'logo_title' ] = $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_title' ] ? $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_title' ] : 'www.eGroupWare.org' ;
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
return $var ;
}
2007-01-05 15:06:34 +01:00
/**
2008-08-18 11:00:19 +02:00
* Returns html with user and time
*
* @ return void
*/
protected static function _user_time_info ()
2007-01-05 15:06:34 +01:00
{
2009-10-12 11:41:46 +02:00
$now = new egw_time ();
$user_info = '<b>' . common :: display_fullname () . '</b>' . ' - ' . lang ( $now -> format ( 'l' )) . ' ' . $now -> format ( true );
2007-01-05 15:06:34 +01:00
2009-11-01 13:48:25 +01:00
$user_tzs = egw_time :: getUserTimezones ();
if ( count ( $user_tzs ) > 1 )
2009-10-12 11:41:46 +02:00
{
2009-11-01 13:48:25 +01:00
$tz = $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'tz' ];
$user_info .= html :: form ( html :: select ( 'tz' , $tz , $user_tzs , true , ' onchange="this.form.submit();"' ), array (),
2009-10-12 11:41:46 +02:00
'/index.php' , '' , 'tz_selection' , ' style="display: inline;"' , 'GET' );
}
return $user_info ;
2007-01-05 15:06:34 +01:00
}
2008-08-18 11:00:19 +02:00
/**
* Prepare the current users
*
* @ return string
*/
protected static function _current_users ()
2007-01-10 00:14:21 +01:00
{
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'admin' ] && $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'show_currentusers' ])
{
2011-04-13 16:11:09 +02:00
$current_users = '<a href="' . egw :: link ( '/index.php' , 'menuaction=admin.admin_accesslog.sessions' ) . '">' .
2011-04-14 11:50:35 +02:00
lang ( 'Current users' ) . ': <span id="currentusers">' . $GLOBALS [ 'egw' ] -> session -> session_count () . '</span></a>' ;
2007-01-10 00:14:21 +01:00
return $current_users ;
}
}
2006-12-11 00:44:18 +01:00
/**
* Prepare the quick add selectbox
*
* @ return string
*/
2008-08-18 11:00:19 +02:00
protected static function _get_quick_add ()
2006-12-11 00:44:18 +01:00
{
2008-03-09 00:21:42 +01:00
$apps = egw_link :: app_list ( 'add' );
2006-12-11 00:44:18 +01:00
asort ( $apps ); // sort them alphabetic
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
$options = array ( lang ( 'Add' ) . ' ...' );
foreach ( $apps as $app => $label )
{
2009-10-12 11:41:46 +02:00
$link = egw :: link ( '/index.php' , egw_link :: add ( $app , $GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ], $GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentid' ]) +
2006-12-11 00:44:18 +01:00
( is_array ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'quick_add' ]) ? $GLOBALS [ 'egw_info' ][ 'flags' ][ 'quick_add' ] : array ()));
2008-03-09 00:21:42 +01:00
if (( $popup = egw_link :: is_popup ( $app , 'add' )))
2006-12-11 00:44:18 +01:00
{
list ( $w , $h ) = explode ( 'x' , $popup );
2010-06-07 16:44:38 +02:00
$action = " egw_openWindowCentered2(' $link ','_blank', $w , $h ,'yes',' $app '); " ;
2006-12-11 00:44:18 +01:00
}
else
{
2010-06-07 16:44:38 +02:00
$action = " egw_link_handler(' $link ',' $app '); " ;
2006-12-11 00:44:18 +01:00
}
$options [ $action ] = $label ;
}
2008-07-21 16:40:54 +02:00
return html :: select ( 'quick_add' , '' , $options , true , $options = ' onchange="eval(this.value); this.value=0; return false;"' );
2006-12-11 00:44:18 +01:00
}
2008-07-21 16:40:54 +02:00
2008-08-18 11:00:19 +02:00
/**
* Prepare notification signal ( blinking bell )
*
* @ return string
*/
protected static function _get_notification_bell ()
2008-03-21 21:11:59 +01:00
{
return html :: div (
html :: a_href (
html :: image ( 'notifications' , 'notificationbell' , lang ( 'notifications' )),
2009-10-26 16:10:05 +01:00
'javascript: egwpopup_display();'
2008-03-21 21:11:59 +01:00
),
'id="notificationbell"' , // options
'' , // class
'display: none' //style
2008-07-21 16:40:54 +02:00
);
2007-11-22 09:29:16 +01:00
}
2008-07-21 16:40:54 +02:00
2008-08-18 11:00:19 +02:00
/**
* Get the link to an application ' s index page
*
* @ param string $app
* @ return string
*/
2010-06-09 17:30:53 +02:00
public static function index ( $app )
2008-08-18 11:00:19 +02:00
{
$data =& $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ $app ];
if ( ! isset ( $data ))
{
throw new egw_exception_wrong_parameter ( " ' $app ' not a valid app for this user! " );
}
$index = '/' . $app . '/index.php' ;
if ( isset ( $data [ 'index' ]))
{
if ( $data [ 'index' ][ 0 ] == '/' )
{
$index = $data [ 'index' ];
}
else
{
$index = '/index.php?menuaction=' . $data [ 'index' ];
}
}
2009-10-12 11:41:46 +02:00
return egw :: link ( $index , $GLOBALS [ 'egw_info' ][ 'flags' ][ 'params' ][ $app ]);
2008-08-18 11:00:19 +02:00
}
2006-12-11 00:44:18 +01:00
2010-06-16 14:48:17 +02:00
/**
* Used internally to store unserialized value of $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'user_apporder' ]
*/
private static $user_apporder = array ();
2010-06-16 14:07:50 +02:00
/**
* Internal usort callback function used to sort an array according to the
* user sort order
*/
private static function _sort_apparray ( $a , $b )
{
//Unserialize the user_apporder array
2010-06-16 14:48:17 +02:00
$arr = self :: $user_apporder ;
2010-06-16 14:07:50 +02:00
$ind_a = isset ( $arr [ $a [ 'name' ]]) ? $arr [ $a [ 'name' ]] : null ;
$ind_b = isset ( $arr [ $b [ 'name' ]]) ? $arr [ $b [ 'name' ]] : null ;
if ( $ind_a == $ind_b )
return 0 ;
if ( $ind_a == null )
return - 1 ;
if ( $ind_b == null )
return 1 ;
return $ind_a > $ind_b ? 1 : - 1 ;
}
2006-12-11 00:44:18 +01:00
/**
* Prepare an array with apps used to render the navbar
2008-07-21 16:40:54 +02:00
*
2006-12-11 00:44:18 +01:00
* This is similar to the former common :: navbar () method - though it returns the vars and does not place them in global scope .
*
* @ return array
*/
2008-08-18 11:00:19 +02:00
protected static function _get_navbar_apps ()
2006-12-11 00:44:18 +01:00
{
list ( $first ) = each ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ]);
if ( is_array ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'admin' ]) && $first != 'admin' )
{
$newarray [ 'admin' ] = $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'admin' ];
foreach ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ] as $index => $value )
{
if ( $index != 'admin' )
{
$newarray [ $index ] = $value ;
}
}
$GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ] = $newarray ;
reset ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ]);
}
unset ( $index );
unset ( $value );
unset ( $newarray );
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
$apps = array ();
foreach ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ] as $app => $data )
{
if ( is_long ( $app ))
{
continue ;
}
if ( $app == 'preferences' || $GLOBALS [ 'egw_info' ][ 'apps' ][ $app ][ 'status' ] != 2 && $GLOBALS [ 'egw_info' ][ 'apps' ][ $app ][ 'status' ] != 3 )
{
$apps [ $app ][ 'title' ] = $GLOBALS [ 'egw_info' ][ 'apps' ][ $app ][ 'title' ];
2008-08-18 11:00:19 +02:00
$apps [ $app ][ 'url' ] = self :: index ( $app );
2006-12-11 00:44:18 +01:00
$apps [ $app ][ 'name' ] = $app ;
// create popup target
if ( $data [ 'status' ] == 4 )
{
$apps [ $app ][ 'target' ] = ' target="' . $app . '" onClick="' . " if (this != '') { window.open(this+' " .
2007-04-30 07:42:05 +02:00
( strpos ( $apps [ $app ][ 'url' ], '?' ) !== false ? '&' : '?' ) .
2007-06-08 12:24:20 +02:00
" referer='+encodeURIComponent(location),this.target,'width=800,height=600,scrollbars=yes,resizable=yes'); return false; } else { return true; } " . '"' ;
2006-12-11 00:44:18 +01:00
}
elseif ( isset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'navbar_target' ]) && $GLOBALS [ 'egw_info' ][ 'flags' ][ 'navbar_target' ])
{
$apps [ $app ][ 'target' ] = 'target="' . $GLOBALS [ 'egw_info' ][ 'flags' ][ 'navbar_target' ] . '"' ;
}
else
{
$apps [ $app ][ 'target' ] = '' ;
}
2008-08-18 11:00:19 +02:00
$icon = isset ( $data [ 'icon' ]) ? $data [ 'icon' ] : 'navbar' ;
$icon_app = isset ( $data [ 'icon_app' ]) ? $data [ 'icon_app' ] : $app ;
2006-12-11 00:44:18 +01:00
if ( $app != $GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ])
{
2009-10-12 11:41:46 +02:00
$apps [ $app ][ 'icon' ] = common :: image ( $icon_app , Array ( $icon , 'nonav' ));
$apps [ $app ][ 'icon_hover' ] = common :: image_on ( $icon_app , Array ( $icon , 'nonav' ), '-over' );
2006-12-11 00:44:18 +01:00
}
else
{
2009-10-12 11:41:46 +02:00
$apps [ $app ][ 'icon' ] = common :: image_on ( $icon_app , Array ( $icon , 'nonav' ), '-over' );
$apps [ $app ][ 'icon_hover' ] = common :: image ( $icon_app , Array ( $icon , 'nonav' ));
2006-12-11 00:44:18 +01:00
}
}
}
2010-06-16 14:07:50 +02:00
//Sort the applications accordingly to their user sort setting
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'user_apporder' ])
{
//Sort the application array using the user_apporder array as sort index
2010-06-16 14:48:17 +02:00
self :: $user_apporder =
unserialize ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'user_apporder' ]);
2010-06-16 14:07:50 +02:00
uasort ( $apps , 'egw_framework::_sort_apparray' );
}
2006-12-11 00:44:18 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ] == 'preferences' || $GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ] == 'about' )
{
2010-06-03 00:43:41 +02:00
$app = $app_title = 'EGroupware' ;
2006-12-11 00:44:18 +01:00
}
else
{
$app = $GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ];
$app_title = $GLOBALS [ 'egw_info' ][ 'apps' ][ $app ][ 'title' ];
}
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'preferences' ]) // preferences last
{
$prefs = $apps [ 'preferences' ];
unset ( $apps [ 'preferences' ]);
$apps [ 'preferences' ] = $prefs ;
}
// We handle this here becuase its special
2011-06-03 20:36:47 +02:00
$apps [ 'about' ][ 'title' ] = 'EGroupware' ;
2006-12-11 00:44:18 +01:00
2010-11-21 14:37:09 +01:00
$apps [ 'about' ][ 'url' ] = egw :: link ( '/about.php' );
2009-10-12 11:41:46 +02:00
$apps [ 'about' ][ 'icon' ] = common :: image ( 'phpgwapi' , Array ( 'about' , 'nonav' ));
$apps [ 'about' ][ 'icon_hover' ] = common :: image_on ( 'phpgwapi' , Array ( 'about' , 'nonav' ), '-over' );
2010-06-04 10:06:02 +02:00
$apps [ 'about' ][ 'name' ] = 'about' ;
2006-12-11 00:44:18 +01:00
$apps [ 'logout' ][ 'title' ] = lang ( 'Logout' );
2009-10-12 11:41:46 +02:00
$apps [ 'logout' ][ 'url' ] = egw :: link ( '/logout.php' );
$apps [ 'logout' ][ 'icon' ] = common :: image ( 'phpgwapi' , Array ( 'logout' , 'nonav' ));
$apps [ 'logout' ][ 'icon_hover' ] = common :: image_on ( 'phpgwapi' , Array ( 'logout' , 'nonav' ), '-over' );
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
return $apps ;
}
2008-07-21 16:40:54 +02:00
2006-12-11 00:44:18 +01:00
/**
* Used by template headers for including CSS in the header
*
2006-12-17 14:14:16 +01:00
* 'app_css' - css styles from a ) the menuaction 's css-method and b) the $GLOBALS[' egw_info '][' flags '][' css ' ]
* 'file_css' - link tag of the app . css file of the current app
* 'theme_css' - url of the theme css file
* 'print_css' - url of the print css file
2008-07-21 16:40:54 +02:00
*
2006-12-11 00:44:18 +01:00
* @ author Dave Hall ( * based * on verdilak ? css inclusion code )
2006-12-17 14:14:16 +01:00
* @ return array with keys 'app_css' from the css method of the menuaction - class and 'file_css' ( app . css file of the application )
2006-12-11 00:44:18 +01:00
*/
2011-01-06 21:47:21 +01:00
public function _get_css ()
2006-12-11 00:44:18 +01:00
{
$app_css = '' ;
if ( isset ( $_GET [ 'menuaction' ]))
{
list ( $app , $class , $method ) = explode ( '.' , $_GET [ 'menuaction' ]);
2008-10-13 20:23:02 +02:00
if ( is_array ( $GLOBALS [ $class ] -> public_functions ) && $GLOBALS [ $class ] -> public_functions [ 'css' ])
2006-12-11 00:44:18 +01:00
{
2008-10-13 20:23:02 +02:00
error_log ( " Deprecated functionality in $app class $class : using of public_function css, use \$ GLOBALS['egw_info']['flags']['css'] or an app.css file! " );
2006-12-11 00:44:18 +01:00
$app_css .= $GLOBALS [ $class ] -> css ();
}
}
if ( isset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'css' ]))
{
$app_css .= $GLOBALS [ 'egw_info' ][ 'flags' ][ 'css' ];
}
// search for app specific css file
2010-06-18 13:19:24 +02:00
self :: includeCSS ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ], 'app' );
2010-11-09 15:44:18 +01:00
2010-06-18 13:19:24 +02:00
// add all css files from self::includeCSS
foreach ( self :: $css_include_files as $path )
2006-12-11 00:44:18 +01:00
{
2010-06-18 13:19:24 +02:00
$css_file .= '<link href="' . $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] .
$path . '?' . filemtime ( EGW_SERVER_ROOT . $path ) . '" type="text/css" rel="StyleSheet" />' . " \n " ;
2006-12-11 00:44:18 +01:00
}
2006-12-17 14:14:16 +01:00
#_debug_array($GLOBALS['egw_info']['user']['preferences']['common']);
2010-06-02 11:20:55 +02:00
$theme_css = $this -> template_dir . '/css/' . $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ] . '.css' ;
2006-12-17 14:14:16 +01:00
if ( ! file_exists ( EGW_SERVER_ROOT . $theme_css ))
{
2010-06-02 11:20:55 +02:00
$theme_css = $this -> template_dir . '/css/' . $this -> template . '.css' ;
2006-12-17 14:14:16 +01:00
}
$theme_css = $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . $theme_css . '?' . filemtime ( EGW_SERVER_ROOT . $theme_css );
2010-06-02 11:20:55 +02:00
$print_css = $this -> template_dir . '/print.css' ;
2009-11-30 17:21:02 +01:00
if ( ! file_exists ( EGW_SERVER_ROOT . $print_css ))
2006-12-17 14:14:16 +01:00
{
$print_css = '/phpgwapi/templates/idots/print.css' ;
}
$print_css = $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . $print_css . '?' . filemtime ( EGW_SERVER_ROOT . $print_css );
2008-07-21 16:40:54 +02:00
2006-12-17 14:14:16 +01:00
return array (
'app_css' => $app_css ,
'css_file' => $css_file ,
'theme_css' => $theme_css ,
'print_css' => $print_css ,
);
2006-12-11 00:44:18 +01:00
}
/**
* Used by the template headers for including javascript in the header
*
* The method is included here to make it easier to change the js support
* in eGW . One change then all templates will support it ( as long as they
* include a call to this method ) .
*
* @ author Dave Hall ( * vaguely based * on verdilak ? css inclusion code )
* @ return string the javascript to be included
*/
2008-08-18 11:00:19 +02:00
public static function _get_js ()
2006-12-11 00:44:18 +01:00
{
$java_script = '' ;
2008-07-21 16:40:54 +02:00
2010-02-12 10:04:44 +01:00
// GLOBAL var to tell egroupware wether or not to enable the IE selectBox resize hack
2011-05-31 09:55:51 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'enable_ie_dropdownmenuhack' ] && html :: $user_agent == 'msie' && html :: $ua_version < 9 )
2010-02-12 10:04:44 +01:00
{
$java_script .= " <script type= \" text/javascript \" > \n var enable_ie_dropdownmenuhack=1; \n </script> \n " ;
}
2006-12-11 00:44:18 +01:00
2010-06-10 10:38:02 +02:00
// set webserver_url for json
$java_script .= " <script type= \" text/javascript \" > \n window.egw_webserverUrl = ' " .
2011-06-02 13:13:41 +02:00
( $GLOBALS [ 'egw_info' ][ 'server' ][ 'enforce_ssl' ] && substr ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ], 0 , 8 ) != 'https://' ? 'https://' . $_SERVER [ 'HTTP_HOST' ] : '' ) .
$GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . " '; \n " ;
// add link registry to non-popup windows, if explicit requested (idots_framework::navbar() loads it, if not explicit specified!)
if ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'js_link_registry' ])
{
$java_script .= 'window.egw_link_registry=' . egw_link :: json_registry () . ';' ;
}
$java_script .= " </script> \n " ;
2010-11-09 15:44:18 +01:00
2008-07-21 16:40:54 +02:00
/* this flag is for all javascript code that has to be put before other jscode .
2006-12-11 00:44:18 +01:00
Think of conf vars etc ... ( pim @ lingewoud . nl ) */
if ( isset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'java_script_thirst' ]))
{
$java_script .= $GLOBALS [ 'egw_info' ][ 'flags' ][ 'java_script_thirst' ] . " \n " ;
}
2008-07-21 16:40:54 +02:00
2010-06-09 17:30:53 +02:00
$java_script .= self :: get_script_links ();
2006-12-11 00:44:18 +01:00
if ( @ isset ( $_GET [ 'menuaction' ]))
{
list ( $app , $class , $method ) = explode ( '.' , $_GET [ 'menuaction' ]);
if ( is_array ( $GLOBALS [ $class ] -> public_functions ) &&
$GLOBALS [ $class ] -> public_functions [ 'java_script' ])
{
$java_script .= $GLOBALS [ $class ] -> java_script ();
}
}
if ( isset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'java_script' ]))
{
$java_script .= $GLOBALS [ 'egw_info' ][ 'flags' ][ 'java_script' ] . " \n " ;
}
return $java_script ;
}
2010-06-02 12:59:58 +02:00
/**
* List available themes
*
* Themes are css file in the template directory
2010-11-09 15:44:18 +01:00
*
2010-06-02 12:59:58 +02:00
* @ param string $themes_dir = 'css'
*/
function list_themes ()
{
$list = array ();
if (( $dh = @ opendir ( EGW_SERVER_ROOT . $this -> template_dir . SEP . 'css' )))
{
while (( $file = readdir ( $dh )))
{
if ( preg_match ( '/' . " \ .css $ " . '/i' , $file ))
{
list ( $name ) = explode ( '.' , $file );
$list [ $name ] = $name ;
}
}
closedir ( $dh );
}
return $list ;
}
/**
* List available templates
*
2010-06-03 00:43:41 +02:00
* @ param boolean $full_data = false true : value is array with values for keys 'name' , 'title' , ...
2010-06-02 12:59:58 +02:00
* @ returns array alphabetically sorted list of templates
*/
2010-06-03 00:43:41 +02:00
static function list_templates ( $full_data = false )
2010-06-02 12:59:58 +02:00
{
$list = array ();
// templates packaged in the api
$d = dir ( EGW_SERVER_ROOT . '/phpgwapi/templates' );
while (( $entry = $d -> read ()))
{
if ( $entry != '..' && file_exists ( EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/class.' . $entry . '_framework.inc.php' ))
{
if ( file_exists ( $f = EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/setup/setup.inc.php' ))
{
include ( $f );
2010-11-09 15:44:18 +01:00
$list [ $entry ] = $full_data ? $GLOBALS [ 'egw_info' ][ 'template' ][ $entry ] :
2010-06-03 00:43:41 +02:00
$GLOBALS [ 'egw_info' ][ 'template' ][ $entry ][ 'title' ];
2010-06-02 12:59:58 +02:00
}
else
{
2010-06-03 00:43:41 +02:00
$list [ $entry ] = $full_data ? array (
'name' => $entry ,
'title' => $entry ,
) : $entry ;
2010-06-02 12:59:58 +02:00
}
}
}
$d -> close ();
// templates packaged like apps in own directories (containing as setup/setup.inc.php file!)
$d = dir ( EGW_SERVER_ROOT );
while (( $entry = $d -> read ()))
{
2011-06-07 09:02:08 +02:00
if ( $entry != '..' && ! isset ( $GLOBALS [ 'egw_info' ][ 'apps' ][ $entry ]) && is_dir ( EGW_SERVER_ROOT . '/' . $entry ) &&
2010-06-02 19:33:26 +02:00
file_exists ( $f = EGW_SERVER_ROOT . '/' . $entry . '/setup/setup.inc.php' ))
2010-06-02 12:59:58 +02:00
{
include ( $f );
if ( isset ( $GLOBALS [ 'egw_info' ][ 'template' ][ $entry ]))
{
2010-11-09 15:44:18 +01:00
$list [ $entry ] = $full_data ? $GLOBALS [ 'egw_info' ][ 'template' ][ $entry ] :
2010-06-03 00:43:41 +02:00
$GLOBALS [ 'egw_info' ][ 'template' ][ $entry ][ 'title' ];
2010-06-02 12:59:58 +02:00
}
}
}
$d -> close ();
ksort ( $list );
return $list ;
}
2010-06-07 13:49:16 +02:00
/**
* Compile entries for topmenu :
* - regular items : links
* - info items
*
* @ param array $vars
* @ param array $apps
*/
function topmenu ( array $vars , array $apps )
{
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'home' ] && isset ( $apps [ 'home' ]))
{
$this -> _add_topmenu_item ( $apps [ 'home' ]);
}
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'preferences' ])
{
$this -> _add_topmenu_item ( $apps [ 'preferences' ]);
}
2011-06-03 20:36:47 +02:00
// allways display pasword in topmenu
if ((( $pw_app = $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'preferences' ]) ||
( $pw_app = $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'password' ])) &&
2010-07-27 16:29:20 +02:00
! $GLOBALS [ 'egw' ] -> acl -> check ( 'nopasswordchange' , 1 ))
{
$this -> _add_topmenu_item ( array (
2011-06-03 20:36:47 +02:00
'name' => $pw_app [ 'name' ] == 'password' ? 'about' : $pw_app [ 'name' ],
'title' => lang ( 'Password' ),
2011-06-07 14:11:16 +02:00
'url' => egw :: link ( $pw_app [ 'name' ] == 'password' ? $pw_app [ 'index' ] : '/index.php?menuaction=preferences.uipassword.change' ),
2010-07-27 16:29:20 +02:00
'icon' => common :: image ( $pw_app [ 'icon' ], $pw_app [ 'icon_app' ]),
));
}
2010-11-09 15:44:18 +01:00
2010-06-07 13:49:16 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'manual' ] && isset ( $apps [ 'manual' ]))
{
2011-06-03 20:36:47 +02:00
$this -> _add_topmenu_item ( array_merge ( $apps [ 'manual' ], array ( 'title' => lang ( 'Help' ))));
2010-06-07 13:49:16 +02:00
}
$GLOBALS [ 'egw' ] -> hooks -> process ( 'topmenu_info' , array (), true );
// Add extra items added by hooks
foreach ( self :: $top_menu_extra as $extra_item ) {
$this -> _add_topmenu_item ( $extra_item );
}
$this -> _add_topmenu_item ( $apps [ 'logout' ]);
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'notifications' ])
{
$this -> _add_topmenu_info_item ( self :: _get_notification_bell ());
}
$this -> _add_topmenu_info_item ( $vars [ 'user_info' ]);
$this -> _add_topmenu_info_item ( $vars [ 'current_users' ]);
$this -> _add_topmenu_info_item ( $vars [ 'quick_add' ]);
}
/**
* Add menu items to the topmenu template class to be displayed
*
* @ param array $app application data
* @ param mixed $alt_label string with alternative menu item label default value = null
* @ param string $urlextra string with alternate additional code inside < a >- tag
* @ access protected
* @ return void
*/
abstract function _add_topmenu_item ( array $app_data , $alt_label = null );
/**
* Add info items to the topmenu template class to be displayed
*
* @ param string $content html of item
* @ access protected
* @ return void
*/
abstract function _add_topmenu_info_item ( $content );
2010-06-10 09:35:16 +02:00
static $top_menu_extra = array ();
2010-06-07 13:49:16 +02:00
/**
* Called by hooks to add an entry in the topmenu location .
* Extra entries will be added just before Logout .
*
* @ param string $id unique element id
* @ param string $url Address for the entry to link to
* @ param string $title Text displayed for the entry
* @ param string $target Optional , so the entry can open in a new page or popup
* @ access public
* @ return void
*/
public static function add_topmenu_item ( $id , $url , $title , $target = '' )
{
$entry [ 'name' ] = $id ;
$entry [ 'url' ] = $url ;
$entry [ 'title' ] = $title ;
$entry [ 'target' ] = $target ;
self :: $top_menu_extra [ $id ] = $entry ;
}
2010-09-07 21:08:13 +02:00
/**
* called by hooks to add an icon in the topmenu info location
*
* @ param string $id unique element id
* @ param string $icon_src src of the icon image . Make sure this nog height then 18 pixels
* @ param string $iconlink where the icon links to
* @ param booleon $blink set true to make the icon blink
* @ param mixed $tooltip string containing the tooltip html , or null of no tooltip
* @ access public
* @ return void
*/
abstract function topmenu_info_icon ( $id , $icon_src , $iconlink , $blink = false , $tooltip = null );
2010-06-07 19:31:43 +02:00
/**
* Call and return content of 'after_navbar' hook
2010-11-09 15:44:18 +01:00
*
2010-06-07 19:31:43 +02:00
* @ return string
*/
protected function _get_after_navbar ()
{
ob_start ();
$GLOBALS [ 'egw' ] -> hooks -> process ( 'after_navbar' , null , true );
$content = ob_get_contents ();
ob_end_clean ();
return $content ;
}
2010-11-09 15:44:18 +01:00
2010-06-08 00:06:35 +02:00
/**
* Return javascript ( eg . for onClick ) to open manual with given url
2010-11-09 15:44:18 +01:00
*
2010-06-08 00:06:35 +02:00
* @ param string $url
*/
abstract function open_manual_js ( $url );
2010-11-09 15:44:18 +01:00
2010-06-09 17:30:53 +02:00
/**
* Methods to add javascript to framework
*/
/**
* Body tags for onLoad , onUnload and onResize
2010-11-09 15:44:18 +01:00
*
2010-06-09 17:30:53 +02:00
* @ var array
*/
protected static $body_tags = array ();
2010-11-09 15:44:18 +01:00
2010-06-09 17:30:53 +02:00
/**
2010-06-15 18:08:10 +02:00
* Sets an onLoad action for a page
*
* @ param string $code = '' javascript to be used
* @ param boolean $replace = false false : append to existing , true : replace existing tag
* @ return string content of onXXX tag after adding code
*/
static function set_onload ( $code = '' , $replace = false )
2010-06-09 17:30:53 +02:00
{
2010-06-15 18:08:10 +02:00
if ( $replace )
{
self :: $body_tags [ 'onLoad' ] = $code ;
}
else
{
self :: $body_tags [ 'onLoad' ] .= $code ;
}
return self :: $body_tags [ 'onLoad' ];
2010-06-09 17:30:53 +02:00
}
/**
2010-06-15 18:08:10 +02:00
* Sets an onUnload action for a page
*
* @ param string $code = '' javascript to be used
* @ param boolean $replace = false false : append to existing , true : replace existing tag
* @ return string content of onXXX tag after adding code
*/
static function set_onunload ( $code = '' , $replace = false )
2010-06-09 17:30:53 +02:00
{
2010-06-15 18:08:10 +02:00
if ( $replace )
{
self :: $body_tags [ 'onUnload' ] = $code ;
}
else
{
self :: $body_tags [ 'onUnload' ] .= $code ;
}
return self :: $body_tags [ 'onUnload' ];
2010-06-09 17:30:53 +02:00
}
/**
* Sets an onResize action for a page
*
2010-06-15 18:08:10 +02:00
* @ param string $code = '' javascript to be used
* @ param boolean $replace = false false : append to existing , true : replace existing tag
2010-06-13 09:44:53 +02:00
* @ return string content of onXXX tag after adding code
2010-06-09 17:30:53 +02:00
*/
2010-06-15 18:08:10 +02:00
static function set_onresize ( $code = '' , $replace = false )
2010-06-09 17:30:53 +02:00
{
2010-06-15 18:08:10 +02:00
if ( $replace )
{
self :: $body_tags [ 'onResize' ] = $code ;
}
else
{
self :: $body_tags [ 'onResize' ] .= $code ;
}
return self :: $body_tags [ 'onResize' ];
2010-06-09 17:30:53 +02:00
}
2010-06-15 18:08:10 +02:00
2010-06-09 17:30:53 +02:00
/**
2010-06-15 18:08:10 +02:00
* Adds on ( Un ) Load = attributes to the body tag of a page
*
* @ returns string the attributes to be used
*/
2011-01-06 21:47:21 +01:00
static public function _get_body_attribs ()
2010-06-09 17:30:53 +02:00
{
$js = '' ;
foreach ( self :: $body_tags as $what => $data )
{
if ( ! empty ( $data ))
{
2010-06-10 16:31:30 +02:00
$js .= ' ' . $what . '="' . htmlspecialchars ( $data ) . '"' ;
2010-06-09 17:30:53 +02:00
}
}
return $js ;
}
2010-11-09 15:44:18 +01:00
2010-06-09 17:30:53 +02:00
/**
* Content from validate_file calls plus preloaded files
2010-11-09 15:44:18 +01:00
*
2010-06-09 17:30:53 +02:00
* @ var array
*/
protected static $js_include_files = array (
// allways load jquery (not -ui) and egw_json first
'/phpgwapi/js/jquery/jquery.js' ,
'/phpgwapi/js/./egw_json.js' ,
// always include javascript helper functions
'/phpgwapi/js/jsapi/jsapi.js' ,
);
/**
* Checks to make sure a valid package and file name is provided
*
2010-06-24 01:01:57 +02:00
* Example call syntax :
2010-11-09 15:44:18 +01:00
* a ) egw_framework :: validate_file ( 'jscalendar' , 'calendar' )
2010-06-24 01:01:57 +02:00
* --> / phpgwapi / js / jscalendar / calendar . js
* b ) egw_framework :: validate_file ( '/phpgwapi/inc/calendar-setup.js' , array ( 'lang' => 'de' ))
* --> / phpgwapi / inc / calendar - setup . js ? lang = de
2010-11-09 15:44:18 +01:00
*
2010-06-24 01:01:57 +02:00
* @ 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
2010-11-09 15:44:18 +01:00
* @ param boolean $append = true should the file be added
2010-06-09 17:30:53 +02:00
*
* @ discuss The browser specific option loads the file which is in the correct
* browser folder . Supported folder are those supported by class . browser . inc . php
*
* @ returns bool was the file found ?
*/
2010-06-24 01:01:57 +02:00
static function validate_file ( $package , $file = null , $app = 'phpgwapi' )
2010-06-09 17:30:53 +02:00
{
//echo "<p>".__METHOD__."($package,$file,$app) --> ".EGW_INCLUDE_ROOT ."/$app/js/$package/$file.js</p>\n";
2010-06-24 01:01:57 +02:00
if ( $package [ 0 ] == '/' && is_readable ( EGW_SERVER_ROOT . ( $path = $package )) ||
is_readable ( EGW_SERVER_ROOT . ( $path = " / $app /js/ $package / $file .js " )) ||
$app != 'phpgwapi' && is_readable ( EGW_SERVER_ROOT . ( $path = " /phpgwapi/js/ $package / $file .js " )))
2010-06-09 17:30:53 +02:00
{
2010-06-24 01:01:57 +02:00
if ( is_array ( $file ))
{
foreach ( $file as $name => $val )
{
$args .= ( empty ( $args ) ? '?' : '&' ) . $name . '=' . urlencode ( $val );
}
$path .= $args ;
}
2010-06-09 17:30:53 +02:00
if ( ! self :: $js_include_files || ! in_array ( $path , self :: $js_include_files ))
{
self :: $js_include_files [] = $path ;
}
return True ;
}
2010-11-21 14:37:09 +01:00
//error_log(__METHOD__."($package,$file,$app) $path NOT found!");
2010-06-09 17:30:53 +02:00
return False ;
}
2010-11-09 15:44:18 +01:00
2010-06-15 18:08:10 +02:00
/**
* Set or return all javascript files set via validate_file
2010-11-09 15:44:18 +01:00
*
2010-06-15 18:08:10 +02:00
* @ param array $files = null array with pathes relative to EGW_SERVER_ROOT , eg . / phpgwapi / js / jquery / jquery . js
* @ return array with pathes relative to EGW_SERVER_ROOT
*/
static function js_files ( array $files = null )
{
if ( isset ( $files ) && is_array ( $files ))
{
self :: $js_include_files = $files ;
}
return self :: $js_include_files ;
}
2010-11-09 15:44:18 +01:00
2010-06-09 17:30:53 +02:00
/**
* Used for generating the list of external js files to be included in the head of a page
*
* NOTE : This method should only be called by the template class .
* The validation is done when the file is added so we don ' t have to worry now
*
* @ returns string the html needed for importing the js into a page
*/
static protected function get_script_links ()
{
$links = " \n " ;
if ( ! empty ( self :: $js_include_files ) && is_array ( self :: $js_include_files ))
{
2010-06-24 12:51:02 +02:00
foreach ( self :: $js_include_files as $path )
2010-06-09 17:30:53 +02:00
{
2010-06-24 12:51:02 +02:00
$query = '' ;
list ( $path , $query ) = explode ( '?' , $path , 2 );
$path .= '?' . filectime ( EGW_SERVER_ROOT . $path ) . ( $query ? '&' . $query : '' );
$links .= '<script type="text/javascript" src="' . $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . $path . '">' . " </script> \n " ;
2010-06-09 17:30:53 +02:00
}
}
return $links . " \n " ;
}
2010-11-09 15:44:18 +01:00
2010-06-18 13:19:24 +02:00
/**
* Content from includeCSS calls
2010-11-09 15:44:18 +01:00
*
2010-06-18 13:19:24 +02:00
* @ var array
*/
protected static $css_include_files = array ();
/**
* Include a css file , either speicified by it ' s path ( relative to EGW_SERVER_ROOT ) or appname and css file name
2010-11-09 15:44:18 +01:00
*
2010-06-24 01:01:57 +02:00
* @ param string $app path ( relative to EGW_SERVER_ROOT ) or appname ( if ! is_null ( $name ))
2010-06-18 13:19:24 +02:00
* @ param string $name = null name of css file in $app / templates / { default | $this -> template } / $name . css
* @ return boolean false : css file not found , true : file found
*/
2010-06-24 01:01:57 +02:00
public static function includeCSS ( $app , $name = null )
2010-06-18 13:19:24 +02:00
{
if ( ! is_null ( $name ))
{
$path = '/' . $app . '/templates/' . $GLOBALS [ 'egw_info' ][ 'server' ][ 'template_set' ] . '/' . $name . '.css' ;
if ( ! file_exists ( EGW_SERVER_ROOT . $path ))
{
$path = '/' . $app . '/templates/default/' . $name . '.css' ;
}
}
2010-06-24 01:01:57 +02:00
else
{
$path = $app ;
}
2010-06-18 13:19:24 +02:00
if ( ! file_exists ( EGW_SERVER_ROOT . $path ))
{
2010-07-30 15:38:49 +02:00
//error_log(__METHOD__."($app,$name) $path NOT found!");
2010-06-18 13:19:24 +02:00
return false ;
}
if ( ! in_array ( $path , self :: $css_include_files ))
{
self :: $css_include_files [] = $path ;
}
return true ;
}
2010-11-09 15:44:18 +01:00
2010-06-24 01:01:57 +02:00
/**
* Add registered CSS and javascript to ajax response
*/
public static function include_css_js_response ()
{
$response = egw_json_response :: get ();
$app = $GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ];
2010-11-09 15:44:18 +01:00
2010-06-24 01:01:57 +02:00
// try to add app specific css file
self :: includeCSS ( $app , 'app' );
// add all css files from egw_framework::includeCSS()
foreach ( self :: $css_include_files as $path )
{
2010-06-24 12:51:02 +02:00
$query = '' ;
list ( $path , $query ) = explode ( '?' , $path , 2 );
$path .= '?' . filectime ( EGW_SERVER_ROOT . $path ) . ( $query ? '&' . $query : '' );
2010-06-24 01:01:57 +02:00
$response -> includeCSS ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . $path );
}
2010-11-09 15:44:18 +01:00
2010-06-24 01:01:57 +02:00
// try to add app specific js file
self :: validate_file ( '.' , 'app' , $app );
// add all js files from egw_framework::validate_file()
foreach ( self :: $js_include_files as $path )
{
2010-06-24 12:51:02 +02:00
$query = '' ;
list ( $path , $query ) = explode ( '?' , $path , 2 );
$path .= '?' . filectime ( EGW_SERVER_ROOT . $path ) . ( $query ? '&' . $query : '' );
2010-06-24 01:01:57 +02:00
$response -> includeScript ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . $path );
}
}
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
*
* @ deprecated use $GLOBALS [ 'egw' ] -> framework :: sidebox ()
*/
function display_sidebox ( $appname , $menu_title , $file )
{
$GLOBALS [ 'egw' ] -> framework -> sidebox ( $appname , $menu_title , $file );
}
2007-01-09 23:42:01 +01:00
}