ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjectAddNewItemGUI Class Reference

Render add new item selector. More...

+ Collaboration diagram for ilObjectAddNewItemGUI:

Public Member Functions

 __construct ($a_parent_ref_id)
 Constructor.
 setMode ($a_mode)
 setDisabledObjectTypes (array $a_types)
 Set object types which may not be created.
 setAfterCreationCallback ($a_ref_id)
 Set after creation callback.
 setCreationUrl ($a_url)
 Set (custom) url for object creation.
 render ()
 Add new item selection to current page incl.

Protected Member Functions

 parsePersonalWorkspace ()
 Parse creatable sub objects for personal workspace.
 parseRepository ()
 Parse creatable sub objects for repository incl.
 getHTML ()
 Get rendered html of sub object list.

Protected Attributes

 $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 12 of file class.ilObjectAddNewItemGUI.php.

Constructor & Destructor Documentation

ilObjectAddNewItemGUI::__construct (   $a_parent_ref_id)

Constructor.

Parameters
int$a_parent_ref_id
Returns
ilObjectAddNewItemGUI

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

References $lng, and ilObjectDefinition\MODE_REPOSITORY.

{
global $lng;
$this->parent_ref_id = (int)$a_parent_ref_id;
$lng->loadLanguageModule("rep");
$lng->loadLanguageModule("cntr");
}

Member Function Documentation

ilObjectAddNewItemGUI::getHTML ( )
protected

Get rendered html of sub object list.

Returns
string

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

References $ilCtrl, $path, $url_creation, ilObject\_getIcon(), ilHelp\getObjCreationTooltipText(), ilUtil\img(), and ilObjectDefinition\MODE_WORKSPACE.

{
global $ilCtrl;
if($this->mode != ilObjectDefinition::MODE_WORKSPACE && !isset($this->url_creation))
{
$base_url = "ilias.php?baseClass=ilRepositoryGUI&ref_id=".$this->parent_ref_id."&cmd=create";
}
else
{
$base_url = $this->url_creation;
}
$base_url = $ilCtrl->appendRequestTokenParameterString($base_url);
if($this->url_creation_callback)
{
$base_url .= "&crtcb=".$this->url_creation_callback;
}
include_once("./Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php");
$gl = new ilGroupedListGUI();
foreach ($this->sub_objects as $item)
{
switch($item["type"])
{
case "column_separator":
$gl->nextColumn();
break;
/*
case "separator":
$gl->addSeparator();
break;
*/
case "group":
$gl->addGroupHeader($item["title"]);
break;
case "object":
$type = $item["value"];
$path = ilObject::_getIcon('', 'tiny', $type);
$icon = ($path != "")
: "";
$url = $base_url . "&new_type=".$type;
$gl->addEntry($icon.$item["title"], $url, "_top", "", "",
$type, $ttip, "bottom center", "top center", false);
break;
}
}
return $gl->getHTML();
}

+ Here is the call graph for this function:

ilObjectAddNewItemGUI::parsePersonalWorkspace ( )
protected

Parse creatable sub objects for personal workspace.

Grouping is not supported here, order is alphabetical (!)

Returns
bool

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

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

Referenced by render().

{
global $objDefinition, $lng, $ilSetting;
$this->sub_objects = array();
$settings_map = array("blog" => "blogs",
"file" => "files",
"tstv" => "certificates",
"excv" => "certificates",
"crsv" => "certificates",
"scov" => "certificates",
"webr" => "links");
$subtypes = $objDefinition->getCreatableSubObjects("wfld", ilObjectDefinition::MODE_WORKSPACE);
if (count($subtypes) > 0)
{
foreach (array_keys($subtypes) as $type)
{
if (isset($settings_map[$type]) &&
$ilSetting->get("disable_wsp_".$settings_map[$type]))
{
continue;
}
$this->sub_objects[] = array("type" => "object",
"value" => $type,
"title" => $lng->txt("wsp_type_".$type));
}
}
$this->sub_objects = ilUtil::sortArray($this->sub_objects, "title", 1);
return (bool)sizeof($this->sub_objects);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectAddNewItemGUI::parseRepository ( )
protected

Parse creatable sub objects for repository incl.

grouping

Returns
bool

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

References $lng, $sub_objects, ilObject\_lookupType(), ilObjRepositorySettings\getDefaultNewItemGrouping(), ilObjRepositorySettings\getNewItemGroups(), ilObjRepositorySettings\getNewItemGroupSubItems(), ilPlugin\lookupTxt(), ilObjRepositorySettings\NEW_ITEM_GROUP_TYPE_GROUP, and ilUtil\sortArray().

Referenced by render().

{
global $objDefinition, $lng, $ilAccess;
$this->sub_objects = array();
if(!is_array($this->disabled_object_types))
{
$this->disabled_object_types = array();
}
$this->disabled_object_types[] = "rolf";
$parent_type = ilObject::_lookupType($this->parent_ref_id, true);
$subtypes = $objDefinition->getCreatableSubObjects($parent_type, $this->mode);
if (count($subtypes) > 0)
{
// grouping of object types
$grp_map = $pos_group_map = array();
include_once("Services/Repository/classes/class.ilObjRepositorySettings.php");
// no groups => use default
if(!$groups)
{
$groups = $default["groups"];
$grp_map = $default["items"];
// reset positions (9999 = "other"/unassigned)
$pos = 0;
foreach($subtypes as $item_type => $item)
{
// see ilObjectDefinition
if(substr($item_type, 0, 1) == "x")
{
$subtypes[$item_type]["pos"] = "99992000";
}
else
{
$subtypes[$item_type]["pos"] = "9999".str_pad(++$pos, 4, "0", STR_PAD_LEFT);
}
}
// assign default positions
foreach($default["sort"] as $item_type => $pos)
{
if(array_key_exists($item_type, $subtypes))
{
$subtypes[$item_type]["pos"] = $pos;
}
}
// sort by default positions
$subtypes = ilUtil::sortArray($subtypes, "pos", "asc", true, true);
}
// use group assignment
else
{
foreach(ilObjRepositorySettings::getNewItemGroupSubItems() as $grp_id => $subitems)
{
foreach($subitems as $subitem)
{
$grp_map[$subitem] = $grp_id;
}
}
}
$group_separators = array();
$pos_group_map[0] = $lng->txt("rep_new_item_group_other");
$old_grp_ids = array();
foreach($groups as $item)
{
{
$pos_group_map[$item["id"]] = $item["title"];
}
else if(sizeof($old_grp_ids))
{
$group_separators[$item["id"]] = $old_grp_ids;
}
$old_grp_ids[] = $item["id"];
}
$current_grp = null;
foreach ($subtypes as $type => $subitem)
{
if (!in_array($type, $this->disabled_object_types))
{
// #9950
if ($ilAccess->checkAccess("create_".$type, "", $this->parent_ref_id, $parent_type))
{
// if only assigned - do not add groups
if(sizeof($pos_group_map) > 1)
{
$obj_grp_id = (int)$grp_map[$type];
if($obj_grp_id !== $current_grp)
{
// add seperator after last group?
$sdone = false;
foreach($group_separators as $idx => $spath)
{
// #11986 - all separators up to next group
if($current_grp && !in_array($obj_grp_id, $spath))
{
// 1 only separator between groups
if(!$sdone)
{
$this->sub_objects[] = array("type" => "column_separator");
$sdone = true;
}
unset($group_separators[$idx]);
}
}
$title = $pos_group_map[$obj_grp_id];
$this->sub_objects[] = array("type" => "group",
"title" => $title);
$current_grp = $obj_grp_id;
}
}
if ($subitem["plugin"])
{
include_once("./Services/Component/classes/class.ilPlugin.php");
$title = ilPlugin::lookupTxt("rep_robj", $type, "obj_".$type);
}
else
{
// #13088
$title = $lng->txt("obj_".$type);
}
$this->sub_objects[] = array("type" => "object",
"value" => $type,
"title" => $title);
}
}
}
}
return (bool)sizeof($this->sub_objects);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectAddNewItemGUI::render ( )

Add new item selection to current page incl.

toolbar (trigger) and overlay

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

References $lng, $tpl, ilObjectDefinition\MODE_WORKSPACE, parsePersonalWorkspace(), and parseRepository().

Referenced by ilContainerGUI\showPossibleSubObjects().

{
global $ilToolbar, $tpl, $lng;
{
if (!$this->parsePersonalWorkspace())
{
return;
}
}
else if(!$this->parseRepository())
{
return;
}
$ov_id = "il_add_new_item_ov";
$ov_trigger_id = $ov_id."_tr";
include_once "Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
$ov = new ilOverlayGUI($ov_id);
// $ov->setAnchor($ov_trigger_id, "tl", "tr");
// $ov->setTrigger($ov_trigger_id, "click", $ov_trigger_id);
$ov->add();
// trigger
$ov->addTrigger($ov_trigger_id, "click", $ov_trigger_id, false, "tl", "tr");
// toolbar
$ilToolbar->addButton($lng->txt("cntr_add_new_item"), "#", "", "",
"", $ov_trigger_id, 'submit emphsubmit');
// css?
$tpl->setVariable("SELECT_OBJTYPE_REPOS",
'<div id="'.$ov_id.'" style="display:none;" class="ilOverlay">'.
$this->getHTML().'</div>');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectAddNewItemGUI::setAfterCreationCallback (   $a_ref_id)

Set after creation callback.

Parameters
int$a_ref_id

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

{
$this->url_creation_callback = $a_ref_id;
}
ilObjectAddNewItemGUI::setCreationUrl (   $a_url)

Set (custom) url for object creation.

Parameters
string$a_url

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

{
$this->url_creation = $a_url;
}
ilObjectAddNewItemGUI::setDisabledObjectTypes ( array  $a_types)

Set object types which may not be created.

Parameters
array$a_types

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

{
$this->disabled_object_types = $a_types;
}
ilObjectAddNewItemGUI::setMode (   $a_mode)

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

Referenced by ilObjOrgUnitGUI\showPossibleSubObjects().

{
$this->mode = (int)$a_mode;
}

+ Here is the caller graph for this function:

Field Documentation

ilObjectAddNewItemGUI::$disabled_object_types
protected

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

ilObjectAddNewItemGUI::$mode
protected

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

ilObjectAddNewItemGUI::$parent_ref_id
protected

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

ilObjectAddNewItemGUI::$sub_objects
protected

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

Referenced by parsePersonalWorkspace(), and parseRepository().

ilObjectAddNewItemGUI::$url_creation
protected

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

Referenced by getHTML().

ilObjectAddNewItemGUI::$url_creation_callback
protected

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


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