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