ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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)
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 $this->addColumn($this->lng->txt('actions'));
44
45 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
46 $this->setRowTemplate("tpl.show_records_row.html","Services/AdvancedMetaData");
47 $this->setDefaultOrderField("title");
48 $this->setDefaultOrderDirection("desc");
49 }
50
58 public function fillRow($a_set)
59 {
60 foreach(ilAdvancedMDRecord::_getAssignableObjectTypes(true) as $obj_type)
61 {
62 $this->tpl->setCurrentBlock('ass_obj_types');
63 $this->tpl->setVariable('VAL_OBJ_TYPE', $obj_type["text"]);
64 $this->tpl->setVariable('ASS_ID',$a_set['id']);
65 $this->tpl->setVariable('ASS_NAME',$obj_type["obj_type"].":".$obj_type["sub_type"]);
66 foreach ($a_set['obj_types'] as $t)
67 {
68 if ($obj_type["obj_type"] == $t["obj_type"] &&
69 $obj_type["sub_type"] == $t["sub_type"])
70 {
71 $this->tpl->setVariable('ASS_CHECKED','checked="checked"');
72 }
73 }
74
76 {
77 $this->tpl->setVariable('ASS_DISABLED','disabled="disabled"');
78 }
79
80 $this->tpl->parseCurrentBlock();
81 }
82 $this->tpl->setVariable('VAL_ID',$a_set['id']);
83 $this->tpl->setVariable('VAL_TITLE',$a_set['title']);
84 if(strlen($a_set['description']))
85 {
86 $this->tpl->setVariable('VAL_DESCRIPTION',$a_set['description']);
87 }
89 if(!count($defs))
90 {
91 $this->tpl->setVariable('TXT_FIELDS',$this->lng->txt('md_adv_no_fields'));
92 }
93 foreach($defs as $definition_obj)
94 {
95 $this->tpl->setCurrentBlock('field_entry');
96 $this->tpl->setVariable('FIELD_NAME',$definition_obj->getTitle().
97 ": ".$this->lng->txt($definition_obj->getTypeTitle()));
98 $this->tpl->parseCurrentBlock();
99 }
100
101 $this->tpl->setVariable('ACTIVE_CHECKED',$a_set['active'] ? ' checked="checked" ' : '');
102 $this->tpl->setVariable('ACTIVE_ID',$a_set['id']);
103
105 {
106 $this->tpl->setVariable('ACTIVE_DISABLED','disabled="disabled"');
107 }
108
109 $this->ctrl->setParameter($this->parent_obj,'record_id',$a_set['id']);
110
112 {
113 $this->tpl->setVariable('EDIT_LINK',$this->ctrl->getLinkTarget($this->parent_obj,'editRecord'));
114 $this->tpl->setVariable('TXT_EDIT_RECORD',$this->lng->txt('edit'));
115 }
117 {
118 $this->tpl->setVariable('EDIT_FIELDS_LINK',$this->ctrl->getLinkTarget($this->parent_obj,'editFields'));
119 $this->tpl->setVariable('TXT_EDIT_FIELDS',$this->lng->txt('md_adv_field_table'));
120 }
121 }
122
130 public function parseRecords($a_records)
131 {
132 foreach($a_records as $record)
133 {
134 $tmp_arr = array();
135 $tmp_arr['id'] = $record->getRecordId();
136 $tmp_arr['active'] = $record->isActive();
137 $tmp_arr['title'] = $record->getTitle();
138 $tmp_arr['description'] = $record->getDescription();
139 $tmp_arr['fields'] = array();
140 $tmp_arr['obj_types'] = $record->getAssignedObjectTypes();
141
142 $tmp_arr['perm'] = $this->permissions->hasPermissions(
144 $record->getRecordId(),
145 array(
151 ));
152
153 $records_arr[] = $tmp_arr;
154 }
155 $this->setData($records_arr ? $records_arr : array());
156 }
157
158}
159
160
161?>
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)
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="")
Add a column to the header.
setData($a_data)
set table data @access public
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.
global $ilCtrl
Definition: ilias.php:18