37 $this->
ctrl = $DIC->ctrl();
38 $this->tpl = $DIC[
"tpl"];
39 $this->
lng = $DIC->language();
40 $this->obj_definition = $DIC[
"objDefinition"];
41 $tree = $DIC->repositoryTree();
43 $this->rep_tree = $tree;
50 $next_class = $this->
ctrl->getNextClass($this);
53 $cmd = $this->
ctrl->getCmd();
55 switch ($next_class) {
67 public function edit(
bool $a_insert =
false): void
81 $form->setFormAction($ilCtrl->getFormAction($this));
83 $form->setTitle($this->
lng->txt(
"cont_insert_resources"));
85 $form->setTitle($this->
lng->txt(
"cont_update_resources"));
90 $childs = $this->rep_tree->getChilds(
$ref_id);
91 $type_counts = array();
92 $item_groups = array();
93 foreach ($childs as
$c) {
96 $key = ($objDefinition->getGroupOfObj($c[
"type"]) !=
"")
97 ? $objDefinition->getGroupOfObj($c[
"type"])
99 $type_counts[
$key] = ($type_counts[
$key] ?? 0) + 1;
100 if ($c[
"type"] ==
"itgr") {
101 $item_groups[$c[
"ref_id"]] = $c[
"title"];
105 if (count($item_groups) > 0) {
108 if (!$a_insert && $this->content_obj->getMainType() ==
"ItemGroup") {
111 $radg->setValue(
"by_type");
115 $radg->addOption($op_type);
117 $radg->addOption($op_itemgroup);
118 $form->addItem($radg);
123 $this->
lng->txt(
"cont_type"),
128 $sub_objs = $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
130 foreach ($sub_objs as $k => $so) {
131 if (!$objDefinition->isPlugin($k)) {
133 $types[$k] = $this->
lng->txt(
"objs_" . $k) .
" (" . (
int) ($type_counts[$k] ?? 0) .
")";
137 $types[$k] = $pl->txt(
"objs_" . $k) .
" (" . (
int) ($type_counts[$k] ?? 0) .
")";
140 $type_prop->setOptions($types);
141 $selected = ($a_insert)
143 : $this->content_obj->getResourceListType();
144 $type_prop->setValue($selected);
145 if (count($item_groups) > 0) {
146 $op_type->addSubItem($type_prop);
148 $form->addItem($type_prop);
151 if (count($item_groups) > 0) {
153 $options = $item_groups;
155 $si->setOptions($options);
156 $selected = ($a_insert)
158 : $this->content_obj->getItemGroupRefId();
159 $op_itemgroup->addSubItem($si);
165 $form->addCommandButton(
"create_resources",
$lng->
txt(
"save"));
166 $form->addCommandButton(
"cancelCreate",
$lng->
txt(
"cancel"));
168 $form->addCommandButton(
"update_resources",
$lng->
txt(
"save"));
169 $form->addCommandButton(
"cancelUpdate",
$lng->
txt(
"cancel"));
171 $html = $form->getHTML();
178 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
180 if ($this->request->getString(
"res_type") !=
"itgr") {
181 $this->content_obj->setResourceListType(
182 $this->request->getString(
"type")
185 $this->content_obj->setItemGroupRefId(
186 $this->request->getString(
"itgr")
189 $this->updated = $this->pg_obj->update();
190 if ($this->updated ===
true) {
191 $this->
ctrl->returnToParent($this,
"jump" . $this->hier_id);
199 if ($this->request->getString(
"res_type") !=
"itgr") {
200 $this->content_obj->setResourceListType(
201 $this->request->getString(
"type")
204 $this->content_obj->setItemGroupRefId(
205 $this->request->getString(
"itgr")
208 $this->updated = $this->pg_obj->update();
209 if ($this->updated ===
true) {
210 $this->
ctrl->returnToParent($this,
"jump" . $this->hier_id);
212 $this->pg_obj->addHierIDs();
225 $objDefinition = $DIC[
"objDefinition"];
226 $tree = $DIC->repositoryTree();
227 $lng = $DIC->language();
240 $type_to_grp = array();
242 $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
243 foreach ($type_grps as $grp => $def) {
244 foreach ($def[
"objs"] as $t) {
245 $type_to_grp[$t] = $grp;
249 $childs = $tree->getChilds(
$ref_id);
250 $childs_by_type = array();
251 $item_groups = array();
252 foreach ($childs as $child) {
253 if (isset($type_to_grp[$child[
"type"]])) {
254 $childs_by_type[$type_to_grp[$child[
"type"]]][] = $child;
255 if ($child[
"type"] ==
"itgr") {
256 $item_groups[(
int) $child[
"ref_id"]] = $child[
"title"];
262 foreach ($type_grps as
$type => $v) {
263 if (is_int(strpos($a_content,
"[list-" .
$type .
"]"))) {
265 $tpl =
new ilTemplate(
"tpl.resource_block.html",
true,
true,
"Services/COPage");
268 if (isset($childs_by_type[
$type]) && count($childs_by_type[$type]) > 0) {
269 foreach ($childs_by_type[$type] as $child) {
292 $a_content = str_replace(
"[list-" . $type .
"]",
$tpl->
get(), $a_content);
297 while (preg_match(
'/\[(item-group-([0-9]*))\]/i', $a_content, $found)) {
298 $itgr_ref_id = (
int) $found[2];
301 if (isset($item_groups[$itgr_ref_id])) {
303 $items = $itgr_items->getValidItems();
306 $tpl =
new ilTemplate(
"tpl.resource_block.html",
true,
true,
"Services/COPage");
307 foreach ($items as $it_ref_id) {
313 if (in_array($it_type, array(
"catr",
"crsr",
"grpr"))) {
326 $html =
"<i>" .
$lng->
txt(
"cont_element_refers_removed_itgr") .
"</i>";
328 $a_content = preg_replace(
'/\[' . $found[1] .
'\]/i', $html, $a_content);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $obj_id)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjId(int $ref_id)
static insertResourcesIntoPageContent(string $a_content)
Insert resources (see also ilContainerContentGUI::determinePageEmbeddedBlocks for presentation) ...
parses the objects.xml it handles the xml-description of all ilias objects
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
static _lookupTitle(int $obj_id)
setContent(string $a_html)
Sets content for standard template.
edit(bool $a_insert=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
static getPluginObjectByType(string $type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin...
ilObjectDefinition $obj_definition
__construct(Container $dic, ilPlugin $plugin)
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
static _lookupType(int $id, bool $reference=false)