PluginProbe
ShiftController Employee Shift Scheduling / 4.9.24
ShiftController Employee Shift Scheduling v4.9.24
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 / html / admin / view / edit.php

edit.php in ShiftController Employee Shift Scheduling 4.9.24, at sh4/notifications/html/admin/view/edit.php

122 lines 3.8 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 SH4_Notifications_Html_Admin_View_Edit
3 {
4 public function __construct(
5 HC3_Hooks $hooks,
6 HC3_Ui $ui,
7 HC3_Ui_Layout1 $layout,
8
9 SH4_Calendars_Query $calendarsQuery,
10 SH4_Calendars_Presenter $calendarsPresenter,
11
12 SH4_Notifications_Template $notificationsTemplate,
13 SH4_Notifications_Service $notificationsService
14 )
15 {
16 $this->self = $hooks->wrap( $this );
17 $this->ui = $ui;
18 $this->layout = $layout;
19
20 $this->calendarsQuery = $hooks->wrap( $calendarsQuery );
21 $this->calendarsPresenter = $hooks->wrap( $calendarsPresenter );
22
23 $this->notificationsTemplate = $hooks->wrap( $notificationsTemplate );
24 $this->notificationsService = $hooks->wrap( $notificationsService );
25 }
26
27 public function render( $calendarId, $notificationId )
28 {
29 $calendar = $this->calendarsQuery->findById( $calendarId );
30 $notification = $this->notificationsService->findById( $notificationId );
31
32 $template = $this->notificationsService->getTemplate( $calendar, $notificationId );
33
34 $template = explode( "\n", $template );
35 $templateSubject = array_shift( $template );
36 $templateBody = join( "\n", $template );
37
38 // echo $model->getTemplateSubject( $calendar );
39 // exit;
40
41 $inputs = $this->ui->makeList()
42 ->add( $this->ui->makeInputText( 'subject', '__Subject__', $templateSubject ) )
43 ->add( $this->ui->makeInputRichTextarea( 'body', '__Body__', $templateBody )->setRows(10) )
44 ;
45
46 $tags = $this->notificationsTemplate->getTags( $calendar );
47
48 $tagsView = $tags;
49 $count = count($tagsView);
50 for( $ii = 0; $ii < $count; $ii++ ){
51 $tagsView[ $ii ] = '{' . strtoupper($tagsView[$ii]) . '}';
52 }
53 $tagsView = $this->ui->makeList( $tagsView )->gutter(1);
54 $tagsView = $this->ui->makeLabelled( '__Template Tags__', $tagsView );
55
56 $inputs = $this->ui->makeGrid()
57 ->add( $inputs, 9, 12 )
58 ->add( $tagsView, 3, 12 )
59 ;
60
61 $buttons = array();
62
63 $to = array( 'admin/notifications', $calendarId, $notificationId );
64 $to = join( '/', $to );
65 $buttons[] = $this->ui->makeInputSubmit( '__Save__')
66 ->setFormAction( $to )
67 ->tag('primary')
68 ;
69
70 $to = array( 'admin/notifications', $calendarId, $notificationId, 'reset' );
71 $to = join( '/', $to );
72 $buttons[] = $this->ui->makeInputSubmit( '__Reset To Defaults__')
73 ->setFormAction( $to )
74 ->tag('secondary')
75 ->tag('font-size', 2)
76 ->tag('confirm')
77 ;
78 $buttons = $this->ui->makeListInline( $buttons )->gutter(3);
79
80 $form = $this->ui->makeList( array($inputs, $buttons) );
81
82 $to = array( 'admin/notifications', $calendarId, $notificationId );
83 $to = join( '/', $to );
84 $form = $this->ui->makeForm( $to, $form );
85
86 $this->layout
87 ->setContent( $form )
88 ->setBreadcrumb( $this->self->breadcrumb($calendar) )
89 ->setHeader( $this->self->header($calendar, $notification) )
90 ->setMenu( $this->self->menu($calendar, $notification) )
91 ;
92
93 $out = $this->layout->render();
94 return $out;
95 }
96
97 public function menu( SH4_Calendars_Model $calendar, $notification )
98 {
99 $return = array();
100 return $return;
101 }
102
103 public function header( SH4_Calendars_Model $calendar, $notification )
104 {
105 $out = $notification->getTitle();
106 return $out;
107 }
108
109 public function breadcrumb( SH4_Calendars_Model $calendar )
110 {
111 $calendarId = $calendar->getId();
112 $calendarTitle = $this->calendarsPresenter->presentTitle( $calendar );
113
114 $return = array();
115 $return['admin'] = array( 'admin', '__Administration__' );
116 $return['calendars'] = array( 'admin/calendars', '__Calendars__' );
117 $return['calendars/edit'] = array( 'admin/calendars/' . $calendarId, $calendarTitle );
118 $return['calendars/notifications'] = array( 'admin/notifications/' . $calendarId, '__Notifications__' );
119
120 return $return;
121 }
122 }