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

Class ilPCResourcesGUI. More...

+ Inheritance diagram for ilPCResourcesGUI:
+ Collaboration diagram for ilPCResourcesGUI:

Public Member Functions

 ilPCResourcesGUI (&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
 Constructor public.
executeCommand ()
 execute command
 insert ()
 Insert new resources component form.
 edit ($a_insert=false)
 Edit resources form.
 create ()
 Create new Resources Component.
 update ()
 Update Resources Component.
- Public Member Functions inherited from ilPageContentGUI
 ilPageContentGUI ($a_pg_obj, $a_content_obj, $a_hier_id=0, $a_pc_id="")
 Constructor public.
 setContentObject ($a_val)
 Set content object.
 getContentObject ()
 Get content object.
 setPage ($a_val)
 Set page.
 getPage ()
 Get page.
 setPageConfig ($a_val)
 Set Page Config.
 getPageConfig ()
 Get Page Config.
 setStyleId ($a_styleid)
 Set Style Id.
 getStyleId ()
 Get Style Id.
 getStyle ()
 Get style object.
 setCharacteristics ($a_chars)
 Set Characteristics.
 getCharacteristics ()
 Get characteristics.
 getHierId ()
 get hierarchical id in dom object
 setHierId ($a_hier_id)
 get hierarchical id in dom object
 getBBMenu ($a_ta_name="par_content")
 Get the bb menu incl.
 delete ()
 delete content element
 moveAfter ()
 move content element after another element
 moveBefore ()
 move content element before another element
 splitPage ()
 split page to new page at specified position
 splitPageNext ()
 split page to next page at specified position
 displayValidationError ()
 display validation errors
 cancelCreate ()
 cancel creating page content
 cancelUpdate ()
 cancel update
 cancel ()
 Cancel.
 deactivate ()
 gui function set enabled if is not enabled and vice versa
 cut ()
 Cut single element.
 copy ()
 Copy single element.
 getTemplateOptions ($a_type)
 Get table templates.

Static Public Member Functions

static insertResourcesIntoPageContent ($a_content)
 Insert resources.
- Static Public Member Functions inherited from ilPageContentGUI
static _getCommonBBButtons ()
 Get common bb buttons.

Additional Inherited Members

- Data Fields inherited from ilPageContentGUI
 $content_obj
 $ilias
 $tpl
 $lng
 $ctrl
 $pg_obj
 $hier_id
 $dom
 $updated
 $target_script
 $return_location
 $page_config = null
- Protected Member Functions inherited from ilPageContentGUI
 getCharacteristicsOfCurrentStyle ($a_type)
 Get characteristics of current style.
- Static Protected Attributes inherited from ilPageContentGUI
static $common_bb_buttons

Detailed Description

Class ilPCResourcesGUI.

User Interface for Resources Component Editing

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Member Function Documentation

ilPCResourcesGUI::create ( )

Create new Resources Component.

Definition at line 184 of file class.ilPCResourcesGUI.php.

References $_POST, ilPageContentGUI\getPage(), insert(), and ilUtil\stripSlashes().

{
$this->content_obj = new ilPCResources($this->getPage());
$this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
if ($_POST["res_type"] != "itgr")
{
$this->content_obj->setResourceListType(ilUtil::stripSlashes($_POST["type"]));
}
else
{
$this->content_obj->setItemGroupRefId(ilUtil::stripSlashes($_POST["itgr"]));
}
$this->updated = $this->pg_obj->update();
if ($this->updated === true)
{
$this->ctrl->returnToParent($this, "jump".$this->hier_id);
}
else
{
$this->insert();
}
}

+ Here is the call graph for this function:

ilPCResourcesGUI::edit (   $a_insert = false)

Edit resources form.

Definition at line 64 of file class.ilPCResourcesGUI.php.

References $_GET, $ilCtrl, ilPageContentGUI\$lng, $options, $ref_id, $ret, $si, ilPageContentGUI\$tpl, ilObject\_lookupObjId(), ilObject\_lookupType(), ilPageContentGUI\displayValidationError(), and ilRadioGroupInputGUI\setValue().

Referenced by insert(), and update().

{
global $ilCtrl, $tpl, $lng, $objDefinition;
// edit form
include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($ilCtrl->getFormAction($this));
if ($a_insert)
{
$form->setTitle($this->lng->txt("cont_insert_resources"));
}
else
{
$form->setTitle($this->lng->txt("cont_update_resources"));
}
// count number of existing objects per type and collect item groups
$ref_id = (int) $_GET["ref_id"];
$childs = $this->rep_tree->getChilds($ref_id);
$type_counts = array();
$item_groups = array();
foreach ($childs as $c)
{
// see bug #12471
//echo "<br>-".$c["type"]."-".$objDefinition->getGroupOfObj($c["type"])."-";
$key = ($objDefinition->getGroupOfObj($c["type"]) != "")
? $objDefinition->getGroupOfObj($c["type"])
: $c["type"];
$type_counts[$key] += 1;
if ($c["type"] == "itgr")
{
$item_groups[$c["ref_id"]] = $c["title"];
}
}
if (count($item_groups) > 0)
{
// radio group for type selection
$radg = new ilRadioGroupInputGUI($lng->txt("cont_resources"), "res_type");
if (!$a_insert && $this->content_obj->getMainType() == "ItemGroup")
{
$radg->setValue("itgr");
}
else
{
$radg->setValue("by_type");
}
$op_type = new ilRadioOption($lng->txt("cont_resources_of_type"), "by_type", "");
$radg->addOption($op_type);
$op_itemgroup = new ilRadioOption($lng->txt("obj_itgr"), "itgr", "");
$radg->addOption($op_itemgroup);
$form->addItem($radg);
}
// type selection
$type_prop = new ilSelectInputGUI($this->lng->txt("cont_type"),
"type");
$obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
$obj_type = ilObject::_lookupType($obj_id);
$sub_objs = $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
$types = array();
foreach($sub_objs as $k => $so)
{
if ($k != "itgr" & $k != "icrs")
{
$types[$k] = $this->lng->txt("objs_".$k)." (".(int) $type_counts[$k].")";
}
}
$type_prop->setOptions($types);
$selected = ($a_insert)
? ""
: $this->content_obj->getResourceListType();
$type_prop->setValue($selected);
if (count($item_groups) > 0)
{
$op_type->addSubItem($type_prop);
}
else
{
$form->addItem($type_prop);
}
if (count($item_groups) > 0)
{
// item groups
$options = $item_groups;
$si = new ilSelectInputGUI($this->lng->txt("obj_itgr"), "itgr");
$si->setOptions($options);
$selected = ($a_insert)
? ""
: $this->content_obj->getItemGroupRefId();
$op_itemgroup->addSubItem($si);
}
// save/cancel buttons
if ($a_insert)
{
$form->addCommandButton("create_resources", $lng->txt("save"));
$form->addCommandButton("cancelCreate", $lng->txt("cancel"));
}
else
{
$form->addCommandButton("update_resources", $lng->txt("save"));
$form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
}
$html = $form->getHTML();
$tpl->setContent($html);
return $ret;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& ilPCResourcesGUI::executeCommand ( )

execute command

Definition at line 35 of file class.ilPCResourcesGUI.php.

References $cmd, and $ret.

{
// get next class that processes or forwards current command
$next_class = $this->ctrl->getNextClass($this);
// get current command
$cmd = $this->ctrl->getCmd();
switch($next_class)
{
default:
$ret =& $this->$cmd();
break;
}
return $ret;
}
ilPCResourcesGUI::ilPCResourcesGUI ( $a_pg_obj,
$a_content_obj,
  $a_hier_id,
  $a_pc_id = "" 
)

Constructor public.

Definition at line 24 of file class.ilPCResourcesGUI.php.

References ilPageContentGUI\ilPageContentGUI().

{
global $tree;
$this->rep_tree = $tree;
parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
}

+ Here is the call graph for this function:

ilPCResourcesGUI::insert ( )

Insert new resources component form.

Definition at line 56 of file class.ilPCResourcesGUI.php.

References edit().

Referenced by create().

{
$this->edit(true);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilPCResourcesGUI::insertResourcesIntoPageContent (   $a_content)
static

Insert resources.

Parameters
@return

Definition at line 239 of file class.ilPCResourcesGUI.php.

References $_GET, ilPageContentGUI\$lng, $ref_id, $t, ilPageContentGUI\$tpl, ilObject\_getIcon(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), and ilUtil\img().

Referenced by ilPageObjectGUI\insertResources().

{
global $objDefinition, $tree, $lng;
$ref_id = (int) $_GET["ref_id"];
$obj_id = (int) ilObject::_lookupObjId($ref_id);
$obj_type = ilObject::_lookupType($obj_id);
// determine type -> group
$type_to_grp = array();
$type_grps =
$objDefinition->getGroupedRepositoryObjectTypes($obj_type);
foreach ($type_grps as $grp => $def)
{
foreach ($def["objs"] as $t)
{
$type_to_grp[$t] = $grp;
}
}
$childs = $tree->getChilds($ref_id);
$childs_by_type = array();
$item_groups = array();
foreach ($childs as $child)
{
$childs_by_type[$type_to_grp[$child["type"]]][] = $child;
if ($child["type"] == "itgr")
{
$item_groups[(int) $child["ref_id"]] = $child["title"];
}
}
// handle "by type" lists
foreach ($type_grps as $type => $v)
{
if (is_int(strpos($a_content, "[list-".$type."]")))
{
// render block
$tpl = new ilTemplate("tpl.resource_block.html", true, true, "Services/COPage");
$cnt = 0;
if (is_array($childs_by_type[$type]) && count($childs_by_type[$type]) > 0)
{
foreach ($childs_by_type[$type] as $child)
{
$tpl->setCurrentBlock("row");
$tpl->setVariable("IMG", ilUtil::img(ilObject::_getIcon($child["obj_id"], "small")));
$tpl->setVariable("TITLE", $child["title"]);
$tpl->parseCurrentBlock();
$cnt++;
}
$tpl->setVariable("HEADER", $lng->txt("objs_".$type));
$a_content = str_replace("[list-".$type."]", $tpl->get(), $a_content);
}
else
{
$tpl->setCurrentBlock("row");
$tpl->setVariable("TITLE", $lng->txt("no_items"));
$tpl->parseCurrentBlock();
$tpl->setVariable("HEADER", $lng->txt("objs_".$type));
$a_content = str_replace("[list-".$type."]", $tpl->get(), $a_content);
}
}
}
// handle item groups
while (eregi("\[(item-group-([0-9]*))\]", $a_content, $found))
{
$itgr_ref_id = (int) $found[2];
// check whether this item group is child -> insert editing html
if (isset($item_groups[$itgr_ref_id]))
{
include_once("./Modules/ItemGroup/classes/class.ilItemGroupItems.php");
$itgr_items = new ilItemGroupItems($itgr_ref_id);
$items = $itgr_items->getValidItems();
// render block
$tpl = new ilTemplate("tpl.resource_block.html", true, true, "Services/COPage");
foreach ($items as $it_ref_id)
{
$it_obj_id = ilObject::_lookupObjId($it_ref_id);
$it_title = ilObject::_lookupTitle($it_obj_id);
$tpl->setCurrentBlock("row");
$tpl->setVariable("IMG", ilUtil::img(ilObject::_getIcon($it_obj_id, "small")));
$tpl->setVariable("TITLE", $it_title);
$tpl->parseCurrentBlock();
}
$tpl->setVariable("HEADER", $item_groups[$itgr_ref_id]);
$html = $tpl->get();
}
else
{
$html = "<i>".$lng->txt("cont_element_refers_removed_itgr")."</i>";
}
$a_content = eregi_replace("\[".$found[1]."\]", $html, $a_content);
}
return $a_content;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCResourcesGUI::update ( )

Update Resources Component.

Definition at line 211 of file class.ilPCResourcesGUI.php.

References $_POST, edit(), and ilUtil\stripSlashes().

{
if ($_POST["res_type"] != "itgr")
{
$this->content_obj->setResourceListType(ilUtil::stripSlashes($_POST["type"]));
}
else
{
$this->content_obj->setItemGroupRefId(ilUtil::stripSlashes($_POST["itgr"]));
}
$this->updated = $this->pg_obj->update();
if ($this->updated === true)
{
$this->ctrl->returnToParent($this, "jump".$this->hier_id);
}
else
{
$this->pg_obj->addHierIDs();
$this->edit();
}
}

+ Here is the call graph for this function:


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