ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjectAddNewItemGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilObjectAddNewItemGUI:

Public Member Functions

 __construct (int $parent_ref_id)
 
 setMode (int $mode)
 
 setDisabledObjectTypes (array $types)
 Set object types which may not be created. More...
 
 setAfterCreationCallback (int $ref_id)
 Set after creation callback. More...
 
 setCreationUrl (string $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

ilLanguage $lng
 
ilObjectDefinition $obj_definition
 
ilSetting $settings
 
ilAccessHandler $access
 
ilCtrl $ctrl
 
ilToolbarGUI $toolbar
 
ilGlobalTemplateInterface $tpl
 
int $parent_ref_id
 
int $mode
 
array $disabled_object_types = []
 
array $sub_objects = []
 
int $url_creation_callback = 0
 
string $url_creation
 
ilGroupedListGUI $gl = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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

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

Constructor & Destructor Documentation

◆ __construct()

ilObjectAddNewItemGUI::__construct ( int  $parent_ref_id)

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

References $DIC, $parent_ref_id, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilObjectDefinition\MODE_REPOSITORY, ILIAS\Repository\settings(), and ILIAS\Repository\toolbar().

45  {
46  global $DIC;
47 
48  $this->lng = $DIC->language();
49  $this->obj_definition = $DIC["objDefinition"];
50  $this->settings = $DIC->settings();
51  $this->access = $DIC->access();
52  $this->ctrl = $DIC->ctrl();
53  $this->toolbar = $DIC->toolbar();
54  $this->tpl = $DIC["tpl"];
55 
56  $this->parent_ref_id = $parent_ref_id;
58 
59  $this->lng->loadLanguageModule("rep");
60  $this->lng->loadLanguageModule("cntr");
61  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ getHTML()

ilObjectAddNewItemGUI::getHTML ( )
protected

Get rendered html of sub object list.

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

References $gl, $path, $type, $url, $url_creation, $url_creation_callback, ilObject\_getIcon(), ilGroupedListGUI\addEntry(), ilGroupedListGUI\addGroupHeader(), ilGroupedListGUI\getHTML(), ilHelp\getObjCreationTooltipText(), ilUtil\img(), ilObjectDefinition\MODE_WORKSPACE, ilGroupedListGUI\nextColumn(), and ilGroupedListGUI\setAsDropDown().

Referenced by render().

259  : string
260  {
261  if ($this->mode != ilObjectDefinition::MODE_WORKSPACE && !isset($this->url_creation)) {
262  $base_url = "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->parent_ref_id . "&cmd=create";
263  } else {
264  $base_url = $this->url_creation;
265  }
266  // I removed the token statement because you can now
267  // generate links with ilCtrl::getLinkTargetByClass()
268  // which automatically appends one.
269 
270  if ($this->url_creation_callback) {
271  $base_url .= "&crtcb=" . $this->url_creation_callback;
272  }
273 
274  $gl = new ilGroupedListGUI("il-add-new-item-gl");
275  $gl->setAsDropDown(true);
276 
277  foreach ($this->sub_objects as $item) {
278  switch ($item["type"]) {
279  case "column_separator":
280  $gl->nextColumn();
281  break;
282  case "group":
283  $gl->addGroupHeader($item["title"]);
284  break;
285  case "object":
286  $type = $item["value"];
287  $path = ilObject::_getIcon(0, 'tiny', $type);
288  $icon = ($path != "") ? ilUtil::img($path, "") . " " : "";
289  $url = $base_url . "&new_type=" . $type;
291  $gl->addEntry(
292  $icon . $item["title"],
293  $url,
294  "_top",
295  "",
296  "",
297  $type,
298  $ttip,
299  "bottom center",
300  "top center",
301  false
302  );
303 
304  break;
305  }
306  }
307  $this->gl = $gl;
308 
309  return $gl->getHTML();
310  }
static getObjCreationTooltipText(string $a_type)
Get object_creation tooltip tab text.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
$type
addEntry(string $a_content, string $a_href="", string $a_target="", string $a_onclick="", string $a_add_class="", string $a_id="", string $a_ttip="", string $a_tt_my="right center", string $a_tt_at="left center", bool $a_tt_use_htmlspecialchars=true)
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
$path
Definition: ltiservices.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$url
setAsDropDown(bool $a_val, bool $a_pullright=false)
addGroupHeader(string $a_content, string $a_add_class="")
+ 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 (!)

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

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

Referenced by render().

97  : bool
98  {
99  $objDefinition = $this->obj_definition;
100  $lng = $this->lng;
102 
103  $this->sub_objects = array();
104 
105  $settings_map = [
106  'blog' => 'blogs',
107  'file' => 'files',
108  'webr' => 'links',
109  ];
110 
111  $subtypes = $objDefinition->getCreatableSubObjects("wfld", ilObjectDefinition::MODE_WORKSPACE);
112  if (count($subtypes) > 0) {
113  foreach (array_keys($subtypes) as $type) {
114  if (isset($settings_map[$type]) &&
115  $ilSetting->get("disable_wsp_" . $settings_map[$type])) {
116  continue;
117  }
118 
119  $this->sub_objects[] = array("type" => "object",
120  "value" => $type,
121  "title" => $lng->txt("wsp_type_" . $type));
122  }
123  }
124 
125  $this->sub_objects = ilArrayUtil::sortArray($this->sub_objects, "title");
126 
127  return (bool) sizeof($this->sub_objects);
128  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
$type
global $ilSetting
Definition: privfeed.php:17
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ 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

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

References $access, $lng, $obj_definition, $sub_objects, $type, ilObject\_lookupType(), ilObjRepositorySettings\getDefaultNewItemGrouping(), ilObjRepositorySettings\getNewItemGroups(), ilObjRepositorySettings\getNewItemGroupSubItems(), ILIAS\Repository\int(), ilObjectPlugin\lookupTxtById(), ilObjRepositorySettings\NEW_ITEM_GROUP_TYPE_GROUP, ilArrayUtil\sortArray(), and ilLanguage\txt().

Referenced by render().

133  : bool
134  {
135  $objDefinition = $this->obj_definition;
136  $lng = $this->lng;
137  $ilAccess = $this->access;
138 
139  $this->sub_objects = array();
140 
141  if (!is_array($this->disabled_object_types)) {
142  $this->disabled_object_types = array();
143  }
144  $this->disabled_object_types[] = "rolf";
145 
146  $parent_type = ilObject::_lookupType($this->parent_ref_id, true);
147  $subtypes = $objDefinition->getCreatableSubObjects($parent_type, $this->mode, $this->parent_ref_id);
148  if (count($subtypes) > 0) {
149  // grouping of object types
150 
151  $grp_map = $pos_group_map = array();
152 
154 
155  // no groups => use default
156  if (!$groups) {
158  $groups = $default["groups"];
159  $grp_map = $default["items"];
160 
161  // reset positions (9999 = "other"/unassigned)
162  $pos = 0;
163  foreach ($subtypes as $item_type => $item) {
164  // see ilObjectDefinition
165  if (substr($item_type, 0, 1) == "x") {
166  $subtypes[$item_type]["pos"] = "99992000";
167  } else {
168  $subtypes[$item_type]["pos"] = "9999" . str_pad((string) ++$pos, 4, "0", STR_PAD_LEFT);
169  }
170  }
171 
172  // assign default positions
173  foreach ($default["sort"] as $item_type => $pos) {
174  if (array_key_exists($item_type, $subtypes)) {
175  $subtypes[$item_type]["pos"] = $pos;
176  }
177  }
178 
179  // sort by default positions
180  $subtypes = ilArrayUtil::sortArray($subtypes, "pos", "asc", true, true);
181  }
182  // use group assignment
183  else {
184  foreach (ilObjRepositorySettings::getNewItemGroupSubItems() as $grp_id => $subitems) {
185  foreach ($subitems as $subitem) {
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) {
196  $pos_group_map[$item["id"]] = $item["title"];
197  } elseif (sizeof($old_grp_ids)) {
198  $group_separators[$item["id"]] = $old_grp_ids;
199  }
200  $old_grp_ids[] = $item["id"];
201  }
202 
203  $current_grp = null;
204  foreach ($subtypes as $type => $subitem) {
205  if (!in_array($type, $this->disabled_object_types)) {
206  // #9950
207  if ($ilAccess->checkAccess("create_" . $type, "", $this->parent_ref_id, $parent_type)) {
208  // if only assigned - do not add groups
209  if (sizeof($pos_group_map) > 1) {
210  $obj_grp_id = 0;
211  if (array_key_exists($type, $grp_map)) {
212  $obj_grp_id = (int) $grp_map[$type];
213  }
214  if ($obj_grp_id !== $current_grp) {
215  // add seperator after last group?
216  $sdone = false;
217  foreach ($group_separators as $idx => $spath) {
218  // #11986 - all separators up to next group
219  if ($current_grp && !in_array($obj_grp_id, $spath)) {
220  // 1 only separator between groups
221  if (!$sdone) {
222  $this->sub_objects[] = array("type" => "column_separator");
223  $sdone = true;
224  }
225  unset($group_separators[$idx]);
226  }
227  }
228 
229  $title = $pos_group_map[$obj_grp_id];
230 
231  $this->sub_objects[] = array("type" => "group",
232  "title" => $title);
233 
234  $current_grp = $obj_grp_id;
235  }
236  }
237 
238  if (isset($subitem["plugin"]) && $subitem["plugin"]) {
239  $title = ilObjectPlugin::lookupTxtById($type, "obj_" . $type);
240  } else {
241  // #13088
242  $title = $lng->txt("obj_" . $type);
243  }
244 
245  $this->sub_objects[] = array("type" => "object",
246  "value" => $type,
247  "title" => $title);
248  }
249  }
250  }
251  }
252 
253  return (bool) sizeof($this->sub_objects);
254  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
$type
static lookupTxtById(string $plugin_id, string $lang_var)
static _lookupType(int $id, bool $reference=false)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ 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 315 of file class.ilObjectAddNewItemGUI.php.

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

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

315  : void
316  {
317  if ($this->mode == ilObjectDefinition::MODE_WORKSPACE) {
318  if (!$this->parsePersonalWorkspace()) {
319  return;
320  }
321  } elseif (!$this->parseRepository()) {
322  return;
323  }
324 
325  $adv = new ilAdvancedSelectionListGUI();
326  $adv->setPullRight(false);
327  $adv->setListTitle($this->lng->txt("cntr_add_new_item"));
328  $this->getHTML();
329  $adv->setGroupedList($this->gl);
331  $this->toolbar->addStickyItem($adv);
332  }
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 ( int  $ref_id)

Set after creation callback.

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

References $ref_id.

79  : void
80  {
81  $this->url_creation_callback = $ref_id;
82  }
$ref_id
Definition: ltiauth.php:67

◆ setCreationUrl()

ilObjectAddNewItemGUI::setCreationUrl ( string  $url)

Set (custom) url for object creation.

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

References $url.

87  : void
88  {
89  $this->url_creation = $url;
90  }
$url

◆ setDisabledObjectTypes()

ilObjectAddNewItemGUI::setDisabledObjectTypes ( array  $types)

Set object types which may not be created.

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

71  : void
72  {
73  $this->disabled_object_types = $types;
74  }

◆ setMode()

ilObjectAddNewItemGUI::setMode ( int  $mode)

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

References $mode.

Referenced by ilObjTalkTemplateAdministrationGUI\showPossibleSubObjects(), and ilObjOrgUnitGUI\showPossibleSubObjects().

63  : void
64  {
65  $this->mode = $mode;
66  }
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilObjectAddNewItemGUI::$access
protected

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

Referenced by parseRepository().

◆ $ctrl

ilCtrl ilObjectAddNewItemGUI::$ctrl
protected

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

◆ $disabled_object_types

array ilObjectAddNewItemGUI::$disabled_object_types = []
protected

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

◆ $gl

ilGroupedListGUI ilObjectAddNewItemGUI::$gl = null
protected

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

Referenced by getHTML().

◆ $lng

ilLanguage ilObjectAddNewItemGUI::$lng
protected

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

Referenced by parsePersonalWorkspace(), and parseRepository().

◆ $mode

int ilObjectAddNewItemGUI::$mode
protected

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

Referenced by setMode().

◆ $obj_definition

ilObjectDefinition ilObjectAddNewItemGUI::$obj_definition
protected

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

Referenced by parsePersonalWorkspace(), and parseRepository().

◆ $parent_ref_id

int ilObjectAddNewItemGUI::$parent_ref_id
protected

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

Referenced by __construct().

◆ $settings

ilSetting ilObjectAddNewItemGUI::$settings
protected

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

Referenced by parsePersonalWorkspace().

◆ $sub_objects

array ilObjectAddNewItemGUI::$sub_objects = []
protected

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

Referenced by parsePersonalWorkspace(), and parseRepository().

◆ $toolbar

ilToolbarGUI ilObjectAddNewItemGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilObjectAddNewItemGUI::$tpl
protected

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

◆ $url_creation

string ilObjectAddNewItemGUI::$url_creation
protected

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

Referenced by getHTML().

◆ $url_creation_callback

int ilObjectAddNewItemGUI::$url_creation_callback = 0
protected

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

Referenced by getHTML().


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