ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilModulesTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("Services/Table/classes/class.ilTable2GUI.php");
5include_once("Services/Component/classes/class.ilComponent.php");
6
16{
17 protected $pos_group_options; // [array]
18 protected $old_grp_id; // [int]
19
20 function __construct($a_parent_obj, $a_parent_cmd = "")
21 {
22 global $ilCtrl, $lng;
23
24 parent::__construct($a_parent_obj, $a_parent_cmd);
25
26 $this->setId("repmodtbl");
27
28 $this->setTitle($lng->txt("cmps_repository_object_types"));
29
30 $this->addColumn($lng->txt("cmps_add_new_rank"), "");
31 $this->addColumn($lng->txt("cmps_rep_object"), "");
32 $this->addColumn($lng->txt("cmps_module"), "");
33 $this->addColumn($lng->txt("cmps_group"), "");
34 $this->addColumn($lng->txt("cmps_enable_creation"), "");
35
36 // save options command
37 $this->addCommandButton("saveModules", $lng->txt("cmps_save_options"));
38
39 $this->setEnableHeader(true);
40 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
41 $this->setRowTemplate("tpl.table_row_module.html", "Services/Repository");
42 $this->setLimit(10000);
43 $this->setExternalSorting(true);
44
45 $this->getComponents();
46
47 $this->old_grp_id = 0;
48 }
49
53 function getComponents()
54 {
55 global $objDefinition, $ilSetting, $lng, $ilPluginAdmin;
56
57 // unassigned objects should be last
58 $this->pos_group_options = array(0 => $lng->txt("rep_new_item_group_unassigned"));
59 $pos_group_map[0] = "9999";
60
61 include_once("Services/Repository/classes/class.ilObjRepositorySettings.php");
63 {
64 // #12807
66 {
67 $this->pos_group_options[$item["id"]] = $item["title"];
68 $pos_group_map[$item["id"]] = $item["pos"];
69 }
70 }
71
72 $obj_types = array();
73
74 // parse modules
75 include_once("./Services/Component/classes/class.ilModule.php");
76 foreach(ilModule::getAvailableCoreModules() as $mod)
77 {
78 $has_repo = false;
79 $rep_types =
80 $objDefinition->getRepositoryObjectTypesForComponent(IL_COMP_MODULE, $mod["subdir"]);
81 if(sizeof($rep_types) > 0)
82 {
83 foreach($rep_types as $ridx => $rt)
84 {
85 // we only want to display repository modules
86 if($rt["repository"])
87 {
88 $has_repo = true;
89 }
90 else
91 {
92 unset($rep_types[$ridx]);
93 }
94 }
95 }
96 if($has_repo)
97 {
98 foreach($rep_types as $rt)
99 {
100 $obj_types[$rt["id"]] = array(
101 "object" => $rt["class_name"],
102 "caption" => $lng->txt("obj_".$rt["id"]),
103 "subdir" => $mod["subdir"],
104 "grp" => $rt["grp"],
105 "default_pos" => $rt["default_pos"]
106 );
107 }
108 }
109 }
110
111 // parse plugins
112 include_once("./Services/Component/classes/class.ilPlugin.php");
113 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "Repository", "robj");
114 foreach ($pl_names as $pl_name)
115 {
116 $pl_id = ilPlugin::lookupIdForName(IL_COMP_SERVICE, "Repository", "robj", $pl_name);
117 if($pl_id)
118 {
119 $obj_types[$pl_id] = array(
120 "object" => $pl_name,
121 "caption" => ilPlugin::lookupTxt("rep_robj", $pl_id, "obj_".$pl_id),
122 "subdir" => $lng->txt("cmps_plugin"),
123 "grp" => "",
124 "default_pos" => 2000
125 );
126 }
127 }
128
129 // parse positions
130 $data = array();
131 foreach($obj_types as $obj_type => $item)
132 {
133 $org_pos = $ilSetting->get("obj_add_new_pos_".$obj_type);
134 if(!(int)$org_pos)
135 {
136 // no setting yet, use default
137 $org_pos = $item["default_pos"];
138 }
139 if(strlen($org_pos) < 8)
140 {
141 // "old" setting without group part, add "unassigned" group
142 $org_pos = $pos_group_map[0].str_pad($org_pos, 4, "0", STR_PAD_LEFT);
143 }
144
145 $pos_grp_id = $ilSetting->get("obj_add_new_pos_grp_".$obj_type, 0);
146
147 $group = null;
148 if ($item["grp"] != "")
149 {
150 $group = $objDefinition->getGroup($item["grp"]);
151 $group = $group["name"];
152 }
153
154 $data[] = array(
155 "id" => $obj_type,
156 "object" => $item["object"],
157 "caption" => $item["caption"],
158 "subdir" => $item["subdir"],
159 "pos" => (int)substr($org_pos, 4),
160 "pos_group" => $pos_grp_id,
161 "creation" => !(bool)$ilSetting->get("obj_dis_creation_".$obj_type, false),
162 "group_id" => $item["grp"],
163 "group" => $group,
164 "sort_key" => (int)$org_pos
165 );
166
167 }
168
169 $data = ilUtil::sortArray($data, "sort_key", "asc", true);
170
171 $this->setData($data);
172 }
173
178 protected function fillRow($a_set)
179 {
180 if($a_set["pos_group"] != $this->old_grp_id)
181 {
182 $this->tpl->setCurrentBlock("pos_grp_bl");
183 $this->tpl->setVariable("TXT_POS_GRP", $this->pos_group_options[$a_set["pos_group"]]);
184 $this->tpl->parseCurrentBlock();
185
186 $this->tpl->setCurrentBlock("tbl_content");
187 $this->tpl->parseCurrentBlock();
188
189 $this->css_row = ($this->css_row != "tblrow1")
190 ? "tblrow1"
191 : "tblrow2";
192 $this->tpl->setVariable("CSS_ROW", $this->css_row);
193
194 $this->old_grp_id = $a_set["pos_group"];
195 }
196
197 // group
198 if ($a_set["group_id"] != "")
199 {
200 $this->tpl->setCurrentBlock("group");
201 $this->tpl->setVariable("VAL_GROUP", $a_set["group"]);
202 $this->tpl->setVariable("VAL_GROUP_ID", $a_set["group_id"]);
203 $this->tpl->parseCurrentBlock();
204 }
205
206 $this->tpl->setCurrentBlock("rep_object");
207 // #11598 - using "caption" (from lng) instead of "object"
208 $this->tpl->setVariable("TXT_REP_OBJECT", $a_set["caption"]);
209 $this->tpl->setVariable("TXT_REP_OBJECT_ID", $a_set["id"]);
210 $this->tpl->setVariable("IMG_REP_OBJECT",
211 ilObject::_getIcon("", "tiny", $a_set["id"]));
212
213 // grouping
214 $sel = ilUtil::formSelect($a_set["pos_group"],
215 "obj_grp[".$a_set["id"]."]", $this->pos_group_options, false, true);
216 $this->tpl->setVariable("GROUP_SEL", $sel);
217
218 // position
219 $this->tpl->setVariable("VAR_POS", "obj_pos[".$a_set["id"]."]");
220 $this->tpl->setVariable("VAL_POS", ilUtil::prepareFormOutput($a_set["pos"]));
221
222 // enable creation
223 $this->tpl->setVariable("VAR_DISABLE_CREATION", "obj_enbl_creation[".$a_set["id"]."]");
224 if ($a_set["creation"])
225 {
226 $this->tpl->setVariable("CHECKED_DISABLE_CREATION",
227 ' checked="checked" ');
228 }
229
230 $this->tpl->setVariable("TXT_MODULE_NAME", $a_set["subdir"]);
231 }
232}
233
234?>
const IL_COMP_SERVICE
const IL_COMP_MODULE
static getAvailableCoreModules()
Get all available core modules.
TableGUI class for module listing.
fillRow($a_set)
Standard Version of Fill Row.
__construct($a_parent_obj, $a_parent_cmd="")
getComponents()
Get pages for list.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
lookupIdForName($a_ctype, $a_cname, $a_slot_id, $a_plugin_name)
Lookup id for name.
static lookupTxt($a_mod_prefix, $a_pl_id, $a_lang_var)
Lookup language text.
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.
setEnableHeader($a_enableheader)
Set Enable Header.
setExternalSorting($a_val)
Set external sorting.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setLimit($a_limit=0, $a_default_limit=0)
set max.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
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.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40