ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\UI\examples\Navigation\Sequence Namespace Reference

Functions

 base ()
 

Function Documentation

◆ base()

ILIAS\UI\examples\Navigation\Sequence\base ( )

description: > Base example for rendering a sequence navigation.

expected output: > ILIAS shows a group of buttons and different placeholders for the segment. The navigation buttons are "back" and "next". At first, the "back" button is inactive until the next button was clicked. On the last segment, the "next" button will be inactive. A view control allows the user to select chunks of data, and an additional button (without real function) is labeled "a global action". On some segments there is an additional button labeled "a segment action <h2>for pos x". In this example, these buttons don't trigger a function.

Definition at line 47 of file base.php.

48{
49 global $DIC;
50 $f = $DIC['ui.factory'];
51 $r = $DIC['ui.renderer'];
52 $df = new \ILIAS\Data\Factory();
53 $refinery = $DIC['refinery'];
54 $request = $DIC->http()->request();
55
56 $binding = new class ($f, $r) implements SegmentRetrieval {
57 private array $seq_data;
58
59 public function __construct(
60 protected UIFactory $f,
61 protected UIRenderer $r
62 ) {
63 $this->seq_data = [
64 ['c0', 'pos 1', '<div style="width: 100%;
65 height: 500px;
66 background-color: #b8d7ea;
67 display: flex;
68 align-items: center;
69 justify-content: center;">
70 placeholder for the segment at position 1</div>'],
71 ['c0', 'pos 2', '<div style="width: 100%;
72 height: 700px;
73 background-color: #f6d9a1;
74 display: flex;
75 align-items: center;
76 justify-content: center;">
77 placeholder for the segment at position 2</div>'],
78 ['c1', 'pos 3', 'the segment at position 3'],
79 ['c2', 'pos 4', 'the segment at position 4'],
80 ['c1', 'pos 5', 'the segment at position 5'],
81 ];
82 }
83
84 public function getAllPositions(
85 ServerRequestInterface $request,
86 mixed $viewcontrol_values,
87 mixed $filter_values,
88 ): array {
89 $chunks = $viewcontrol_values['chunks'] ?? [];
90 $chunks[] = 'c0';
91 return array_values(
92 array_filter(
93 $this->seq_data,
94 fn($posdata) => in_array($posdata[0], $chunks)
95 )
96 );
97 }
98
99 public function getSegment(
100 ServerRequestInterface $request,
101 mixed $position_data,
102 mixed $viewcontrol_values,
103 mixed $filter_values,
104 ): Segment {
105 list($chunk, $title, $data) = $position_data;
106
107 $segment = $this->f->legacy()->segment($title, $data);
108
109 if ($chunk === 'c0') {
110 $segment = $segment->withSegmentActions(
111 $this->f->button()->standard('a segment action for ' . $title, '#')
112 );
113 }
114 return $segment;
115 }
116 };
117
118 $viewcontrols = $f->input()->container()->viewControl()->standard([
119 $f->input()->viewControl()->fieldSelection(
120 [
121 'c1' => 'chunk 1',
122 'c2' => 'chunk 2',
123 ],
124 'shown chunks',
125 'apply'
126 )
127 ->withAdditionalTransformation($refinery->custom()->transformation(
128 fn($v) => ['chunks' => $v]
129 ))
130 ])
131 ->withAdditionalTransformation(
132 $refinery->custom()->transformation(fn($v) => array_shift($v))
133 );
134
135 $global_actions = [
136 $f->button()->standard('a global action', '#')
137 ];
138
139 $sequence = $f->navigation()->sequence($binding)
140 ->withViewControls($viewcontrols)
141 ->withId('example')
142 ->withActions($global_actions)
143 ->withRequest($request);
144
145 $out = [];
146 $out[] = $sequence;
147
148 return $r->render($out);
149}
$out
Definition: buildRTE.php:24
withSegmentActions(Button\Standard ... $actions)
Segments MAY add actions to the sequence.
The SegmentRetrieval defines available stops for the sequence and builds it's segments.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $data, $DIC, Vendor\Package\$f, $out, ILIAS\UI\examples\Layout\Page\Standard\$refinery, and ILIAS\__construct().

+ Here is the call graph for this function: