"fix for JScalendar, to bei schown, under under the Menupoint \" Grant Access\""

This commit is contained in:
Stefan Becker 2008-07-23 13:59:16 +00:00
parent 9facd0bfdf
commit 1999c90df4

View File

@ -39,20 +39,22 @@ class jscalendar
* @param string $path='jscalendar' * @param string $path='jscalendar'
* @return jscalendar * @return jscalendar
*/ */
function jscalendar($do_header=True,$path='jscalendar') function jscalendar($do_header=True,$path='jscalendar',$scriptreturn=false)
{ {
$this->jscalendar_url = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js/'.$path; $this->jscalendar_url = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js/'.$path;
$this->dateformat = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; $this->dateformat = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
if ($do_header && (strpos($GLOBALS['egw_info']['flags']['java_script'],'jscalendar')===false)) $js=
{
$GLOBALS['egw_info']['flags']['java_script'] .=
'<link rel="stylesheet" type="text/css" media="all" href="'.$this->jscalendar_url.'/calendar-blue.css" title="blue" /> '<link rel="stylesheet" type="text/css" media="all" href="'.$this->jscalendar_url.'/calendar-blue.css" title="blue" />
<script type="text/javascript" src="'.$this->jscalendar_url.'/calendar.js"></script> <script type="text/javascript" src="'.$this->jscalendar_url.'/calendar.js"></script>
<script type="text/javascript" src="'.$GLOBALS['egw']->link('/phpgwapi/inc/jscalendar-setup.php', <script type="text/javascript" src="'.$GLOBALS['egw']->link('/phpgwapi/inc/jscalendar-setup.php',
array_intersect_key($GLOBALS['egw_info']['user']['preferences']['common'],array('lang'=>1,'dateformat'=>1))).'"></script> array_intersect_key($GLOBALS['egw_info']['user']['preferences']['common'],array('lang'=>1,'dateformat'=>1))).'"></script>
'; ';
if ($do_header && (strpos($GLOBALS['egw_info']['flags']['java_script'],'jscalendar')===false))
{
$GLOBALS['egw_info']['flags']['java_script'] .=$js;
} }
if ($scriptreturn==true) return $js; //if the header is already send to the Browser
} }
/** /**
@ -140,6 +142,7 @@ Calendar.setup(
*/ */
function flat($url,$date=null,$weekUrl='',$weekTTip='',$monthUrl='',$monthTTip='',$id='calendar-container') function flat($url,$date=null,$weekUrl='',$weekTTip='',$monthUrl='',$monthTTip='',$id='calendar-container')
{ {
$javascript=$this->jscalendar(false,'jscalendar',true);
if ($date) // string if format YYYYmmdd or timestamp if ($date) // string if format YYYYmmdd or timestamp
{ {
$date = is_int($date) ? adodb_date('m/d/Y',$date) : $date = is_int($date) ? adodb_date('m/d/Y',$date) :
@ -147,7 +150,7 @@ Calendar.setup(
} }
return ' return '
<div id="'.$id.'"></div> <div id="'.$id.'"></div>
'.$javascript.'
<script type="text/javascript"> <script type="text/javascript">
function dateChanged(calendar) { function dateChanged(calendar) {
'. // Beware that this function is called even if the end-user only '. // Beware that this function is called even if the end-user only
@ -167,7 +170,7 @@ function monthClicked(calendar,monthstart) {
window.location = "'.$monthUrl.'&date=" + monthstart.print("%Y%m%d"); window.location = "'.$monthUrl.'&date=" + monthstart.print("%Y%m%d");
} }
' : '').' ' : '').'
if (document.Calendar){
Calendar.setup( Calendar.setup(
{ {
flat : "'.$id.'", flat : "'.$id.'",
@ -180,7 +183,7 @@ if (document.Calendar){
' : '').' ' : '').'
} }
); );
}
</script>'; </script>';
} }