27 return $this->
renderMode($component, $default_renderer);
46 $active = $component->getActive();
48 $activate_first_item =
true;
51 foreach ($component->getLabelledActions() as $label =>
$action) {
52 $tpl->setVariable(
"ARIA", $this->
txt($component->getAriaLabel()));
53 $tpl->setVariable(
"ROLE", self::MODE_ROLE);
55 $tpl->setCurrentBlock(
"view_control");
58 if ($activate_first_item) {
59 $tpl->setVariable(
"BUTTON", $default_renderer->render(
$f->button()->standard($label,
$action)->WithUnavailableAction()->withAriaLabel($label)->withAriaChecked()));
60 $activate_first_item =
false;
61 } elseif ($active == $label) {
62 $tpl->setVariable(
"BUTTON", $default_renderer->render(
$f->button()->standard($label,
$action)->withUnavailableAction()->withAriaLabel($label)->withAriaChecked()));
64 $tpl->setVariable(
"BUTTON", $default_renderer->render(
$f->button()->standard($label,
$action)->withAriaLabel($label)));
66 $tpl->parseCurrentBlock();
79 $tpl->setVariable(
"BUTTON", $default_renderer->render($component->getSelectorButton()));
97 $uptype = strtoupper(
$type);
99 $action = $component->getAction();
101 if ($component->isActive()) {
102 $tpl->setCurrentBlock(
$type .
"_with_href");
104 $tpl->parseCurrentBlock();
118 $component = $component->withResetSignals();
119 $triggeredSignals = $component->getTriggeredSignals();
120 if ($triggeredSignals) {
121 $internal_signal = $component->getSelectSignal();
122 $signal = $triggeredSignals[0]->getSignal();
123 $options = json_encode($signal->getOptions());
125 $component = $component->withOnLoadCode(
function (
$id) use ($internal_signal, $signal) {
126 return "$(document).on('{$internal_signal}', function(event, signalData) { 127 il.UI.viewcontrol.sortation.onInternalSelect(event, signalData, '{$signal}', '{$id}'); 138 $options = $component->getOptions();
139 $init_label = $component->getLabel();
141 foreach (
$options as $val => $label) {
142 if ($triggeredSignals) {
143 $shy =
$f->button()->shy($label, $val)->withOnClick($internal_signal);
145 $url = $component->getTargetURL();
146 $url .= (strpos(
$url,
'?') ===
false) ?
'?' :
'&';
147 $url .= $component->getParameterName() .
'=' . $val;
148 $shy =
$f->button()->shy($label,
$url);
153 $dd =
$f->dropdown()->standard($items)
154 ->withLabel($init_label);
156 $tpl->setVariable(
'SORTATION_DROPDOWN', $default_renderer->render($dd));
166 $component = $component->withResetSignals();
167 $triggeredSignals = $component->getTriggeredSignals();
168 if ($triggeredSignals) {
169 $internal_signal = $component->getInternalSignal();
170 $signal = $triggeredSignals[0]->getSignal();
171 $component = $component->withOnLoadCode(
function (
$id) use ($internal_signal, $signal) {
172 return "$(document).on('{$internal_signal}', function(event, signalData) { 173 il.UI.viewcontrol.pagination.onInternalSelect(event, signalData, '{$signal}', '{$id}'); 183 $chunk_options = array();
184 foreach ($range as $entry) {
186 if ((
int) $entry === $component->getCurrentPage()) {
187 $shy = $shy->withUnavailableAction();
189 $chunk_options[] = $shy;
192 if ($component->getDropdownAt() == null ||
193 $component->getDropdownAt() > $component->getNumberOfPages()) {
194 foreach ($chunk_options as $entry) {
195 $tpl->setCurrentBlock(
"entry");
196 $tpl->setVariable(
'BUTTON', $default_renderer->render($entry));
197 $tpl->parseCurrentBlock();
202 $dd =
$f->dropdown()->standard($chunk_options)->withLabel(
203 (
string) ($component->getCurrentPage() + 1)
205 $tpl->setCurrentBlock(
"entry");
206 $tpl->setVariable(
'BUTTON', $default_renderer->render($dd));
207 $tpl->parseCurrentBlock();
210 if ($component->getMaxPaginationButtons()) {
227 if (!$component->getMaxPaginationButtons()) {
229 $stop = max($component->getNumberOfPages() - 1, 0);
232 $start = (int) ($component->getCurrentPage() - floor($component->getMaxPaginationButtons() / 2));
235 $stop =
$start + $component->getMaxPaginationButtons() - 1;
237 if ($stop > $component->getNumberOfPages() - 1) {
238 $stop = max($component->getNumberOfPages() - 1, 0);
239 $start = $stop - $component->getMaxPaginationButtons();
240 $start = max($start, 0);
243 return range(
$start, $stop);
259 $label = (string) ($val + 1);
262 if ($component->getTriggeredSignals()) {
263 $shy =
$f->button()->shy($label, (
string) $val)->withOnClick($component->getInternalSignal());
265 $url = $component->getTargetURL();
266 if (strpos(
$url,
'?') ===
false) {
267 $url .=
'?' . $component->getParameterName() .
'=' . $val;
272 $params[$component->getParameterName()] = $val;
275 $shy =
$f->button()->shy($label,
$url);
291 $prev = max(0, $component->getCurrentPage() - 1);
292 $next = $component->getCurrentPage() + 1;
296 if ($component->getTriggeredSignals()) {
297 $back =
$f->glyph()->back(
'')->withOnClick($component->getInternalSignal());
298 $forward =
$f->glyph()->next(
'')->withOnClick($component->getInternalSignal());
300 $url = $component->getTargetURL();
301 if (strpos(
$url,
'?') ===
false) {
302 $url_prev =
$url .
'?' . $component->getParameterName() .
'=' . $prev;
303 $url_next =
$url .
'?' . $component->getParameterName() .
'=' . $next;
309 $params[$component->getParameterName()] = $prev;
311 $params[$component->getParameterName()] = $next;
315 $back =
$f->glyph()->back($url_prev);
316 $forward =
$f->glyph()->next($url_next);
319 if ($component->getCurrentPage() === 0) {
320 $back = $back->withUnavailableAction();
322 if ($component->getCurrentPage() >= $component->getNumberOfPages() - 1) {
323 $forward = $forward->withUnavailableAction();
326 $tpl->setVariable(
'PREVIOUS', $default_renderer->render($back));
327 $tpl->setVariable(
'NEXT', $default_renderer->render($forward));
342 if (!in_array(0, $range)) {
344 $tpl->setVariable(
'FIRST', $default_renderer->render($shy));
346 $last = max($component->getNumberOfPages() - 1, 0);
347 if (!in_array($last, $range)) {
349 $tpl->setVariable(
'LAST', $default_renderer->render($shy));
359 parent::registerResources($registry);
360 $registry->register(
'./src/UI/templates/js/ViewControl/sortation.js');
361 $registry->register(
'./src/UI/templates/js/ViewControl/pagination.js');
369 $tpl->setCurrentBlock($block);
370 $tpl->setVariable($template_var,
$id);
371 $tpl->parseCurrentBlock();
renderSection(Component\ViewControl\Section $component, RendererInterface $default_renderer)
renderSortation(Component\ViewControl\Sortation $component, RendererInterface $default_renderer)
render(Component\Component $component, RendererInterface $default_renderer)
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
setPaginationBrowseControls(Component\ViewControl\Pagination $component, RendererInterface $default_renderer, &$tpl)
Add back/next-glyphs to the template for left/right browsing in pagination.
if(!array_key_exists('StateId', $_REQUEST)) $id
getComponentInterfaceName()
getPaginationShyButton($val, Component\ViewControl\Pagination $component, $label='')
renderSectionButton(Component\Button\Button $component, $tpl, $type)
txt($id)
Get a text from the language file.
getPaginationRange(Component\ViewControl\Pagination $component)
Get the range of pagintaion-buttons to show.
registerResources(\ILIAS\UI\Implementation\Render\ResourceRegistry $registry)
renderMode(Component\ViewControl\Mode $component, RendererInterface $default_renderer)
maybeRenderId(Component\Component $component, $tpl, $block, $template_var)
setPaginationFirstLast(Component\ViewControl\Pagination $component, $range, RendererInterface $default_renderer, &$tpl)
Add quick-access to first/last pages in pagination.
renderPagination(Component\ViewControl\Pagination $component, RendererInterface $default_renderer)
getUIFactory()
Get a UI factory.
getTemplate($name, $purge_unfilled_vars, $purge_unused_blocks)
Get template of component this renderer is made for.
Base class for all component renderers.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.