ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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

 $lng
 
 $obj_definition
 
 $settings
 
 $access
 
 $ctrl
 
 $toolbar
 
 $tpl
 
 $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 63 of file class.ilObjectAddNewItemGUI.php.

References $DIC, $lng, ilObjectDefinition\MODE_REPOSITORY, and settings().

64  {
65  global $DIC;
66 
67  $this->lng = $DIC->language();
68  $this->obj_definition = $DIC["objDefinition"];
69  $this->settings = $DIC->settings();
70  $this->access = $DIC->access();
71  $this->ctrl = $DIC->ctrl();
72  $this->toolbar = $DIC->toolbar();
73  $this->tpl = $DIC["tpl"];
74  $lng = $DIC->language();
75 
76  $this->parent_ref_id = (int) $a_parent_ref_id;
78 
79  $lng->loadLanguageModule("rep");
80  $lng->loadLanguageModule("cntr");
81  }
settings()
Definition: settings.php:2
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:

Member Function Documentation

◆ getHTML()

ilObjectAddNewItemGUI::getHTML ( )
protected

Get rendered html of sub object list.

Returns
string

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

References $ctrl, $type, $url, $url_creation, $url_creation_callback, ilObject\_getIcon(), ilHelp\getObjCreationTooltipText(), ilUtil\img(), and ilObjectDefinition\MODE_WORKSPACE.

Referenced by render().

291  {
292  $ilCtrl = $this->ctrl;
293 
294  if ($this->mode != ilObjectDefinition::MODE_WORKSPACE && !isset($this->url_creation)) {
295  $base_url = "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->parent_ref_id . "&cmd=create";
296  } else {
297  $base_url = $this->url_creation;
298  }
299  $base_url = $ilCtrl->appendRequestTokenParameterString($base_url);
300 
301  if ($this->url_creation_callback) {
302  $base_url .= "&crtcb=" . $this->url_creation_callback;
303  }
304 
305  include_once("./Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php");
306  $gl = new ilGroupedListGUI("il-add-new-item-gl");
307  $gl->setAsDropDown(true, false);
308 
309  foreach ($this->sub_objects as $item) {
310  switch ($item["type"]) {
311  case "column_separator":
312  $gl->nextColumn();
313  break;
314 
315  /*
316  case "separator":
317  $gl->addSeparator();
318  break;
319  */
320 
321  case "group":
322  $gl->addGroupHeader($item["title"]);
323  break;
324 
325  case "object":
326  $type = $item["value"];
327 
328  $path = ilObject::_getIcon('', 'tiny', $type);
329  $icon = ($path != "")
330  ? ilUtil::img($path, "") . " "
331  : "";
332 
333  $url = $base_url . "&new_type=" . $type;
334 
336 
337  $gl->addEntry(
338  $icon . $item["title"],
339  $url,
340  "_top",
341  "",
342  "",
343  $type,
344  $ttip,
345  "bottom center",
346  "top center",
347  false
348  );
349 
350  break;
351  }
352  }
353  $this->gl = $gl;
354 
355  return $gl->getHTML();
356  }
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
$type
Grouped list GUI class.
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static getObjCreationTooltipText($a_type)
Get object_creation tooltip tab text.
$url
+ 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 125 of file class.ilObjectAddNewItemGUI.php.

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

Referenced by render().

126  {
128  $lng = $this->lng;
130 
131  $this->sub_objects = array();
132 
133  $settings_map = [
134  'blog' => 'blogs',
135  'file' => 'files',
136  'webr' => 'links',
137  ];
138 
139  $subtypes = $objDefinition->getCreatableSubObjects("wfld", ilObjectDefinition::MODE_WORKSPACE);
140  if (count($subtypes) > 0) {
141  foreach (array_keys($subtypes) as $type) {
142  if (isset($settings_map[$type]) &&
143  $ilSetting->get("disable_wsp_" . $settings_map[$type])) {
144  continue;
145  }
146 
147  $this->sub_objects[] = array("type" => "object",
148  "value" => $type,
149  "title" => $lng->txt("wsp_type_" . $type));
150  }
151  }
152 
153  $this->sub_objects = ilUtil::sortArray($this->sub_objects, "title", 1);
154 
155  return (bool) sizeof($this->sub_objects);
156  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$type
global $ilSetting
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 163 of file class.ilObjectAddNewItemGUI.php.

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

Referenced by render().

164  {
166  $lng = $this->lng;
167  $ilAccess = $this->access;
168 
169  $this->sub_objects = array();
170 
171  if (!is_array($this->disabled_object_types)) {
172  $this->disabled_object_types = array();
173  }
174  $this->disabled_object_types[] = "rolf";
175 
176  $parent_type = ilObject::_lookupType($this->parent_ref_id, true);
177  $subtypes = $objDefinition->getCreatableSubObjects($parent_type, $this->mode, $this->parent_ref_id);
178  if (count($subtypes) > 0) {
179  // grouping of object types
180 
181  $grp_map = $pos_group_map = array();
182 
183  include_once("Services/Repository/classes/class.ilObjRepositorySettings.php");
185 
186  // no groups => use default
187  if (!$groups) {
189  $groups = $default["groups"];
190  $grp_map = $default["items"];
191 
192  // reset positions (9999 = "other"/unassigned)
193  $pos = 0;
194  foreach ($subtypes as $item_type => $item) {
195  // see ilObjectDefinition
196  if (substr($item_type, 0, 1) == "x") {
197  $subtypes[$item_type]["pos"] = "99992000";
198  } else {
199  $subtypes[$item_type]["pos"] = "9999" . str_pad(++$pos, 4, "0", STR_PAD_LEFT);
200  }
201  }
202 
203  // assign default positions
204  foreach ($default["sort"] as $item_type => $pos) {
205  if (array_key_exists($item_type, $subtypes)) {
206  $subtypes[$item_type]["pos"] = $pos;
207  }
208  }
209 
210  // sort by default positions
211  $subtypes = ilUtil::sortArray($subtypes, "pos", "asc", true, true);
212  }
213  // use group assignment
214  else {
215  foreach (ilObjRepositorySettings::getNewItemGroupSubItems() as $grp_id => $subitems) {
216  foreach ($subitems as $subitem) {
217  $grp_map[$subitem] = $grp_id;
218  }
219  }
220  }
221 
222  $group_separators = array();
223  $pos_group_map[0] = $lng->txt("rep_new_item_group_other");
224  $old_grp_ids = array();
225  foreach ($groups as $item) {
227  $pos_group_map[$item["id"]] = $item["title"];
228  } elseif (sizeof($old_grp_ids)) {
229  $group_separators[$item["id"]] = $old_grp_ids;
230  }
231  $old_grp_ids[] = $item["id"];
232  }
233 
234  $current_grp = null;
235  foreach ($subtypes as $type => $subitem) {
236  if (!in_array($type, $this->disabled_object_types)) {
237  // #9950
238  if ($ilAccess->checkAccess("create_" . $type, "", $this->parent_ref_id, $parent_type)) {
239  // if only assigned - do not add groups
240  if (sizeof($pos_group_map) > 1) {
241  $obj_grp_id = (int) $grp_map[$type];
242  if ($obj_grp_id !== $current_grp) {
243  // add seperator after last group?
244  $sdone = false;
245  foreach ($group_separators as $idx => $spath) {
246  // #11986 - all separators up to next group
247  if ($current_grp && !in_array($obj_grp_id, $spath)) {
248  // 1 only separator between groups
249  if (!$sdone) {
250  $this->sub_objects[] = array("type" => "column_separator");
251  $sdone = true;
252  }
253  unset($group_separators[$idx]);
254  }
255  }
256 
257  $title = $pos_group_map[$obj_grp_id];
258 
259  $this->sub_objects[] = array("type" => "group",
260  "title" => $title);
261 
262  $current_grp = $obj_grp_id;
263  }
264  }
265 
266  if ($subitem["plugin"]) {
267  include_once("./Services/Component/classes/class.ilPlugin.php");
268  $title = ilObjectPlugin::lookupTxtById($type, "obj_" . $type);
269  } else {
270  // #13088
271  $title = $lng->txt("obj_" . $type);
272  }
273 
274  $this->sub_objects[] = array("type" => "object",
275  "value" => $type,
276  "title" => $title);
277  }
278  }
279  }
280  }
281 
282  return (bool) sizeof($this->sub_objects);
283  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static lookupTxtById($plugin_id, $lang_var)
$type
static _lookupType($a_id, $a_reference=false)
lookup object type
+ 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 361 of file class.ilObjectAddNewItemGUI.php.

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

Referenced by ilContainerGUI\showPossibleSubObjects(), ilObjFolderGUI\showPossibleSubObjects(), and ilObjCourseGUI\showPossibleSubObjects().

362  {
363  $ilToolbar = $this->toolbar;
364  $tpl = $this->tpl;
365  $lng = $this->lng;
366 
367  if ($this->mode == ilObjectDefinition::MODE_WORKSPACE) {
368  if (!$this->parsePersonalWorkspace()) {
369  return;
370  }
371  } elseif (!$this->parseRepository()) {
372  return;
373  }
374 
375  $ov_id = "il_add_new_item_ov";
376  $ov_trigger_id = $ov_id . "_tr";
377 
378 
379  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
380  $adv = new ilAdvancedSelectionListGUI();
381  $adv->setPullRight(false);
382  $adv->setListTitle($lng->txt("cntr_add_new_item"));
383  $this->getHTML();
384  $adv->setGroupedList($this->gl);
386  //$ilToolbar->addAdvancedSelectionList($adv);
387  $ilToolbar->addStickyItem($adv);
388  //$tpl->setVariable("SELECT_OBJTYPE_REPOS", $adv->getHTML());
389  }
parseRepository()
Parse creatable sub objects for repository incl.
getHTML()
Get rendered html of sub object list.
parsePersonalWorkspace()
Parse creatable sub objects for personal workspace.
+ 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 103 of file class.ilObjectAddNewItemGUI.php.

104  {
105  $this->url_creation_callback = $a_ref_id;
106  }

◆ setCreationUrl()

ilObjectAddNewItemGUI::setCreationUrl (   $a_url)

Set (custom) url for object creation.

Parameters
string$a_url

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

114  {
115  $this->url_creation = $a_url;
116  }

◆ setDisabledObjectTypes()

ilObjectAddNewItemGUI::setDisabledObjectTypes ( array  $a_types)

Set object types which may not be created.

Parameters
array$a_types

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

94  {
95  $this->disabled_object_types = $a_types;
96  }

◆ setMode()

ilObjectAddNewItemGUI::setMode (   $a_mode)

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

Referenced by ilObjOrgUnitGUI\showPossibleSubObjects().

84  {
85  $this->mode = (int) $a_mode;
86  }
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilObjectAddNewItemGUI::$access
protected

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

Referenced by parseRepository().

◆ $ctrl

ilObjectAddNewItemGUI::$ctrl
protected

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

Referenced by getHTML().

◆ $disabled_object_types

ilObjectAddNewItemGUI::$disabled_object_types
protected

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

◆ $lng

ilObjectAddNewItemGUI::$lng
protected

◆ $mode

ilObjectAddNewItemGUI::$mode
protected

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

◆ $obj_definition

ilObjectAddNewItemGUI::$obj_definition
protected

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

Referenced by parsePersonalWorkspace(), and parseRepository().

◆ $parent_ref_id

ilObjectAddNewItemGUI::$parent_ref_id
protected

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

◆ $settings

ilObjectAddNewItemGUI::$settings
protected

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

Referenced by parsePersonalWorkspace().

◆ $sub_objects

ilObjectAddNewItemGUI::$sub_objects
protected

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

Referenced by parsePersonalWorkspace(), and parseRepository().

◆ $toolbar

ilObjectAddNewItemGUI::$toolbar
protected

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

Referenced by render().

◆ $tpl

ilObjectAddNewItemGUI::$tpl
protected

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

Referenced by render().

◆ $url_creation

ilObjectAddNewItemGUI::$url_creation
protected

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

Referenced by getHTML().

◆ $url_creation_callback

ilObjectAddNewItemGUI::$url_creation_callback
protected

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

Referenced by getHTML().


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