ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilItemGroupItemsTableGUI.php
Go to the documentation of this file.
1<?php
2
20
27{
29 protected array $items;
31 protected ilTree $tree;
33
34 public function __construct(
36 ilObjItemGroupGUI $a_parent_obj,
37 string $a_parent_cmd
38 ) {
39 global $DIC;
40
41 $this->gui = $gui;
42 $lng = $DIC->language();
43 $ilCtrl = $DIC->ctrl();
44 $tree = $DIC->repositoryTree();
45 $objDefinition = $DIC["objDefinition"];
46
47 $this->lng = $lng;
48 $this->ctrl = $ilCtrl;
49 $this->tree = $tree;
50 $this->obj_def = $objDefinition;
51
52 $this->item_group_items = new ilItemGroupItems($a_parent_obj->getObject()->getRefId());
53 $this->items = $this->item_group_items->getItems();
54
55 parent::__construct($a_parent_obj, $a_parent_cmd);
56 $this->setLimit(9999);
57
58 $this->getMaterials();
59 $this->setTitle($lng->txt("itgr_assigned_materials"));
60
61 $this->addColumn("", "", "1px", true);
62 $this->addColumn($this->lng->txt("itgr_item"));
63 $this->addColumn($this->lng->txt("itgr_assignment"));
64 $this->setSelectAllCheckbox("items[]");
65
66 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
67 $this->setRowTemplate("tpl.item_group_items_row.html", "components/ILIAS/ItemGroup");
68
69 $this->addCommandButton("saveItemAssignment", $lng->txt("save"));
70 }
71
72 public function getMaterials(): void
73 {
74 $materials = array();
75 $items = $this->item_group_items->getAssignableItems();
76
77 foreach ($items as $item) {
78 $item["sorthash"] = (int) (!in_array($item['ref_id'], $this->items)) . $item["title"];
79 $materials[] = $item;
80 }
81
82 $materials = ilArrayUtil::sortArray($materials, "sorthash", "asc");
83 $this->setData($materials);
84 }
85
86 protected function fillRow(array $a_set): void
87 {
89 $f = $this->gui->ui()->factory();
90 $r = $this->gui->ui()->renderer();
91
92 $this->tpl->setVariable("ITEM_REF_ID", $a_set["child"]);
93 $this->tpl->setVariable("TITLE", $a_set["title"]);
94 $this->tpl->setVariable("IMG", ilUtil::img(
95 ilObject::_getIcon((int) $a_set["obj_id"], "tiny"),
96 "",
97 "",
98 "",
99 "",
100 "",
101 "ilIcon"
102 ));
103
104 if (in_array($a_set["child"], $this->items)) {
105 $i = $f->symbol()->icon()->custom(
106 ilUtil::getImagePath("standard/icon_ok.svg"),
107 $this->lng->txt("yes")
108 );
109 $this->tpl->setVariable("IMG_ASSIGNED", $r->render($i));
110 $this->tpl->setVariable("CHECKED", "checked='checked'");
111 } else {
112 $i = $f->symbol()->icon()->custom(
113 ilUtil::getImagePath("standard/icon_not_ok.svg"),
114 $this->lng->txt("no")
115 );
116 $this->tpl->setVariable("IMG_ASSIGNED", $r->render($i));
117 }
118 }
119}
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(InternalGUIService $gui, ilObjItemGroupGUI $a_parent_obj, string $a_parent_cmd)
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...
User Interface class for item groups.
parses the objects.xml it handles the xml-description of all ilias objects
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
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)
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
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26