3declare(strict_types=1);
52 $this->
lng = $domain_service->lng();
53 $this->
lng->loadLanguageModule(
"content");
55 $this->request = $gui_service
57 $this->gui = $gui_service;
59 $images = $this->request->getFiles();
60 if (count($images) == 1 &&
$manager->filenameExists(current($images))) {
61 $this->current_image = current($images);
62 $this->current_images = $images;
64 $this->current_images = array_filter($images,
function (
$i) use (
$manager) {
70 $this->tpl = $gui_service->mainTemplate();
75 $ctrl = $this->gui->ctrl();
77 $next_class = $ctrl->getNextClass($this);
78 $cmd = $ctrl->getCmd(
"listImages");
80 switch ($next_class) {
83 "listImages",
"addImage",
"cancelUpload",
"uploadImage",
"deleteImage",
84 "resizeImageForm",
"resizeImage"
93 $tpl = $this->gui->mainTemplate();
94 $ilToolbar = $this->gui->toolbar();
95 $ilCtrl = $this->gui->ctrl();
98 if ($this->access_manager->checkWrite()) {
99 $ilToolbar->addButton(
101 $ilCtrl->getLinkTarget($this,
"addImage")
108 $this->access_manager,
116 $tpl = $this->gui->mainTemplate();
124 $ilCtrl = $this->gui->ctrl();
126 $ilCtrl->redirect($this,
"listImages");
131 $tpl = $this->gui->mainTemplate();
132 $ilCtrl = $this->gui->ctrl();
136 if ($form->checkInput()) {
137 $this->manager->uploadImage();
138 $ilCtrl->redirect($this,
"listImages");
148 $ilCtrl = $this->gui->ctrl();
152 $form_gui->setTitle(
$lng->
txt(
"sty_add_image"));
155 $file_input->setSuffixes([
"jpg",
"jpeg",
"png",
"gif",
"svg"]);
156 $file_input->setRequired(
true);
157 $form_gui->addItem($file_input);
159 $form_gui->addCommandButton(
"uploadImage",
$lng->
txt(
"upload"));
160 $form_gui->addCommandButton(
"cancelUpload",
$lng->
txt(
"cancel"));
161 $form_gui->setFormAction($ilCtrl->getFormAction($this));
168 $ilCtrl = $this->gui->ctrl();
169 foreach ($this->current_images as
$i) {
170 $this->manager->deleteByFilename(
$i);
172 $ilCtrl->redirect($this,
"listImages");
182 $ctrl = $this->gui->ctrl();
187 $image = $this->manager->getByFilename($this->current_image);
191 " / " .
$lng->
txt(
"cont_height"),
"width_height");
192 $width_height->setConstrainProportions(
true);
193 $width_height->setHeight($image->getHeight());
194 $width_height->setWidth($image->getWidth());
195 $form->addItem($width_height);
199 $hi->setValue($this->current_image);
202 $form->addCommandButton(
"resizeImage",
$lng->
txt(
"sty_resize"));
204 $form->setTitle(
$lng->
txt(
"sty_resize_image"));
205 $form->setFormAction($ctrl->getFormAction($this));
212 $ctrl = $this->gui->ctrl();
214 $main_tpl = $this->gui->mainTemplate();
217 if ($form->checkInput()) {
218 $wh = $form->getInput(
"width_height");
220 $this->manager->resizeImage(
221 $this->current_image,
222 (
int) ($wh[
"width"] ?? 0),
223 (
int) ($wh[
"height"] ?? 0),
224 (
bool) ($wh[
"const_prop"] ??
false)
227 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
"msg_obj_modified"),
true);
228 $ctrl->redirect($this,
"listImages");
230 $form->setValuesByPost();
231 $main_tpl->setContent($form->getHTML());
Manages access to content style editing.
Main business logic for content style images.
Content style internal ui factory.
ilGlobalTemplateInterface $tpl
Content InternalGUIService $gui
__construct(Content\InternalDomainService $domain_service, Content\InternalGUIService $gui_service, Access\StyleAccessManager $access_manager, Content\ImageManager $manager)
Content ImageManager $manager
Content StandardGUIRequest $request
Access StyleAccessManager $access_manager
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
TableGUI class for style editor (image list)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_html)
Sets content for standard template.
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...