ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
$DIC
Definition: xapitoken.php:46
+ 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 294 of file class.ilObjectAddNewItemGUI.php.

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

Referenced by render().

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

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

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