ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
with_all_view_controls.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
16 function with_all_view_controls(): string
17 {
18  global $DIC;
19  $f = $DIC->ui()->factory();
20  $renderer = $DIC->ui()->renderer();
21  $refinery = $DIC->refinery();
22  $request_wrapper = $DIC->http()->wrapper()->query();
23 
24  $url = $DIC->http()->request()->getRequestTarget();
25 
26  $actions = $f->dropdown()->standard([
27  $f->button()->shy("ILIAS", "https://www.ilias.de"),
28  $f->button()->shy("GitHub", "https://www.github.com")
29  ]);
30  $current_sortation = 'abc';
31  if ($request_wrapper->has('sort')) {
32  $current_sortation = $request_wrapper->retrieve('sort', $refinery->kindlyTo()->string());
33  }
34 
35  $sortation_options = [
36  'abc' => 'Sort by Alphabet',
37  'date' => 'Sort by Date',
38  'location' => 'Sort by Location'
39  ];
40  $sortation = $f->viewControl()->sortation($sortation_options, $current_sortation)
41  ->withTargetURL($url, "sort");
42 
43  $current_presentation = 'list';
44  if ($request_wrapper->has('mode')) {
45  $current_presentation = $request_wrapper->retrieve('mode', $refinery->kindlyTo()->string());
46  }
47  $presentation_options = [
48  'list' => 'List View',
49  'tile' => 'Tile View'
50  ];
51  $modes = $f->viewControl()->mode(
52  array_reduce(
53  array_keys($presentation_options),
54  static function ($carry, $item) use ($presentation_options, $url) {
55  $carry[$presentation_options[$item]] = "$url&mode=$item";
56  return $carry;
57  },
58  []
59  ),
60  'Presentation Mode'
61  )
62  ->withActive($presentation_options[$current_presentation]);
63 
64  $current_page = 0;
65  if ($request_wrapper->has('page')) {
66  $current_page = $request_wrapper->retrieve('page', $refinery->kindlyTo()->int());
67  }
68  $pagination = $f->viewControl()->pagination()
69  ->withTargetURL($url, "page")
70  ->withTotalEntries(98)
71  ->withPageSize(10)
72  ->withCurrentPage($current_page);
73 
74  $view_controls = [
75  $sortation,
76  $modes,
77  $pagination
78  ];
79 
80  if ($current_presentation === 'list') {
81  $item1 = $f->item()->standard("Item Title")
82  ->withActions($actions)
83  ->withProperties([
84  "Origin" => "Course Title 1",
85  "Last Update" => "24.11.2011",
86  "Location" => "Room 123, Main Street 44, 3012 Bern"
87  ])
88  ->withDescription(
89  "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
90  );
91 
92  $item2 = $f->item()->standard("Item 2 Title")
93  ->withActions($actions)
94  ->withDescription(
95  "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
96  );
97 
98  $item3 = $f->item()->standard("Item 3 Title")
99  ->withActions($actions)
100  ->withDescription(
101  "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
102  );
103  } else {
104  $image = $f->image()->responsive(
105  "./assets/images/logo/HeaderIcon.svg",
106  "Thumbnail Example"
107  );
108  $content = $f->listing()->descriptive(
109  [
110  "Entry 1" => "Some text",
111  "Entry 2" => "Some more text",
112  ]
113  );
114  $item1 = $item2 = $item3 = $f->card()->standard("Item Title", $image)
115  ->withSections([$content]);
116  }
117 
118  $std_list = $f->panel()->secondary()->legacy(
119  "List Title",
120  $f->legacy(
121  $renderer->render([
122  $f->item()->group("Subtitle 1", [
123  $item1,
124  $item2
125  ]),
126  $f->item()->group("Subtitle 2", [
127  $item3
128  ])
129  ])
130  )
131  )
132  ->withActions($actions)
133  ->withViewControls($view_controls);
134 
135  return $renderer->render($std_list);
136 }
$renderer
$url
Definition: shib_logout.php:63
global $DIC
Definition: shib_login.php:25
with_all_view_controls()
description: > Example for rendering a secondary legacy panel listing with all view controls...