ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\UI\examples\Table\Presentation Namespace Reference

Functions

 base ()
 
 included_data ()
 
 base1 ()
 
 environment ()
 
 included_data1 ()
 
 without_data ()
 

Function Documentation

◆ base()

ILIAS\UI\examples\Table\Presentation\base ( )

description: > Example for rendering a presentation table.

expected output: > This example is very similiar to the example of the base1 example. But it includes three entries with different

content (different title, informations etc.).

Definition at line 33 of file base.php.

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';
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}
$renderer
withAction(URI|Signal|string $action)
global $DIC
Definition: shib_login.php:26

References $data, $DIC, Vendor\Package\$f, ILIAS\UI\examples\Layout\Page\Standard\$refinery, $renderer, ILIAS\UI\examples\Layout\Page\Standard\$request_wrapper, ILIAS\UI\examples\Table\Presentation\included_data(), and ILIAS\GlobalScreen\Scope\Footer\Factory\withAction().

+ Here is the call graph for this function:

◆ base1()

ILIAS\UI\examples\Table\Presentation\base1 ( )

description: > Example for rendering a presentation table. You can also leave out "further fields" and use alignments instead, add one or more Blocks and Layouts to the content of the row and add an leading image.

expected output: > ILIAS shows a box titled "Presentation Table with Alignments" and a table. The table includes two entries. Those have got a title each, a small subtitle and some informations. Clicking onto ">" opens the entries with additional informations. Additionally ever entry has got a button "Zur Frage" which opens a modal. The table's header shows two buttons on the left: "expand all" and "collapse all". Clicking that button collapses/expands all entries.

In the header on the right a filter is displayed. It filter the number of answers.

Definition at line 40 of file base1.php.

41{
42 global $DIC;
43 $ui_factory = $DIC->ui()->factory();
44 $renderer = $DIC->ui()->renderer();
45 $tpl = $DIC['tpl'];
46 $target = $DIC->http()->request()->getRequestTarget();
47 $refinery = $DIC->refinery();
48 $request_wrapper = $DIC->http()->wrapper()->query();
49
50 $tpl->addCss('src/UI/examples/Table/Presentation/presentation_alignment_example.css');
51
52 //example data
54
55 //build viewcontrols
56 $aria_label = "filter entries";
57 $active_view_control = 'Alle';
58 $actions = [
59 "Alle" => $target . '&all=1',
60 "Mehr als 5 Antworten" => $target . '&all=0'
61 ];
62 if ($request_wrapper->has('all') && $request_wrapper->retrieve('all', $refinery->kindlyTo()->int()) === 0) {
63 $data = [array_shift($data)];
64 $active_view_control = 'Mehr als 5 Antworten';
65 }
66 $view_controls = array(
67 $ui_factory->viewControl()->mode($actions, $aria_label)->withActive($active_view_control)
68 );
69
70 //build an example modal
71 $modal = $ui_factory->modal()->interruptive('zur Frage', 'This is just an example', '#')
72 ->withActionButtonLabel('Go');
73
74 $mapping_closure = function ($row, $record, $ui_factory, $environment) use ($modal) {
75 return $row
76 ->withHeadline($record['question_title'])
77 ->withLeadingSymbol(
78 $ui_factory->symbol()->icon()->custom('assets/images/standard/icon_ques.svg', '')
79 )
80 ->withSubheadline($record['question_txt'])
81 ->withImportantFields(
82 array(
83 $record['type'],
84 'Beantwortet: ' => $record['stats']['total'],
85 'Häufigste Antwort: ' => $record['answers'][$record['stats']['most_common']]['title']
86 )
87 )
88 ->withContent(
89 $ui_factory->layout()->alignment()->horizontal()->dynamicallyDistributed(
90 $ui_factory->layout()->alignment()->vertical(
91 $ui_factory->listing()->descriptive([
92 'Werte' => $environment['totals']($record['answers'])
93 ]),
94 $ui_factory->listing()->descriptive([
95 'Chart' => $environment['chart']($record['answers'])
96 ])
97 ),
98 $ui_factory->listing()->descriptive([
99 '' => $environment['stats']($record)
100 ])
101 )
102 )
103 ->withAction(
104 $ui_factory->button()->standard('zur Frage', '#')
105 ->withOnClick($modal->getShowSignal())
106 );
107 };
108
109 $ptable = $ui_factory->table()->presentation(
110 'Presentation Table with Alignments', //title
111 $view_controls,
112 $mapping_closure
113 )
114 ->withEnvironment(environment());
115
116
117 //apply data to table and render
118 return $renderer->render([
119 $modal,
120 $ptable->withData($data)
121 ]);
122}

References $data, $DIC, ILIAS\UI\examples\Layout\Page\Standard\$refinery, $renderer, ILIAS\UI\examples\Layout\Page\Standard\$request_wrapper, ILIAS\UI\examples\Table\Presentation\environment(), ILIAS\UI\examples\Table\Presentation\included_data1(), and ILIAS\GlobalScreen\Scope\Footer\Factory\withAction().

+ Here is the call graph for this function:

◆ environment()

ILIAS\UI\examples\Table\Presentation\environment ( )

Definition at line 124 of file base1.php.

125{
126 $totals = function ($answers) {
127 $ret = '<div class="example_block content"><table>';
128 $ret .= '<tr><td></td>'
129 . '<td>Amount</td>'
130 . '<td style="padding-left: 10px;">Proportion</td></tr>';
131
132 foreach ($answers as $answer) {
133 $ret .= '<tr>'
134 . '<td style="padding-right: 10px;">' . $answer['title'] . '</td>'
135 . '<td style="text-align:right">' . $answer['amount'] . '</td>'
136 . '<td style="text-align:right">' . $answer['proportion'] . '%</td>'
137 . '</tr>';
138 }
139
140 $ret .= '</table></div>';
141 return $ret;
142 };
143
144 $chart = function ($answers) {
145 $ret = '<div class="example_block content"><table style="width:100%">';
146 foreach ($answers as $answer) {
147 $ret .= '<tr style="border-bottom: 1px solid black;">'
148 . '<td style="width: 200px;">'
149 . $answer['title']
150 . '</td><td>'
151 . '<div style="background-color:grey; height:20px; width:' . $answer['proportion'] . '%;"></div>'
152 . '</td></tr>';
153 }
154 $ret .= '</table></div>';
155 return $ret;
156 };
157
158 $stats = function ($answers) {
159 global $DIC;
160 $ui_factory = $DIC->ui()->factory();
161 $ui_renderer = $DIC->ui()->renderer();
162
163 $icon = $ui_factory->symbol()->icon()->custom('assets/images/standard/icon_ques.svg', '');
164
165 $ret = '<div class="example_block stats">';
166 $ret .= '<h5>' . $ui_renderer->render($icon) . ' ' . $answers['type'] . '</h5>';
167 $ret .= '<span class="c-stats--title">Beantwortet:</span> '
168 . $answers['stats']['total'] . '<br>'
169 . '<span class="c-stats--title">Übersprungen:</span> '
170 . $answers['stats']['skipped'] . '<br>'
171 . '<span class="c-stats--title">Häufigste Antwort:</span> '
172 . $answers['answers'][$answers['stats']['most_common']]['title'] . '<br>'
173 . '<span class="c-stats--title">Anzahl Häufigste:</span> '
174 . $answers['stats']['most_common_total'] . '<br>'
175 . '<span class="c-stats--title">Median:</span> '
176 . $answers['answers'][$answers['stats']['median']]['title'];
177 $ret .= '</div>';
178 return $ret;
179 };
180
181 return array(
182 'totals' => $totals,
183 'chart' => $chart,
184 'stats' => $stats
185 );
186}

References $DIC.

Referenced by ILIAS\Setup\ObjectiveIterator\__construct(), ILIAS\UI\examples\Table\Presentation\base1(), ILIAS\Setup\ObjectiveIterator\setEnvironment(), ILIAS\Tests\Setup\ArrayEnvironmentTest\setUp(), ILIAS\Tests\Setup\ArrayEnvironmentTest\testConfigFor(), ILIAS\Tests\Setup\ArrayEnvironmentTest\testDuplicateConfigFor(), ILIAS\Tests\Setup\ArrayEnvironmentTest\testGetResource(), ILIAS\Tests\Setup\ArrayEnvironmentTest\testHasConfigFor(), ILIAS\Tests\Setup\ArrayEnvironmentTest\testSetResourceRejectsDuplicates(), ILIAS\Tests\Setup\ArrayEnvironmentTest\testWithResource(), and ILIAS\Tests\Setup\ArrayEnvironmentTest\testWrongConfigId().

+ Here is the caller graph for this function:

◆ included_data()

ILIAS\UI\examples\Table\Presentation\included_data ( )

Definition at line 117 of file base.php.

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}

Referenced by ILIAS\UI\examples\Table\Presentation\base().

+ Here is the caller graph for this function:

◆ included_data1()

ILIAS\UI\examples\Table\Presentation\included_data1 ( )

Definition at line 188 of file base1.php.

189{
190 return array(
191 array(
192 'type' => 'Single Choice Frage',
193 'question_title' => 'Belastbarkeit',
194 'question_txt' => 'Wie ausgeprägt ist die Belastbarkeit des / der Auszubildenden?',
195 'answers' => array(
196 array('title' => 'weniger ausgeprägt', 'amount' => 2, 'proportion' => 20),
197 array('title' => 'teilweise ausgeprägt', 'amount' => 0, 'proportion' => 0),
198 array('title' => 'ausgeprägt', 'amount' => 6, 'proportion' => 60),
199 array('title' => 'deutlich ausgeprägt', 'amount' => 1, 'proportion' => 10),
200 array('title' => 'stark ausgeprägt', 'amount' => 0, 'proportion' => 0),
201 array('title' => 'sehr stark ausgeprägt', 'amount' => 0, 'proportion' => 0),
202 array('title' => 'übermäßig ausgeprägt', 'amount' => 1, 'proportion' => 10)
203 ),
204 'stats' => array(
205 'total' => 10,
206 'skipped' => 2,
207 'most_common' => 2,
208 'most_common_total' => 6,
209 'median' => 2,
210 )
211 ),
212
213 array(
214 'type' => 'Single Choice Frage',
215 'question_title' => 'Dialogfähigkeit, Kundenorientierung, Beratungsfähigkeit',
216 'question_txt' => 'Wie ausgeprägt ist die Dialogfähigkeit, Kundenorientierung und Beratungsfähigkeit des / der Auszubildenden?',
217 'answers' => array(
218 array('title' => 'weniger ausgeprägt', 'amount' => 0, 'proportion' => 0),
219 array('title' => 'teilweise ausgeprägt', 'amount' => 1, 'proportion' => 100),
220 array('title' => 'ausgeprägt', 'amount' => 0, 'proportion' => 0),
221 array('title' => 'deutlich ausgeprägt', 'amount' => 0, 'proportion' => 0),
222 array('title' => 'stark ausgeprägt', 'amount' => 0, 'proportion' => 0),
223 array('title' => 'sehr stark ausgeprägt', 'amount' => 0, 'proportion' => 0),
224 array('title' => 'übermäßig ausgeprägt', 'amount' => 0, 'proportion' => 0)
225 ),
226 'stats' => array(
227 'total' => 1,
228 'skipped' => 0,
229 'most_common' => 1,
230 'most_common_total' => 1,
231 'median' => 1,
232 )
233 ),
234 );
235}

Referenced by ILIAS\UI\examples\Table\Presentation\base1().

+ Here is the caller graph for this function:

◆ without_data()

ILIAS\UI\examples\Table\Presentation\without_data ( )

description: > Example showing a presentation table without any data and hence no entries, which will automatically display an according message.

expected output: > Instead of several rows with expander glyphs, ILIAS shows a message "No records".

Viewcontrols are still there but have no effect.

Definition at line 37 of file without_data.php.

37 : string
38{
39 global $DIC;
40
41 $factory = $DIC->ui()->factory();
42 $renderer = $DIC->ui()->renderer();
43
44 $minimal_mapping = static fn(
45 PresentationRow $row,
46 mixed $record,
47 Factory $ui_factory,
48 mixed $environment
49 ): PresentationRow => $row;
50
51 $table = $factory->table()->presentation(
52 'Empty Presentation Table',
53 [$factory->viewControl()->mode(['All' => '#'], '')],
54 $minimal_mapping
55 );
56
57 // Note: this is an optional call, it should merely demonstrate that we have
58 // an empty table.
59 $table->withData([]);
60
61 return $renderer->render($table);
62}
This describes a Row used in Presentation Table.
This is how the factory for UI elements looks.
Definition: Factory.php:38

References $DIC, and $renderer.