ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
base.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
33 function base()
34 {
35  global $DIC;
36  $f = $DIC->ui()->factory();
37  $renderer = $DIC->ui()->renderer();
38  $target = $DIC->http()->request()->getRequestTarget();
39  $refinery = $DIC->refinery();
40  $request_wrapper = $DIC->http()->wrapper()->query();
41 
42  //example data as from an assoc-query, list of arrays
43  $active_view_control = 'All';
44  $data = included_data();
45  if ($request_wrapper->has('upcoming') && $request_wrapper->retrieve('upcoming', $refinery->kindlyTo()->int()) === 1) {
46  $data = [array_shift($data)];
47  $active_view_control = 'Upcoming events';
48  }
49 
50  //build viewcontrols
51  $actions = [
52  "All" => $target . '&upcoming=0',
53  "Upcoming events" => $target . '&upcoming=1'
54  ];
55  $aria_label = "filter entries";
56  $view_controls = array(
57  $f->viewControl()->mode($actions, $aria_label)->withActive($active_view_control)
58  );
59 
60  //build an example modal
61  $modal = $f->modal()->interruptive('Book Course', 'This is just an example', '#')
62  ->withActionButtonLabel('Do Something');
63 
64  //build table
65  $ptable = $f->table()->presentation(
66  'Presentation Table', //title
67  $view_controls,
68  function ($row, $record, $ui_factory, $environment) use ($modal) { //mapping-closure
69  return $row
70  ->withHeadline($record['title'])
71  ->withSubheadline($record['type'])
72  ->withImportantFields(
73  array(
74  $record['begin_date'],
75  $record['location'],
76  'Available Slots: ' => $record['bookings_available']
77  )
78  )
79 
80  ->withContent(
81  $ui_factory->listing()->descriptive(
82  array(
83  'Targetgroup' => $record['target_group'],
84  'Goals' => $record['goals'],
85  'Topics' => $record['topics']
86  )
87  )
88  )
89 
90  ->withFurtherFieldsHeadline('Detailed Information')
91  ->withFurtherFields(
92  array(
93  'Location: ' => $record['location'],
94  $record['address'],
95  'Date: ' => $record['date'],
96  'Available Slots: ' => $record['bookings_available'],
97  'Fee: ' => $record['fee']
98  )
99  )
100  ->withAction(
101  $ui_factory->button()
102  ->standard('book course', '')
103  ->withOnClick($modal->getShowSignal())
104  );
105  }
106  );
107 
108 
109 
110  //apply data to table and render
111  return $renderer->render([
112  $modal,
113  $ptable->withData($data)
114  ]);
115 }
116 
117 function included_data()
118 {
119  return [
120  [
121  'title' => 'Online Presentation of some Insurance Topic',
122  'type' => 'Webinar',
123  'begin_date' => (new \DateTime())->modify('+1 day')->format('d.m.Y'),
124  'bookings_available' => '3',
125  'target_group' => 'Employees, Field Service',
126  'goals' => 'Lorem Ipsum....',
127  'topics' => '<ul><li>Tranportations</li><li>Europapolice</li></ul>',
128  'date' => (new \DateTime())->modify('+1 day')->format('d.m.Y')
129  . ' - '
130  . (new \DateTime())->modify('+2 day')->format('d.m.Y'),
131  'location' => 'Hamburg',
132  'address' => 'Hauptstraße 123',
133  'fee' => '380 €'
134  ],
135  [
136  'title' => 'Workshop: Life Insurance 2017',
137  'type' => 'Face 2 Face',
138  'begin_date' => '12.12.2017',
139  'bookings_available' => '12',
140  'target_group' => 'Agencies, Field Service',
141  'goals' => 'Life insurance (or life assurance, especially in the Commonwealth of Nations), is a contract between an insurance policy holder and an insurer or assurer, where the insurer promises to pay a designated beneficiary a sum of money (the benefit) in exchange for a premium, upon the death of an insured person (often the policy holder). Depending on the contract, other events such as terminal illness or critical illness can also trigger payment. The policy holder typically pays a premium, either regularly or as one lump sum. Other expenses (such as funeral expenses) can also be included in the benefits.',
142  'topics' => 'Life-based contracts tend to fall into two major categories:
143  <ul><li>Protection policies – designed to provide a benefit, typically a lump sum payment, in the event of a specified occurrence. A common form - more common in years past - of a protection policy design is term insurance.</li>
144  <li>Investment policies – the main objective of these policies is to facilitate the growth of capital by regular or single premiums. Common forms (in the U.S.) are whole life, universal life, and variable life policies.</li></ul>',
145  'date' => '12.12.2017 - 14.12.2017',
146  'location' => 'Cologne',
147  'address' => 'Holiday Inn, Am Dom 12, 50667 Köln',
148  'fee' => '500 €'
149  ],
150  [
151  'title' => 'Basics: Preparation for Seminars',
152  'type' => 'Online Training',
153  'begin_date' => '-',
154  'bookings_available' => 'unlimited',
155  'target_group' => 'All',
156  'goals' => '',
157  'topics' => '',
158  'date' => '-',
159  'location' => 'online',
160  'address' => '',
161  'fee' => '-'
162  ]
163  ];
164 }
$renderer
global $DIC
Definition: shib_login.php:22
base()
description: > Example for rendering a presentation table.
Definition: base.php:33