ILIAS  release_4-4 Revision
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.

References $lng, and ilObjectDefinition\MODE_REPOSITORY.

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

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.

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

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 
295  foreach ($this->sub_objects as $item)
296  {
297  switch($item["type"])
298  {
299  case "column_separator":
300  $gl->nextColumn();
301  break;
302 
303  /*
304  case "separator":
305  $gl->addSeparator();
306  break;
307  */
308 
309  case "group":
310  $gl->addGroupHeader($item["title"]);
311  break;
312 
313  case "object":
314  $type = $item["value"];
315 
316  $path = ilObject::_getIcon('', 'tiny', $type);
317  $icon = ($path != "")
318  ? ilUtil::img($path)." "
319  : "";
320 
321  $url = $base_url . "&new_type=".$type;
322 
323  $ttip = ilHelp::getObjCreationTooltipText($type);
324 
325  $gl->addEntry($icon.$item["title"], $url, "_top", "", "",
326  $type, $ttip, "bottom center", "top center", false);
327 
328  break;
329  }
330  }
331 
332  return $gl->getHTML();
333  }
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="")
Build img tag.
global $ilCtrl
Definition: ilias.php:18
Grouped list GUI class.
static getObjCreationTooltipText($a_type)
Get object_creation tooltip tab text.
$path
Definition: index.php:22
+ Here is the call 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.

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

Referenced by render().

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
global $lng
Definition: privfeed.php:40
+ 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.

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().

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);
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 sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static lookupTxt($a_mod_prefix, $a_pl_id, $a_lang_var)
Lookup language text.
static _lookupType($a_id, $a_reference=false)
lookup object type
global $lng
Definition: privfeed.php:40
+ 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 338 of file class.ilObjectAddNewItemGUI.php.

References $lng, $tpl, ilObjectDefinition\MODE_WORKSPACE, parsePersonalWorkspace(), and parseRepository().

Referenced by ilContainerGUI\showPossibleSubObjects().

339  {
340  global $ilToolbar, $tpl, $lng;
341 
342  if($this->mode == ilObjectDefinition::MODE_WORKSPACE)
343  {
344  if (!$this->parsePersonalWorkspace())
345  {
346  return;
347  }
348  }
349  else if(!$this->parseRepository())
350  {
351  return;
352  }
353 
354  $ov_id = "il_add_new_item_ov";
355  $ov_trigger_id = $ov_id."_tr";
356 
357  include_once "Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
358  $ov = new ilOverlayGUI($ov_id);
359 // $ov->setAnchor($ov_trigger_id, "tl", "tr");
360 // $ov->setTrigger($ov_trigger_id, "click", $ov_trigger_id);
361  $ov->add();
362 
363  // trigger
364  $ov->addTrigger($ov_trigger_id, "click", $ov_trigger_id, false, "tl", "tr");
365 
366  // toolbar
367  $ilToolbar->addButton($lng->txt("cntr_add_new_item"), "#", "", "",
368  "", $ov_trigger_id, 'submit emphsubmit');
369 
370  // css?
371  $tpl->setVariable("SELECT_OBJTYPE_REPOS",
372  '<div id="'.$ov_id.'" style="display:none;" class="ilOverlay">'.
373  $this->getHTML().'</div>');
374  }
parseRepository()
Parse creatable sub objects for repository incl.
This is a utility class for the yui overlays.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
parsePersonalWorkspace()
Parse creatable sub objects for personal workspace.
global $lng
Definition: privfeed.php:40
+ 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 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.

Referenced by ilObjOrgUnitGUI\showPossibleSubObjects().

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

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: