ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilNewItemGroupTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("Services/Table/classes/class.ilTable2GUI.php");
5 include_once("Services/Repository/classes/class.ilObjRepositorySettings.php");
6 
16 {
20  protected $ctrl;
21 
22  protected $has_write; // [bool]
23 
24  public function __construct($a_parent_obj, $a_parent_cmd = "", $a_has_write = false)
25  {
26  global $DIC;
27 
28  $this->ctrl = $DIC->ctrl();
29  $this->lng = $DIC->language();
30  $ilCtrl = $DIC->ctrl();
31  $lng = $DIC->language();
32 
33  $this->has_write = (bool) $a_has_write;
34 
35  parent::__construct($a_parent_obj, $a_parent_cmd);
36 
37  $this->setId("repnwitgrptbl");
38 
39  $this->setTitle($lng->txt("rep_new_item_groups"));
40 
41  if ($this->has_write) {
42  $this->addColumn("", "", 1);
43  }
44  $this->addColumn($lng->txt("cmps_add_new_rank"), "");
45  $this->addColumn($lng->txt("title"), "");
46  $this->addColumn($lng->txt("rep_new_item_group_nr_subitems"), "");
47 
48  if ($this->has_write) {
49  $this->addColumn($lng->txt("action"), "");
50  }
51 
52  if ($this->has_write) {
53  $this->addCommandButton("saveNewItemGroupOrder", $lng->txt("cmps_save_options"));
54  $this->addMultiCommand("confirmDeleteNewItemGroup", $lng->txt("delete"));
55  }
56 
57  $this->setEnableHeader(true);
58  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
59  $this->setRowTemplate("tpl.table_row_new_item_group.html", "Services/Repository");
60  $this->setLimit(10000);
61 
62  $this->setExternalSorting(true);
63  $this->getGroups();
64  }
65 
69  public function getGroups()
70  {
71  $lng = $this->lng;
72 
73  $data = array();
74 
76 
77  if ($subitems[0]) {
78  ilUtil::sendInfo(sprintf(
79  $lng->txt("rep_new_item_group_unassigned_subitems"),
80  is_array($subitems[0]) ? sizeof($subitems[0]) : 0
81  ));
82  unset($subitems[0]);
83  }
84 
85  foreach (ilObjRepositorySettings::getNewItemGroups() as $item) {
86  $data[] = array(
87  "id" => $item["id"],
88  "pos" => $item["pos"],
89  "title" => $item["title"],
90  "type" => $item["type"],
91  "subitems" => is_array($subitems[$item["id"]]) ? sizeof($subitems[$item["id"]]) : 0
92  );
93  }
94 
95  $data = ilUtil::sortArray($data, "pos", "asc", true);
96 
97  $this->setData($data);
98  }
99 
100  protected function fillRow($a_set)
101  {
102  $lng = $this->lng;
104 
105  if ($this->has_write) {
106  $this->tpl->setVariable("VAR_MULTI", "grp_id[]");
107  $this->tpl->setVariable("VAL_MULTI", $a_set["id"]);
108  }
109 
110  $this->tpl->setVariable("VAR_POS", "grp_order[" . $a_set["id"] . "]");
111  $this->tpl->setVariable("VAL_POS", $a_set["pos"]);
112  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
113 
115  $this->tpl->setVariable("VAL_ITEMS", $a_set["subitems"]);
116 
117  if ($this->has_write) {
118  $ilCtrl->setParameter($this->parent_obj, "grp_id", $a_set["id"]);
119  $url = $ilCtrl->getLinkTarget($this->parent_obj, "editNewItemGroup");
120  $ilCtrl->setParameter($this->parent_obj, "grp_id", "");
121 
122  $this->tpl->setVariable("URL_EDIT", $url);
123  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
124  }
125  }
126  }
127 }
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
setExternalSorting($a_val)
Set external sorting.
TableGUI class for new item groups.
global $DIC
Definition: saml.php:7
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
__construct($a_parent_obj, $a_parent_cmd="", $a_has_write=false)
Class ilTable2GUI.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
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.
setEnableHeader($a_enableheader)
Set Enable Header.
$url
setLimit($a_limit=0, $a_default_limit=0)