ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilContentStyleImageGUI Class Reference

Content style images UI. 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 ()
 
 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

Content style images UI.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

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

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

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

49  {
50  $this->access_manager = $access_manager;
51 
52  $this->lng = $domain_service->lng();
53  $this->lng->loadLanguageModule("content");
54 
55  $this->request = $gui_service
56  ->standardRequest();
57  $this->gui = $gui_service;
58 
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;
63  } else {
64  $this->current_images = array_filter($images, function ($i) use ($manager) {
65  return $manager->filenameExists($i);
66  });
67  }
68 
69  $this->manager = $manager;
70  $this->tpl = $gui_service->mainTemplate();
71  }
Access StyleAccessManager $access_manager
$i
Definition: metadata.php:41
+ Here is the call graph for this function:

Member Function Documentation

◆ addImage()

ilContentStyleImageGUI::addImage ( )

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

References getImageForm(), and ilGlobalTemplateInterface\setContent().

114  : void
115  {
116  $tpl = $this->gui->mainTemplate();
117 
118  $form = $this->getImageForm();
119  $tpl->setContent($form->getHTML());
120  }
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.
+ Here is the call graph for this function:

◆ cancelUpload()

ilContentStyleImageGUI::cancelUpload ( )

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

122  : void
123  {
124  $ilCtrl = $this->gui->ctrl();
125 
126  $ilCtrl->redirect($this, "listImages");
127  }

◆ deleteImage()

ilContentStyleImageGUI::deleteImage ( )

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

References $i.

166  : void
167  {
168  $ilCtrl = $this->gui->ctrl();
169  foreach ($this->current_images as $i) {
170  $this->manager->deleteByFilename($i);
171  }
172  $ilCtrl->redirect($this, "listImages");
173  }
$i
Definition: metadata.php:41

◆ executeCommand()

ilContentStyleImageGUI::executeCommand ( )

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

73  : void
74  {
75  $ctrl = $this->gui->ctrl();
76 
77  $next_class = $ctrl->getNextClass($this);
78  $cmd = $ctrl->getCmd("listImages");
79 
80  switch ($next_class) {
81  default:
82  if (in_array($cmd, [
83  "listImages", "addImage", "cancelUpload", "uploadImage", "deleteImage",
84  "resizeImageForm", "resizeImage"
85  ])) {
86  $this->$cmd();
87  }
88  }
89  }

◆ getImageForm()

ilContentStyleImageGUI::getImageForm ( )
protected

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

References $lng, ilFileInputGUI\setSuffixes(), and ilLanguage\txt().

Referenced by addImage(), and uploadImage().

146  {
147  $lng = $this->lng;
148  $ilCtrl = $this->gui->ctrl();
149 
150  $form_gui = new ilPropertyFormGUI();
151 
152  $form_gui->setTitle($lng->txt("sty_add_image"));
153 
154  $file_input = new ilImageFileInputGUI($lng->txt("sty_image_file"), "image_file");
155  $file_input->setSuffixes(["jpg","jpeg","png","gif","svg"]);
156  $file_input->setRequired(true);
157  $form_gui->addItem($file_input);
158 
159  $form_gui->addCommandButton("uploadImage", $lng->txt("upload"));
160  $form_gui->addCommandButton("cancelUpload", $lng->txt("cancel"));
161  $form_gui->setFormAction($ilCtrl->getFormAction($this));
162 
163  return $form_gui;
164  }
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...
setSuffixes(array $a_suffixes)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getResizeImageForm()

ilContentStyleImageGUI::getResizeImageForm ( )

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

References $lng, ilWidthHeightInputGUI\setConstrainProportions(), and ilLanguage\txt().

Referenced by resizeImage(), and resizeImageForm().

181  {
182  $ctrl = $this->gui->ctrl();
183  $lng = $this->lng;
184 
185  $form = new ilPropertyFormGUI();
186 
187  $image = $this->manager->getByFilename($this->current_image);
188 
189  // width height
190  $width_height = new ilWidthHeightInputGUI($lng->txt("cont_width") .
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);
196 
197  // file
198  $hi = new ilHiddenInputGUI("file");
199  $hi->setValue($this->current_image);
200  $form->addItem($hi);
201 
202  $form->addCommandButton("resizeImage", $lng->txt("sty_resize"));
203 
204  $form->setTitle($lng->txt("sty_resize_image"));
205  $form->setFormAction($ctrl->getFormAction($this));
206 
207  return $form;
208  }
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...
setConstrainProportions(bool $a_constrainproportions)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listImages()

ilContentStyleImageGUI::listImages ( )

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

References $lng, ilGlobalTemplateInterface\setContent(), and ilLanguage\txt().

91  : void
92  {
93  $tpl = $this->gui->mainTemplate();
94  $ilToolbar = $this->gui->toolbar();
95  $ilCtrl = $this->gui->ctrl();
96  $lng = $this->lng;
97 
98  if ($this->access_manager->checkWrite()) {
99  $ilToolbar->addButton(
100  $lng->txt("sty_add_image"),
101  $ilCtrl->getLinkTarget($this, "addImage")
102  );
103  }
104 
105  $table_gui = new ilStyleImageTableGUI(
106  $this,
107  "listImages",
108  $this->access_manager,
109  $this->manager
110  );
111  $tpl->setContent($table_gui->getHTML());
112  }
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...
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.
TableGUI class for style editor (image list)
+ Here is the call graph for this function:

◆ resizeImage()

ilContentStyleImageGUI::resizeImage ( )

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

References $lng, getResizeImageForm(), and ilLanguage\txt().

210  : void
211  {
212  $ctrl = $this->gui->ctrl();
213  $lng = $this->lng;
214  $main_tpl = $this->gui->mainTemplate();
215 
216  $form = $this->getResizeImageForm();
217  if ($form->checkInput()) {
218  $wh = $form->getInput("width_height");
219 
220  $this->manager->resizeImage(
221  $this->current_image,
222  (int) ($wh["width"] ?? 0),
223  (int) ($wh["height"] ?? 0),
224  (bool) ($wh["const_prop"] ?? false)
225  );
226 
227  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
228  $ctrl->redirect($this, "listImages");
229  } else {
230  $form->setValuesByPost();
231  $main_tpl->setContent($form->getHTML());
232  }
233  }
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...
+ Here is the call graph for this function:

◆ resizeImageForm()

ilContentStyleImageGUI::resizeImageForm ( )
protected

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

References getResizeImageForm().

175  : void
176  {
177  $this->tpl->setContent($this->getResizeImageForm()->getHTML());
178  }
+ Here is the call graph for this function:

◆ uploadImage()

ilContentStyleImageGUI::uploadImage ( )

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

References getImageForm(), and ilGlobalTemplateInterface\setContent().

129  : void
130  {
131  $tpl = $this->gui->mainTemplate();
132  $ilCtrl = $this->gui->ctrl();
133 
134  $form = $this->getImageForm();
135 
136  if ($form->checkInput()) {
137  $this->manager->uploadImage();
138  $ilCtrl->redirect($this, "listImages");
139  } else {
140  //$this->form_gui->setImageFormValuesByPost();
141  $tpl->setContent($form->getHTML());
142  }
143  }
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.
+ Here is the call graph for this function:

Field Documentation

◆ $access_manager

Access StyleAccessManager ilContentStyleImageGUI::$access_manager
protected

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

Referenced by __construct().

◆ $current_image

string ilContentStyleImageGUI::$current_image = null
protected

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

◆ $current_images

array ilContentStyleImageGUI::$current_images = []
protected

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

◆ $gui

Content InternalGUIService ilContentStyleImageGUI::$gui
protected

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

◆ $lng

ilLanguage ilContentStyleImageGUI::$lng
protected

◆ $manager

Content ImageManager ilContentStyleImageGUI::$manager
protected

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

Referenced by __construct().

◆ $object

ilObjStyleSheet ilContentStyleImageGUI::$object
protected

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

◆ $request

Content StandardGUIRequest ilContentStyleImageGUI::$request
protected

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

◆ $tpl

ilGlobalTemplateInterface ilContentStyleImageGUI::$tpl
protected

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


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