4 require_once(
"./Services/COPage/classes/class.ilPCResources.php");
5 require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
24 function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id =
"")
28 $this->rep_tree = $tree;
29 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
38 $next_class = $this->ctrl->getNextClass($this);
41 $cmd = $this->ctrl->getCmd();
64 function edit($a_insert =
false)
71 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
73 $form->setFormAction($ilCtrl->getFormAction($this));
76 $form->setTitle($this->lng->txt(
"cont_insert_resources"));
80 $form->setTitle($this->lng->txt(
"cont_update_resources"));
85 $childs = $this->rep_tree->getChilds(
$ref_id);
86 $type_counts =
array();
87 $item_groups =
array();
88 foreach ($childs as $c)
92 $key = ($objDefinition->getGroupOfObj($c[
"type"]) !=
"")
93 ? $objDefinition->getGroupOfObj($c[
"type"])
95 $type_counts[$key] += 1;
96 if ($c[
"type"] ==
"itgr")
98 $item_groups[$c[
"ref_id"]] = $c[
"title"];
102 if (count($item_groups) > 0)
106 if (!$a_insert && $this->content_obj->getMainType() ==
"ItemGroup")
112 $radg->setValue(
"by_type");
115 $op_type =
new ilRadioOption($lng->txt(
"cont_resources_of_type"),
"by_type",
"");
116 $radg->addOption($op_type);
117 $op_itemgroup =
new ilRadioOption($lng->txt(
"obj_itgr"),
"itgr",
"");
118 $radg->addOption($op_itemgroup);
119 $form->addItem($radg);
127 $sub_objs = $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
129 foreach($sub_objs as $k => $so)
133 $types[$k] = $this->lng->txt(
"objs_".$k).
" (".(int) $type_counts[$k].
")";
136 $type_prop->setOptions($types);
137 $selected = ($a_insert)
139 : $this->content_obj->getResourceListType();
140 $type_prop->setValue($selected);
141 if (count($item_groups) > 0)
143 $op_type->addSubItem($type_prop);
147 $form->addItem($type_prop);
150 if (count($item_groups) > 0)
156 $selected = ($a_insert)
158 : $this->content_obj->getItemGroupRefId();
159 $op_itemgroup->addSubItem(
$si);
166 $form->addCommandButton(
"create_resources", $lng->txt(
"save"));
167 $form->addCommandButton(
"cancelCreate", $lng->txt(
"cancel"));
171 $form->addCommandButton(
"update_resources", $lng->txt(
"save"));
172 $form->addCommandButton(
"cancelUpdate", $lng->txt(
"cancel"));
174 $html = $form->getHTML();
175 $tpl->setContent(
$html);
187 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
189 if (
$_POST[
"res_type"] !=
"itgr")
197 $this->updated = $this->pg_obj->update();
198 if ($this->updated ===
true)
200 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
213 if (
$_POST[
"res_type"] !=
"itgr")
221 $this->updated = $this->pg_obj->update();
222 if ($this->updated ===
true)
224 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
228 $this->pg_obj->addHierIDs();
241 global $objDefinition, $tree,
$lng;
248 $type_to_grp =
array();
250 $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
251 foreach ($type_grps as $grp => $def)
253 foreach ($def[
"objs"] as
$t)
255 $type_to_grp[
$t] = $grp;
259 $childs = $tree->getChilds(
$ref_id);
260 $childs_by_type =
array();
261 $item_groups =
array();
262 foreach ($childs as $child)
264 $childs_by_type[$type_to_grp[$child[
"type"]]][] = $child;
265 if ($child[
"type"] ==
"itgr")
267 $item_groups[(int) $child[
"ref_id"]] = $child[
"title"];
272 foreach ($type_grps as $type => $v)
274 if (is_int(strpos(
$a_content,
"[list-".$type.
"]")))
277 $tpl =
new ilTemplate(
"tpl.resource_block.html",
true,
true,
"Services/COPage");
280 if (is_array($childs_by_type[$type]) && count($childs_by_type[$type]) > 0)
282 foreach ($childs_by_type[$type] as $child)
284 $tpl->setCurrentBlock(
"row");
286 $tpl->setVariable(
"TITLE", $child[
"title"]);
287 $tpl->parseCurrentBlock();
290 $tpl->setVariable(
"HEADER", $lng->txt(
"objs_".$type));
295 $tpl->setCurrentBlock(
"row");
296 $tpl->setVariable(
"TITLE", $lng->txt(
"no_items"));
297 $tpl->parseCurrentBlock();
298 $tpl->setVariable(
"HEADER", $lng->txt(
"objs_".$type));
305 while (preg_match(
'/\[(item-group-([0-9]*))\]/i',
$a_content, $found))
307 $itgr_ref_id = (int) $found[2];
310 if (isset($item_groups[$itgr_ref_id]))
312 include_once(
"./Modules/ItemGroup/classes/class.ilItemGroupItems.php");
314 $items = $itgr_items->getValidItems();
317 $tpl =
new ilTemplate(
"tpl.resource_block.html",
true,
true,
"Services/COPage");
318 foreach ($items as $it_ref_id)
325 if(in_array($it_type,
array(
"catr",
"crsr",
"grpr")))
327 include_once(
'./Services/ContainerReference/classes/class.ilContainerReference.php');
332 $tpl->setCurrentBlock(
"row");
334 $tpl->setVariable(
"TITLE", $it_title);
335 $tpl->parseCurrentBlock();
337 $tpl->setVariable(
"HEADER", $item_groups[$itgr_ref_id]);
342 $html =
"<i>".$lng->txt(
"cont_element_refers_removed_itgr").
"</i>";
This class represents an option in a radio group.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor public.
edit($a_insert=false)
Edit resources form.
static _lookupTitle($a_id)
lookup object title
static insertResourcesIntoPageContent($a_content)
Insert resources.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
create()
Create new Resources Component.
static _lookupTitle($a_obj_id)
Overwitten from base class.
if(!is_array($argv)) $options
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
displayValidationError()
display validation errors
executeCommand()
execute command
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
insert()
Insert new resources component form.
update()
Update Resources Component.