ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAdvancedMDRecordTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
13 include_once('Services/Table/classes/class.ilTable2GUI.php');
14 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
15 
17 {
18  protected $lng = null;
19  protected $ctrl;
20  protected $permissions; // [ilAdvancedMDPermissionHelper]
21 
29  public function __construct($a_parent_obj, $a_parent_cmd = '', ilAdvancedMDPermissionHelper $a_permissions, $a_in_object_context = false)
30  {
31  global $lng,$ilCtrl;
32 
33  $this->lng = $lng;
34  $this->ctrl = $ilCtrl;
35  $this->permissions = $a_permissions;
36 
37  parent::__construct($a_parent_obj, $a_parent_cmd);
38  $this->addColumn('', '', 1);
39  $this->addColumn($this->lng->txt('title'), 'title');
40  $this->addColumn($this->lng->txt('md_fields'), 'fields');
41  $this->addColumn($this->lng->txt('md_adv_scope'), 'scope');
42  $this->addColumn($this->lng->txt('md_obj_types'), 'obj_types');
43  $this->addColumn($this->lng->txt('md_adv_active'), 'active');
44 
45  $this->addColumn($this->lng->txt('actions'));
46 
47  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
48  $this->setRowTemplate("tpl.show_records_row.html", "Services/AdvancedMetaData");
49  $this->setDefaultOrderField("title");
50  $this->setDefaultOrderDirection("desc");
51  }
52 
60  public function fillRow($a_set)
61  {
62  // assigned object types
64  $options = array(
65  0 => $this->lng->txt("meta_obj_type_inactive"),
66  1 => $this->lng->txt("meta_obj_type_mandatory"),
67  2 => $this->lng->txt("meta_obj_type_optional")
68  );
69 
70  $do_select = (!$a_set["readonly"] && !$a_set["local"]);
71  foreach (ilAdvancedMDRecord::_getAssignableObjectTypes(true) as $obj_type) {
72  $value = 0;
73  foreach ($a_set['obj_types'] as $t) {
74  if ($obj_type["obj_type"] == $t["obj_type"] &&
75  $obj_type["sub_type"] == $t["sub_type"]) {
76  if ($t["context"] &&
77  !$a_set["local"]) {
78  $obj_type["text"] = '<span class="il_ItemAlertProperty">' . $obj_type["text"] . '</span>';
79  }
80 
81  $value = $t["optional"]
82  ? 2
83  : 1;
84  break;
85  }
86  }
87 
88  if (!$do_select && !$value) {
89  continue;
90  }
91 
92  $this->tpl->setCurrentBlock('ass_obj_types');
93  $this->tpl->setVariable('VAL_OBJ_TYPE', $obj_type["text"]);
94 
95  if ($do_select) {
96  $type_options = $options;
97  switch ($obj_type["obj_type"]) {
98  case "orgu":
99  // currently only optional records for org unit (types)
100  unset($type_options[1]);
101  break;
102  case "prg":
103  // currently only optional records for study programme (types)
104  unset($type_options[1]);
105  break;
106  case "rcrs":
107  // optional makes no sense for ecs-courses
108  unset($type_options[2]);
109  break;
110  }
111  $select = ilUtil::formSelect(
112  $value,
113  "obj_types[" . $a_set['id'] . "][" . $obj_type["obj_type"] . ":" . $obj_type["sub_type"] . "]",
114  $type_options,
115  false,
116  true,
117  0,
118  "",
119  array("style"=>"min-width:125px"),
120  $disabled
121  );
122  $this->tpl->setVariable('VAL_OBJ_TYPE_STATUS', $select);
123  }
124 
125  $this->tpl->parseCurrentBlock();
126  }
127 
128  $record = ilAdvancedMDRecord::_getInstanceByRecordId($a_set['id']);
129  if (!$a_set['local'] && count($record->getScopeRefIds())) {
130  $this->tpl->setCurrentBlock('scope_txt');
131  $this->tpl->setVariable('LOCAL_OR_GLOBAL', $this->lng->txt('md_adv_scope_list_header'));
132  $this->tpl->parseCurrentBlock();
133 
134  foreach ($record->getScopeRefIds() as $ref_id) {
135  $this->tpl->setCurrentBlock('scope_entry');
136  $this->tpl->setVariable('LINK_HREF', ilLink::_getLink($ref_id));
137  $this->tpl->setVariable('LINK_NAME', ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)));
138  $this->tpl->parseCurrentBlock();
139  }
140  } else {
141  $this->tpl->setCurrentBlock('scope_txt');
142  $this->tpl->setVariable('LOCAL_OR_GLOBAL', $a_set['local'] ? $this->lng->txt('meta_local') : $this->lng->txt('meta_global'));
143  $this->tpl->parseCurrentBlock();
144  }
145 
146  if (!$a_set["readonly"] || $a_set["local"]) {
147  $this->tpl->setVariable('VAL_ID', $a_set['id']);
148  }
149 
150  $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
151  if (strlen($a_set['description'])) {
152  $this->tpl->setVariable('VAL_DESCRIPTION', $a_set['description']);
153  }
155  if (!count($defs)) {
156  $this->tpl->setVariable('TXT_FIELDS', $this->lng->txt('md_adv_no_fields'));
157  }
158  foreach ($defs as $definition_obj) {
159  $this->tpl->setCurrentBlock('field_entry');
160  $this->tpl->setVariable('FIELD_NAME', $definition_obj->getTitle() .
161  ": " . $this->lng->txt($definition_obj->getTypeTitle()));
162  $this->tpl->parseCurrentBlock();
163  }
164 
165  $this->tpl->setVariable('ACTIVE_CHECKED', $a_set['active'] ? ' checked="checked" ' : '');
166  $this->tpl->setVariable('ACTIVE_ID', $a_set['id']);
167 
168  if (($a_set["readonly"] && !$a_set["optional"]) ||
170  $this->tpl->setVariable('ACTIVE_DISABLED', 'disabled="disabled"');
171  }
172 
173  if (!$a_set["readonly"]) {
174  $this->ctrl->setParameter($this->parent_obj, 'record_id', $a_set['id']);
175 
177  $this->tpl->setVariable('EDIT_LINK', $this->ctrl->getLinkTarget($this->parent_obj, 'editRecord'));
178  $this->tpl->setVariable('TXT_EDIT_RECORD', $this->lng->txt('edit'));
179  }
181  $this->tpl->setVariable('EDIT_FIELDS_LINK', $this->ctrl->getLinkTarget($this->parent_obj, 'editFields'));
182  $this->tpl->setVariable('TXT_EDIT_FIELDS', $this->lng->txt('md_adv_field_table'));
183  }
184  }
185  }
186 }
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
static _lookupTitle($a_id)
lookup object title
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
Class ilTable2GUI.
Advanced metadata permission helper.
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
static _lookupObjId($a_id)
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 _getAssignableObjectTypes($a_include_text=false)
Get assignable object type.
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
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.
__construct($a_parent_obj, $a_parent_cmd='', ilAdvancedMDPermissionHelper $a_permissions, $a_in_object_context=false)
Constructor.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20