ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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: saml.php:7
+ 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 292 of file class.ilObjectAddNewItemGUI.php.

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

Referenced by render().

293  {
295 
296  if ($this->mode != ilObjectDefinition::MODE_WORKSPACE && !isset($this->url_creation)) {
297  $base_url = "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->parent_ref_id . "&cmd=create";
298  } else {
299  $base_url = $this->url_creation;
300  }
301  $base_url = $ilCtrl->appendRequestTokenParameterString($base_url);
302 
303  if ($this->url_creation_callback) {
304  $base_url .= "&crtcb=" . $this->url_creation_callback;
305  }
306 
307  include_once("./Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php");
308  $gl = new ilGroupedListGUI();
309  $gl->setAsDropDown(true, true);
310 
311  foreach ($this->sub_objects as $item) {
312  switch ($item["type"]) {
313  case "column_separator":
314  $gl->nextColumn();
315  break;
316 
317  /*
318  case "separator":
319  $gl->addSeparator();
320  break;
321  */
322 
323  case "group":
324  $gl->addGroupHeader($item["title"]);
325  break;
326 
327  case "object":
328  $type = $item["value"];
329 
330  $path = ilObject::_getIcon('', 'tiny', $type);
331  $icon = ($path != "")
332  ? ilUtil::img($path, "") . " "
333  : "";
334 
335  $url = $base_url . "&new_type=" . $type;
336 
338 
339  $gl->addEntry(
340  $icon . $item["title"],
341  $url,
342  "_top",
343  "",
344  "",
345  $type,
346  $ttip,
347  "bottom center",
348  "top center",
349  false
350  );
351 
352  break;
353  }
354  }
355  $this->gl = $gl;
356 
357  return $gl->getHTML();
358  }
$path
Definition: aliased.php:25
$type
global $ilCtrl
Definition: ilias.php:18
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  {
127  $objDefinition = $this->obj_definition;
128  $lng = $this->lng;
130 
131  $this->sub_objects = array();
132 
133  $settings_map = array("blog" => "blogs",
134  "file" => "files",
135  "tstv" => "certificates",
136  "excv" => "certificates",
137  "crsv" => "certificates",
138  "scov" => "certificates",
139  "webr" => "links");
140 
141  $subtypes = $objDefinition->getCreatableSubObjects("wfld", ilObjectDefinition::MODE_WORKSPACE);
142  if (count($subtypes) > 0) {
143  foreach (array_keys($subtypes) as $type) {
144  if (isset($settings_map[$type]) &&
145  $ilSetting->get("disable_wsp_" . $settings_map[$type])) {
146  continue;
147  }
148 
149  $this->sub_objects[] = array("type" => "object",
150  "value" => $type,
151  "title" => $lng->txt("wsp_type_" . $type));
152  }
153  }
154 
155  $this->sub_objects = ilUtil::sortArray($this->sub_objects, "title", 1);
156 
157  return (bool) sizeof($this->sub_objects);
158  }
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 165 of file class.ilObjectAddNewItemGUI.php.

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

Referenced by render().

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

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

Referenced by ilContainerGUI\showPossibleSubObjects().

364  {
365  $ilToolbar = $this->toolbar;
366  $tpl = $this->tpl;
367  $lng = $this->lng;
368 
369  if ($this->mode == ilObjectDefinition::MODE_WORKSPACE) {
370  if (!$this->parsePersonalWorkspace()) {
371  return;
372  }
373  } elseif (!$this->parseRepository()) {
374  return;
375  }
376 
377  $ov_id = "il_add_new_item_ov";
378  $ov_trigger_id = $ov_id . "_tr";
379 
380 
381  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
382  $adv = new ilAdvancedSelectionListGUI();
383  $adv->setListTitle($lng->txt("cntr_add_new_item"));
384  $this->getHTML();
385  $adv->setGroupedList($this->gl);
387  $tpl->setVariable("SELECT_OBJTYPE_REPOS", $adv->getHTML());
388  //$ilToolbar->addDropDown($lng->txt("cntr_add_new_item"), $this->getHTML());
389 
390  return;
391 
392  // toolbar
393  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
394  $button = ilLinkButton::getInstance();
395  $button->setId($ov_trigger_id);
396  $button->setCaption("cntr_add_new_item");
397  $button->setPrimary(true);
398  $ilToolbar->addButtonInstance($button);
399 
400  // css?
401  $tpl->setVariable(
402  "SELECT_OBJTYPE_REPOS",
403  '<div id="' . $ov_id . '" style="display:none;" class="ilOverlay">' .
404  $this->getHTML() . '</div>'
405  );
406  }
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.
+ 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: