ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilStyleImageTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
24 
31 {
36  protected UIServices $ui;
38 
42  public function __construct(
43  object $a_parent_obj,
44  string $a_parent_cmd,
45  Access\StyleAccessManager $access_manager,
46  Content\ImageManager $image_manager
47  ) {
48  global $DIC;
49 
50  $this->ctrl = $DIC->ctrl();
51  $this->lng = $DIC->language();
52  $this->access = $DIC->access();
53  $this->rbacsystem = $DIC->rbac()->system();
54  $ilCtrl = $DIC->ctrl();
55  $lng = $DIC->language();
56  $this->access_manager = $access_manager;
57  $this->image_manager = $image_manager;
58  $this->ui = $DIC->ui();
59 
60  parent::__construct($a_parent_obj, $a_parent_cmd);
61 
62  $this->setTitle($lng->txt("sty_images"));
63 
64  $this->addColumn("", "", "1"); // checkbox
65  $this->addColumn($this->lng->txt("thumbnail"));
66  $this->addColumn($this->lng->txt("file"), "file");
67  $this->addColumn($this->lng->txt("sty_width_height"));
68  $this->addColumn($this->lng->txt("size"));
69  $this->addColumn($this->lng->txt("actions"));
70  $this->setEnableHeader(true);
71  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
72  $this->setRowTemplate("tpl.style_image_row.html", "Services/Style/Content/Images");
73  $this->setSelectAllCheckbox("file");
74  $this->getItems();
75 
76  // action commands
77  if ($this->access_manager->checkWrite()) {
78  $this->addMultiCommand("deleteImage", $lng->txt("delete"));
79  }
80 
81  //$this->addMultiCommand("editLink", $lng->txt("cont_set_link"));
82  //$this->addCommandButton("addImage", $this->lng->txt("sty_add_image"));
83 
84  $this->setEnableTitle(true);
85  }
86 
90  public function getItems(): void
91  {
92  $images = [];
94  foreach ($this->image_manager->getImages() as $i) {
95  $images[] = [
96  "file" => $i->getFilename(),
97  "obj" => $i
98  ];
99  }
100  $this->setData($images);
101  }
102 
103  protected function fillRow(array $a_set): void
104  {
105  $ilCtrl = $this->ctrl;
106  $ui = $this->ui;
107 
109  $image = $a_set["obj"];
110 
111  $image_file = $this->image_manager->getWebPath($image);
112  if (is_file($image_file)) {
113  $this->tpl->setCurrentBlock("thumbnail");
114  $this->tpl->setVariable("IMG_ALT", $image->getFilename());
115  $this->tpl->setVariable("IMG_SRC", $image_file);
116  $this->tpl->parseCurrentBlock();
117  }
118 
119  if ($image->getWidth() > 0 && $image->getHeight() > 0) {
120  $this->tpl->setVariable(
121  "VAL_WIDTH_HEIGHT",
122  $image->getWidth() . "px x " . $image->getHeight() . "px"
123  );
124  }
125 
126  $size = $image->getSize();
127  $this->tpl->setVariable("VAL_FILENAME", $image->getFilename());
128  $this->tpl->setVariable(
129  "VAL_SIZE",
130  round($size->getSize(), 1) . " " . "kB"
131  );
132  $this->tpl->setVariable("FILE", $image->getFilename());
133 
134  if ($this->access_manager->checkWrite()) {
135  $ilCtrl->setParameter($this->parent_obj, "file", rawurlencode($image->getFilename()));
136 
137  $links = [];
138  if ($this->image_manager->supportsResize($image)) {
139  $links[] = $ui->factory()->link()->standard(
140  $this->lng->txt("sty_resize"),
141  $ilCtrl->getLinkTargetByClass("ilContentStyleImageGUI", "resizeImageForm")
142  );
143  }
144 
145  $dd = $ui->factory()->dropdown()->standard($links);
146 
147  $this->tpl->setVariable(
148  "ACTIONS",
149  $ui->renderer()->render($dd)
150  );
151  }
152  }
153 }
setData(array $a_data)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
setFormAction(string $a_form_action, bool $a_multipart=false)
setEnableTitle(bool $a_enabletitle)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
__construct(object $a_parent_obj, string $a_parent_cmd, Access\StyleAccessManager $access_manager, Content\ImageManager $image_manager)
Constructor.
ilLanguage $lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Access StyleAccessManager $access_manager
global $DIC
Definition: feed.php:28
Provides fluid interface to RBAC services.
Definition: UIServices.php:23
Main business logic for content style images.
fillRow(array $a_set)
Standard Version of Fill Row.
renderer()
Get a renderer for UI components.
Definition: UIServices.php:43
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
TableGUI class for style editor (image list)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
Content ImageManager $image_manager
__construct(Container $dic, ilPlugin $plugin)
Manages access to content style editing.
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
factory()
Get the factory that crafts UI components.
Definition: UIServices.php:35
addMultiCommand(string $a_cmd, string $a_text)
setEnableHeader(bool $a_enableheader)
$i
Definition: metadata.php:41