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