Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
time.php
Go to the documentation of this file.
1 <?php
2 /*******************************************************************************
3  * File: HTML/QuickForm/calendar.php
4  * Author: Steve Hannah <shannah@sfu.ca>
5  * Created: March 10, 2006
6  * Description:
7  * HMTL Quickform calendar widget. This is essentially a wrapper to use the
8  * DynArch jscalendar widget - a really cool calendar widget.
9  *
10  ******************************************************************************/
11 
12 
13 require_once 'HTML/QuickForm/select.php';
14 
15 
24 class HTML_QuickForm_time extends HTML_QuickForm_select {
25 
26  function HTML_QuickForm_time($elementName=null, $elementLabel=null, $attributes=null, $properties=array())
27  {
28  if ( isset($elementName) ){
29  $start = (isset($properties['starttime']) ? $properties['starttime'] : '08:00');
30  $end = (isset($properties['endtime']) ? $properties['endtime'] : '18:00');
31  $interval = (isset($properties['interval']) ? $properties['interval'] : '30' );
32  $format = (isset($properties['format']) ? $properties['format'] : 'H:i');
33 
34 
35 
36  $properties['starttime'] = $start;
37  $properties['endtime'] = $end;
38  $properties['interval'] = $interval;
39  $properties['format'] = $format;
40 
41  if ( intval($properties['interval']) <= 0 ) $properties['interval'] = 30;
42 
43  $starttime = strtotime($properties['starttime']);
44  $endtime = strtotime($properties['endtime']);
45  $interval_seconds = intval($properties['interval'])*60;
46  $opts = array(''=>'---');
47  $j=0;
48  for ( $i=$starttime; $i<=$endtime; $i+=$interval_seconds){
49  $opts[date('H:i:s', $i)] = date($properties['format'], $i);
50 
51  $j++;
52  }
53 
54 
55  parent::HTML_QuickForm_select($elementName, $elementLabel, $opts, $attributes);
56  }
57 
58  } //end constructor
59 
60 
61  function getValue(){
62  $val = parent::getValue();
63  if ( is_array($val) ){
64  return $val[0];
65  }
66  return $val;
67  }
68 
69 
70 
71 
72 }
73