ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPCResourcesGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
 
 executeCommand ()
 
 insert ()
 
 edit (bool $a_insert=false)
 
 create ()
 
 update ()
 
- Public Member Functions inherited from ilPageContentGUI
 __construct (ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id="", string $a_pc_id="0")
 
 setContentObject (ilPageContent $a_val)
 
 getContentObject ()
 
 setPage (ilPageObject $a_val)
 
 getPage ()
 
 setPageConfig (ilPageConfig $a_val)
 
 getPageConfig ()
 
 setStyleId (int $a_styleid)
 
 getStyleId ()
 
 getStyle ()
 
 getCharacteristicsOfCurrentStyle (array $a_type)
 Get characteristics of current style and call setCharacteristics, if style is given. More...
 
 setCharacteristics (array $a_chars)
 
 getCharacteristics ()
 
 getHierId ()
 
 setHierId (string $a_hier_id)
 set hierarchical id in dom object More...
 
 delete ()
 
 moveAfter ()
 move content element after another element More...
 
 moveBefore ()
 move content element before another element More...
 
 splitPage ()
 split page to new page at specified position More...
 
 splitPageNext ()
 split page to next page at specified position More...
 
 displayValidationError ()
 
 cancelCreate ()
 cancel creating page content More...
 
 cancelUpdate ()
 cancel update More...
 
 cancel ()
 Cancel. More...
 
 deactivate ()
 gui function set enabled if is not enabled and vice versa More...
 
 cut ()
 Cut single element. More...
 
 copy ()
 Copy single element. More...
 
 getTemplateOptions (string $a_type="")
 Get table templates. More...
 

Static Public Member Functions

static insertResourcesIntoPageContent (string $a_content)
 Insert resources (see also ilContainerContentGUI::determinePageEmbeddedBlocks for presentation) More...
 
- Static Public Member Functions inherited from ilPageContentGUI
static _getCommonBBButtons ()
 

Protected Attributes

ilTree $rep_tree
 
ilObjectDefinition $obj_definition
 
- Protected Attributes inherited from ilPageContentGUI
EditSessionRepository $edit_repo
 
string $pc_id = ""
 
array $chars
 
ilObjStyleSheet $style = null
 
ilLogger $log
 
int $styleid = 0
 
EditGUIRequest $request
 
string $sub_command = ""
 
int $requested_ref_id = 0
 
Style Content CharacteristicManager $char_manager
 

Additional Inherited Members

- Data Fields inherited from ilPageContentGUI
ilPageContent $content_obj
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilPageObject $pg_obj
 
string $hier_id = ""
 
php4DOMDocument $dom
 
 $updated
 
string $target_script = ""
 
string $return_location = ""
 
ilPageConfig $page_config = null
 
- Static Public Attributes inherited from ilPageContentGUI
static string $style_selector_reset = "margin-top:2px; margin-bottom:2px; text-indent:0px; position:static; float:none; width: auto;"
 
- Protected Member Functions inherited from ilPageContentGUI
 redirectToParent (string $hier_id="")
 
 getParentReturn (string $hier_id="")
 
 updateAndReturn ()
 
 setCurrentTextLang (string $lang_key)
 
 getCurrentTextLang ()
 
- Static Protected Attributes inherited from ilPageContentGUI
static array $common_bb_buttons
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning User Interface for Resources Component Editing

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilPCResourcesGUI::__construct ( ilPageObject  $a_pg_obj,
?ilPageContent  $a_content_obj,
string  $a_hier_id,
string  $a_pc_id = "" 
)

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

34  {
35  global $DIC;
36 
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();
42 
43  $this->rep_tree = $tree;
44  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
45  }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilPCResourcesGUI::create ( )

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

References ILIAS\Repository\ctrl(), ilPageContentGUI\getPage(), and insert().

175  : void
176  {
177  $this->content_obj = new ilPCResources($this->getPage());
178  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
179 
180  if ($this->request->getString("res_type") != "itgr") {
181  $this->content_obj->setResourceListType(
182  $this->request->getString("type")
183  );
184  } else {
185  $this->content_obj->setItemGroupRefId(
186  $this->request->getString("itgr")
187  );
188  }
189  $this->updated = $this->pg_obj->update();
190  if ($this->updated === true) {
191  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
192  } else {
193  $this->insert();
194  }
195  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ edit()

ilPCResourcesGUI::edit ( bool  $a_insert = false)

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

References $c, ilPageContentGUI\$ctrl, ILIAS\LTI\ToolProvider\$key, ilPageContentGUI\$lng, $obj_definition, $ref_id, ilPageContentGUI\$requested_ref_id, ilPageContentGUI\$tpl, ilObject\_lookupObjId(), ilObject\_lookupType(), ilPageContentGUI\displayValidationError(), ilObjectPlugin\getPluginObjectByType(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilGlobalTemplateInterface\setContent(), ilRadioGroupInputGUI\setValue(), and ilLanguage\txt().

Referenced by insert(), and update().

67  : void
68  {
69  $ilCtrl = $this->ctrl;
70  $tpl = $this->tpl;
71  $lng = $this->lng;
72  $objDefinition = $this->obj_definition;
73 
74  $op_type = null;
75  $op_itemgroup = null;
76 
77  $this->displayValidationError();
78 
79  // edit form
80  $form = new ilPropertyFormGUI();
81  $form->setFormAction($ilCtrl->getFormAction($this));
82  if ($a_insert) {
83  $form->setTitle($this->lng->txt("cont_insert_resources"));
84  } else {
85  $form->setTitle($this->lng->txt("cont_update_resources"));
86  }
87 
88  // count number of existing objects per type and collect item groups
90  $childs = $this->rep_tree->getChilds($ref_id);
91  $type_counts = array();
92  $item_groups = array();
93  foreach ($childs as $c) {
94  // see bug #12471
95  //echo "<br>-".$c["type"]."-".$objDefinition->getGroupOfObj($c["type"])."-";
96  $key = ($objDefinition->getGroupOfObj($c["type"]) != "")
97  ? $objDefinition->getGroupOfObj($c["type"])
98  : $c["type"];
99  $type_counts[$key] = ($type_counts[$key] ?? 0) + 1;
100  if ($c["type"] == "itgr") {
101  $item_groups[$c["ref_id"]] = $c["title"];
102  }
103  }
104 
105  if (count($item_groups) > 0) {
106  // radio group for type selection
107  $radg = new ilRadioGroupInputGUI($lng->txt("cont_resources"), "res_type");
108  if (!$a_insert && $this->content_obj->getMainType() == "ItemGroup") {
109  $radg->setValue("itgr");
110  } else {
111  $radg->setValue("by_type");
112  }
113 
114  $op_type = new ilRadioOption($lng->txt("cont_resources_of_type"), "by_type", "");
115  $radg->addOption($op_type);
116  $op_itemgroup = new ilRadioOption($lng->txt("obj_itgr"), "itgr", "");
117  $radg->addOption($op_itemgroup);
118  $form->addItem($radg);
119  }
120 
121  // type selection
122  $type_prop = new ilSelectInputGUI(
123  $this->lng->txt("cont_type"),
124  "type"
125  );
126  $obj_id = ilObject::_lookupObjId($this->requested_ref_id);
127  $obj_type = ilObject::_lookupType($obj_id);
128  $sub_objs = $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
129  $types = array();
130  foreach ($sub_objs as $k => $so) {
131  if (!$objDefinition->isPlugin($k)) {
132  if ($k != "itgr") {
133  $types[$k] = $this->lng->txt("objs_" . $k) . " (" . (int) ($type_counts[$k] ?? 0) . ")";
134  }
135  } else {
137  $types[$k] = $pl->txt("objs_" . $k) . " (" . (int) ($type_counts[$k] ?? 0) . ")";
138  }
139  }
140  $type_prop->setOptions($types);
141  $selected = ($a_insert)
142  ? ""
143  : $this->content_obj->getResourceListType();
144  $type_prop->setValue($selected);
145  if (count($item_groups) > 0) {
146  $op_type->addSubItem($type_prop);
147  } else {
148  $form->addItem($type_prop);
149  }
150 
151  if (count($item_groups) > 0) {
152  // item groups
153  $options = $item_groups;
154  $si = new ilSelectInputGUI($this->lng->txt("obj_itgr"), "itgr");
155  $si->setOptions($options);
156  $selected = ($a_insert)
157  ? ""
158  : $this->content_obj->getItemGroupRefId();
159  $op_itemgroup->addSubItem($si);
160  }
161 
162 
163  // save/cancel buttons
164  if ($a_insert) {
165  $form->addCommandButton("create_resources", $lng->txt("save"));
166  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
167  } else {
168  $form->addCommandButton("update_resources", $lng->txt("save"));
169  $form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
170  }
171  $html = $form->getHTML();
172  $tpl->setContent($html);
173  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$c
Definition: cli.php:38
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...
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:67
This class represents a property in a property form.
setContent(string $a_html)
Sets content for standard template.
string $key
Consumer key/client ID value.
Definition: System.php:193
ilGlobalTemplateInterface $tpl
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
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilPCResourcesGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl().

47  : void
48  {
49  // get next class that processes or forwards current command
50  $next_class = $this->ctrl->getNextClass($this);
51 
52  // get current command
53  $cmd = $this->ctrl->getCmd();
54 
55  switch ($next_class) {
56  default:
57  $this->$cmd();
58  break;
59  }
60  }
+ Here is the call graph for this function:

◆ insert()

ilPCResourcesGUI::insert ( )

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

References edit().

Referenced by create().

62  : void
63  {
64  $this->edit(true);
65  }
edit(bool $a_insert=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertResourcesIntoPageContent()

static ilPCResourcesGUI::insertResourcesIntoPageContent ( string  $a_content)
static

Insert resources (see also ilContainerContentGUI::determinePageEmbeddedBlocks for presentation)

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

References $DIC, ilPageContentGUI\$lng, $ref_id, ilPageContentGUI\$tpl, $type, ilObject\_getIcon(), ilObject\_lookupObjId(), ilContainerReference\_lookupTitle(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilGlobalTemplateInterface\get(), ilUtil\img(), ILIAS\Repository\int(), ilGlobalTemplateInterface\parseCurrentBlock(), ilGlobalTemplateInterface\setCurrentBlock(), ilGlobalTemplateInterface\setVariable(), and ilLanguage\txt().

Referenced by ilPageObjectGUI\insertResources().

222  : string {
223  global $DIC;
224 
225  $objDefinition = $DIC["objDefinition"];
226  $tree = $DIC->repositoryTree();
227  $lng = $DIC->language();
228 
229  $ref_id = $DIC
230  ->copage()
231  ->internal()
232  ->gui()
233  ->pc()
234  ->editRequest()
235  ->getRefId();
236  $obj_id = ilObject::_lookupObjId($ref_id);
237  $obj_type = ilObject::_lookupType($obj_id);
238 
239  // determine type -> group
240  $type_to_grp = array();
241  $type_grps =
242  $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
243  foreach ($type_grps as $grp => $def) {
244  foreach ($def["objs"] as $t) {
245  $type_to_grp[$t] = $grp;
246  }
247  }
248 
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"];
257  }
258  }
259  }
260 
261  // handle "by type" lists
262  foreach ($type_grps as $type => $v) {
263  if (is_int(strpos($a_content, "[list-" . $type . "]"))) {
264  // render block
265  $tpl = new ilTemplate("tpl.resource_block.html", true, true, "Services/COPage");
266  $cnt = 0;
267 
268  if (isset($childs_by_type[$type]) && count($childs_by_type[$type]) > 0) {
269  foreach ($childs_by_type[$type] as $child) {
270  $tpl->setCurrentBlock("row");
271  $tpl->setVariable("IMG",
272  ilUtil::img(
273  ilObject::_getIcon((int) $child["obj_id"], "small"),
274  null,
275  "",
276  "",
277  0,
278  "",
279  "ilListItemIcon"
280  )
281  );
282  $tpl->setVariable("TITLE", $child["title"]);
284  $cnt++;
285  }
286  } else {
287  $tpl->setCurrentBlock("row");
288  $tpl->setVariable("TITLE", $lng->txt("no_items"));
290  }
291  $tpl->setVariable("HEADER", $lng->txt("objs_" . $type));
292  $a_content = str_replace("[list-" . $type . "]", $tpl->get(), $a_content);
293  }
294  }
295 
296  // handle item groups
297  while (preg_match('/\[(item-group-([0-9]*))\]/i', $a_content, $found)) {
298  $itgr_ref_id = (int) $found[2];
299 
300  // check whether this item group is child -> insert editing html
301  if (isset($item_groups[$itgr_ref_id])) {
302  $itgr_items = new ilItemGroupItems($itgr_ref_id);
303  $items = $itgr_items->getValidItems();
304 
305  // render block
306  $tpl = new ilTemplate("tpl.resource_block.html", true, true, "Services/COPage");
307  foreach ($items as $it_ref_id) {
308  $it_obj_id = ilObject::_lookupObjId($it_ref_id);
309  $it_title = ilObject::_lookupTitle($it_obj_id);
310  $it_type = ilObject::_lookupType($it_obj_id);
311 
312  // TODO: Handle this switch by module.xml definitions
313  if (in_array($it_type, array("catr", "crsr", "grpr"))) {
314  $it_title = ilContainerReference::_lookupTitle($it_obj_id);
315  }
316 
317 
318  $tpl->setCurrentBlock("row");
319  $tpl->setVariable("IMG", ilUtil::img(ilObject::_getIcon($it_obj_id, "small")));
320  $tpl->setVariable("TITLE", $it_title);
322  }
323  $tpl->setVariable("HEADER", $item_groups[$itgr_ref_id]);
324  $html = $tpl->get();
325  } else {
326  $html = "<i>" . $lng->txt("cont_element_refers_removed_itgr") . "</i>";
327  }
328  $a_content = preg_replace('/\[' . $found[1] . '\]/i', $html, $a_content);
329  }
330 
331 
332  return $a_content;
333  }
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...
$type
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.
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static _lookupTitle(int $obj_id)
ilGlobalTemplateInterface $tpl
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.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilPCResourcesGUI::update ( )

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

References ILIAS\Repository\ctrl(), and edit().

197  : void
198  {
199  if ($this->request->getString("res_type") != "itgr") {
200  $this->content_obj->setResourceListType(
201  $this->request->getString("type")
202  );
203  } else {
204  $this->content_obj->setItemGroupRefId(
205  $this->request->getString("itgr")
206  );
207  }
208  $this->updated = $this->pg_obj->update();
209  if ($this->updated === true) {
210  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
211  } else {
212  $this->pg_obj->addHierIDs();
213  $this->edit();
214  }
215  }
edit(bool $a_insert=false)
+ Here is the call graph for this function:

Field Documentation

◆ $obj_definition

ilObjectDefinition ilPCResourcesGUI::$obj_definition
protected

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

Referenced by edit().

◆ $rep_tree

ilTree ilPCResourcesGUI::$rep_tree
protected

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


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