added two new widgets:

- hour with 12/24 preference
- day of week
This commit is contained in:
Ralf Becker 2004-10-07 21:58:33 +00:00
parent 72140f4425
commit 33f5cb30c8
4 changed files with 123 additions and 14 deletions

View File

@ -20,7 +20,8 @@
@param $format: ''=timestamp or eg. 'Y-m-d H:i' for 2002-12-31 23:59
@param $options: &1 = year is int-input not selectbox, &2 = show a [Today] button, \
&4 = 1min steps for time (default is 5min, with fallback to 1min if value is not in 5min-steps),
&8 = dont show time for readonly and type date-time if time is 0:00
&8 = dont show time for readonly and type date-time if time is 0:00,
&16 = prefix r/o display with dow
@discussion This widget is independent of the UI as it only uses etemplate-widgets and has therefor no render-function
*/
class date_widget
@ -32,23 +33,29 @@
var $human_name = array(
'date' => 'Date', // just a date, no time
'date-time' => 'Date+Time', // date + time
'date-timeonly' => 'Time'
'date-timeonly' => 'Time', // time
'date-houronly' => 'Hour', // hour
);
function date_widget($ui)
{
if ($ui == 'html')
{
$this->jscal = CreateObject('phpgwapi.jscalendar');
if (!is_object($GLOBALS['phpgw']->jscalendar))
{
$GLOBALS['phpgw']->jscalendar = CreateObject('phpgwapi.jscalendar');
}
$this->jscal = &$GLOBALS['phpgw']->jscalendar;
}
$this->timeformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'];
}
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
{
list($data_format,$options) = explode(',',$cell['size']);
$extension_data = $data_format;
$type = $cell['type'];
list($data_format,$options) = explode(',',$cell['size']);
if ($type == 'date-houronly' && empty($data_format)) $data_format = 'H';
$extension_data = $data_format;
if (!$value)
{
@ -119,10 +126,17 @@
3 => ' ',
4 => ':'
);
for ($str='',$n = $type == 'date-timeonly' ? 3 : 0; $n < count($format); ++$n)
for ($str='',$n = substr($type,-4) == 'only' ? 3 : 0; $n < count($format); ++$n)
{
$str .= ($str != '' ? $sep[$n] : '');
$str .= $value[$format[$n]];
if ($value[$format[$n]])
{
if (!$n && $options & 16 )
{
$str = lang(date('l',mktime(12,0,0,$value['m'],$value['d'],$value['Y']))).' ';
}
$str .= ($str != '' ? $sep[$n] : '') . $value[$format[$n]];
}
if ($type == 'date-houronly') ++$n; // no minutes
}
$value = $str;
$cell['type'] = 'label';
@ -158,7 +172,7 @@
'i' => 'Minute'
);
$row = array();
for ($i=0,$n=$type == 'date-timeonly'?3:0; $n < ($type == 'date' ? 3 : 5); ++$n,++$i)
for ($i=0,$n= substr($type,-4) == 'only' ? 3 : 0; $n < ($type == 'date' ? 3 : 5); ++$n,++$i)
{
$dcell = $tpl->empty_cell();
// test if we can use jsCalendar
@ -169,8 +183,6 @@
$value['str'] = $this->jscal->input($name.'[str]',False,$value['Y'],$value['m'],$value['d'],lang($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
{
@ -183,7 +195,7 @@
{
$dcell['label'] = ':'; // put a : between hour and minute
}
$dcell['no_lang'] = True;
$dcell['no_lang'] = 2;
$row[$tpl->num2chrs($i)] = &$dcell;
unset($dcell);
@ -193,6 +205,7 @@
$dcell['name'] = 'today';
$dcell['label'] = 'Today';
$dcell['help'] = 'sets today as date';
$dcell['no_lang'] = True;
if (($js = $tmpl->java_script()))
{
$dcell['needed'] = True; // to get a button
@ -208,10 +221,11 @@
$dcell['type'] = 'html';
$dcell['name'] = 'space';
$value['space'] = ' &nbsp; &nbsp; ';
$dcell['no_lang'] = True;
$row[$tpl->num2chrs(++$i)] = &$dcell;
unset($dcell);
}
if ($type == 'date-houronly') $n++; // no minutes
if ($n == 4 && $type != 'date' && $this->timeformat == '12')
{
$dcell = $tpl->empty_cell();

View File

@ -22,7 +22,8 @@
class select_widget
{
var $public_functions = array(
'pre_process' => True
'pre_process' => True,
'post_process' => True,
);
var $human_name = array( // this are the names for the editor
'select-percent' => 'Select Percentage',
@ -36,6 +37,7 @@
'select-year' => 'Select Year',
'select-month' => 'Select Month',
'select-day' => 'Select Day',
'select-dow' => 'Select Day of week',
'select-number' => 'Select Number',
'select-app' => 'Select Application'
);
@ -127,6 +129,8 @@
{
list($rows,$type,$type2,$type3) = explode(',',$cell['size']);
$extension_data = $cell['type'];
switch ($cell['type'])
{
case 'select-percent': // options: #row,decrement(default=10)
@ -281,6 +285,65 @@
$value = intval($value);
break;
case 'select-dow':
if (!defined('MCAL_M_SUNDAY'))
{
define('MCAL_M_SUNDAY',1);
define('MCAL_M_MONDAY',2);
define('MCAL_M_TUESDAY',4);
define('MCAL_M_WEDNESDAY',8);
define('MCAL_M_THURSDAY',16);
define('MCAL_M_FRIDAY',32);
define('MCAL_M_SATURDAY',64);
define('MCAL_M_WEEKDAYS',62);
define('MCAL_M_WEEKEND',65);
define('MCAL_M_ALLDAYS',127);
}
$weekstart = $GLOBALS['phpgw_info']['user']['preferences']['calendar']['weekdaystarts'];
$cell['sel_options'] = array(
MCAL_M_ALLDAYS => 'all days',
MCAL_M_WEEKDAYS => 'working days',
MCAL_M_WEEKEND => 'weekend',
);
if ($weekstart == 'Saturday') $cell['sel_options'][MCAL_M_SATURDAY] = 'saturday';
if ($weekstart != 'Monday') $cell['sel_options'][MCAL_M_SUNDAY] = 'sunday';
$cell['sel_options'] += array(
MCAL_M_MONDAY => 'monday',
MCAL_M_TUESDAY => 'tuesday',
MCAL_M_WEDNESDAY=> 'wednesday',
MCAL_M_THURSDAY => 'thursday',
MCAL_M_FRIDAY => 'friday',
);
if ($weekstart != 'Saturday') $cell['sel_options'][MCAL_M_SATURDAY] = 'saturday';
if ($weekstart == 'Monday') $cell['sel_options'][MCAL_M_SUNDAY] = 'sunday';
$value_in = $value;
$value = array();
$readonly = $cell['readonly'] || $readonlys;
foreach($cell['sel_options'] as $val => $lable)
{
if (($value_in & $val) == $val)
{
$value[] = $readonly ? lang($lable) : $val;
if ($val == MCAL_M_ALLDAYS ||
$val == MCAL_M_WEEKDAYS && $value_in == MCAL_M_WEEKDAYS ||
$val == MCAL_M_WEEKEND && $value_in == MCAL_M_WEEKEND)
{
break; // dont set the others
}
}
}
if ($readonly)
{
$cell['type'] = 'lable';
}
else
{
$GLOBALS['phpgw_info']['etemplate']['to_process'][$name] = 'ext-select-dow';
}
break;
case 'select-day':
$type = 1;
$type2 = 31;
@ -384,4 +447,28 @@
}
return $info;
}
/**
* postprocessing only used by select-dow so far
*/
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
{
switch ($extension_data)
{
case 'select-dow':
$value = 0;
if (!is_array($value_in)) $value_in = explode(',',$value_in);
foreach($value_in as $val)
{
$value |= $val;
}
//echo "<p>select_widget::post_process('$name',...,'$value_in'): value='$value'</p>\n";
break;
default:
$value = $value_in;
break;
}
//echo "<p>select_widget::post_process('$name',,'$extension_data',,,'$value_in'): value='$value'</p>\n";
return $value != null;
}
}

View File

@ -21,6 +21,7 @@ add table etemplate de Tabelle zuf
align etemplate de Ausrichtung
alignment of label and input-field in table-cell etemplate de Ausrichtung der Beschriftung und des Eingabefeldes in der Tabellenzelle
alignment of the v/hbox containing table-cell etemplate de Ausrichtung der die V/HBox enthaltenden Tabellenzelle
all days etemplate de alle Tage
am etemplate de Vormittag
an indexed column speeds up querys using that column (cost space on the disk !!!) etemplate de eine indizierte Spalte beschleunigt Anfragen die diese benutzen (kostet Plattenplatz !!!)
application etemplate de Anwendung
@ -223,6 +224,7 @@ select application etemplate de Anwendung ausw
select category etemplate de Kategorie auswählen
select country etemplate de Land auswählen
select day etemplate de Tag auswählen
select day of week etemplate de Wochentag auswählen
select if content of field should not be translated (label gets always translated) etemplate de abhaken wenn Inhalt des Feldes nicht übersetzt werden soll (Beschriftung wird immer übersetzt)
select month etemplate de Monat auswählen
select number etemplate de Zahl auswählen
@ -277,11 +279,13 @@ vbox etemplate de VBox
version etemplate de Version
version-number, should be in the form: major.minor.revision.number (eg. 0.9.13.001 all numbers filled up with zeros) etemplate de Versionsnummer, in der Form major.minor.revision.number (zB. 0.9.15.001 alle Zahlen mit Nullen aufgefüllt)
view this linked entry in its application etemplate de Zeige diesen Eintrag in seiner Anwendung an
weekend etemplate de Wochenende
what happens with overflowing content: visible (default), hidden, scroll, auto (browser decides) etemplate de was passiert mit überbreitem Inhalt: sichtbar (standard), versteckt, rollend, automatich (der Browser entscheidet)
width etemplate de Breite
width of col (in % or pixel), disable col: [! = not]<value>[=<check>] eg: '!@data' disable col if content of data is empty etemplate de Breite der Spalte (in % oder Punkten), deaktiviert Spalten: [! = nicht]<wert>[=<test>] zB.: '!@data' deaktiviert Spalte wenn data leer ist
width of the table in % or pixels for the table-tag and (optional) div etemplate de Breite der Tabelle in % oder Punkten
width, disabled etemplate de Breite, Deaktiviert
working days etemplate de Werktage
write <app>/setup/tables_current.inc.php etemplate de schreibt <app>/setup/tables_current.inc.php
write langfile etemplate de Sprachdatei
write tables etemplate de Tabelle Schreiben

View File

@ -21,6 +21,7 @@ add table etemplate en Add Table
align etemplate en Align
alignment of label and input-field in table-cell etemplate en alignment of label and input-field in table-cell
alignment of the v/hbox containing table-cell etemplate en Alignment of the V/HBox containing table-cell
all days etemplate en all days
am etemplate en am
an indexed column speeds up querys using that column (cost space on the disk !!!) etemplate en an indexed column speeds up querys using that column (cost space on the disk !!!)
application etemplate en Application
@ -223,6 +224,7 @@ select application etemplate en Select Application
select category etemplate en Select Category
select country etemplate en Select Country
select day etemplate en Select Day
select day of week etemplate en select day of week
select if content of field should not be translated (label gets always translated) etemplate en select if content of field should not be translated (label gets always translated)
select month etemplate en Select Month
select number etemplate en Select Number
@ -277,11 +279,13 @@ vbox etemplate en VBox
version etemplate en Version
version-number, should be in the form: major.minor.revision.number (eg. 0.9.13.001 all numbers filled up with zeros) etemplate en version-number, should be in the form: major.minor.revision.number (eg. 0.9.13.001 all numbers filled up with zeros)
view this linked entry in its application etemplate en view this linked entry in its application
weekend etemplate en weekend
what happens with overflowing content: visible (default), hidden, scroll, auto (browser decides) etemplate en what happens with overflowing content: visible (default), hidden, scroll, auto (browser decides)
width etemplate en Width
width of col (in % or pixel), disable col: [! = not]<value>[=<check>] eg: '!@data' disable col if content of data is empty etemplate en width of col (in % or pixel), disable col: [! = not]<value>[=<check>] eg: '!@data' disable col if content of data is empty
width of the table in % or pixels for the table-tag and (optional) div etemplate en Width of the table in % or pixels for the table-tag and (optional) div
width, disabled etemplate en Width, Disabled
working days etemplate en working days
write <app>/setup/tables_current.inc.php etemplate en Write <app>/setup/tables_current.inc.php
write langfile etemplate en Write Langfile
write tables etemplate en Write Tables