ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPCMediaObjectEditorGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
11 {
15  public function getEditorElements(\ILIAS\COPage\Editor\Server\UIWrapper $ui_wrapper, string $page_type, ilPageObjectGUI $page_gui, int $style_id) : array
16  {
17  global $DIC;
18  $lng = $DIC->language();
19  $lng->loadLanguageModule("content");
20 
21  $acc = new ilAccordionGUI();
22  $acc->addItem($lng->txt("cont_upload_file"), $this->getRenderedUploadForm($ui_wrapper, $lng));
23  $acc->addItem($lng->txt("cont_add_url"), $this->getRenderedUrlForm($ui_wrapper, $lng));
24  $acc->addItem($lng->txt("cont_choose_from_pool"), $this->getRenderedPoolBar($ui_wrapper, $lng));
25  $acc->addItem($lng->txt("cont_choose_from_clipboard"), $this->getRenderedClipboardBar($ui_wrapper, $lng, $page_gui));
26  $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
27 
28  return [
29  "creation_form" => $acc->getHTML(),
30  "icon" => $ui_wrapper->getRenderedIcon("pemed")
31  ];
32  }
33 
37  public function getEditComponentForm(\ILIAS\COPage\Editor\Server\UIWrapper $ui_wrapper, string $page_type, \ilPageObjectGUI $page_gui, int $style_id, $pcid) : string
38  {
39  global $DIC;
40  $lng = $DIC->language();
41  $lng->loadLanguageModule("content");
42 
43  $media_type = new ILIAS\MediaObjects\MediaType\MediaType();
44 
45  $form = new ilPropertyFormGUI();
46  $form->setShowTopButtons(false);
47  $form->setTitle($lng->txt("cont_edit_mob"));
48 
50  $pc_media = $page_gui->getPageObject()->getContentObjectForPcId($pcid);
51 
52  $quick_edit = new ilPCMediaObjectQuickEdit($pc_media);
53 
54  $pc_media_gui = new ilPCMediaObjectGUI(
55  $page_gui->getPageObject(),
56  $pc_media,
57  $page_gui->getPageObject()->getHierIdForPcId($pcid),
58  $pcid
59  );
60  $pc_media_gui->setStyleId($style_id);
61  $pc_media_gui->getCharacteristicsOfCurrentStyle("media_cont");
62 
63  $media = $pc_media->getMediaObject()->getMediaItem("Standard");
64 
65  // title
66  $title = new ilTextInputGUI($lng->txt("title"), "standard_title");
67  $title->setSize(40);
68  $title->setMaxLength(120);
69  $title->setValue($quick_edit->getTitle());
70  $form->addItem($title);
71 
72  // style
73  if ($pc_media_gui->checkStyleSelection()) {
74  $style_input = $pc_media_gui->getStyleInput();
75  $form->addItem($style_input);
76  }
77 
78  // horizonal align
79  $align_prop = new ilSelectInputGUI(
80  $lng->txt("cont_align"),
81  "horizontal_align"
82  );
83  $options = array(
84  "Left" => $lng->txt("cont_left"),
85  "Center" => $lng->txt("cont_center"),
86  "Right" => $lng->txt("cont_right"),
87  "LeftFloat" => $lng->txt("cont_left_float"),
88  "RightFloat" => $lng->txt("cont_right_float"));
89  $align_prop->setOptions($options);
90  $align_prop->setValue($quick_edit->getHorizontalAlign());
91  $form->addItem($align_prop);
92 
93  // fullscreen
94  if ($media_type->isImage($media->getFormat())) {
95  $cb = new ilCheckboxInputGUI($lng->txt("cont_show_fullscreen"), "fullscreen");
96  $cb->setChecked($quick_edit->getUseFullscreen());
97  $form->addItem($cb);
98  }
99 
100  // standard caption
101  $caption = new ilTextAreaInputGUI($lng->txt("cont_caption"), "standard_caption");
102  $caption->setRows(2);
103  $caption->setValue($quick_edit->getCaption());
104  $form->addItem($caption);
105 
106  // text representation
107  if ($media_type->usesAltTextProperty($media->getFormat())) {
108  $ta = new ilTextAreaInputGUI($lng->txt("text_repr"), "text_representation");
109  $ta->setRows(2);
110  $ta->setInfo($lng->txt("text_repr_info"));
111  $ta->setValue($quick_edit->getTextRepresentation());
112  $form->addItem($ta);
113  }
114 
115  $html = $ui_wrapper->getRenderedForm(
116  $form,
117  [["Page", "component.update", $lng->txt("save")],
118  ["Page", "component.cancel", $lng->txt("cancel")]]
119  );
120 
121  $link = $ui_wrapper->getRenderedLink($lng->txt("cont_advanced_settings"), "Page", "link", "component.settings");
122 
123  return $html . $link;
124  }
125 
131  protected function getRenderedUploadForm(\ILIAS\COPage\Editor\Server\UIWrapper $ui_wrapper, $lng)
132  {
133  $form = new ilPropertyFormGUI();
134  $form->setShowTopButtons(false);
135 
136  // standard type
137  $hi = new ilHiddenInputGUI("standard_type");
138  $hi->setValue("File");
139  $form->addItem($hi);
140 
141  // standard size
142  $hi2 = new ilHiddenInputGUI("standard_size");
143  $hi2->setValue("original");
144  $form->addItem($hi2);
145 
146  // standard size
147  $hi3 = new ilHiddenInputGUI("full_type");
148  $hi3->setValue("None");
149  $form->addItem($hi3);
150 
151  // standard file
152  $up = new ilFileInputGUI($lng->txt("cont_file"), "standard_file");
154  $up->setForbiddenSuffixes(ilObjMediaObject::getForbiddenFileTypes());
155  $form->addItem($up);
156 
157  $html = $ui_wrapper->getRenderedForm(
158  $form,
159  [["Page", "component.save", $lng->txt("insert")],
160  ["Page", "component.cancel", $lng->txt("cancel")]]
161  );
162 
163  return $html;
164  }
165 
171  protected function getRenderedUrlForm(\ILIAS\COPage\Editor\Server\UIWrapper $ui_wrapper, $lng)
172  {
173  $form = new ilPropertyFormGUI();
174  $form->setShowTopButtons(false);
175 
176  // standard type
177  $hi = new ilHiddenInputGUI("standard_type");
178  $hi->setValue("Reference");
179  $form->addItem($hi);
180 
181  // standard size
182  $hi2 = new ilHiddenInputGUI("standard_size");
183  $hi2->setValue("original");
184  $form->addItem($hi2);
185 
186  // standard size
187  $hi3 = new ilHiddenInputGUI("full_type");
188  $hi3->setValue("None");
189  $form->addItem($hi3);
190 
191  // standard reference
192  $ti = new ilTextInputGUI($lng->txt("url"), "standard_reference");
193  $ti->setInfo($lng->txt("cont_url_info"));
194  $form->addItem($ti);
195 
196 
197  $html = $ui_wrapper->getRenderedForm(
198  $form,
199  [["Page", "component.save", $lng->txt("insert")],
200  ["Page", "component.cancel", $lng->txt("cancel")]]
201  );
202 
203  return $html;
204  }
205 
211  protected function getRenderedPoolBar(\ILIAS\COPage\Editor\Server\UIWrapper $ui_wrapper, $lng)
212  {
213  global $DIC;
214 
215  $ui = $DIC->ui();
216  $ctrl = $DIC->ctrl();
217  $lng = $DIC->language();
218 
219  $buttons = [];
220 
221  $ctrl->setParameterByClass("ilpcmediaobjectgui", "subCmd", "poolSelection");
222  $buttons[] = $ui_wrapper->getButton(
223  $lng->txt("cont_choose_media_pool"),
224  "media-action",
225  "select.pool",
226  [
227  "url" => $ctrl->getLinkTargetByClass("ilpcmediaobjectgui", "insert")
228  ],
229  "MediaObject"
230  );
231  $buttons[] = $ui_wrapper->getButton(
232  $lng->txt("cancel"),
233  "form-button",
234  "component.cancel",
235  [
236  ],
237  "Page"
238  );
239  $ctrl->setParameterByClass("ilpcmediaobjectgui", "subCmd", "poolSelection");
240 
241  return $ui_wrapper->getRenderedFormFooter($buttons);
242  }
243 
251  protected function getRenderedClipboardBar(\ILIAS\COPage\Editor\Server\UIWrapper $ui_wrapper, $lng,
252  $page_gui)
253  {
254  global $DIC;
255 
256  $ctrl = $DIC->ctrl();
257 
258  $return_cmd = $ctrl->getLinkTargetByClass("ilpageeditorgui", "insertFromClipboard");
259 
260  $ctrl->setParameterByClass("ileditclipboardgui", "returnCommand", rawurlencode($return_cmd));
261 
262  $buttons = [];
263 
264  $buttons[] = $ui_wrapper->getButton(
265  $lng->txt("cont_open_clipboard"),
266  "media-action",
267  "open.clipboard",
268  ["url" => $ctrl->getLinkTargetByClass([get_class($page_gui), "ileditclipboardgui"], "getObject")],
269  "MediaObject"
270  );
271 
272  $buttons[] = $ui_wrapper->getButton(
273  $lng->txt("cancel"),
274  "form-button",
275  "component.cancel",
276  [
277  ],
278  "Page"
279  );
280 
281  return $ui_wrapper->getRenderedFormFooter($buttons);
282  }
283 
284 }
getEditorElements(\ILIAS\COPage\Editor\Server\UIWrapper $ui_wrapper, string $page_type, ilPageObjectGUI $page_gui, int $style_id)
getPageObject()
Get Page Object.
This class represents a property form user interface.
This class represents a file property in a property form.
Class ChatMainBarProvider .
getRenderedUrlForm(\ILIAS\COPage\Editor\Server\UIWrapper $ui_wrapper, $lng)
Get upload form.
Class ilPageObjectGUI.
This class represents a checkbox property in a property form.
Class ilPCMediaObjectGUI.
setChecked($a_checked)
Set Checked.
This class represents a hidden form property in a property form.
$lng
global $DIC
Definition: goto.php:24
getRenderedPoolBar(\ILIAS\COPage\Editor\Server\UIWrapper $ui_wrapper, $lng)
Get pool link.
static getForbiddenFileTypes()
Get forbidden file types.
Manages business logic in media slate editing.
getRenderedClipboardBar(\ILIAS\COPage\Editor\Server\UIWrapper $ui_wrapper, $lng, $page_gui)
Get pool link.
getEditComponentForm(UIWrapper $ui_wrapper, string $page_type, \ilPageObjectGUI $page_gui, int $style_id, $pcid)
Get rendered editor elements.
static getRestrictedFileTypes()
Get restricted file types (this is for the input form, this list will be empty, if "allowed list" is ...
This class represents a text area property in a property form.
setStyleId($a_styleid)
Set Style Id.
getRenderedUploadForm(\ILIAS\COPage\Editor\Server\UIWrapper $ui_wrapper, $lng)
Get upload form.
Accordion user interface class.
setSuffixes($a_suffixes)
Set Accepted Suffixes.