66 $this->storage = $DIC->resourceStorage();
67 $this->upload_service = $DIC->upload();
69 $this->
filesystem = $DIC->filesystem()->storage();
71 if ($existant_bibl_id !== 0) {
72 $this->
setId($existant_bibl_id);
78 $this->bib_field_factory =
new ilBiblFieldFactory($this->bib_type_factory->getInstanceForType($this->getFileType()));
81 $this->bib_field_factory,
82 $this->bib_type_factory->getInstanceForType($this->getFileType()),
83 $this->bib_overview_factory
95 if (!$this->upload_service->hasBeenProcessed()) {
96 $this->upload_service->process();
98 $array_result = $this->upload_service->getResults();
99 $result = reset($array_result);
100 if (!$result->isOK()) {
105 $this->storage->manage()->appendNewRevision(
113 return $this->storage->manage()->upload($result, $this->stakeholder);
120 protected function doCreate(
bool $clone_mode =
false): void
122 if ($this->upload_service->hasUploads()) {
123 if (!$this->upload_service->hasBeenProcessed()) {
124 $this->upload_service->process();
132 "id" => [
"integer", $this->
getId()],
134 "file_type" => [
"integer",
137 "rid" => [
"string", (($rid = $this->
getResourceId()) !==
null) ? $rid->serialize() :
''],
144 protected function doRead():
void 152 if (!empty($rid = $bibl_data->getResourceId()) &&
$id = $this->storage->manage()->find($rid)) {
160 $has_valid_upload = $this->upload_service->hasUploads() && !$this->upload_service->hasBeenProcessed();
162 if ($has_valid_upload) {
172 if ($has_valid_upload) {
183 "rid" => [
"string", (($rid = $this->
getResourceId()) !==
null) ? $rid->serialize() :
''],
185 [
"id" => [
"integer", $this->
getId()]]
189 protected function doDelete(
bool $leave_out_il_bibl_data =
false,
bool $leave_out_delete_file =
false): void
191 if (!$leave_out_delete_file) {
195 $this->db->manipulate(
196 "DELETE FROM il_bibl_attribute WHERE il_bibl_attribute.entry_id IN " 197 .
"(SELECT il_bibl_entry.id FROM il_bibl_entry WHERE il_bibl_entry.data_id = " . $this->db->quote(
203 $this->bib_entry_factory->deleteEntryById($this->
getId());
205 if (!$leave_out_il_bibl_data) {
207 $this->db->manipulate(
208 "DELETE FROM il_bibl_data WHERE id = " . $this->db->quote($this->getId(),
"integer")
220 return "{$this->getType()}/{$this->getId()}";
226 private function copyFile(
string $file_to_copy): void
229 $this->
filesystem->copy($file_to_copy, $target);
247 public function getFilePath(
bool $without_filename =
false): ?string
251 if ($without_filename) {
252 return substr((
string) $file_name, 0, strrpos((
string) $file_name, DIRECTORY_SEPARATOR));
265 return $this->filename = $this->storage->manage()
285 $this->storage->consume()->stream($this->
getResourceId())->getStream() :
288 return $stream->getMetadata(
'uri');
298 return $this->bib_type_factory->getInstanceForType(
$type)->getStringRepresentation();
304 if ($filename ===
null) {
307 $instance = $this->bib_type_factory->getInstanceForFileName($filename);
309 return $instance->getId();
318 if (!$cp_options->isRootNode($this->getRefId())) {
322 $new_obj->cloneStructure($this->
getId());
323 $new_obj->parseFileToDatabase();
337 $this->
setTitle($original->getTitle());
338 $this->
setType($original->getType());
339 $identification = $original->getResourceId();
341 $new_identification = $this->storage->manage()->clone($identification);
344 $this->
copyFile($original->getFileAbsolutePath());
353 foreach ($filters->getAllForObjectId($original_id) as $filter) {
354 $cloned_filter = clone $filter;
355 $cloned_filter->setId(0);
356 $cloned_filter->setObjectId($this->
getId());
357 $cloned_filter->create();
371 $reader = $this->bib_filereader_factory->getByType(
373 $this->bib_entry_factory,
374 $this->bib_field_factory,
375 $this->bib_attribute_factory
378 $this->entries = $reader->parseContentToEntries($this);
388 $this->resource_id = $identification;
404 return $this->storage->manage()->getResource($this->
getResourceId())->getStorageID();
414 $this->is_migrated = $migrated;
419 return $this->bib_type_factory->getInstanceForFileName($filename)->getId();
setFileType(int $file_type)
cloneStructure(int $original_id)
Attention only use this for objects who have not yet been created (use like: $x = new ilObjDataCollec...
ilBiblFieldFactory $bib_field_factory
__construct(int $existant_bibl_id=0)
If bibliographic object exists, read it's data from database, otherwise create it.
handleUpload()
handles a FileUpload and returns an IRSS identification string.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getFilePath(bool $without_filename=false)
Indicates general problems with the input or output operations.
ilBiblEntryFactory $bib_entry_factory
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilBiblAttributeFactory $bib_attribute_factory
setFilename(string $filename)
ilBiblFileReaderFactory $bib_filereader_factory
static where($where, $operator=null)
determineFileTypeByFileName(string $filename)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setMigrated(bool $migrated)
ilObjBibliographicStakeholder $stakeholder
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setResourceId(ResourceIdentification $identification)
static _removeEntriesForObject(int $a_obj_id)
remove all history entries for an object
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
doCloneObject(ilObject2 $new_obj, int $a_target_id, ?int $a_copy_id=null)
Class ilObjBibliographicStakeholder.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ResourceIdentification.
doDelete(bool $leave_out_il_bibl_data=false, bool $leave_out_delete_file=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ResourceIdentification $resource_id
copyFile(string $file_to_copy)
ilBiblOverviewModelFactory $bib_overview_factory
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilBiblTypeFactory $bib_type_factory
static _getInstance(int $a_copy_id)
Class ilObjBibliographic.
FileUpload $upload_service
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setDescription(string $description)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parseFileToDatabase()
Reads out the source file and writes all entries to the database.
ilBiblDataFactoryInterface $bib_data_factory
doCreate(bool $clone_mode=false)
Create object.