ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\UI\examples\Launcher\Inline Namespace Reference

Functions

 base ()
 

expected output: > ILIAS shows the rendered Component. More...

 
 with_fields ()
 

expected output: > ILIAS shows the rendered Component. More...

 

Function Documentation

◆ base()

ILIAS\UI\examples\Launcher\Inline\base ( )


expected output: > ILIAS shows the rendered Component.


Definition at line 29 of file base.php.

References $DIC, $renderer, and $url.

30 {
31  global $DIC;
32  $ui_factory = $DIC->ui()->factory();
33  $data_factory = new \ILIAS\Data\Factory();
34  $renderer = $DIC->ui()->renderer();
35  $spacer = $ui_factory->divider()->horizontal();
36 
37  $url = $data_factory->uri($DIC->http()->request()->getUri()->__toString());
38 
39  $target = $data_factory->link('Start Test', $url);
40  $launcher = $ui_factory->launcher()
41  ->inline($target)
42  ->withDescription('<p>You will have <strong>90 minutes to answer all questions.</strong></p><p>Please make sure that you have the time to complete the test and that you will be undisturbed. There is no way for you to pause or re-take this test.</p>');
43 
44  $icon = $ui_factory->symbol()->icon()->standard('ps', '', 'large');
45 
46  $status_message = $ui_factory->messageBox()->failure("You have to complete all preconditions first.")
47  ->withLinks([
48  $ui_factory->link()->standard("Do this first", "#"),
49  $ui_factory->link()->standard("And this is mandatory, too", "#")
50  ]);
51 
52  $launcher2 = $launcher
53  ->withDescription('<p>This course goes into advanced knowledge for students preparing for the final exam. You should have a firm understanding of the basics before enrolling.</p>')
54  ->withButtonLabel('Course is locked', false)
55  ->withStatusIcon($icon)
56  ->withStatusMessageBox($status_message);
57 
58  $target = $data_factory->link('Continue Survey', $url);
59  $progressmeter = $ui_factory->chart()->progressMeter()->mini(100, 50, 100);
60  $status_message = $ui_factory->messageBox()->info("There are still 8 questions left in the survey.");
61  $launcher3 = $ui_factory->launcher()
62  ->inline($target)
63  ->withStatusIcon($progressmeter)
64  ->withStatusMessageBox($status_message)
65  ->withDescription('');
66 
67  $target = $data_factory->link('Repeat Test', $url);
68  $status_message = $ui_factory->messageBox()->success("You have completed this test already. If you want you can try it again.");
69  $icon = $ui_factory->symbol()->icon()->standard('task', '', 'large');
70  $launcher4 = $ui_factory->launcher()
71  ->inline($target)
72  ->withStatusIcon($icon)
73  ->withStatusMessageBox($status_message);
74 
75  return $renderer->render([
76  $launcher,
77  $spacer,
78  $launcher2,
79  $spacer,
80  $launcher3,
81  $spacer,
82  $launcher4
83  ]);
84 }
$renderer
$url
Definition: shib_logout.php:68
global $DIC
Definition: shib_login.php:26

◆ with_fields()

ILIAS\UI\examples\Launcher\Inline\with_fields ( )


expected output: > ILIAS shows the rendered Component.

In this example, the Launcher is configured with inputs;

a Modal containing a Form will open upon clicking the launch-button.

Definition at line 35 of file with_fields.php.

References $DIC, $renderer, $url, ILIAS\Data\Result\isOK(), and ILIAS\Data\Result\value().

36 {
37  global $DIC;
38  $ui_factory = $DIC['ui.factory'];
39  $renderer = $DIC['ui.renderer'];
40  $data_factory = new \ILIAS\Data\Factory();
41  $request = $DIC->http()->request();
42  $ctrl = $DIC['ilCtrl'];
43  $spacer = $ui_factory->divider()->horizontal();
44 
45  $url = $data_factory->uri($DIC->http()->request()->getUri()->__toString());
46  $url = $url->withParameter('launcher_redirect', '');
47 
48  //A Launcher with a checkbox-form
49  $description = '<p>Before you can join this group, you will have to accept the terms and conditions</p>';
50  $instruction = $ui_factory->messageBox()->info('Accept the conditions.');
51  $group = $ui_factory->input()->field()->group([
52  $ui_factory->input()->field()->checkbox('Understood', 'ok')
53  ]);
54  $evaluation = function (Result $result, Launcher &$launcher) use ($ctrl, $ui_factory) {
55  if ($result->isOK() && $result->value()[0]) {
56  $ctrl->redirectToURL(
57  (string) $launcher->getTarget()->getURL()->withParameter('launcher_redirect', 'terms accepted (' . $launcher->getButtonLabel() . ')')
58  );
59  }
60  $launcher = $launcher->withStatusMessageBox($ui_factory->messageBox()->failure('You must accept the conditions.'));
61  };
62 
63  $target = $data_factory->link('Join Group', $url->withParameter('launcher_id', 'l1'));
64 
65  $launcher = $ui_factory->launcher()
66  ->inline($target)
67  ->withDescription($description)
68  ->withInputs($group, $evaluation, $instruction);
69 
70  if (array_key_exists('launcher_id', $request->getQueryParams()) && $request->getQueryParams()['launcher_id'] === 'l1') {
71  $launcher = $launcher->withRequest($request);
72  }
73 
74  //A Launcher with icon
75  $icon = $ui_factory->symbol()->icon()->standard('auth', 'authentification needed', 'large');
76  $description = '<p>Before you can take the survey, you have to agree to our terms and conditions.</p>';
77  $target = $data_factory->link('Take Survey', $url->withParameter('launcher_id', 'l2'));
78  $launcher2 = $ui_factory->launcher()
79  ->inline($target)
80  ->withStatusIcon($icon)
81  ->withButtonLabel('Take Survey')
82  ->withDescription($description)
83  ->withInputs($group, $evaluation);
84 
85  if (array_key_exists('launcher_id', $request->getQueryParams()) && $request->getQueryParams()['launcher_id'] === 'l2') {
86  $launcher2 = $launcher2->withRequest($request);
87  }
88 
89 
90  //A Launcher with password field
91  $icon = $ui_factory->symbol()->icon()->standard('ps', 'authentification needed', 'large');
92  $status_message = $ui_factory->messageBox()->info("You will be asked for your personal passcode when you start the test.");
93  $instruction = $ui_factory->messageBox()->info('Fill the form; use password "ilias" to pass');
94  $group = $ui_factory->input()->field()->group([
95  $ui_factory->input()->field()->password('pwd', 'Password')
96  ]);
97  $evaluation = function (Result $result, Launcher &$launcher) use ($ctrl, $ui_factory) {
98  if ($result->isOK() && $result->value()[0]->toString() === 'ilias') {
99  $ctrl->redirectToURL(
100  (string) $launcher->getTarget()->getURL()->withParameter('launcher_redirect', 'password protected')
101  );
102  }
103  $launcher = $launcher->withStatusMessageBox($ui_factory->messageBox()->failure('nope. wrong pass.'));
104  };
105 
106  $target = $data_factory->link('Begin Exam', $url->withParameter('launcher_id', 'l3'));
107  $launcher3 = $ui_factory->launcher()
108  ->inline($target)
109  ->withDescription('')
110  ->withInputs($group, $evaluation, $instruction)
111  ->withStatusIcon($icon)
112  ->withStatusMessageBox($status_message)
113  ->withModalSubmitLabel('Begin Exam')
114  ->withModalCancelLabel('Cancel')
115  ;
116 
117  if (array_key_exists('launcher_id', $request->getQueryParams()) && $request->getQueryParams()['launcher_id'] === 'l3') {
118  $launcher3 = $launcher3->withRequest($request);
119  }
120 
121 
122  $result = "not submitted or wrong pass";
123 
124  if (array_key_exists('launcher_redirect', $request->getQueryParams())
125  && $v = $request->getQueryParams()['launcher_redirect']
126  ) {
127  $result = "<b>sucessfully redirected ($v)</b>";
128  }
129 
130  return $result . "<hr/>" . $renderer->render([
131  $launcher,
132  $spacer,
133  $launcher2,
134  $spacer,
135  $launcher3
136  ]);
137 }
$renderer
$url
Definition: shib_logout.php:68
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function: