ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilExcCriteriaTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once "Services/Table/classes/class.ilTable2GUI.php";
6 
14 {
15  protected $cat_id; // [int]
16 
17  public function __construct($a_parent_obj, $a_parent_cmd, $a_cat_id)
18  {
19  global $DIC;
20 
21  $this->ctrl = $DIC->ctrl();
22  $this->lng = $DIC->language();
23  $ilCtrl = $DIC->ctrl();
24  $lng = $DIC->language();
25 
26  $this->cat_id = $a_cat_id;
27  $this->setId("exccrit" . $this->cat_id);
28 
29  parent::__construct($a_parent_obj, $a_parent_cmd);
30 
31  $this->setLimit(9999); // because of manual order
32 
33  $this->setTitle($lng->txt("exc_criterias"));
34 
35  $this->addColumn("", "", "1", true);
36  $this->addColumn($this->lng->txt("position"), "pos", "10%");
37  $this->addColumn($this->lng->txt("title"), "title");
38  $this->addColumn($this->lng->txt("type"), "type");
39  $this->addColumn($this->lng->txt("actions"));
40 
41  $this->setDefaultOrderField("pos");
42  $this->setDefaultOrderDirection("asc");
43 
44  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
45  $this->setRowTemplate("tpl.exc_crit_row.html", "Modules/Exercise");
46  $this->setSelectAllCheckbox("id");
47 
48  $this->addMultiCommand("confirmDeletion", $lng->txt("delete"));
49 
50  if ($this->getItems()) {
51  $this->addCommandButton("saveOrder", $lng->txt("exc_save_order"));
52  }
53  }
54 
55  protected function getItems()
56  {
57  $data = array();
58 
59  $pos = 0;
60  foreach (ilExcCriteria::getInstancesByParentId($this->cat_id) as $item) {
61  $pos += 10;
62 
63  $data[] = array(
64  "id" => $item->getId()
65  ,"type" => $item->getTranslatedType()
66  ,"pos" => $pos
67  ,"title" => $item->getTitle()
68  );
69  }
70 
71  $this->setData($data);
72 
73  return (bool) sizeof($data);
74  }
75 
76  public function numericOrdering($a_field)
77  {
78  return in_array($a_field, array("pos"));
79  }
80 
81  protected function fillRow($a_set)
82  {
83  $lng = $this->lng;
85 
86  $this->tpl->setVariable("ID", $a_set["id"]);
87  $this->tpl->setVariable("POS", $a_set["pos"]);
88  $this->tpl->setVariable("TYPE", $a_set["type"]);
89  $this->tpl->setVariable("TITLE", $a_set["title"]);
90 
91  $ilCtrl->setParameter($this->getParentObject(), "crit_id", $a_set["id"]);
92  $url = $ilCtrl->getLinkTarget($this->getParentObject(), "edit");
93  $ilCtrl->setParameter($this->getParentObject(), "crit_id", "");
94 
95  $this->tpl->setCurrentBlock("action_bl");
96  $this->tpl->setVariable("ACTION_URL", $url);
97  $this->tpl->setVariable("ACTION_TXT", $lng->txt("edit"));
98  $this->tpl->parseCurrentBlock();
99  }
100 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
__construct($a_parent_obj, $a_parent_cmd, $a_cat_id)
global $DIC
Definition: saml.php:7
getParentObject()
Get parent object.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
static getInstancesByParentId($a_parent_id)
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
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.
$url
Class ilExcCriteriaTableGUI.
setLimit($a_limit=0, $a_default_limit=0)