PluginProbe
ShiftController Employee Shift Scheduling / 4.9.95
ShiftController Employee Shift Scheduling v4.9.95
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.95, at sh4/notifications/html/admin/view/edit.php

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