ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilClipboardTableGUI.php
Go to the documentation of this file.
1 <?php
2 
24 {
26  protected ilObjUser $user;
27 
28  public function __construct(
29  object $a_parent_obj,
30  string $a_parent_cmd
31  ) {
32  global $DIC;
33 
34  $this->ctrl = $DIC->ctrl();
35  $this->lng = $DIC->language();
36  $this->access = $DIC->access();
37  $this->user = $DIC->user();
38  $ilCtrl = $DIC->ctrl();
39  $lng = $DIC->language();
40 
41  parent::__construct($a_parent_obj, $a_parent_cmd);
42  $lng->loadLanguageModule("mep");
43 
44  $this->addColumn("", "", "1"); // checkbox
45  $this->addColumn($lng->txt("mep_thumbnail"), "", "1");
46  $this->addColumn($lng->txt("mep_title_and_description"), "", "100%");
47  $this->setEnableHeader(true);
48  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
49  $this->setRowTemplate(
50  "tpl.clipboard_tbl_row.html",
51  "Modules/MediaPool/Clipboard"
52  );
53  $this->getItems();
54 
55  // title
56  $this->setTitle($lng->txt("clipboard"));
57 
58  $this->setDefaultOrderField("title");
59 
60  // action commands
61  if ($this->parent_obj->mode === "getObject") {
62  $this->addMultiCommand("insert", $this->parent_obj->getInsertButtonTitle());
63  }
64  $this->addMultiCommand("remove", $lng->txt("remove"));
65 
66  $this->setSelectAllCheckbox("id");
67  }
68 
72  public function getItems(): void
73  {
75 
76  $objs = $ilUser->getClipboardObjects("mob");
77  $objs2 = $ilUser->getClipboardObjects("incl");
78  $objs = array_merge($objs, $objs2);
79 
80  $this->setData($objs);
81  }
82 
83  protected function fillRow(array $a_set): void
84  {
85  $ilCtrl = $this->ctrl;
86 
87  $mob = null;
88  if ($a_set["type"] === "mob") {
89  // output thumbnail
90  $mob = new ilObjMediaObject($a_set["id"]);
91  $med = $mob->getMediaItem("Standard");
92  $target = $med->getThumbnailTarget();
93  if ($target !== "") {
94  $this->tpl->setCurrentBlock("thumbnail");
95  $this->tpl->setVariable("IMG_THUMB", $target);
96  $this->tpl->parseCurrentBlock();
97  }
98  if (ilUtil::deducibleSize($med->getFormat()) &&
99  $med->getLocationType() === "Reference") {
100  $size = getimagesize($med->getLocation());
101  if ($size[0] > 0 && $size[1] > 0) {
102  $wr = $size[0] / 80;
103  $hr = $size[1] / 80;
104  $r = max($wr, $hr);
105  $w = (int) ($size[0] / $r);
106  $h = (int) ($size[1] / $r);
107  $this->tpl->setVariable(
108  "IMG",
109  ilUtil::img($med->getLocation(), "", $w, $h)
110  );
111  }
112  }
113  } elseif ($a_set["type"] === "incl") {
114  $this->tpl->setCurrentBlock("thumbnail");
115  $this->tpl->setVariable(
116  "IMG_THUMB",
117  ilUtil::getImagePath("icon_pg.svg")
118  );
119  $this->tpl->parseCurrentBlock();
120  }
121 
122  // allow editing of media objects
123  if ($this->parent_obj->mode !== "getObject" && $a_set["type"] === "mob") {
124  // output edit link
125  $this->tpl->setCurrentBlock("edit");
126  $ilCtrl->setParameter($this->parent_obj, "clip_item_id", $a_set["id"]);
127  $ilCtrl->setParameterByClass("ilObjMediaObjectGUI", "clip_item_id", $a_set["id"]);
128  $this->tpl->setVariable(
129  "EDIT_LINK",
130  $ilCtrl->getLinkTargetByClass(
131  "ilObjMediaObjectGUI",
132  "edit"
133  )
134  );
135  $this->tpl->setVariable("TEXT_OBJECT", $a_set["title"] .
136  " [" . $a_set["id"] . "]");
137  } else { // just list elements for selection
138  $this->tpl->setCurrentBlock("show");
139  $this->tpl->setVariable("TEXT_OBJECT2", $a_set["title"] .
140  " [" . $a_set["id"] . "]");
141  }
142  $this->tpl->parseCurrentBlock();
143 
144  if ($a_set["type"] === "mob") {
145  $this->tpl->setVariable(
146  "MEDIA_INFO",
148  );
149  }
150  $this->tpl->setVariable("CHECKBOX_ID", $a_set["type"] . ":" . $a_set["id"]);
151  }
152 }
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)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
loadLanguageModule(string $a_module)
Load language module.
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
ilLanguage $lng
global $DIC
Definition: feed.php:28
getItems()
Get items from user clipboard.
__construct(object $a_parent_obj, string $a_parent_cmd)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
static deducibleSize(string $a_mime)
checks if mime type is provided by getimagesize()
__construct(Container $dic, ilPlugin $plugin)
$ilUser
Definition: imgupload.php:34
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)
static _getMediaInfoHTML(ilObjMediaObject $a_mob)
get media info as html
addMultiCommand(string $a_cmd, string $a_text)
setEnableHeader(bool $a_enableheader)