ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
13include_once('Services/Table/classes/class.ilTable2GUI.php');
14include_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_active'),'active');
42 $this->addColumn($this->lng->txt('md_obj_types'),'obj_types');
43
44 $this->addColumn($this->lng->txt('actions'));
45
46 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
47 $this->setRowTemplate("tpl.show_records_row.html","Services/AdvancedMetaData");
48 $this->setDefaultOrderField("title");
49 $this->setDefaultOrderDirection("desc");
50 }
51
59 public function fillRow($a_set)
60 {
61 // assigned object types
63 $options = array(
64 0 => $this->lng->txt("meta_obj_type_inactive"),
65 1 => $this->lng->txt("meta_obj_type_mandatory"),
66 2 => $this->lng->txt("meta_obj_type_optional")
67 );
68
69 $do_select = (!$a_set["readonly"] && !$a_set["local"]);
70 foreach(ilAdvancedMDRecord::_getAssignableObjectTypes(true) as $obj_type)
71 {
72 $value = 0;
73 foreach ($a_set['obj_types'] as $t)
74 {
75 if ($obj_type["obj_type"] == $t["obj_type"] &&
76 $obj_type["sub_type"] == $t["sub_type"])
77 {
78 if($t["context"] &&
79 !$a_set["local"])
80 {
81 $obj_type["text"] = '<span class="il_ItemAlertProperty">'.$obj_type["text"].'</span>';
82 }
83
84 $value = $t["optional"]
85 ? 2
86 : 1;
87 break;
88 }
89 }
90
91 if(!$do_select && !$value)
92 {
93 continue;
94 }
95
96 $this->tpl->setCurrentBlock('ass_obj_types');
97 $this->tpl->setVariable('VAL_OBJ_TYPE', $obj_type["text"]);
98
99 if($do_select)
100 {
101 $type_options = $options;
102 switch($obj_type["obj_type"])
103 {
104 case "orgu":
105 // currently only optional records for org unit (types)
106 unset($type_options[1]);
107 break;
108 case "prg":
109 // currently only optional records for study programme (types)
110 unset($type_options[1]);
111 break;
112 case "rcrs":
113 // optional makes no sense for ecs-courses
114 unset($type_options[2]);
115 break;
116 }
117 $select = ilUtil::formSelect(
118 $value,
119 "obj_types[".$a_set['id']."][".$obj_type["obj_type"].":".$obj_type["sub_type"]."]",
120 $type_options,
121 false,
122 true,
123 0,
124 "",
125 array("style"=>"min-width:125px"),
126 $disabled
127 );
128 $this->tpl->setVariable('VAL_OBJ_TYPE_STATUS', $select);
129 }
130
131 $this->tpl->parseCurrentBlock();
132 }
133
134 if($a_set["readonly"] && !$a_set["local"])
135 {
136 $a_set['description'] .= ' <span class="il_ItemAlertProperty">'.$this->lng->txt("meta_global").'</span>';
137 }
138
139 if(!$a_set["readonly"] || $a_set["local"])
140 {
141 $this->tpl->setVariable('VAL_ID',$a_set['id']);
142 }
143
144 $this->tpl->setVariable('VAL_TITLE',$a_set['title']);
145 if(strlen($a_set['description']))
146 {
147 $this->tpl->setVariable('VAL_DESCRIPTION',$a_set['description']);
148 }
150 if(!count($defs))
151 {
152 $this->tpl->setVariable('TXT_FIELDS',$this->lng->txt('md_adv_no_fields'));
153 }
154 foreach($defs as $definition_obj)
155 {
156 $this->tpl->setCurrentBlock('field_entry');
157 $this->tpl->setVariable('FIELD_NAME',$definition_obj->getTitle().
158 ": ".$this->lng->txt($definition_obj->getTypeTitle()));
159 $this->tpl->parseCurrentBlock();
160 }
161
162 $this->tpl->setVariable('ACTIVE_CHECKED',$a_set['active'] ? ' checked="checked" ' : '');
163 $this->tpl->setVariable('ACTIVE_ID',$a_set['id']);
164
165 if(($a_set["readonly"] && !$a_set["optional"]) ||
167 {
168 $this->tpl->setVariable('ACTIVE_DISABLED','disabled="disabled"');
169 }
170
171 if(!$a_set["readonly"])
172 {
173 $this->ctrl->setParameter($this->parent_obj,'record_id',$a_set['id']);
174
176 {
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 {
182 $this->tpl->setVariable('EDIT_FIELDS_LINK',$this->ctrl->getLinkTarget($this->parent_obj,'editFields'));
183 $this->tpl->setVariable('TXT_EDIT_FIELDS',$this->lng->txt('md_adv_field_table'));
184 }
185 }
186 }
187}
188
189
190?>
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
Advanced metadata permission helper
__construct($a_parent_obj, $a_parent_cmd='', ilAdvancedMDPermissionHelper $a_permissions, $a_in_object_context=false)
Constructor.
static _getAssignableObjectTypes($a_include_text=false)
Get assignable object type.
Class ilTable2GUI.
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.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
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.
global $ilCtrl
Definition: ilias.php:18
if(!is_array($argv)) $options