ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilMediaPoolGSToolProvider.php
Go to the documentation of this file.
1 <?php
2 
22 
28 {
29  public const SHOW_FOLDERS_TOOL = 'show_folders_tool';
30 
32  {
33  return $this->context_collection->main()->repository();
34  }
35 
36  public function getToolsForContextStack(CalledContexts $called_contexts): array
37  {
38  global $DIC;
39 
40  $access = $DIC->access();
41 
42  $tools = [];
43  $additional_data = $called_contexts->current()->getAdditionalData();
44  if ($additional_data->is(self::SHOW_FOLDERS_TOOL, true)) {
45  $iff = function ($id) {
46  return $this->identification_provider->contextAwareIdentifier($id);
47  };
48  $l = function (string $content) {
49  return $this->dic->ui()->factory()->legacy($content);
50  };
51  $ref_id = $called_contexts->current()->getReferenceId()->toInt();
52 
53  if (!$access->checkAccess("read", "", $ref_id)) {
54  return $tools;
55  }
56 
57  $title = "Folders";
58  $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("icon_fldm.svg"), $title);
59  $tools[] = $this->factory->tool($iff("tree"))
60  ->withTitle($title)
61  ->withSymbol($icon)
62  ->withContentWrapper(function () use ($l, $ref_id) {
63  return $l($this->getTree($ref_id));
64  });
65  }
66 
67  return $tools;
68  }
69 
70 
71  private function getTree(int $ref_id): string
72  {
73  try {
75  $pool = ilObjectFactory::getInstanceByRefId($ref_id);
76  $pool_gui = new ilObjMediaPoolGUI($ref_id);
77  $exp = new ilMediaPoolExplorerGUI($pool_gui, "listMedia", $pool);
78 
79  return $exp->getHTML(true);
80  } catch (Exception $e) {
81  return "";
82  }
83  }
84 }
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getToolsForContextStack(CalledContexts $called_contexts)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User Interface class for media pool objects.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23