ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
SubObjectTableBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28
30{
31 protected array $page_layouts;
32
33 public function __construct(
34 protected InternalDomainService $domain,
35 protected InternalGUIService $gui,
36 protected string $title,
37 protected int $lm_id,
38 protected string $type,
39 object $parent_gui,
40 string $parent_cmd
41 ) {
42 $this->page_layouts = \ilPageLayout::activeLayouts(
44 );
45 parent::__construct($parent_gui, $parent_cmd);
46 }
47
48 protected function getId(): string
49 {
50 return "subobj";
51 }
52
53 protected function getTitle(): string
54 {
55 return $this->title;
56 }
57
58 protected function getRetrieval(): RetrievalInterface
59 {
60 $request = $this->gui->editing()->request();
61 return $this->domain->subObjectRetrieval(
62 $this->lm_id,
63 $this->type,
64 $request->getObjId(),
65 $request->getTranslation()
66 );
67 }
68
69 protected function getOrderingCommand(): string
70 {
71 return "saveOrder";
72 }
73
74 protected function transformRow(array $data_row): array
75 {
76 $lng = $this->domain->lng();
77 $f = $this->gui->ui()->factory();
78 $ctrl = $this->gui->ctrl();
79 if ($data_row["type"] === "pg") {
80 $img_sc = $data_row["scheduled"]
81 ? "_sc"
82 : "";
83
84 if (!$data_row["active"]) {
85 $img = "standard/icon_pg_d" . $img_sc . ".svg";
86 $alt = $lng->txt("cont_page_deactivated");
87 } else {
88 if ($data_row["deactivated_elements"]) {
89 $img = "standard/icon_pg_del" . $img_sc . ".svg";
90 $alt = $lng->txt("cont_page_deactivated_elements");
91 } else {
92 $img = "standard/icon_pg" . $img_sc . ".svg";
93 $alt = $lng->txt("pg");
94 }
95 }
96 } else {
97 $img = "standard/icon_st.svg";
98 $alt = $lng->txt("st");
99 }
100 $target = "#";
101 if ($data_row["type"] === "pg") {
102 $ctrl->setParameterByClass(\ilLMPageGUI::class, "obj_id", $data_row["id"]);
103 $target = $ctrl->getLinkTargetByClass([
104 \ilObjLearningModuleGUI::class,
105 \ilLMPageObjectGUI::class,
106 \ilLMPageGUI::class
107 ], "edit");
108 } elseif ($data_row["type"] === "st") {
109 $ctrl->setParameterByClass(\ilStructureObjectGUI::class, "obj_id", $data_row["id"]);
110 $target = $ctrl->getLinkTargetByClass([
111 \ilObjLearningModuleGUI::class,
112 \ilStructureObjectGUI::class,
113 EditSubObjectsGUI::class
114 ], "editPages");
115 }
116
117 $title = $f->link()->standard($data_row["title"], $target);
118 return [
119 "id" => $data_row["id"],
120 "type" => $f->symbol()->icon()->custom(\ilUtil::getImagePath($img), $alt),
121 "title" => $title,
122 "trans_title" => $data_row["trans_title"],
123 ];
124 }
125
127 {
128 $lng = $this->domain->lng();
129 $user = $this->domain->user();
130 $transl = $this->gui->editing()->request()->getTranslation();
131 $table = $table
132 ->iconColumn("type", $lng->txt("type"))
133 ->linkColumn("title", $lng->txt("title"));
134 if (!in_array($transl, ["-", ""])) {
135 $table = $table->textColumn("trans_title", $lng->txt("title") .
136 " (" . $lng->txt("meta_l_" . $transl) . ")");
137 }
138 if ($this->type === "st") {
140 "editPages",
141 $lng->txt("lm_list_pages"),
142 [\ilObjLearningModuleGUI::class, \ilStructureObjectGUI::class, EditSubObjectsGUI::class],
143 "editPages",
144 "obj_id"
145 );
147 "editTitle",
148 $lng->txt("cont_edit_title"),
149 true
150 );
152 "insertChapterAfter",
153 $lng->txt("lm_insert_chapter_after"),
154 true
155 );
157 "insertChapterBefore",
158 $lng->txt("lm_insert_chapter_before"),
159 true
160 );
161 if ($user->clipboardHasObjectsOfType("st")) {
163 "insertChapterClipAfter",
164 $lng->txt("lm_insert_chapter_clip_after"),
165 [EditSubObjectsGUI::class],
166 "insertChapterClipAfter",
167 "target_id"
168 );
170 "insertChapterClipBefore",
171 $lng->txt("lm_insert_chapter_clip_before"),
172 [EditSubObjectsGUI::class],
173 "insertChapterClipBefore",
174 "target_id"
175 );
176 }
177 } else {
179 "editPage",
180 $lng->txt("lm_edit_content"),
181 [\ilObjLearningModuleGUI::class, \ilLMPageObjectGUI::class],
182 "edit",
183 "obj_id"
184 );
186 "editTitle",
187 $lng->txt("cont_edit_title"),
188 true
189 );
191 "insertPageAfter",
192 $lng->txt("lm_insert_page_after"),
193 true
194 );
196 "insertPageBefore",
197 $lng->txt("lm_insert_page_before"),
198 true
199 );
200 if ($user->clipboardHasObjectsOfType("pg")) {
202 "insertPageClipAfter",
203 $lng->txt("lm_insert_page_clip_after"),
204 [EditSubObjectsGUI::class],
205 "insertPageClipAfter",
206 "target_id"
207 );
209 "insertPageClipBefore",
210 $lng->txt("lm_insert_page_clip_before"),
211 [EditSubObjectsGUI::class],
212 "insertPageClipBefore",
213 "target_id"
214 );
215 }
216 }
217 $table = $table
219 "delete",
220 $lng->txt("delete")
221 )
222 ->standardAction(
223 "cutItems",
224 $lng->txt("cut")
225 )
226 ->standardAction(
227 "copyItems",
228 $lng->txt("copy")
229 );
230 if ($this->type === "pg") {
232 "activatePages",
233 $lng->txt("cont_de_activate")
234 );
235 }
236 return $table;
237 }
238
239}
__construct(protected InternalDomainService $domain, protected InternalGUIService $gui, protected string $title, protected int $lm_id, protected string $type, object $parent_gui, string $parent_cmd)
transformRow(array $data_row)
transform raw data array to table row data array
textColumn(string $key, string $title, bool $sortable=false)
singleAction(string $action, string $title, bool $async=false)
standardAction(string $action, string $title)
singleRedirectAction(string $action, string $title, array $class_path, string $cmd="", string $id_param="", bool $async=false)
iconColumn(string $key, string $title, bool $sortable=false)
static activeLayouts(int $a_module=0)
Get active layouts.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:31