ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilItemGroupItemsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Table/classes/class.ilTable2GUI.php");
6 
16 {
20  protected $tree;
21 
25  protected $obj_def;
26 
30  public function __construct($a_parent_obj, $a_parent_cmd)
31  {
32  global $DIC;
33 
34  $lng = $DIC->language();
35  $ilCtrl = $DIC->ctrl();
36  $tree = $DIC->repositoryTree();
37  $objDefinition = $DIC["objDefinition"];
38 
39  $this->lng = $lng;
40  $this->ctrl = $ilCtrl;
41  $this->tree = $tree;
42  $this->obj_def = $objDefinition;
43 
44  include_once 'Modules/ItemGroup/classes/class.ilItemGroupItems.php';
45  $this->item_group_items = new ilItemGroupItems($a_parent_obj->object->getRefId());
46  $this->items = $this->item_group_items->getItems();
47 
48  parent::__construct($a_parent_obj, $a_parent_cmd);
49  $this->setLimit(9999);
50 
51  $this->getMaterials();
52  $this->setTitle($lng->txt("itgr_assigned_materials"));
53 
54  $this->addColumn("", "", "1px", true);
55  $this->addColumn($this->lng->txt("itgr_item"));
56  $this->addColumn($this->lng->txt("itgr_assignment"));
57  $this->setSelectAllCheckbox("items[]");
58 
59  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
60  $this->setRowTemplate("tpl.item_group_items_row.html", "Modules/ItemGroup");
61 
62  $this->addCommandButton("saveItemAssignment", $lng->txt("save"));
63  }
64 
71  public function getMaterials()
72  {
73  $materials = array();
74  $items = $this->item_group_items->getAssignableItems();
75 
76  foreach ($items as $item) {
77  $item["sorthash"] = (int) (!in_array($item['ref_id'], $this->items)) . $item["title"];
78  $materials[] = $item;
79  }
80 
81  $materials = ilUtil::sortArray($materials, "sorthash", "asc");
82  $this->setData($materials);
83  }
84 
88  protected function fillRow($a_set)
89  {
90  $lng = $this->lng;
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($a_set["obj_id"], "tiny"),
96  "",
97  "",
98  "",
99  "",
100  "",
101  "ilIcon"
102  ));
103 
104  if (in_array($a_set["child"], $this->items)) {
105  $this->tpl->setVariable("IMG_ASSIGNED", ilUtil::img(
106  ilUtil::getImagePath("icon_ok.svg")
107  ));
108  $this->tpl->setVariable("CHECKED", "checked='checked'");
109  } else {
110  $this->tpl->setVariable("IMG_ASSIGNED", ilUtil::img(
111  ilUtil::getImagePath("icon_not_ok.svg")
112  ));
113  }
114  }
115 }
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
global $DIC
Definition: saml.php:7
__construct($a_parent_obj, $a_parent_cmd)
Constructor.
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Item group items.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setLimit($a_limit=0, $a_default_limit=0)