ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilObjectAddNewItemGUI Class Reference

Render add new item selector. More...

+ Collaboration diagram for ilObjectAddNewItemGUI:

Public Member Functions

 __construct ($a_parent_ref_id)
 Constructor. More...
 
 setMode ($a_mode)
 
 setDisabledObjectTypes (array $a_types)
 Set object types which may not be created. More...
 
 setAfterCreationCallback ($a_ref_id)
 Set after creation callback. More...
 
 setCreationUrl ($a_url)
 Set (custom) url for object creation. More...
 
 render ()
 Add new item selection to current page incl. More...
 

Protected Member Functions

 parsePersonalWorkspace ()
 Parse creatable sub objects for personal workspace. More...
 
 parseRepository ()
 Parse creatable sub objects for repository incl. More...
 
 getHTML ()
 Get rendered html of sub object list. More...
 

Protected Attributes

 $mode
 
 $parent_ref_id
 
 $disabled_object_types
 
 $sub_objects
 
 $url_creation_callback
 
 $url_creation
 

Detailed Description

Render add new item selector.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id
class.ilContainerGUI.php 43751 2013-07-30 10:07:45Z jluetzen

Definition at line 12 of file class.ilObjectAddNewItemGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjectAddNewItemGUI::__construct (   $a_parent_ref_id)

Constructor.

Parameters
int$a_parent_ref_id
Returns
ilObjectAddNewItemGUI

Definition at line 27 of file class.ilObjectAddNewItemGUI.php.

28 {
29 global $lng;
30
31 $this->parent_ref_id = (int)$a_parent_ref_id;
33
34 $lng->loadLanguageModule("rep");
35 $lng->loadLanguageModule("cntr");
36 }
global $lng
Definition: privfeed.php:40

References $lng, and ilObjectDefinition\MODE_REPOSITORY.

Member Function Documentation

◆ getHTML()

ilObjectAddNewItemGUI::getHTML ( )
protected

Get rendered html of sub object list.

Returns
string

Definition at line 273 of file class.ilObjectAddNewItemGUI.php.

274 {
275 global $ilCtrl;
276
277 if($this->mode != ilObjectDefinition::MODE_WORKSPACE && !isset($this->url_creation))
278 {
279 $base_url = "ilias.php?baseClass=ilRepositoryGUI&ref_id=".$this->parent_ref_id."&cmd=create";
280 }
281 else
282 {
283 $base_url = $this->url_creation;
284 }
285 $base_url = $ilCtrl->appendRequestTokenParameterString($base_url);
286
287 if($this->url_creation_callback)
288 {
289 $base_url .= "&crtcb=".$this->url_creation_callback;
290 }
291
292 include_once("./Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php");
293 $gl = new ilGroupedListGUI();
294 $gl->setAsDropDown(true, true);
295
296 foreach ($this->sub_objects as $item)
297 {
298 switch($item["type"])
299 {
300 case "column_separator":
301 $gl->nextColumn();
302 break;
303
304 /*
305 case "separator":
306 $gl->addSeparator();
307 break;
308 */
309
310 case "group":
311 $gl->addGroupHeader($item["title"]);
312 break;
313
314 case "object":
315 $type = $item["value"];
316
317 $path = ilObject::_getIcon('', 'tiny', $type);
318 $icon = ($path != "")
319 ? ilUtil::img($path)." "
320 : "";
321
322 $url = $base_url . "&new_type=".$type;
323
325
326 $gl->addEntry($icon.$item["title"], $url, "_top", "", "",
327 $type, $ttip, "bottom center", "top center", false);
328
329 break;
330 }
331 }
332 $this->gl = $gl;
333
334 return $gl->getHTML();
335 }
Grouped list GUI class.
static getObjCreationTooltipText($a_type)
Get object_creation tooltip tab text.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
global $ilCtrl
Definition: ilias.php:18
$url
Definition: shib_logout.php:72
$path
Definition: index.php:22

References $ilCtrl, $path, $url, $url_creation, ilObject\_getIcon(), ilHelp\getObjCreationTooltipText(), ilUtil\img(), and ilObjectDefinition\MODE_WORKSPACE.

Referenced by render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parsePersonalWorkspace()

ilObjectAddNewItemGUI::parsePersonalWorkspace ( )
protected

Parse creatable sub objects for personal workspace.

Grouping is not supported here, order is alphabetical (!)

Returns
bool

Definition at line 80 of file class.ilObjectAddNewItemGUI.php.

81 {
82 global $objDefinition, $lng, $ilSetting;
83
84 $this->sub_objects = array();
85
86 $settings_map = array("blog" => "blogs",
87 "file" => "files",
88 "tstv" => "certificates",
89 "excv" => "certificates",
90 "crsv" => "certificates",
91 "scov" => "certificates",
92 "webr" => "links");
93
94 $subtypes = $objDefinition->getCreatableSubObjects("wfld", ilObjectDefinition::MODE_WORKSPACE);
95 if (count($subtypes) > 0)
96 {
97 foreach (array_keys($subtypes) as $type)
98 {
99 if (isset($settings_map[$type]) &&
100 $ilSetting->get("disable_wsp_".$settings_map[$type]))
101 {
102 continue;
103 }
104
105 $this->sub_objects[] = array("type" => "object",
106 "value" => $type,
107 "title" => $lng->txt("wsp_type_".$type));
108 }
109 }
110
111 $this->sub_objects = ilUtil::sortArray($this->sub_objects, "title", 1);
112
113 return (bool)sizeof($this->sub_objects);
114 }
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
global $ilSetting
Definition: privfeed.php:40

References $ilSetting, $lng, $sub_objects, ilObjectDefinition\MODE_WORKSPACE, and ilUtil\sortArray().

Referenced by render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseRepository()

ilObjectAddNewItemGUI::parseRepository ( )
protected

Parse creatable sub objects for repository incl.

grouping

Returns
bool

Definition at line 121 of file class.ilObjectAddNewItemGUI.php.

122 {
123 global $objDefinition, $lng, $ilAccess;
124
125 $this->sub_objects = array();
126
127 if(!is_array($this->disabled_object_types))
128 {
129 $this->disabled_object_types = array();
130 }
131 $this->disabled_object_types[] = "rolf";
132
133 $parent_type = ilObject::_lookupType($this->parent_ref_id, true);
134 $subtypes = $objDefinition->getCreatableSubObjects($parent_type, $this->mode, $this->parent_ref_id);
135 if (count($subtypes) > 0)
136 {
137 // grouping of object types
138
139 $grp_map = $pos_group_map = array();
140
141 include_once("Services/Repository/classes/class.ilObjRepositorySettings.php");
143
144 // no groups => use default
145 if(!$groups)
146 {
148 $groups = $default["groups"];
149 $grp_map = $default["items"];
150
151 // reset positions (9999 = "other"/unassigned)
152 $pos = 0;
153 foreach($subtypes as $item_type => $item)
154 {
155 // see ilObjectDefinition
156 if(substr($item_type, 0, 1) == "x")
157 {
158 $subtypes[$item_type]["pos"] = "99992000";
159 }
160 else
161 {
162 $subtypes[$item_type]["pos"] = "9999".str_pad(++$pos, 4, "0", STR_PAD_LEFT);
163 }
164 }
165
166 // assign default positions
167 foreach($default["sort"] as $item_type => $pos)
168 {
169 if(array_key_exists($item_type, $subtypes))
170 {
171 $subtypes[$item_type]["pos"] = $pos;
172 }
173 }
174
175 // sort by default positions
176 $subtypes = ilUtil::sortArray($subtypes, "pos", "asc", true, true);
177 }
178 // use group assignment
179 else
180 {
181 foreach(ilObjRepositorySettings::getNewItemGroupSubItems() as $grp_id => $subitems)
182 {
183 foreach($subitems as $subitem)
184 {
185 $grp_map[$subitem] = $grp_id;
186 }
187 }
188 }
189
190 $group_separators = array();
191 $pos_group_map[0] = $lng->txt("rep_new_item_group_other");
192 $old_grp_ids = array();
193 foreach($groups as $item)
194 {
196 {
197 $pos_group_map[$item["id"]] = $item["title"];
198 }
199 else if(sizeof($old_grp_ids))
200 {
201 $group_separators[$item["id"]] = $old_grp_ids;
202 }
203 $old_grp_ids[] = $item["id"];
204 }
205
206 $current_grp = null;
207 foreach ($subtypes as $type => $subitem)
208 {
209 if (!in_array($type, $this->disabled_object_types))
210 {
211 // #9950
212 if ($ilAccess->checkAccess("create_".$type, "", $this->parent_ref_id, $parent_type))
213 {
214 // if only assigned - do not add groups
215 if(sizeof($pos_group_map) > 1)
216 {
217 $obj_grp_id = (int)$grp_map[$type];
218 if($obj_grp_id !== $current_grp)
219 {
220 // add seperator after last group?
221 $sdone = false;
222 foreach($group_separators as $idx => $spath)
223 {
224 // #11986 - all separators up to next group
225 if($current_grp && !in_array($obj_grp_id, $spath))
226 {
227 // 1 only separator between groups
228 if(!$sdone)
229 {
230 $this->sub_objects[] = array("type" => "column_separator");
231 $sdone = true;
232 }
233 unset($group_separators[$idx]);
234 }
235 }
236
237 $title = $pos_group_map[$obj_grp_id];
238
239 $this->sub_objects[] = array("type" => "group",
240 "title" => $title);
241
242 $current_grp = $obj_grp_id;
243 }
244 }
245
246 if ($subitem["plugin"])
247 {
248 include_once("./Services/Component/classes/class.ilPlugin.php");
249 $title = ilPlugin::lookupTxt("rep_robj", $type, "obj_".$type);
250 }
251 else
252 {
253 // #13088
254 $title = $lng->txt("obj_".$type);
255 }
256
257 $this->sub_objects[] = array("type" => "object",
258 "value" => $type,
259 "title" => $title);
260 }
261 }
262 }
263 }
264
265 return (bool)sizeof($this->sub_objects);
266 }
static _lookupType($a_id, $a_reference=false)
lookup object type
static lookupTxt($a_mod_prefix, $a_pl_id, $a_lang_var)
Lookup language text.

References $lng, $sub_objects, ilObject\_lookupType(), ilObjRepositorySettings\getDefaultNewItemGrouping(), ilObjRepositorySettings\getNewItemGroups(), ilObjRepositorySettings\getNewItemGroupSubItems(), ilPlugin\lookupTxt(), ilObjRepositorySettings\NEW_ITEM_GROUP_TYPE_GROUP, and ilUtil\sortArray().

Referenced by render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ilObjectAddNewItemGUI::render ( )

Add new item selection to current page incl.

toolbar (trigger) and overlay

Definition at line 340 of file class.ilObjectAddNewItemGUI.php.

341 {
342 global $ilToolbar, $tpl, $lng;
343
344 if($this->mode == ilObjectDefinition::MODE_WORKSPACE)
345 {
346 if (!$this->parsePersonalWorkspace())
347 {
348 return;
349 }
350 }
351 else if(!$this->parseRepository())
352 {
353 return;
354 }
355
356 $ov_id = "il_add_new_item_ov";
357 $ov_trigger_id = $ov_id."_tr";
358
359
360 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
361 $adv = new ilAdvancedSelectionListGUI();
362 $adv->setListTitle($lng->txt("cntr_add_new_item"));
363 $this->getHTML();
364 $adv->setGroupedList($this->gl);
366 $tpl->setVariable("SELECT_OBJTYPE_REPOS", $adv->getHTML());
367 //$ilToolbar->addDropDown($lng->txt("cntr_add_new_item"), $this->getHTML());
368
369 return;
370
371 // toolbar
372 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
373 $button = ilLinkButton::getInstance();
374 $button->setId($ov_trigger_id);
375 $button->setCaption("cntr_add_new_item");
376 $button->setPrimary(true);
377 $ilToolbar->addButtonInstance($button);
378
379 // css?
380 $tpl->setVariable("SELECT_OBJTYPE_REPOS",
381 '<div id="'.$ov_id.'" style="display:none;" class="ilOverlay">'.
382 $this->getHTML().'</div>');
383 }
global $tpl
Definition: ilias.php:8
User interface class for advanced drop-down selection lists.
static getInstance()
Factory.
parsePersonalWorkspace()
Parse creatable sub objects for personal workspace.
parseRepository()
Parse creatable sub objects for repository incl.
getHTML()
Get rendered html of sub object list.

References $lng, $tpl, getHTML(), ilLinkButton\getInstance(), ilObjectDefinition\MODE_WORKSPACE, parsePersonalWorkspace(), parseRepository(), and ilAdvancedSelectionListGUI\STYLE_EMPH.

+ Here is the call graph for this function:

◆ setAfterCreationCallback()

ilObjectAddNewItemGUI::setAfterCreationCallback (   $a_ref_id)

Set after creation callback.

Parameters
int$a_ref_id

Definition at line 58 of file class.ilObjectAddNewItemGUI.php.

59 {
60 $this->url_creation_callback = $a_ref_id;
61 }

◆ setCreationUrl()

ilObjectAddNewItemGUI::setCreationUrl (   $a_url)

Set (custom) url for object creation.

Parameters
string$a_url

Definition at line 68 of file class.ilObjectAddNewItemGUI.php.

69 {
70 $this->url_creation = $a_url;
71 }

◆ setDisabledObjectTypes()

ilObjectAddNewItemGUI::setDisabledObjectTypes ( array  $a_types)

Set object types which may not be created.

Parameters
array$a_types

Definition at line 48 of file class.ilObjectAddNewItemGUI.php.

49 {
50 $this->disabled_object_types = $a_types;
51 }

◆ setMode()

ilObjectAddNewItemGUI::setMode (   $a_mode)

Definition at line 38 of file class.ilObjectAddNewItemGUI.php.

39 {
40 $this->mode = (int)$a_mode;
41 }

Field Documentation

◆ $disabled_object_types

ilObjectAddNewItemGUI::$disabled_object_types
protected

Definition at line 16 of file class.ilObjectAddNewItemGUI.php.

◆ $mode

ilObjectAddNewItemGUI::$mode
protected

Definition at line 14 of file class.ilObjectAddNewItemGUI.php.

◆ $parent_ref_id

ilObjectAddNewItemGUI::$parent_ref_id
protected

Definition at line 15 of file class.ilObjectAddNewItemGUI.php.

◆ $sub_objects

ilObjectAddNewItemGUI::$sub_objects
protected

Definition at line 17 of file class.ilObjectAddNewItemGUI.php.

Referenced by parsePersonalWorkspace(), and parseRepository().

◆ $url_creation

ilObjectAddNewItemGUI::$url_creation
protected

Definition at line 19 of file class.ilObjectAddNewItemGUI.php.

Referenced by getHTML().

◆ $url_creation_callback

ilObjectAddNewItemGUI::$url_creation_callback
protected

Definition at line 18 of file class.ilObjectAddNewItemGUI.php.


The documentation for this class was generated from the following file: