ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilStyleImageTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24
31{
36 protected UIServices $ui;
38
42 public function __construct(
43 object $a_parent_obj,
44 string $a_parent_cmd,
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", "components/ILIAS/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(true) 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) || str_starts_with($image_file, "http")) {
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}
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
renderer()
Get a renderer for UI components.
Definition: UIServices.php:44
factory()
Get the factory that crafts UI components.
Definition: UIServices.php:36
Manages access to content style editing.
Main business logic for content style images.
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...
Class ilObjStyleSheet.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
TableGUI class for style editor (image list)
Content ImageManager $image_manager
__construct(object $a_parent_obj, string $a_parent_cmd, Access\StyleAccessManager $access_manager, Content\ImageManager $image_manager)
Constructor.
Access StyleAccessManager $access_manager
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setEnableTitle(bool $a_enabletitle)
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
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)
setEnableHeader(bool $a_enableheader)
fillRow(array $a_set)
Standard Version of Fill Row.
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
ilLanguage $lng
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26