ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 13 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 28 of file class.ilObjectAddNewItemGUI.php.

References $lng, and ilObjectDefinition\MODE_REPOSITORY.

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

Member Function Documentation

◆ getHTML()

ilObjectAddNewItemGUI::getHTML ( )
protected

Get rendered html of sub object list.

Returns
string

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

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

Referenced by render().

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

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

Referenced by render().

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

References $lng, $sub_objects, $title, ilObject\_lookupType(), array, ilObjRepositorySettings\getDefaultNewItemGrouping(), ilObjRepositorySettings\getNewItemGroups(), ilObjRepositorySettings\getNewItemGroupSubItems(), ilObjectPlugin\lookupTxtById(), ilObjRepositorySettings\NEW_ITEM_GROUP_TYPE_GROUP, and ilUtil\sortArray().

Referenced by render().

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

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

Referenced by ilContainerGUI\showPossibleSubObjects().

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

◆ setAfterCreationCallback()

ilObjectAddNewItemGUI::setAfterCreationCallback (   $a_ref_id)

Set after creation callback.

Parameters
int$a_ref_id

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

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

◆ setCreationUrl()

ilObjectAddNewItemGUI::setCreationUrl (   $a_url)

Set (custom) url for object creation.

Parameters
string$a_url

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

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

◆ setDisabledObjectTypes()

ilObjectAddNewItemGUI::setDisabledObjectTypes ( array  $a_types)

Set object types which may not be created.

Parameters
array$a_types

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

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

◆ setMode()

ilObjectAddNewItemGUI::setMode (   $a_mode)

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

Referenced by ilObjOrgUnitGUI\showPossibleSubObjects().

40  {
41  $this->mode = (int)$a_mode;
42  }
+ Here is the caller graph for this function:

Field Documentation

◆ $disabled_object_types

ilObjectAddNewItemGUI::$disabled_object_types
protected

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

◆ $mode

ilObjectAddNewItemGUI::$mode
protected

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

◆ $parent_ref_id

ilObjectAddNewItemGUI::$parent_ref_id
protected

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

◆ $sub_objects

ilObjectAddNewItemGUI::$sub_objects
protected

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

Referenced by parsePersonalWorkspace(), and parseRepository().

◆ $url_creation

ilObjectAddNewItemGUI::$url_creation
protected

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

Referenced by getHTML().

◆ $url_creation_callback

ilObjectAddNewItemGUI::$url_creation_callback
protected

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


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