ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ItemBuilderUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\UI\Component\Button\Standard as StandardButton;
25
27{
28 protected \ilCtrl $ctrl;
30 protected \ILIAS\UI\Factory $ui_factory;
31
32 public function __construct(
36 ) {
37 $this->ui_factory = $ui_factory;
38 $this->prop_builder = $prop_builder;
39 $this->ctrl = $ctrl;
40 }
41
42 protected function addPropertyToItemProperties(array &$props, ?array $prop): void
43 {
44 if ($prop) {
45 $props[$prop["prop"]] = $prop["val"];
46 }
47 }
48
49 public function getItem(Assignment $ass, int $user_id): \ILIAS\UI\Component\Item\Standard
50 {
52 $pb->build($ass, $user_id);
53
54 $props = [];
55 $this->addPropertyToItemProperties($props, $pb->getHeadProperty($pb::PROP_DEADLINE));
56 $this->addPropertyToItemProperties($props, $pb->getHeadProperty($pb::PROP_REQUIREMENT));
57 $this->addPropertyToItemProperties($props, $pb->getHeadProperty($pb::PROP_SUBMISSION));
58 $this->addPropertyToItemProperties($props, $pb->getHeadProperty($pb::PROP_TYPE));
59 $this->addPropertyToItemProperties($props, $pb->getHeadProperty($pb::PROP_GRADING));
60 $this->addPropertyToItemProperties($props, $pb->getHeadProperty($pb::PROP_MARK));
61 foreach ($pb->getAdditionalHeadProperties() as $p) {
62 $this->addPropertyToItemProperties($props, $p);
63 }
64
65 // actions
66 $actions = [];
67 $main_action = null;
68 foreach ($pb->getSections() as $sec => $txt) {
69 if ($act = $pb->getMainAction($sec)) {
70 $main_action = $this->ui_factory->button()->standard(
71 $act->getLabel(),
72 $act->getAction()
73 );
74 }
75 }
76
77 foreach ($pb->getSections(true, true) as $sec => $txt) {
78 foreach ($pb->getActions($sec) as $act) {
79 $actions[] = $act;
80 }
81 }
82
83
84 $this->ctrl->setParameterByClass(\ilAssignmentPresentationGUI::class, "ass_id", $ass->getId());
85 $title = $this->ui_factory->link()->standard(
86 $ass->getTitle(),
87 $this->ctrl->getLinkTargetByClass(\ilAssignmentPresentationGUI::class, "")
88 );
89 $item = $this->ui_factory->item()->standard(
90 $title
91 )->withProperties($props)->withLeadText($pb->getLeadText() . " ");
92 if (count($actions) > 0) {
93 $ks_actions = [];
94 foreach ($actions as $act) {
95 if ($act instanceof StandardButton) {
96 $ks_actions[] = $this->ui_factory->button()->shy(
97 $act->getLabel(),
98 $act->getAction()
99 );
100 } else {
101 $ks_actions[] = $act;
102 }
103 }
104 $item = $item->withActions($this->ui_factory->dropdown()->standard($ks_actions));
105 }
106 if ($main_action) {
107 $item = $item->withMainAction($main_action);
108 }
109 $this->ctrl->setParameterByClass(\ilAssignmentPresentationGUI::class, "ass_id", null);
110 return $item;
111 }
112
113
114}
Builds data types.
Definition: Factory.php:36
addPropertyToItemProperties(array &$props, ?array $prop)
getItem(Assignment $ass, int $user_id)
PropertyAndActionBuilderUI $prop_builder
__construct(PropertyAndActionBuilderUI $prop_builder, \ILIAS\UI\Factory $ui_factory, \ilCtrl $ctrl)
Definition: UI.php:24
Class ilCtrl provides processing control methods.
$txt
Definition: error.php:31
This describes a standard button.
Definition: Standard.php:27
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.