ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  function __construct($a_parent_obj, $a_parent_cmd)
21  {
22  global $lng, $ilCtrl, $tree, $objDefinition;
23 
24  $this->lng = $lng;
25  $this->ctrl = $ilCtrl;
26  $this->tree = $tree;
27  $this->obj_def = $objDefinition;
28 
29  include_once 'Modules/ItemGroup/classes/class.ilItemGroupItems.php';
30  $this->item_group_items = new ilItemGroupItems($a_parent_obj->object->getRefId());
31  $this->items = $this->item_group_items->getItems();
32 
33  parent::__construct($a_parent_obj, $a_parent_cmd);
34  $this->setLimit(9999);
35 
36  $this->getMaterials();
37  $this->setTitle($lng->txt("itgr_assigned_materials"));
38 
39  $this->addColumn("", "", "1px", true);
40  $this->addColumn($this->lng->txt("itgr_item"));
41  $this->addColumn($this->lng->txt("itgr_assignment"));
42  $this->setSelectAllCheckbox("items[]");
43 
44  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
45  $this->setRowTemplate("tpl.item_group_items_row.html", "Modules/ItemGroup");
46 
47  $this->addCommandButton("saveItemAssignment", $lng->txt("save"));
48  }
49 
56  function getMaterials()
57  {
58  $materials = array();
59  $items = $this->item_group_items->getAssignableItems();
60 
61  foreach($items as $item)
62  {
63  $item["sorthash"] = (int)(!in_array($item['ref_id'], $this->items)).$item["title"];
64  $materials[] = $item;
65  }
66 
67  $materials = ilUtil::sortArray($materials, "sorthash", "asc");
68  $this->setData($materials);
69  }
70 
74  protected function fillRow($a_set)
75  {
76  global $lng;
77 
78  $this->tpl->setVariable("ITEM_REF_ID", $a_set["child"]);
79  $this->tpl->setVariable("TITLE", $a_set["title"]);
80  $this->tpl->setVariable("IMG", ilUtil::img(
81  ilObject::_getIcon($a_set["obj_id"], "tiny")));
82 
83  if (in_array($a_set["child"], $this->items))
84  {
85  $this->tpl->setVariable("IMG_ASSIGNED", ilUtil::img(
86  ilUtil::getImagePath("icon_ok.png")));
87  $this->tpl->setVariable("CHECKED", "checked='checked'");
88  }
89  else
90  {
91  $this->tpl->setVariable("IMG_ASSIGNED", ilUtil::img(
92  ilUtil::getImagePath("icon_not_ok.png")));
93  }
94  }
95 
96 }
97 ?>