ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilContentStyleImageGUI Class Reference

@ilCtrl_Calls ilContentStyleImageGUI: ilRepoStandardUploadHandlerGUI More...

+ Collaboration diagram for ilContentStyleImageGUI:

Public Member Functions

 __construct (Content\InternalDomainService $domain_service, Content\InternalGUIService $gui_service, Access\StyleAccessManager $access_manager, Content\ImageManager $manager)
 
 executeCommand ()
 
 listImages ()
 
 addImage ()
 
 cancelUpload ()
 
 uploadImage ()
 
 handleImageUpload (\ILIAS\FileUpload\FileUpload $upload, \ILIAS\FileUpload\DTO\UploadResult $result)
 
 confirmDeleteImage (string $file)
 
 deleteImage ()
 
 resizeImageForm (string $file="")
 
 getResizeImageForm ()
 
 resizeImage ()
 

Protected Member Functions

 getImageTable ()
 
 getImageForm ()
 

Protected Attributes

ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
Content InternalGUIService $gui
 
Content StandardGUIRequest $request
 
ilObjStyleSheet $object
 
Content ImageManager $manager
 
Access StyleAccessManager $access_manager
 
string $current_image = null
 
array $current_images = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilContentStyleImageGUI::__construct ( Content\InternalDomainService  $domain_service,
Content\InternalGUIService  $gui_service,
Access\StyleAccessManager  $access_manager,
Content\ImageManager  $manager 
)

Definition at line 43 of file class.ilContentStyleImageGUI.php.

48 {
49 $this->access_manager = $access_manager;
50
51 $this->lng = $domain_service->lng();
52 $this->lng->loadLanguageModule("content");
53
54 $this->request = $gui_service
55 ->standardRequest();
56 $this->gui = $gui_service;
57
58 $images = $this->request->getFiles();
59 if (count($images) == 1 && $manager->filenameExists(current($images))) {
60 $this->current_image = current($images);
61 $this->current_images = $images;
62 } else {
63 $this->current_images = array_filter($images, function ($i) use ($manager) {
64 return $manager->filenameExists($i);
65 });
66 }
67
68 $this->manager = $manager;
69 $this->tpl = $gui_service->mainTemplate();
70 }
Access StyleAccessManager $access_manager

References $access_manager, $manager, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ addImage()

ilContentStyleImageGUI::addImage ( )

Definition at line 128 of file class.ilContentStyleImageGUI.php.

128 : void
129 {
130 $tpl = $this->gui->mainTemplate();
131
132 $form = $this->getImageForm();
133 $tpl->setContent($form->render());
134 }
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.

References $tpl, getImageForm(), and ILIAS\UICore\GlobalTemplate\setContent().

+ Here is the call graph for this function:

◆ cancelUpload()

ilContentStyleImageGUI::cancelUpload ( )

Definition at line 136 of file class.ilContentStyleImageGUI.php.

136 : void
137 {
138 $ilCtrl = $this->gui->ctrl();
139
140 $ilCtrl->redirect($this, "listImages");
141 }

◆ confirmDeleteImage()

ilContentStyleImageGUI::confirmDeleteImage ( string  $file)

Definition at line 181 of file class.ilContentStyleImageGUI.php.

181 : void
182 {
183 if ($file === "") {
184 $this->gui->ctrl()->redirect($this, "listImages");
185 return;
186 }
187
188 $this->getImageTable()->renderDeletionConfirmation(
189 $this->lng->txt("delete"),
190 $this->lng->txt("info_delete_sure"),
191 "deleteImage",
192 [$file => $file]
193 );
194 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ deleteImage()

ilContentStyleImageGUI::deleteImage ( )

Definition at line 196 of file class.ilContentStyleImageGUI.php.

196 : void
197 {
198 $ilCtrl = $this->gui->ctrl();
199 $files = $this->getImageTable()->getItemIds();
200 if (count($files) === 1) {
201 $this->manager->deleteByFilename($files[0]);
202 }
203 $ilCtrl->redirect($this, "listImages");
204 }

References $files.

◆ executeCommand()

ilContentStyleImageGUI::executeCommand ( )

Definition at line 72 of file class.ilContentStyleImageGUI.php.

72 : void
73 {
74 $ctrl = $this->gui->ctrl();
75
76 $next_class = $ctrl->getNextClass($this);
77 $cmd = $ctrl->getCmd("listImages");
78
79 switch ($next_class) {
80
81 case strtolower(ilRepoStandardUploadHandlerGUI::class):
82 $form = $this->getImageForm();
83 $gui = $form->getRepoStandardUploadHandlerGUI("image");
84 $ctrl->forwardCommand($gui);
85 break;
86
87 default:
88 if (in_array($cmd, [
89 "listImages", "addImage", "cancelUpload", "uploadImage", "confirmDeleteImage", "deleteImage",
90 "resizeImageForm", "resizeImage"
91 ])) {
92 $this->$cmd();
93 }
94 }
95 }
Content InternalGUIService $gui

References $gui, and getImageForm().

+ Here is the call graph for this function:

◆ getImageForm()

ilContentStyleImageGUI::getImageForm ( )
protected

Definition at line 150 of file class.ilContentStyleImageGUI.php.

151 {
152 $form = $this->gui->form([self::class], "uploadImage")
153 ->section("image_section", $this->lng->txt("sty_add_image"))
154 ->file(
155 "image",
156 $this->lng->txt("sty_image_file"),
157 $this->handleImageUpload(...), // Placeholder for upload handler
158 "image_id",
159 "",
160 1, // Limit to 1 file upload
161 ["image/jpeg", "image/png", "image/gif", "image/svg+xml"] // Accepted file types
162 );
163 return $form;
164 }
section(string $key, string $title, string $description="")

References ILIAS\Repository\lng(), and ILIAS\Repository\Form\FormAdapterGUI\section().

Referenced by addImage(), and executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImageTable()

ilContentStyleImageGUI::getImageTable ( )
protected

Definition at line 118 of file class.ilContentStyleImageGUI.php.

119 {
120 return $this->gui->image()->imageTableBuilder(
121 $this->access_manager,
122 $this->manager,
123 $this,
124 "listImages"
125 )->getTable();
126 }

References ILIAS\Repository\Table\TableAdapterGUI\getTable().

Referenced by listImages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getResizeImageForm()

ilContentStyleImageGUI::getResizeImageForm ( )

Definition at line 214 of file class.ilContentStyleImageGUI.php.

215 {
216 $ctrl = $this->gui->ctrl();
218
219 $form = new ilPropertyFormGUI();
220
221 $image = $this->manager->getByFilename($this->current_image);
222
223 // width height
224 $width_height = new ilWidthHeightInputGUI($lng->txt("cont_width") .
225 " / " . $lng->txt("cont_height"), "width_height");
226 $width_height->setConstrainProportions(true);
227 $width_height->setHeight($image->getHeight());
228 $width_height->setWidth($image->getWidth());
229 $form->addItem($width_height);
230
231 // file
232 $hi = new ilHiddenInputGUI("file");
233 $hi->setValue($this->current_image);
234 $form->addItem($hi);
235
236 $form->addCommandButton("resizeImage", $lng->txt("sty_resize"));
237
238 $form->setTitle($lng->txt("sty_resize_image"));
239 $form->setFormAction($ctrl->getFormAction($this));
240
241 return $form;
242 }
This class represents a hidden form property in a property form.
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This class represents a property form user interface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $lng.

◆ handleImageUpload()

ilContentStyleImageGUI::handleImageUpload ( \ILIAS\FileUpload\FileUpload  $upload,
\ILIAS\FileUpload\DTO\UploadResult  $result 
)

Definition at line 166 of file class.ilContentStyleImageGUI.php.

170 $this->manager->importFromUploadResult(
171 $result
172 );
173 return new \ILIAS\FileUpload\Handler\BasicHandlerResult(
174 '',
175 \ILIAS\FileUpload\Handler\HandlerResult::STATUS_OK,
176 "dummy",
177 ''
178 );
179 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

◆ listImages()

ilContentStyleImageGUI::listImages ( )

Definition at line 97 of file class.ilContentStyleImageGUI.php.

97 : void
98 {
99 $tpl = $this->gui->mainTemplate();
100 $ilToolbar = $this->gui->toolbar();
101 $ilCtrl = $this->gui->ctrl();
103
104 if ($this->access_manager->checkWrite()) {
105 $ilToolbar->addButton(
106 $lng->txt("sty_add_image"),
107 $ilCtrl->getLinkTarget($this, "addImage")
108 );
109 }
110
111 $table = $this->getImageTable();
112 if ($table->handleCommand()) {
113 return;
114 }
115 $tpl->setContent($table->render());
116 }

References $lng, $tpl, getImageTable(), ILIAS\UICore\GlobalTemplate\setContent(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ resizeImage()

ilContentStyleImageGUI::resizeImage ( )

Definition at line 244 of file class.ilContentStyleImageGUI.php.

244 : void
245 {
246 $ctrl = $this->gui->ctrl();
248 $main_tpl = $this->gui->mainTemplate();
249
250 $form = $this->getResizeImageForm();
251 if ($form->checkInput()) {
252 $wh = $form->getInput("width_height");
253
254 $this->manager->resizeImage(
255 $this->current_image,
256 (int) ($wh["width"] ?? 0),
257 (int) ($wh["height"] ?? 0),
258 (bool) ($wh["const_prop"] ?? false)
259 );
260
261 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
262 $ctrl->redirect($this, "listImages");
263 } else {
264 $form->setValuesByPost();
265 $main_tpl->setContent($form->getHTML());
266 }
267 }

References $lng.

◆ resizeImageForm()

ilContentStyleImageGUI::resizeImageForm ( string  $file = "")

Definition at line 206 of file class.ilContentStyleImageGUI.php.

206 : void
207 {
208 if ($file !== "") {
209 $this->current_image = $file;
210 }
211 $this->tpl->setContent($this->getResizeImageForm()->getHTML());
212 }

◆ uploadImage()

ilContentStyleImageGUI::uploadImage ( )

Definition at line 143 of file class.ilContentStyleImageGUI.php.

143 : void
144 {
145 $tpl = $this->gui->mainTemplate();
146 $ilCtrl = $this->gui->ctrl();
147 $ilCtrl->redirect($this, "listImages");
148 }

References $tpl.

Field Documentation

◆ $access_manager

Access StyleAccessManager ilContentStyleImageGUI::$access_manager
protected

Definition at line 36 of file class.ilContentStyleImageGUI.php.

Referenced by __construct().

◆ $current_image

string ilContentStyleImageGUI::$current_image = null
protected

Definition at line 37 of file class.ilContentStyleImageGUI.php.

◆ $current_images

array ilContentStyleImageGUI::$current_images = []
protected

Definition at line 41 of file class.ilContentStyleImageGUI.php.

◆ $gui

Content InternalGUIService ilContentStyleImageGUI::$gui
protected

Definition at line 32 of file class.ilContentStyleImageGUI.php.

Referenced by executeCommand().

◆ $lng

ilLanguage ilContentStyleImageGUI::$lng
protected

Definition at line 31 of file class.ilContentStyleImageGUI.php.

Referenced by listImages().

◆ $manager

Content ImageManager ilContentStyleImageGUI::$manager
protected

Definition at line 35 of file class.ilContentStyleImageGUI.php.

Referenced by __construct().

◆ $object

ilObjStyleSheet ilContentStyleImageGUI::$object
protected

Definition at line 34 of file class.ilContentStyleImageGUI.php.

◆ $request

Content StandardGUIRequest ilContentStyleImageGUI::$request
protected

Definition at line 33 of file class.ilContentStyleImageGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilContentStyleImageGUI::$tpl
protected

Definition at line 30 of file class.ilContentStyleImageGUI.php.

Referenced by addImage(), listImages(), and uploadImage().


The documentation for this class was generated from the following file: