ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSkillProfileUploadHandlerGUI.php
Go to the documentation of this file.
1 <?php
2 
27 
36 {
39 
40  public function __construct()
41  {
42  global $DIC;
44  $this->storage = $DIC['resource_storage'];
45  $this->stakeholder = new ilSkillProfileStorageStakeHolder();
46  }
47 
48  protected function getUploadResult(): HandlerResultInterface
49  {
50  $this->upload->process();
54  $array = $this->upload->getResults();
55  $result = end($array);
56  if ($result instanceof UploadResult && $result->isOK()) {
57  $i = $this->storage->manage()->upload($result, $this->stakeholder);
58  $status = HandlerResultInterface::STATUS_OK;
59  $identifier = $i->serialize();
60  $message = 'Upload ok';
61  } else {
62  $status = HandlerResultInterface::STATUS_FAILED;
63  $identifier = '';
64  $message = $result->getStatus()->getMessage();
65  }
66 
67  return new BasicHandlerResult($this->getFileIdentifierParameterName(), $status, $identifier, $message);
68  }
69 
70  protected function getRemoveResult(string $identifier): HandlerResultInterface
71  {
72  $id = $this->storage->manage()->find($identifier);
73  if ($id !== null) {
74  $this->storage->manage()->remove($id, $this->stakeholder);
75 
76  return new BasicHandlerResult($this->getFileIdentifierParameterName(), HandlerResultInterface::STATUS_OK, $identifier, 'file deleted');
77  } else {
78  return new BasicHandlerResult($this->getFileIdentifierParameterName(), HandlerResultInterface::STATUS_FAILED, $identifier, 'file not found');
79  }
80  }
81 
82  public function getInfoResult(string $identifier): ?FileInfoResult
83  {
84  $id = $this->storage->manage()->find($identifier);
85  if ($id === null) {
86  return new BasicFileInfoResult($this->getFileIdentifierParameterName(), 'unknown', 'unknown', 0, 'unknown');
87  }
88  $r = $this->storage->manage()->getCurrentRevision($id)->getInformation();
89 
90  return new BasicFileInfoResult(
92  $identifier,
93  $r->getTitle(),
94  $r->getSize(),
95  $r->getMimeType()
96  );
97  }
98 
99  public function getInfoForExistingFiles(array $file_ids): array
100  {
101  $infos = [];
102  foreach ($file_ids as $file_id) {
103  $id = $this->storage->manage()->find($file_id);
104  if ($id === null) {
105  continue;
106  }
107  $r = $this->storage->manage()->getCurrentRevision($id)->getInformation();
108 
109  $infos[] = new BasicFileInfoResult($this->getFileIdentifierParameterName(), $file_id, $r->getTitle(), $r->getSize(), $r->getMimeType());
110  }
111 
112  return $infos;
113  }
114 }
Class ilSkillProfileUploadHandlerGUI.
Class ilSkillProfileStorageStakeHolder.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$message
Definition: xapiexit.php:32
$i
Definition: metadata.php:41