ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilPCMediaObjectEditorGUI.php
Go to the documentation of this file.
1<?php
2
21
26{
27 public function getEditorElements(
28 UIWrapper $ui_wrapper,
29 string $page_type,
30 ilPageObjectGUI $page_gui,
31 int $style_id
32 ): array {
33 global $DIC;
34 $lng = $DIC->language();
35 $lng->loadLanguageModule("content");
36
37 $acc = new ilAccordionGUI();
38 $acc->addItem($lng->txt("cont_upload_file"), $this->getRenderedUploadForm($ui_wrapper, $lng));
39 $acc->addItem($lng->txt("cont_add_url"), $this->getRenderedUrlForm($ui_wrapper, $lng));
40 $acc->addItem($lng->txt("cont_choose_from_pool"), $this->getRenderedPoolBar($ui_wrapper, $lng));
41 $acc->addItem($lng->txt("cont_choose_from_clipboard"), $this->getRenderedClipboardBar($ui_wrapper, $lng, $page_gui));
42 $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
43
44 return [
45 "creation_form" => $acc->getHTML(true),
46 "icon" => $ui_wrapper->getRenderedIcon("pemed")
47 ];
48 }
49
50 public function getEditComponentForm(
51 UIWrapper $ui_wrapper,
52 string $page_type,
53 \ilPageObjectGUI $page_gui,
54 int $style_id,
55 string $pcid
56 ): string {
57 global $DIC;
58 $lng = $DIC->language();
59 $lng->loadLanguageModule("content");
60
61 $media_type = $DIC->mediaObjects()
62 ->internal()
63 ->domain()
64 ->mediaType();
65
66 $form = new ilPropertyFormGUI();
67 $form->setShowTopButtons(false);
68 $form->setTitle($lng->txt("cont_edit_mob"));
69
71 $pc_media = $page_gui->getPageObject()->getContentObjectForPcId($pcid);
72
73 $quick_edit = new ilPCMediaObjectQuickEdit($pc_media);
74
75 $pc_media_gui = new ilPCMediaObjectGUI(
76 $page_gui->getPageObject(),
77 $pc_media,
78 $page_gui->getPageObject()->getHierIdForPcId($pcid),
79 $pcid
80 );
81 $pc_media_gui->setStyleId($style_id);
82 $pc_media_gui->getCharacteristicsOfCurrentStyle(["media_cont"]);
83
84 if (is_null($pc_media->getMediaObject())) {
85 return "<div id='copg-top-actions'>" . $ui_wrapper->getRenderedInfoBox($lng->txt("copg_pc_mob_does_not_exist")) .
86 $ui_wrapper->getRenderedButton($lng->txt("cancel"), "form-button", "component.cancel", null, "Page") . "</div>";
87 }
88 $media = $pc_media->getMediaObject()->getMediaItem("Standard");
89
90 // title
91 $title = new ilTextInputGUI($lng->txt("title"), "standard_title");
92 $title->setSize(40);
93 $title->setMaxLength(120);
94 $title->setValue($quick_edit->getTitle());
95 $form->addItem($title);
96
97 // style
98 if ($pc_media_gui->checkStyleSelection()) {
99 $style_input = $pc_media_gui->getStyleInput();
100 $form->addItem($style_input);
101 }
102
103 // horizonal align
104 $align_prop = new ilSelectInputGUI(
105 $lng->txt("cont_align"),
106 "horizontal_align"
107 );
108 $options = array(
109 "Left" => $lng->txt("cont_left"),
110 "Center" => $lng->txt("cont_center"),
111 "Right" => $lng->txt("cont_right"),
112 "LeftFloat" => $lng->txt("cont_left_float"),
113 "RightFloat" => $lng->txt("cont_right_float"));
114 $align_prop->setOptions($options);
115 $align_prop->setValue($quick_edit->getHorizontalAlign());
116 $form->addItem($align_prop);
117
118 // fullscreen
119 if ($media_type->isImage($media->getFormat())) {
120 $cb = new ilCheckboxInputGUI($lng->txt("cont_show_fullscreen"), "fullscreen");
121 $cb->setChecked($quick_edit->getUseFullscreen());
122 $form->addItem($cb);
123 }
124
125 // standard caption
126 $caption = new ilTextAreaInputGUI($lng->txt("cont_caption"), "standard_caption");
127 $caption->setRows(2);
128 $caption->setValue($quick_edit->getCaption());
129 $form->addItem($caption);
130
131 // text representation
132 if ($media_type->usesAltTextProperty($media->getFormat())) {
133 $ta = new ilTextAreaInputGUI($lng->txt("text_repr"), "text_representation");
134 $ta->setRows(2);
135 $ta->setInfo($lng->txt("text_repr_info"));
136 $ta->setValue($quick_edit->getTextRepresentation());
137 $form->addItem($ta);
138 }
139
140 $html = $ui_wrapper->getRenderedForm(
141 $form,
142 [["Page", "component.update", $lng->txt("save")],
143 ["Page", "component.cancel", $lng->txt("cancel")]]
144 );
145
146 $link = $ui_wrapper->getRenderedLink($lng->txt("cont_advanced_settings"), "Page", "link", "component.settings");
147
148 return $html . $link;
149 }
150
151 public function getRenderedUploadForm(
152 UIWrapper $ui_wrapper,
154 ?ilPropertyFormGUI $form = null
155 ): string {
156 if (!$form) {
157 $form = $this->getUploadForm($lng);
158 }
159
160 $html = $ui_wrapper->getRenderedForm(
161 $form,
162 [["Page", "component.save", $lng->txt("insert")],
163 ["Page", "component.cancel", $lng->txt("cancel")]]
164 );
165
166 return $html;
167 }
168
169 public function getUploadForm(
170 $lng
172 global $DIC;
173 $media_types = $DIC->mediaObjects()->internal()->domain()->mediaType();
174
175 $form = new ilPropertyFormGUI();
176 $form->setShowTopButtons(false);
177
178 // standard type
179 $hi = new ilHiddenInputGUI("standard_type");
180 $hi->setValue("File");
181 $form->addItem($hi);
182
183 // standard size
184 $hi2 = new ilHiddenInputGUI("standard_size");
185 $hi2->setValue("original");
186 $form->addItem($hi2);
187
188 // standard size
189 $hi3 = new ilHiddenInputGUI("full_type");
190 $hi3->setValue("None");
191 $form->addItem($hi3);
192
193 // standard file
194 $up = new ilFileInputGUI($lng->txt("cont_file"), "standard_file");
195 $up->setSuffixes(iterator_to_array($media_types->getAllowedSuffixes()));
196 //$up->setForbiddenSuffixes(ilObjMediaObject::getForbiddenFileTypes());
197 $up->setRequired(true);
198 $form->addItem($up);
199
200 return $form;
201 }
202
203 public function getRenderedUrlForm(
204 UIWrapper $ui_wrapper,
206 ?ilPropertyFormGUI $form = null
207 ): string {
208 if (!$form) {
209 $form = $this->getUrlForm($lng);
210 }
211
212 $html = $ui_wrapper->getRenderedForm(
213 $form,
214 [["Page", "component.save", $lng->txt("insert")],
215 ["Page", "component.cancel", $lng->txt("cancel")]]
216 );
217
218 return $html;
219 }
220
221 public function getUrlForm(
224 global $DIC;
225 $media_types = $DIC->mediaObjects()->internal()->domain()->mediaType();
226 $form = new ilPropertyFormGUI();
227 $form->setShowTopButtons(false);
228
229 // standard type
230 $hi = new ilHiddenInputGUI("standard_type");
231 $hi->setValue("Reference");
232 $form->addItem($hi);
233
234 // standard size
235 $hi2 = new ilHiddenInputGUI("standard_size");
236 $hi2->setValue("original");
237 $form->addItem($hi2);
238
239 // standard size
240 $hi3 = new ilHiddenInputGUI("full_type");
241 $hi3->setValue("None");
242 $form->addItem($hi3);
243
244 // standard reference
245 $lng->loadLanguageModule("mob");
246 $ti = new ilTextInputGUI($lng->txt("url"), "standard_reference");
247 $info = $lng->txt("mob_url_info1") . " " . implode(", ", iterator_to_array($media_types->getAllowedSuffixes())) . ".";
248 $info .= " " . $lng->txt("mob_url_info_video");
249 $ti->setInfo($info);
250 $ti->setRequired(true);
251 $form->addItem($ti);
252
253 return $form;
254 }
255
256 protected function getRenderedPoolBar(
257 UIWrapper $ui_wrapper,
259 ): string {
260 global $DIC;
261
262 $ui = $DIC->ui();
263 $ctrl = $DIC->ctrl();
264 $lng = $DIC->language();
265
266 $buttons = [];
267
268 $ctrl->setParameterByClass("ilpcmediaobjectgui", "subCmd", "poolSelection");
269 $buttons[] = $ui_wrapper->getButton(
270 $lng->txt("cont_choose_media_pool"),
271 "media-action",
272 "select.pool",
273 [
274 "url" => $ctrl->getLinkTargetByClass("ilpcmediaobjectgui", "insert")
275 ],
276 "MediaObject"
277 );
278 $buttons[] = $ui_wrapper->getButton(
279 $lng->txt("cancel"),
280 "form-button",
281 "component.cancel",
282 [
283 ],
284 "Page"
285 );
286 $ctrl->setParameterByClass("ilpcmediaobjectgui", "subCmd", "poolSelection");
287
288 return $ui_wrapper->getRenderedFormFooter($buttons);
289 }
290
291 protected function getRenderedClipboardBar(
292 UIWrapper $ui_wrapper,
294 ilPageObjectGUI $page_gui
295 ): string {
296 global $DIC;
297
298 $ctrl = $DIC->ctrl();
299
300 $return_cmd = $ctrl->getLinkTargetByClass("ilpageeditorgui", "insertFromClipboard");
301
302 $ctrl->setParameterByClass("ileditclipboardgui", "returnCommand", rawurlencode($return_cmd));
303
304 $buttons = [];
305
306 $buttons[] = $ui_wrapper->getButton(
307 $lng->txt("cont_open_clipboard"),
308 "media-action",
309 "open.clipboard",
310 ["url" => $ctrl->getLinkTargetByClass([get_class($page_gui), "ileditclipboardgui"], "getObject")],
311 "MediaObject"
312 );
313
314 $buttons[] = $ui_wrapper->getButton(
315 $lng->txt("cancel"),
316 "form-button",
317 "component.cancel",
318 [
319 ],
320 "Page"
321 );
322
323 return $ui_wrapper->getRenderedFormFooter($buttons);
324 }
325}
getRenderedForm(\ilPropertyFormGUI $form, array $buttons)
getRenderedLink(string $content, string $component, string $type, string $action, ?array $data=null)
getButton(string $content, string $type, string $action, ?array $data=null, string $component="", bool $primary=false, string $aria_label="")
getRenderedInfoBox(string $text, array $buttons=[])
getRenderedButton(string $content, string $type, string $action, ?array $data=null, string $component="", bool $primary=false, string $aria_label="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
This class represents a file property in a property form.
This class represents a hidden form property in a property form.
language handling
getRenderedUploadForm(UIWrapper $ui_wrapper, ilLanguage $lng, ?ilPropertyFormGUI $form=null)
getRenderedClipboardBar(UIWrapper $ui_wrapper, ilLanguage $lng, ilPageObjectGUI $page_gui)
getRenderedUrlForm(UIWrapper $ui_wrapper, ilLanguage $lng, ?ilPropertyFormGUI $form=null)
getEditorElements(UIWrapper $ui_wrapper, string $page_type, ilPageObjectGUI $page_gui, int $style_id)
getRenderedPoolBar(UIWrapper $ui_wrapper, ilLanguage $lng)
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 ilPageObjectGUI.
This class represents a property form user interface.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
$info
Definition: entry_point.php:21
global $lng
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26