ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilBadgeImageTemplateTableGUI.php
Go to the documentation of this file.
1 <?php
2 
24 {
25  public function __construct(
26  object $a_parent_obj,
27  string $a_parent_cmd = "",
28  protected bool $has_write = false
29  ) {
30  global $DIC;
31 
32  $this->ctrl = $DIC->ctrl();
33  $this->lng = $DIC->language();
34  $ilCtrl = $DIC->ctrl();
35  $lng = $DIC->language();
36 
37  $this->setId("bdgtmpl");
38 
39  parent::__construct($a_parent_obj, $a_parent_cmd);
40 
41  $this->setLimit(9999);
42 
43  $this->setTitle($lng->txt("badge_image_templates"));
44 
45  if ($this->has_write) {
46  $this->addColumn("", "", 1);
47  }
48 
49  $this->addColumn($lng->txt("title"), "title");
50  $this->addColumn($lng->txt("image"), "image");
51 
52  if ($this->has_write) {
53  $this->addColumn($lng->txt("action"), "");
54  $this->addMultiCommand("confirmDeleteImageTemplates", $lng->txt("delete"));
55  }
56 
57  $this->setSelectAllCheckbox("id");
58 
59  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
60  $this->setRowTemplate("tpl.template_row.html", "Services/Badge");
61  $this->setDefaultOrderField("title");
62 
63  $this->getItems();
64  }
65 
66  public function getItems(): void
67  {
68  $data = array();
69 
70  foreach (ilBadgeImageTemplate::getInstances() as $template) {
71  $data[] = array(
72  "id" => $template->getId(),
73  "title" => $template->getTitle(),
74  "path" => $template->getImagePath(),
75  "file" => $template->getImage()
76  );
77  }
78 
79  $this->setData($data);
80  }
81 
82  protected function fillRow(array $a_set): void
83  {
84  $lng = $this->lng;
85  $ilCtrl = $this->ctrl;
86 
87  if ($this->has_write) {
88  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
89  }
90 
91  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
92  $this->tpl->setVariable("VAL_IMG", ilWACSignedPath::signFile($a_set["path"]));
93  $this->tpl->setVariable("TXT_IMG", $a_set["file"]);
94 
95  if ($this->has_write) {
96  $ilCtrl->setParameter($this->getParentObject(), "tid", $a_set["id"]);
97  $url = $ilCtrl->getLinkTarget($this->getParentObject(), "editImageTemplate");
98  $ilCtrl->setParameter($this->getParentObject(), "tid", "");
99 
100  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
101  $this->tpl->setVariable("URL_EDIT", $url);
102  }
103  }
104 }
setData(array $a_data)
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)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
ilLanguage $lng
setId(string $a_val)
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
$url
Definition: ltiregstart.php:35
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setLimit(int $a_limit=0, int $a_default_limit=0)
static signFile(string $path_to_file)
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
addMultiCommand(string $a_cmd, string $a_text)
__construct(object $a_parent_obj, string $a_parent_cmd="", protected bool $has_write=false)