added option to suppress time in the readonly display if it's 0h0

This commit is contained in:
Ralf Becker 2004-08-28 17:57:44 +00:00
parent 2f7c4cb8fc
commit ff47845902
2 changed files with 17 additions and 9 deletions

View File

@ -360,9 +360,9 @@ implement only a subset of XUL. Here are the main differences:</p>
<a name="widgets"> <a name="widgets">
<h2>standard widgets and extensions of the eTemplates</h2> <h2>standard widgets and extensions of the eTemplates</h2>
<table border=1> <table border="1">
<tr> <tr>
<th>Widget Name in Editor</th> <th>Widget Name<br>in Editor</th>
<th>xml tag</th> <th>xml tag</th>
<th>xul</th> <th>xul</th>
<th>internal name</th> <th>internal name</th>
@ -441,7 +441,7 @@ implement only a subset of XUL. Here are the main differences:</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><b>Formatted Text (HTML)</b></td> <td><b>Formatted Text</b><br>(HTML)</td>
<td>&lt;htmlarea /></td> <td>&lt;htmlarea /></td>
<td>no</td> <td>no</td>
<td>htmlarea</td> <td>htmlarea</td>
@ -607,7 +607,7 @@ implement only a subset of XUL. Here are the main differences:</p>
<td> <td>
<b>Date-/Time-input</b> via selectboxes or a field for the year<br> <b>Date-/Time-input</b> via selectboxes or a field for the year<br>
The order of the input-fields is determined by the prefs of the user.<br> The order of the input-fields is determined by the prefs of the user.<br>
<b>Options</b>: [datetime-storage-format][,&1=year-no-selectbox|&2=today-button]<br> <b>Options</b>: [datetime-storage-format] [,&1=year-no-selectbox|&2=today-button|&4=one-min-steps|&8=ro-suppress-0h0]<br>
<b>datetime-storage-format</b> is the format, in which the date is stored in the variable: <b>datetime-storage-format</b> is the format, in which the date is stored in the variable:
empty means an unix-timestamp (in GMT), or a string containing the letters <b>Y</b>, <b>m</b>, empty means an unix-timestamp (in GMT), or a string containing the letters <b>Y</b>, <b>m</b>,
<b>d</b>, <b>H</b>, <b>i</b> plus separators, eg. 'Y-m-d': 2002-12-31. The storage format <b>d</b>, <b>H</b>, <b>i</b> plus separators, eg. 'Y-m-d': 2002-12-31. The storage format
@ -617,6 +617,8 @@ implement only a subset of XUL. Here are the main differences:</p>
select-year widget.<br> select-year widget.<br>
<b>today-button</b>: if set (&2) a [Today] button is displayed which sets the fields to <b>today-button</b>: if set (&2) a [Today] button is displayed which sets the fields to
the up-to-date date (via javascript)<br> the up-to-date date (via javascript)<br>
<b>one-min-steps</b>: if set (&4) the minute-selectbox uses one minutes steps, default 5min steps<br>
<b>ro-suppress-0h0</b>: if set (&8) the time is suppressed for readonly and a time of 0h0<br>
<b>Sub-widgets</b>: <b>date-time</b>: a date and a time and <b>date-timeonly</b>: only a time<br> <b>Sub-widgets</b>: <b>date-time</b>: a date and a time and <b>date-timeonly</b>: only a time<br>
These widgets allow the input of times too or only, they use 12h am/pm or 24h format as These widgets allow the input of times too or only, they use 12h am/pm or 24h format as
specified in the user prefs.<br> specified in the user prefs.<br>
@ -783,13 +785,13 @@ function index($content = 0)
</td> </td>
</tr> </tr>
<tr> <tr>
<td><b>Nextmatch-SortHeader</b><p><b>Nextmatch-FilterHeader</b></td> <td><b>Nextmatch-<br>SortHeader</b><p><b>Nextmatch-<br>FilterHeader</b></td>
<td> <td>
&lt;nextmatch type="nextmatch-sortheader" id="col-name" label="ColLabel"/><p> &lt;nextmatch type="nextmatch-sortheader" id="col-name" label="ColLabel"/><p>
&lt;nextmatch type="nextmatch-filterheader" id="col-name"/> &lt;nextmatch type="nextmatch-filterheader" id="col-name"/>
</td> </td>
<td>no</td> <td>no</td>
<td>nextmatch-sortheader<p>nextmatch-filterheader</td> <td>nextmatch-<br>sortheader<p>nextmatch-<br>filterheader</td>
<td> <td>
These widget are an optional part of the nextmatch widget.<p> These widget are an optional part of the nextmatch widget.<p>
<b>nextmatch-sortheader</b><br> <b>nextmatch-sortheader</b><br>

View File

@ -19,7 +19,8 @@
@param Options/$cell['size'] = $format[,$options], @param Options/$cell['size'] = $format[,$options],
@param $format: ''=timestamp or eg. 'Y-m-d H:i' for 2002-12-31 23:59 @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, \ @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) &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
@discussion This widget is independent of the UI as it only uses etemplate-widgets and has therefor no render-function @discussion This widget is independent of the UI as it only uses etemplate-widgets and has therefor no render-function
*/ */
class date_widget class date_widget
@ -88,6 +89,8 @@
'i' => date('i',$value) 'i' => date('i',$value)
); );
} }
$time_0h0 = !(int)$value['H'] && !(int)$value['i'];
$timeformat = array(3 => 'H', 4 => 'i'); $timeformat = array(3 => 'H', 4 => 'i');
if ($this->timeformat == '12') if ($this->timeformat == '12')
{ {
@ -101,11 +104,14 @@
} }
$format = split('[/.-]',$sep=$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); $format = split('[/.-]',$sep=$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
if ($type != 'date') $readonly = $cell['readonly'] || $readonlys;
// no time also if $options&8 and readonly and time=0h0
if ($type != 'date' && !($readonly && ($options & 8) && $time_0h0))
{ {
$format += $timeformat; $format += $timeformat;
} }
if ($cell['readonly'] || $readonlys) // is readonly if ($readonly) // is readonly
{ {
$sep = array( $sep = array(
1 => $sep[1], 1 => $sep[1],