PluginProbe
ShiftController Employee Shift Scheduling / 4.9.66
ShiftController Employee Shift Scheduling v4.9.66
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / hc3 / ui / element / input / timerange.php

timerange.php in ShiftController Employee Shift Scheduling 4.9.66, at hc3/ui/element/input/timerange.php

59 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 class HC3_Ui_Element_Input_TimeRange extends HC3_Ui_Abstract_Input
3 {
4 protected $el = 'select';
5 protected $uiType = 'input/timerange';
6 protected $timeFormatOptions = array();
7
8 public function __construct( $htmlFactory, $name, $label = NULL, $timeFormatOptions = array(), $value = array() )
9 {
10 parent::__construct( $htmlFactory, $name, $label, $value );
11 $this->timeFormatOptions = $timeFormatOptions;
12 }
13
14 public function setValue( $value )
15 {
16 if( ! is_array($value) ){
17 $value = explode( '-', $value );
18 }
19 $this->value = $value;
20 return $this;
21 }
22
23 public function render()
24 {
25 $input_value = NULL;
26 if( $this->value && is_array($this->value) ){
27 $input_value = array();
28 foreach( $this->value as $v ){
29 $input_value[] = $v;
30 }
31 $input_value = join('-', $input_value);
32 }
33 $hidden = $this->htmlFactory->makeInputHidden( $this->name(), $input_value );
34
35 $display = $this->htmlFactory->makeBlock()
36 ->addAttr('class', 'hcj-display')
37 ;
38
39 $out = $this->htmlFactory->makeCollection( array($hidden, $display) );
40 $out = $this->htmlFactory->makeBlock( $out )
41 ->addAttr('class', 'hcj-timerange-input')
42 ;
43
44 // time options
45 $data_atts = array(
46 'time-format' => $this->timeFormatOptions,
47 );
48 foreach( $data_atts as $k => $v ){
49 $out->addAttr('data-' . $k, htmlentities(json_encode($v)));
50 }
51
52 if( strlen($this->label) ){
53 $out = $this->htmlFactory->makeLabelled( $this->label, $out, $this->htmlId() );
54 }
55
56 return $out;
57 }
58 }
59