ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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)
 
 deleteImage ()
 
 getResizeImageForm ()
 
 resizeImage ()
 

Protected Member Functions

 getImageForm ()
 
 resizeImageForm ()
 

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 120 of file class.ilContentStyleImageGUI.php.

120 : void
121 {
122 $tpl = $this->gui->mainTemplate();
123
124 $form = $this->getImageForm();
125 $tpl->setContent($form->render());
126 }
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 128 of file class.ilContentStyleImageGUI.php.

128 : void
129 {
130 $ilCtrl = $this->gui->ctrl();
131
132 $ilCtrl->redirect($this, "listImages");
133 }

◆ deleteImage()

ilContentStyleImageGUI::deleteImage ( )

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

173 : void
174 {
175 $ilCtrl = $this->gui->ctrl();
176 foreach ($this->current_images as $i) {
177 $this->manager->deleteByFilename($i);
178 }
179 $ilCtrl->redirect($this, "listImages");
180 }

◆ 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", "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 142 of file class.ilContentStyleImageGUI.php.

143 {
144 $form = $this->gui->form(self::class, "uploadImage")
145 ->section("image_section", $this->lng->txt("sty_add_image"))
146 ->file(
147 "image",
148 $this->lng->txt("sty_image_file"),
149 $this->handleImageUpload(...), // Placeholder for upload handler
150 "image_id",
151 "",
152 1, // Limit to 1 file upload
153 ["image/jpeg", "image/png", "image/gif", "image/svg+xml"] // Accepted file types
154 );
155 return $form;
156 }
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:

◆ getResizeImageForm()

ilContentStyleImageGUI::getResizeImageForm ( )

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

188 {
189 $ctrl = $this->gui->ctrl();
191
192 $form = new ilPropertyFormGUI();
193
194 $image = $this->manager->getByFilename($this->current_image);
195
196 // width height
197 $width_height = new ilWidthHeightInputGUI($lng->txt("cont_width") .
198 " / " . $lng->txt("cont_height"), "width_height");
199 $width_height->setConstrainProportions(true);
200 $width_height->setHeight($image->getHeight());
201 $width_height->setWidth($image->getWidth());
202 $form->addItem($width_height);
203
204 // file
205 $hi = new ilHiddenInputGUI("file");
206 $hi->setValue($this->current_image);
207 $form->addItem($hi);
208
209 $form->addCommandButton("resizeImage", $lng->txt("sty_resize"));
210
211 $form->setTitle($lng->txt("sty_resize_image"));
212 $form->setFormAction($ctrl->getFormAction($this));
213
214 return $form;
215 }
This class represents a hidden form property in a property form.
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 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 158 of file class.ilContentStyleImageGUI.php.

162 $this->manager->importFromUploadResult(
163 $result
164 );
165 return new \ILIAS\FileUpload\Handler\BasicHandlerResult(
166 '',
167 \ILIAS\FileUpload\Handler\HandlerResult::STATUS_OK,
168 "dummy",
169 ''
170 );
171 }
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_gui = new ilStyleImageTableGUI(
112 $this,
113 "listImages",
114 $this->access_manager,
115 $this->manager
116 );
117 $tpl->setContent($table_gui->getHTML());
118 }
TableGUI class for style editor (image list)

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

+ Here is the call graph for this function:

◆ resizeImage()

ilContentStyleImageGUI::resizeImage ( )

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

217 : void
218 {
219 $ctrl = $this->gui->ctrl();
221 $main_tpl = $this->gui->mainTemplate();
222
223 $form = $this->getResizeImageForm();
224 if ($form->checkInput()) {
225 $wh = $form->getInput("width_height");
226
227 $this->manager->resizeImage(
228 $this->current_image,
229 (int) ($wh["width"] ?? 0),
230 (int) ($wh["height"] ?? 0),
231 (bool) ($wh["const_prop"] ?? false)
232 );
233
234 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
235 $ctrl->redirect($this, "listImages");
236 } else {
237 $form->setValuesByPost();
238 $main_tpl->setContent($form->getHTML());
239 }
240 }

References $lng.

◆ resizeImageForm()

ilContentStyleImageGUI::resizeImageForm ( )
protected

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

182 : void
183 {
184 $this->tpl->setContent($this->getResizeImageForm()->getHTML());
185 }

◆ uploadImage()

ilContentStyleImageGUI::uploadImage ( )

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

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

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: