added the jsCalendar to the date_widget

This commit is contained in:
Ralf Becker 2003-08-18 23:15:59 +00:00
parent b32fe49d9b
commit 940249850e
2 changed files with 52 additions and 9 deletions

View File

@ -36,6 +36,10 @@
function date_widget($ui)
{
if ($ui == 'html')
{
$this->jscal = CreateObject('phpgwapi.jscalendar');
}
$this->timeformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'];
}
@ -144,10 +148,24 @@
for ($i=0,$n=$type == 'date-timeonly'?3:0; $n < ($type == 'date' ? 3 : 5); ++$n,++$i)
{
$dcell = $tpl->empty_cell();
// test if we can use jsCalendar
if ($n == 0 && $this->jscal && $tmpl->java_script())
{
$dcell['type'] = 'html';
$dcell['name'] = 'str';
$value['str'] = $this->jscal->input($name.'[str]',False,$value['Y'],$value['m'],$value['d'],$cell['help']);
$n = 2; // no other fields
$options &= ~2; // no set-today button
// register us for process_exec
$GLOBALS['phpgw_info']['etemplate']['to_process'][$name] = 'ext-'.$cell['type'];
}
else
{
$dcell['type'] = $types[$format[$n]];
$dcell['size'] = $opts[$format[$n]];
$dcell['name'] = $format[$n];
$dcell['help'] = lang($help[$format[$n]]).': '.$cell['help']; // note: no lang on help, already done
}
if ($n == 4)
{
$dcell['label'] = ':'; // put a : between hour and minute
@ -207,10 +225,10 @@
return True; // extra Label is ok
}
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl)
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
{
//echo "date_widget::post_process('$name','$extension_data') value=<pre>"; print_r($value); echo "</pre>\n";
if (!isset($value))
//echo "<p>date_widget::post_process('$name','$extension_data') value="; print_r($value); echo ", value_in="; print_r($value_in); echo "</p>\n";
if (!isset($value) && !isset($value_in))
{
return False;
}
@ -222,6 +240,10 @@
$value[$d] = date($d);
}
}
if (isset($value_in['str']))
{
$value = $this->jscal->input2date($value_in['str'],False,'d','m','Y');
}
if ($value['d'] || isset($value['H']) && $value['H'] !== '' ||
isset($value['i']) && $value['i'] !== '')
{

View File

@ -114,6 +114,7 @@
{
$GLOBALS['phpgw_info']['flags']['app_header'] = $content['app_header'];
}
/*
$html = '';
if ($this->stable)
{
@ -134,6 +135,7 @@
$hooked = $hooked['body_data'];
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('java_script' => $this->include_java_script(2)));
}
*/
if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'etemplate')
{
$GLOBALS['phpgw']->translation->add_app('etemplate'); // some extensions have own texts
@ -142,13 +144,32 @@
$GLOBALS['phpgw_info']['etemplate']['loop'] = False;
$GLOBALS['phpgw_info']['etemplate']['form_options'] = ''; // might be set in show
$GLOBALS['phpgw_info']['etemplate']['to_process'] = array();
$html .= ($this->stable ? $this->html->themeStyles()."\n\n" : ''). // so they get included once
$html = ($this->stable ? $this->html->themeStyles()."\n\n" : ''). // so they get included once
$this->html->form($this->include_java_script(1).
$this->show($this->complete_array_merge($content,$changes),$sel_options,$readonlys,'exec'),array(
'etemplate_exec_id' => $id,
'etemplate_exec_app' => $GLOBALS['phpgw_info']['flags']['currentapp']
),'/etemplate/process_exec.php','','eTemplate',$GLOBALS['phpgw_info']['etemplate']['form_options']);
//_debug_array($GLOBALS['phpgw_info']['etemplate']['to_process']);
if ($this->stable)
{
$hooked = $GLOBALS['phpgw']->template->get_var('phpgw_body');
if (!@$GLOBALS['phpgw_info']['etemplate']['hooked'] && !$return_html)
{
$GLOBALS['phpgw_info']['flags']['java_script'] .= $this->include_java_script(2);
$GLOBALS['phpgw']->common->phpgw_header();
}
else
{
$html = $this->include_java_script(2).$html; // better than nothing
}
}
else
{
$hooked = $GLOBALS['phpgw']->xslttpl->get_var('phpgw');
$hooked = $hooked['body_data'];
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('java_script' => $GLOBALS['phpgw_info']['flags']['java_script'].$this->include_java_script(2)));
}
list($width,$height,,,,,$overflow) = explode(',',$this->size);
if ($overflow)
{