4 require_once(
"./Services/COPage/classes/class.ilPCResources.php");
5 require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
34 public function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id =
"")
38 $this->ctrl = $DIC->ctrl();
39 $this->tpl = $DIC[
"tpl"];
40 $this->lng = $DIC->language();
41 $this->obj_definition = $DIC[
"objDefinition"];
42 $tree = $DIC->repositoryTree();
44 $this->rep_tree = $tree;
45 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
54 $next_class = $this->ctrl->getNextClass($this);
57 $cmd = $this->ctrl->getCmd();
59 switch ($next_class) {
79 public function edit($a_insert =
false)
89 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
93 $form->setTitle($this->lng->txt(
"cont_insert_resources"));
95 $form->setTitle($this->lng->txt(
"cont_update_resources"));
99 $ref_id = (int)
$_GET[
"ref_id"];
100 $childs = $this->rep_tree->getChilds($ref_id);
101 $type_counts =
array();
102 $item_groups =
array();
103 foreach ($childs as $c) {
106 $key = ($objDefinition->getGroupOfObj($c[
"type"]) !=
"")
107 ? $objDefinition->getGroupOfObj($c[
"type"])
109 $type_counts[
$key] += 1;
110 if ($c[
"type"] ==
"itgr") {
111 $item_groups[$c[
"ref_id"]] = $c[
"title"];
115 if (count($item_groups) > 0) {
118 if (!$a_insert && $this->content_obj->getMainType() ==
"ItemGroup") {
121 $radg->setValue(
"by_type");
124 $op_type =
new ilRadioOption(
$lng->txt(
"cont_resources_of_type"),
"by_type",
"");
125 $radg->addOption($op_type);
127 $radg->addOption($op_itemgroup);
128 $form->addItem($radg);
133 $this->lng->txt(
"cont_type"),
138 $sub_objs = $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
140 foreach ($sub_objs as $k => $so) {
141 if (!$objDefinition->isPlugin($k)) {
143 $types[$k] = $this->lng->txt(
"objs_" . $k) .
" (" . (int) $type_counts[$k] .
")";
146 include_once(
"./Services/Component/classes/class.ilPlugin.php");
148 $types[$k] = $pl->txt(
"objs_" . $k) .
" (" . (int) $type_counts[$k] .
")";
152 $type_prop->setOptions($types);
153 $selected = ($a_insert)
155 : $this->content_obj->getResourceListType();
156 $type_prop->setValue($selected);
157 if (count($item_groups) > 0) {
158 $op_type->addSubItem($type_prop);
160 $form->addItem($type_prop);
163 if (count($item_groups) > 0) {
168 $selected = ($a_insert)
170 : $this->content_obj->getItemGroupRefId();
171 $op_itemgroup->addSubItem(
$si);
177 $form->addCommandButton(
"create_resources",
$lng->txt(
"save"));
178 $form->addCommandButton(
"cancelCreate",
$lng->txt(
"cancel"));
180 $form->addCommandButton(
"update_resources",
$lng->txt(
"save"));
181 $form->addCommandButton(
"cancelUpdate",
$lng->txt(
"cancel"));
195 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
197 if (
$_POST[
"res_type"] !=
"itgr") {
202 $this->updated = $this->pg_obj->update();
203 if ($this->updated ===
true) {
204 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
215 if (
$_POST[
"res_type"] !=
"itgr") {
220 $this->updated = $this->pg_obj->update();
221 if ($this->updated ===
true) {
222 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
224 $this->pg_obj->addHierIDs();
239 $objDefinition = $DIC[
"objDefinition"];
240 $tree = $DIC->repositoryTree();
241 $lng = $DIC->language();
243 $ref_id = (int)
$_GET[
"ref_id"];
248 $type_to_grp =
array();
250 $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
251 foreach ($type_grps as $grp =>
$def) {
252 foreach (
$def[
"objs"] as
$t) {
253 $type_to_grp[
$t] = $grp;
257 $childs = $tree->getChilds($ref_id);
258 $childs_by_type =
array();
259 $item_groups =
array();
260 foreach ($childs as $child) {
261 $childs_by_type[$type_to_grp[$child[
"type"]]][] = $child;
262 if ($child[
"type"] ==
"itgr") {
263 $item_groups[(int) $child[
"ref_id"]] = $child[
"title"];
268 foreach ($type_grps as
$type => $v) {
271 $tpl =
new ilTemplate(
"tpl.resource_block.html",
true,
true,
"Services/COPage");
274 if (is_array($childs_by_type[
$type]) && count($childs_by_type[$type]) > 0) {
275 foreach ($childs_by_type[$type] as $child) {
276 $tpl->setCurrentBlock(
"row");
278 $tpl->setVariable(
"TITLE", $child[
"title"]);
279 $tpl->parseCurrentBlock();
282 $tpl->setVariable(
"HEADER",
$lng->txt(
"objs_" . $type));
285 $tpl->setCurrentBlock(
"row");
286 $tpl->setVariable(
"TITLE",
$lng->txt(
"no_items"));
287 $tpl->parseCurrentBlock();
288 $tpl->setVariable(
"HEADER",
$lng->txt(
"objs_" . $type));
295 while (preg_match(
'/\[(item-group-([0-9]*))\]/i',
$a_content, $found)) {
296 $itgr_ref_id = (int) $found[2];
299 if (isset($item_groups[$itgr_ref_id])) {
300 include_once(
"./Modules/ItemGroup/classes/class.ilItemGroupItems.php");
302 $items = $itgr_items->getValidItems();
305 $tpl =
new ilTemplate(
"tpl.resource_block.html",
true,
true,
"Services/COPage");
306 foreach ($items as $it_ref_id) {
312 if (in_array($it_type,
array(
"catr",
"crsr",
"grpr"))) {
313 include_once(
'./Services/ContainerReference/classes/class.ilContainerReference.php');
318 $tpl->setCurrentBlock(
"row");
320 $tpl->setVariable(
"TITLE", $it_title);
321 $tpl->parseCurrentBlock();
323 $tpl->setVariable(
"HEADER", $item_groups[$itgr_ref_id]);
326 $html =
"<i>" .
$lng->txt(
"cont_element_refers_removed_itgr") .
"</i>";
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
This class represents an option in a radio group.
__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 (see also ilContainerContentGUI::determinePageEmbeddedBlocks for presentation) ...
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(isset($_POST['submit'])) $form
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
static getRepoPluginObjectByType($type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin...
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.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
update()
Update Resources Component.