ILIAS  release_8 Revision v8.25
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 $form = new ilPropertyFormGUI();
173 $form->setShowTopButtons(false);
174
175 // standard type
176 $hi = new ilHiddenInputGUI("standard_type");
177 $hi->setValue("File");
178 $form->addItem($hi);
179
180 // standard size
181 $hi2 = new ilHiddenInputGUI("standard_size");
182 $hi2->setValue("original");
183 $form->addItem($hi2);
184
185 // standard size
186 $hi3 = new ilHiddenInputGUI("full_type");
187 $hi3->setValue("None");
188 $form->addItem($hi3);
189
190 // standard file
191 $up = new ilFileInputGUI($lng->txt("cont_file"), "standard_file");
193 $up->setForbiddenSuffixes(ilObjMediaObject::getForbiddenFileTypes());
194 $up->setRequired(true);
195 $form->addItem($up);
196
197 return $form;
198 }
199
200 public function getRenderedUrlForm(
201 UIWrapper $ui_wrapper,
203 ilPropertyFormGUI $form = null
204 ): string {
205 if (!$form) {
206 $form = $this->getUrlForm($lng);
207 }
208
209 $html = $ui_wrapper->getRenderedForm(
210 $form,
211 [["Page", "component.save", $lng->txt("insert")],
212 ["Page", "component.cancel", $lng->txt("cancel")]]
213 );
214
215 return $html;
216 }
217
218 public function getUrlForm(
221 $form = new ilPropertyFormGUI();
222 $form->setShowTopButtons(false);
223
224 // standard type
225 $hi = new ilHiddenInputGUI("standard_type");
226 $hi->setValue("Reference");
227 $form->addItem($hi);
228
229 // standard size
230 $hi2 = new ilHiddenInputGUI("standard_size");
231 $hi2->setValue("original");
232 $form->addItem($hi2);
233
234 // standard size
235 $hi3 = new ilHiddenInputGUI("full_type");
236 $hi3->setValue("None");
237 $form->addItem($hi3);
238
239 // standard reference
240 $ti = new ilTextInputGUI($lng->txt("url"), "standard_reference");
241 $ti->setInfo($lng->txt("cont_url_info"));
242 $ti->setRequired(true);
243 $form->addItem($ti);
244
245 return $form;
246 }
247
248 protected function getRenderedPoolBar(
249 UIWrapper $ui_wrapper,
251 ): string {
252 global $DIC;
253
254 $ui = $DIC->ui();
255 $ctrl = $DIC->ctrl();
256 $lng = $DIC->language();
257
258 $buttons = [];
259
260 $ctrl->setParameterByClass("ilpcmediaobjectgui", "subCmd", "poolSelection");
261 $buttons[] = $ui_wrapper->getButton(
262 $lng->txt("cont_choose_media_pool"),
263 "media-action",
264 "select.pool",
265 [
266 "url" => $ctrl->getLinkTargetByClass("ilpcmediaobjectgui", "insert")
267 ],
268 "MediaObject"
269 );
270 $buttons[] = $ui_wrapper->getButton(
271 $lng->txt("cancel"),
272 "form-button",
273 "component.cancel",
274 [
275 ],
276 "Page"
277 );
278 $ctrl->setParameterByClass("ilpcmediaobjectgui", "subCmd", "poolSelection");
279
280 return $ui_wrapper->getRenderedFormFooter($buttons);
281 }
282
283 protected function getRenderedClipboardBar(
284 UIWrapper $ui_wrapper,
286 ilPageObjectGUI $page_gui
287 ): string {
288 global $DIC;
289
290 $ctrl = $DIC->ctrl();
291
292 $return_cmd = $ctrl->getLinkTargetByClass("ilpageeditorgui", "insertFromClipboard");
293
294 $ctrl->setParameterByClass("ileditclipboardgui", "returnCommand", rawurlencode($return_cmd));
295
296 $buttons = [];
297
298 $buttons[] = $ui_wrapper->getButton(
299 $lng->txt("cont_open_clipboard"),
300 "media-action",
301 "open.clipboard",
302 ["url" => $ctrl->getLinkTargetByClass([get_class($page_gui), "ileditclipboardgui"], "getObject")],
303 "MediaObject"
304 );
305
306 $buttons[] = $ui_wrapper->getButton(
307 $lng->txt("cancel"),
308 "form-button",
309 "component.cancel",
310 [
311 ],
312 "Page"
313 );
314
315 return $ui_wrapper->getRenderedFormFooter($buttons);
316 }
317}
getRenderedForm(\ilPropertyFormGUI $form, array $buttons)
getRenderedLink(string $content, string $component, string $type, string $action, array $data=null)
getRenderedButton(string $content, string $type, string $action, array $data=null, string $component="", string $aria_label="")
getButton(string $content, string $type, string $action, array $data=null, string $component="", 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 file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
static getRestrictedFileTypes()
Get restricted file types (this is for the input form, this list will be empty, if "allowed list" is ...
static getForbiddenFileTypes()
Get forbidden file types.
getRenderedClipboardBar(UIWrapper $ui_wrapper, ilLanguage $lng, ilPageObjectGUI $page_gui)
getEditorElements(UIWrapper $ui_wrapper, string $page_type, ilPageObjectGUI $page_gui, int $style_id)
getRenderedUploadForm(UIWrapper $ui_wrapper, ilLanguage $lng, ilPropertyFormGUI $form=null)
getRenderedUrlForm(UIWrapper $ui_wrapper, ilLanguage $lng, ilPropertyFormGUI $form=null)
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.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
global $DIC
Definition: feed.php:28
$lng