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