PluginProbe
ShiftController Employee Shift Scheduling / 4.9.85
ShiftController Employee Shift Scheduling v4.9.85
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 / sh4 / notifications / template.php

template.php in ShiftController Employee Shift Scheduling 4.9.85, at sh4/notifications/template.php

82 lines 1.9 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 interface SH4_Notifications_ITemplate
3 {
4 public function parse( $template, SH4_Shifts_Model $shift );
5 public function getTags( SH4_Calendars_Model $calendar );
6 }
7
8 class SH4_Notifications_Template implements SH4_Notifications_ITemplate
9 {
10 public $self, $shiftsPresenter;
11
12 public function __construct(
13 HC3_Hooks $hooks,
14 SH4_Shifts_Presenter $shiftsPresenter
15 )
16 {
17 $this->self = $hooks->wrap( $this );
18 $this->shiftsPresenter = $hooks->wrap( $shiftsPresenter );
19 }
20
21 public function parse( $template, SH4_Shifts_Model $shift )
22 {
23 $calendar = $shift->getCalendar();
24
25 $return = $template;
26
27 $tags = $this->self->getTags( $calendar );
28 $values = array();
29 foreach( $tags as $tag ){
30 $v = $this->self->getTagValue( $tag, $shift );
31 $values[ $tag ] = $v;
32 }
33
34 reset( $values );
35 foreach( $values as $k => $v ){
36 $k = '{' . strtoupper($k) . '}';
37 $return = str_replace( $k, $v, $return );
38 }
39
40 return $return;
41 }
42
43 public function getTagValue( $tag, SH4_Shifts_Model $shift )
44 {
45 $return = NULL;
46
47 $calendar = $shift->getCalendar();
48 $employee = $shift->getEmployee();
49
50 switch( $tag ){
51 case 'id':
52 $return = $shift->getId();
53 break;
54 case 'datetime':
55 $return = $this->shiftsPresenter->presentFullTime($shift);
56 $breakView = $this->shiftsPresenter->presentBreak( $shift );
57 if( $breakView ){
58 $return .= ' (' . '__Break__' . ' ' . $breakView . ')';
59 }
60 break;
61 case 'calendar':
62 $return = $calendar->getTitle();
63 break;
64 case 'employee':
65 $return = $employee->getTitle();
66 break;
67 }
68
69 return $return;
70 }
71
72 public function getTags( SH4_Calendars_Model $calendar )
73 {
74 $return = array();
75 $return[] = 'calendar';
76 $return[] = 'datetime';
77 $return[] = 'employee';
78 $return[] = 'id';
79
80 return $return;
81 }
82 }