ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
SubObjectTableBuilder.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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  if ($data_row["type"] === "pg") {
79  $img_sc = $data_row["scheduled"]
80  ? "_sc"
81  : "";
82 
83  if (!$data_row["active"]) {
84  $img = "standard/icon_pg_d" . $img_sc . ".svg";
85  $alt = $lng->txt("cont_page_deactivated");
86  } else {
87  if ($data_row["deactivated_elements"]) {
88  $img = "standard/icon_pg_del" . $img_sc . ".svg";
89  $alt = $lng->txt("cont_page_deactivated_elements");
90  } else {
91  $img = "standard/icon_pg" . $img_sc . ".svg";
92  $alt = $lng->txt("pg");
93  }
94  }
95  } else {
96  $img = "standard/icon_st.svg";
97  $alt = $lng->txt("st");
98  }
99  return [
100  "id" => $data_row["id"],
101  "type" => $f->symbol()->icon()->custom(\ilUtil::getImagePath($img), $alt),
102  "title" => $data_row["title"],
103  "trans_title" => $data_row["trans_title"],
104  ];
105  }
106 
108  {
109  $lng = $this->domain->lng();
110  $user = $this->domain->user();
111  $transl = $this->gui->editing()->request()->getTranslation();
112  $table = $table
113  ->iconColumn("type", $lng->txt("type"))
114  ->textColumn("title", $lng->txt("title"));
115  if (!in_array($transl, ["-", ""])) {
116  $table = $table->textColumn("trans_title", $lng->txt("title") .
117  " (" . $lng->txt("meta_l_" . $transl) . ")");
118  }
119  if ($this->type === "st") {
120  $acts = [
121  [
122  "editPages",
123  $lng->txt("edit"),
124  [\ilObjLearningModuleGUI::class, \ilStructureObjectGUI::class, EditSubObjectsGUI::class],
125  "editPages",
126  "obj_id"
127  ],
128  [
129  "insertChapterAfter",
130  $lng->txt("lm_insert_chapter_after"),
131  [EditSubObjectsGUI::class],
132  "insertChapterAfter",
133  "target_id"
134  ],
135  [
136  "insertChapterBefore",
137  $lng->txt("lm_insert_chapter_before"),
138  [EditSubObjectsGUI::class],
139  "insertChapterBefore",
140  "target_id"
141  ]
142  ];
143  if ($user->clipboardHasObjectsOfType("st")) {
144  $acts[] = [
145  "insertChapterClipAfter",
146  $lng->txt("lm_insert_chapter_clip_after"),
147  [EditSubObjectsGUI::class],
148  "insertChapterClipAfter",
149  "target_id"
150  ];
151  $acts[] = [
152  "insertChapterClipBefore",
153  $lng->txt("lm_insert_chapter_clip_before"),
154  [EditSubObjectsGUI::class],
155  "insertChapterClipBefore",
156  "target_id"
157  ];
158  }
159  } else {
160  $acts = [
161  [
162  "editPage",
163  $lng->txt("edit"),
164  [\ilObjLearningModuleGUI::class, \ilLMPageObjectGUI::class],
165  "edit",
166  "obj_id"
167  ],
168  [
169  "insertPageAfter",
170  $lng->txt("lm_insert_page_after"),
171  [EditSubObjectsGUI::class],
172  "insertPageAfter",
173  "target_id"
174  ],
175  [
176  "insertPageBefore",
177  $lng->txt("lm_insert_page_before"),
178  [EditSubObjectsGUI::class],
179  "insertPageBefore",
180  "target_id"
181  ]
182  ];
183  if ($user->clipboardHasObjectsOfType("pg")) {
184  $acts[] = [
185  "insertPageClipAfter",
186  $lng->txt("lm_insert_page_clip_after"),
187  [EditSubObjectsGUI::class],
188  "insertPageClipAfter",
189  "target_id"
190  ];
191  $acts[] = [
192  "insertPageClipBefore",
193  $lng->txt("lm_insert_page_clip_before"),
194  [EditSubObjectsGUI::class],
195  "insertPageClipBefore",
196  "target_id"
197  ];
198  }
199  if (count($this->page_layouts) > 0) {
200  $acts[] = [
201  "insertLayoutAfter",
202  $lng->txt("lm_insert_layout_after"),
203  [EditSubObjectsGUI::class],
204  "insertLayoutAfter",
205  "target_id"
206  ];
207  $acts[] = [
208  "insertLayoutBefore",
209  $lng->txt("lm_insert_layout_before"),
210  [EditSubObjectsGUI::class],
211  "insertLayoutBefore",
212  "target_id"
213  ];
214  }
215  }
216  foreach ($acts as $a) {
217  $table = $table->singleRedirectAction(
218  $a[0],
219  $a[1],
220  $a[2],
221  $a[3],
222  $a[4]
223  );
224  }
225  $table = $table
226  ->standardAction(
227  "delete",
228  $lng->txt("delete")
229  )
230  ->singleAction(
231  "editTitle",
232  $lng->txt("cont_edit_title"),
233  true
234  )
235  ->standardAction(
236  "cutItems",
237  $lng->txt("cut")
238  )
239  ->standardAction(
240  "copyItems",
241  $lng->txt("copy")
242  );
243  if ($this->type === "pg") {
244  $table = $table->standardAction(
245  "activatePages",
246  $lng->txt("cont_de_activate")
247  );
248  }
249  return $table;
250  }
251 
252 }
singleRedirectAction(string $action, string $title, array $class_path, string $cmd="", string $id_param="")
textColumn(string $key, string $title, bool $sortable=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
iconColumn(string $key, string $title, bool $sortable=false)
__construct(protected InternalDomainService $domain, protected InternalGUIService $gui, protected string $title, protected int $lm_id, protected string $type, object $parent_gui, string $parent_cmd)
standardAction(string $action, string $title)
__construct(Container $dic, ilPlugin $plugin)
global $lng
Definition: privfeed.php:31
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples