ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
base.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
17 function base()
18 {
19  global $DIC;
20  $f = $DIC->ui()->factory();
21  $renderer = $DIC->ui()->renderer();
22  $target = $DIC->http()->request()->getRequestTarget();
23  $refinery = $DIC->refinery();
24  $request_wrapper = $DIC->http()->wrapper()->query();
25 
26  //example data as from an assoc-query, list of arrays
27  $active_view_control = 'All';
28  $data = included_data();
29  if ($request_wrapper->has('upcoming') && $request_wrapper->retrieve('upcoming', $refinery->kindlyTo()->int()) === 1) {
30  $data = [array_shift($data)];
31  $active_view_control = 'Upcoming events';
32  }
33 
34  //build viewcontrols
35  $actions = [
36  "All" => $target . '&upcoming=0',
37  "Upcoming events" => $target . '&upcoming=1'
38  ];
39  $aria_label = "filter entries";
40  $view_controls = array(
41  $f->viewControl()->mode($actions, $aria_label)->withActive($active_view_control)
42  );
43 
44  //build an example modal
45  $modal = $f->modal()->interruptive('Book Course', 'This is just an example', '#')
46  ->withActionButtonLabel('Do Something');
47 
48  //build table
49  $ptable = $f->table()->presentation(
50  'Presentation Table', //title
51  $view_controls,
52  function ($row, $record, $ui_factory, $environment) use ($modal) { //mapping-closure
53  return $row
54  ->withHeadline($record['title'])
55  ->withSubheadline($record['type'])
56  ->withImportantFields(
57  array(
58  $record['begin_date'],
59  $record['location'],
60  'Available Slots: ' => $record['bookings_available']
61  )
62  )
63 
64  ->withContent(
65  $ui_factory->listing()->descriptive(
66  array(
67  'Targetgroup' => $record['target_group'],
68  'Goals' => $record['goals'],
69  'Topics' => $record['topics']
70  )
71  )
72  )
73 
74  ->withFurtherFieldsHeadline('Detailed Information')
75  ->withFurtherFields(
76  array(
77  'Location: ' => $record['location'],
78  $record['address'],
79  'Date: ' => $record['date'],
80  'Available Slots: ' => $record['bookings_available'],
81  'Fee: ' => $record['fee']
82  )
83  )
84  ->withAction(
85  $ui_factory->button()
86  ->standard('book course', '')
87  ->withOnClick($modal->getShowSignal())
88  );
89  }
90  );
91 
92 
93 
94  //apply data to table and render
95  return $renderer->render([
96  $modal,
97  $ptable->withData($data)
98  ]);
99 }
100 
101 function included_data()
102 {
103  return [
104  [
105  'title' => 'Online Presentation of some Insurance Topic',
106  'type' => 'Webinar',
107  'begin_date' => (new \DateTime())->modify('+1 day')->format('d.m.Y'),
108  'bookings_available' => '3',
109  'target_group' => 'Employees, Field Service',
110  'goals' => 'Lorem Ipsum....',
111  'topics' => '<ul><li>Tranportations</li><li>Europapolice</li></ul>',
112  'date' => (new \DateTime())->modify('+1 day')->format('d.m.Y')
113  . ' - '
114  . (new \DateTime())->modify('+2 day')->format('d.m.Y'),
115  'location' => 'Hamburg',
116  'address' => 'Hauptstraße 123',
117  'fee' => '380 €'
118  ],
119  [
120  'title' => 'Workshop: Life Insurance 2017',
121  'type' => 'Face 2 Face',
122  'begin_date' => '12.12.2017',
123  'bookings_available' => '12',
124  'target_group' => 'Agencies, Field Service',
125  '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.',
126  'topics' => 'Life-based contracts tend to fall into two major categories:
127  <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>
128  <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>',
129  'date' => '12.12.2017 - 14.12.2017',
130  'location' => 'Cologne',
131  'address' => 'Holiday Inn, Am Dom 12, 50667 Köln',
132  'fee' => '500 €'
133  ],
134  [
135  'title' => 'Basics: Preparation for Seminars',
136  'type' => 'Online Training',
137  'begin_date' => '-',
138  'bookings_available' => 'unlimited',
139  'target_group' => 'All',
140  'goals' => '',
141  'topics' => '',
142  'date' => '-',
143  'location' => 'online',
144  'address' => '',
145  'fee' => '-'
146  ]
147  ];
148 }
$renderer
global $DIC
Definition: shib_login.php:25
base()
description: > Example for rendering a presentation table.
Definition: base.php:17