ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilWorkspaceContentGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 private object $object_gui;
28 private array $shared_objects;
29 protected int $current_node;
30 protected bool $admin;
32 protected \ILIAS\DI\UIServices $ui;
33 protected ilLanguage $lng;
34 protected ilObjUser $user;
36 protected ilCtrl $ctrl;
38
39 public function __construct(
40 object $object_gui,
41 int $node_id,
42 bool $admin,
44 \ILIAS\DI\UIServices $ui,
50 ) {
51 $this->current_node = $node_id;
52 $this->admin = $admin;
53 $this->access_handler = $access_handler;
54 $this->object_gui = $object_gui;
55 $this->ui = $ui;
56 $this->lng = $lng;
57 $this->user = $user;
58 $this->obj_definition = $obj_definition;
59 $this->ctrl = $ctrl;
60 $this->user_folder_settings = $user_folder_settings;
61
62 $this->folder_sorting = new ilWorkspaceFolderSorting();
63 }
64
65 public function render(): string
66 {
67 $html = "";
68 $first = true;
69 foreach ($this->getItems() as $i) {
70 if ($first) {
71 $first = false;
72 } else {
73 $html .= $this->ui->renderer()->render($this->ui->factory()->divider()->horizontal());
74 }
75 $html .= $this->getItemHTML($i);
76 }
77
78 if ($this->admin) {
79 $tpl = new ilTemplate("tpl.admin_container.html", true, true, "components/ILIAS/WorkspaceFolder");
80 $tpl->setVariable("ITEMS", $html);
81 $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
82 $html = $tpl->get();
83 }
84
85
86 // output sortation
87 $tree = new ilWorkspaceTree($this->user->getId());
88 $parent_id = $tree->getParentId($this->object_gui->getRefId());
89 $parent_effective = ($parent_id > 0)
90 ? $this->user_folder_settings->getEffectiveSortation($parent_id)
91 : 0;
92 $selected = $this->user_folder_settings->getSortation($this->object_gui->getObject()->getId());
93 $sort_options = $this->folder_sorting->getOptionsByType($this->object_gui->getObject()->getType(), $selected, $parent_effective);
94 $sortation = $this->ui->factory()->viewControl()->sortation($sort_options, $selected)
95 ->withTargetURL($this->ctrl->getLinkTarget($this->object_gui, "setSortation"), 'sortation');
96
97 if ($first) {
98 return "";
99 }
100
101 $leg = $this->ui->factory()->legacy()->content($html);
102
103 $panel = $this->ui->factory()->panel()->standard($this->lng->txt("content"), [$leg]);
104
105 if (method_exists($panel, "withViewControls")) {
106 $panel = $panel->withViewControls(array($sortation));
107 }
108
109
110
111 return $this->ui->renderer()->render($panel);
112 }
113
114 protected function getItems(): array
115 {
117
118 $tree = new ilWorkspaceTree($user->getId());
119 $nodes = $tree->getChilds($this->current_node, "title");
120
121 if (sizeof($nodes)) {
123 foreach ($nodes as $node) {
124 $preloader->addItem($node["obj_id"], $node["type"]);
125 }
126 $preloader->preload();
127 unset($preloader);
128 }
129
130 $this->shared_objects = $this->access_handler->getObjectsIShare();
131
132 $nodes = $this->folder_sorting->sortNodes($nodes, $this->user_folder_settings->getEffectiveSortation($this->object_gui->getRefId()));
133
134 return $nodes;
135 }
136
137 protected function getItemHTML(array $node): string
138 {
139 $objDefinition = $this->obj_definition;
140 $ilCtrl = $this->ctrl;
141 //bug ilCertificateVerificationClassMap in 6 beta was cmiv instead of cmxv
142 if ($node["type"] == "cmiv") {
143 return "";
144 }
145
146 $class = $objDefinition->getClassName($node["type"]);
147 $full_class = "ilObj" . $class . "ListGUI";
148
149 $item_list_gui = new $full_class(ilObjectListGUI::CONTEXT_WORKSPACE);
150
151 $item_list_gui->setDetailsLevel(ilObjectListGUI::DETAILS_ALL);
152 $item_list_gui->enableDelete(true);
153 $item_list_gui->enableCut(true);
154 $item_list_gui->enableSubscribe(false);
155 $item_list_gui->enableLink(false);
156 $item_list_gui->enablePath(false);
157 $item_list_gui->enableLinkedPath(false);
158 $item_list_gui->enableSearchFragments(true);
159 $item_list_gui->enableIcon(true);
160 $item_list_gui->enableTimings(false);
161 $item_list_gui->enableCheckbox($this->admin);
162
163 $item_list_gui->enableNotes(true);
164 $item_list_gui->enableCopy($objDefinition->allowCopy($node["type"]));
165
166 if ($node["type"] == "file") {
167 $item_list_gui->enableRepositoryTransfer(true);
168 }
169
170 $item_list_gui->setContainerObject($this->object_gui);
171
172 if (in_array($node["type"], array("file", "blog"))) {
173 // add "share" link
174 $ilCtrl->setParameterByClass("ilworkspaceaccessgui", "wsp_id", $node["wsp_id"]);
175 $share_link = $ilCtrl->getLinkTargetByClass(array("ilObj" . $class . "GUI", "ilworkspaceaccessgui"), "share");
176 $item_list_gui->addCustomCommand($share_link, "wsp_permissions");
177
178 // show "shared" status
179 if (in_array($node["obj_id"], $this->shared_objects)) {
180 $item_list_gui->addCustomProperty($this->lng->txt("status"), $this->lng->txt("wsp_status_shared"), true, true);
181 }
182 }
183
184 $html = $item_list_gui->getListItemHTML(
185 $node["wsp_id"],
186 $node["obj_id"],
187 (string) $node["title"],
188 (string) $node["description"]
189 );
190
191 return $html;
192 }
193}
Class ilCtrl provides processing control methods.
language handling
User class.
parses the objects.xml it handles the xml-description of all ilias objects
Preloader for object list GUIs.
special template class to simplify handling of ITX/PEAR
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $object_gui, int $node_id, bool $admin, ilWorkspaceAccessHandler $access_handler, \ILIAS\DI\UIServices $ui, ilLanguage $lng, ilObjUser $user, ilObjectDefinition $obj_definition, ilCtrl $ctrl, ilWorkspaceFolderUserSettings $user_folder_settings)
ilWorkspaceFolderSorting $folder_sorting
ilWorkspaceFolderUserSettings $user_folder_settings
ilWorkspaceAccessHandler $access_handler
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class HTTPServicesTest.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.