ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilMediaPoolGSToolProvider.php
Go to the documentation of this file.
1<?php
2
6
14{
15 const SHOW_FOLDERS_TOOL = 'show_folders_tool';
16
17
22 {
23 return $this->context_collection->main()->repository();
24 }
25
26
30 public function getToolsForContextStack(CalledContexts $called_contexts) : array
31 {
32 global $DIC;
33
34 $access = $DIC->access();
35
36 $tools = [];
37 $additional_data = $called_contexts->current()->getAdditionalData();
38 if ($additional_data->is(self::SHOW_FOLDERS_TOOL, true)) {
39 $iff = function ($id) {
40 return $this->identification_provider->contextAwareIdentifier($id);
41 };
42 $l = function (string $content) {
43 return $this->dic->ui()->factory()->legacy($content);
44 };
45 $ref_id = $called_contexts->current()->getReferenceId()->toInt();
46
47 if (!$access->checkAccess("read", "", $ref_id)) {
48 return $tools;
49 }
50
51 $title = "Folders";
52 $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("outlined/icon_fldm.svg"), $title);
53 $tools[] = $this->factory->tool($iff("tree"))
54 ->withTitle($title)
55 ->withSymbol($icon)
56 ->withContentWrapper(function () use ($l, $ref_id) {
57 return $l($this->getTree($ref_id));
58 });
59 }
60
61 return $tools;
62 }
63
64
70 private function getTree(int $ref_id) : string
71 {
72 try {
74 $pool_gui = new ilObjMediaPoolGUI($ref_id);
75 $exp = new ilMediaPoolExplorerGUI($pool_gui, "listMedia", $pool);
76
77 return $exp->getHTML(true);
78 } catch (Exception $e) {
79 return "";
80 }
81 }
82}
An exception for terminatinating execution or to throw for unit testing.
Media pool explorer GUI class.
getToolsForContextStack(CalledContexts $called_contexts)
@inheritDoc
User Interface class for media pool objects.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$DIC
Definition: xapitoken.php:46