3 require_once(
'./Services/Repository/classes/class.ilObjectPlugin.php');
67 $this->lng = $DIC->language();
68 $this->obj_definition = $DIC[
"objDefinition"];
70 $this->access = $DIC->access();
71 $this->ctrl = $DIC->ctrl();
72 $this->toolbar = $DIC->toolbar();
73 $this->tpl = $DIC[
"tpl"];
74 $lng = $DIC->language();
76 $this->parent_ref_id = (int) $a_parent_ref_id;
79 $lng->loadLanguageModule(
"rep");
80 $lng->loadLanguageModule(
"cntr");
85 $this->mode = (int) $a_mode;
95 $this->disabled_object_types = $a_types;
105 $this->url_creation_callback = $a_ref_id;
115 $this->url_creation = $a_url;
131 $this->sub_objects = array();
133 $settings_map = array(
"blog" =>
"blogs",
135 "tstv" =>
"certificates",
136 "excv" =>
"certificates",
137 "crsv" =>
"certificates",
138 "scov" =>
"certificates",
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])) {
149 $this->sub_objects[] = array(
"type" =>
"object",
151 "title" =>
$lng->txt(
"wsp_type_" . $type));
171 $this->sub_objects = array();
173 if (!is_array($this->disabled_object_types)) {
174 $this->disabled_object_types = array();
176 $this->disabled_object_types[] =
"rolf";
179 $subtypes = $objDefinition->getCreatableSubObjects($parent_type, $this->mode, $this->parent_ref_id);
180 if (count($subtypes) > 0) {
183 $grp_map = $pos_group_map = array();
185 include_once(
"Services/Repository/classes/class.ilObjRepositorySettings.php");
196 foreach ($subtypes as $item_type => $item) {
198 if (substr($item_type, 0, 1) ==
"x") {
199 $subtypes[$item_type][
"pos"] =
"99992000";
201 $subtypes[$item_type][
"pos"] =
"9999" . str_pad(++$pos, 4,
"0", STR_PAD_LEFT);
206 foreach (
$default[
"sort"] as $item_type => $pos) {
207 if (array_key_exists($item_type, $subtypes)) {
208 $subtypes[$item_type][
"pos"] = $pos;
218 foreach ($subitems as $subitem) {
219 $grp_map[$subitem] = $grp_id;
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;
233 $old_grp_ids[] = $item[
"id"];
237 foreach ($subtypes as
$type => $subitem) {
238 if (!in_array(
$type, $this->disabled_object_types)) {
240 if ($ilAccess->checkAccess(
"create_" .
$type,
"", $this->parent_ref_id, $parent_type)) {
242 if (
sizeof($pos_group_map) > 1) {
243 $obj_grp_id = (int) $grp_map[
$type];
244 if ($obj_grp_id !== $current_grp) {
247 foreach ($group_separators as $idx => $spath) {
249 if ($current_grp && !in_array($obj_grp_id, $spath)) {
252 $this->sub_objects[] = array(
"type" =>
"column_separator");
255 unset($group_separators[$idx]);
259 $title = $pos_group_map[$obj_grp_id];
261 $this->sub_objects[] = array(
"type" =>
"group",
264 $current_grp = $obj_grp_id;
268 if ($subitem[
"plugin"]) {
269 include_once(
"./Services/Component/classes/class.ilPlugin.php");
276 $this->sub_objects[] = array(
"type" =>
"object",
297 $base_url =
"ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->parent_ref_id .
"&cmd=create";
301 $base_url =
$ilCtrl->appendRequestTokenParameterString($base_url);
303 if ($this->url_creation_callback) {
307 include_once(
"./Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php");
309 $gl->setAsDropDown(
true,
true);
311 foreach ($this->sub_objects as $item) {
312 switch ($item[
"type"]) {
313 case "column_separator":
324 $gl->addGroupHeader($item[
"title"]);
328 $type = $item[
"value"];
330 $path = ilObject::_getIcon(
'',
'tiny',
$type);
331 $icon = (
$path !=
"")
340 $icon . $item[
"title"],
357 return $gl->getHTML();
377 $ov_id =
"il_add_new_item_ov";
378 $ov_trigger_id = $ov_id .
"_tr";
381 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
383 $adv->setListTitle(
$lng->txt(
"cntr_add_new_item"));
385 $adv->setGroupedList($this->gl);
387 $tpl->setVariable(
"SELECT_OBJTYPE_REPOS", $adv->getHTML());
393 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
395 $button->setId($ov_trigger_id);
396 $button->setCaption(
"cntr_add_new_item");
397 $button->setPrimary(
true);
398 $ilToolbar->addButtonInstance($button);
402 "SELECT_OBJTYPE_REPOS",
403 '<div id="' . $ov_id .
'" style="display:none;" class="ilOverlay">' .
setCreationUrl($a_url)
Set (custom) url for object creation.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static lookupTxtById($plugin_id, $lang_var)
static getNewItemGroups()
static getNewItemGroupSubItems()
parseRepository()
Parse creatable sub objects for repository incl.
getHTML()
Get rendered html of sub object list.
static getDefaultNewItemGrouping()
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static _lookupType($a_id, $a_reference=false)
lookup object type
static getObjCreationTooltipText($a_type)
Get object_creation tooltip tab text.
setDisabledObjectTypes(array $a_types)
Set object types which may not be created.
User interface class for advanced drop-down selection lists.
parsePersonalWorkspace()
Parse creatable sub objects for personal workspace.
Render add new item selector.
__construct($a_parent_ref_id)
Constructor.
render()
Add new item selection to current page incl.
setAfterCreationCallback($a_ref_id)
Set after creation callback.
const NEW_ITEM_GROUP_TYPE_GROUP