65 $this->storage = $DIC->resourceStorage();
66 $this->upload_service = $DIC->upload();
68 $this->
filesystem = $DIC->filesystem()->storage();
70 if ($existant_bibl_id !== 0) {
71 $this->
setId($existant_bibl_id);
77 $this->bib_field_factory =
new ilBiblFieldFactory($this->bib_type_factory->getInstanceForType($this->getFileType()));
80 $this->bib_field_factory,
81 $this->bib_type_factory->getInstanceForType($this->getFileType()),
82 $this->bib_overview_factory
94 if (!$this->upload_service->hasBeenProcessed()) {
95 $this->upload_service->process();
97 $array_result = $this->upload_service->getResults();
98 $result = reset($array_result);
99 if (!$result->isOK()) {
104 $this->storage->manage()->appendNewRevision(
112 return $this->storage->manage()->upload($result, $this->stakeholder);
119 protected function doCreate(
bool $clone_mode =
false): void
121 if ($this->upload_service->hasUploads()) {
122 if (!$this->upload_service->hasBeenProcessed()) {
123 $this->upload_service->process();
131 "id" => [
"integer", $this->
getId()],
133 "file_type" => [
"integer",
136 "rid" => [
"string", (($rid = $this->
getResourceId()) !==
null) ? $rid->serialize() :
''],
143 protected function doRead():
void 151 if (!empty($rid = $bibl_data->getResourceId()) &&
$id = $this->storage->manage()->find($rid)) {
159 $has_valid_upload = $this->upload_service->hasUploads() && !$this->upload_service->hasBeenProcessed();
161 if ($has_valid_upload) {
171 if ($has_valid_upload) {
182 "rid" => [
"string", (($rid = $this->
getResourceId()) !==
null) ? $rid->serialize() :
''],
184 [
"id" => [
"integer", $this->
getId()]]
188 protected function doDelete(
bool $leave_out_il_bibl_data =
false,
bool $leave_out_delete_file =
false): void
190 if (!$leave_out_delete_file) {
194 $this->db->manipulate(
195 "DELETE FROM il_bibl_attribute WHERE il_bibl_attribute.entry_id IN " 196 .
"(SELECT il_bibl_entry.id FROM il_bibl_entry WHERE il_bibl_entry.data_id = " . $this->db->quote(
202 $this->bib_entry_factory->deleteEntryById($this->
getId());
204 if (!$leave_out_il_bibl_data) {
206 $this->db->manipulate(
207 "DELETE FROM il_bibl_data WHERE id = " . $this->db->quote($this->getId(),
"integer")
219 return "{$this->getType()}/{$this->getId()}";
225 private function copyFile(
string $file_to_copy): void
228 $this->
filesystem->copy($file_to_copy, $target);
246 public function getFilePath(
bool $without_filename =
false): ?string
250 if ($without_filename) {
251 return substr((
string) $file_name, 0, strrpos((
string) $file_name, DIRECTORY_SEPARATOR));
264 return $this->filename = $this->storage->manage()
284 $this->storage->consume()->stream($this->
getResourceId())->getStream() :
287 return $stream->getMetadata(
'uri');
297 return $this->bib_type_factory->getInstanceForType(
$type)->getStringRepresentation();
303 if ($filename ===
null) {
306 $instance = $this->bib_type_factory->getInstanceForFileName($filename);
308 return $instance->getId();
317 if (!$cp_options->isRootNode($this->getRefId())) {
321 $new_obj->cloneStructure($this->
getId());
322 $new_obj->parseFileToDatabase();
336 $this->
setTitle($original->getTitle());
337 $this->
setType($original->getType());
338 $identification = $original->getResourceId();
340 $new_identification = $this->storage->manage()->clone($identification);
343 $this->
copyFile($original->getFileAbsolutePath());
352 foreach ($filters->getAllForObjectId($original_id) as $filter) {
353 $cloned_filter = clone $filter;
354 $cloned_filter->setId(0);
355 $cloned_filter->setObjectId($this->
getId());
356 $cloned_filter->create();
370 $reader = $this->bib_filereader_factory->getByType(
372 $this->bib_entry_factory,
373 $this->bib_field_factory,
374 $this->bib_attribute_factory
377 $this->entries = $reader->parseContentToEntries($this);
387 $this->resource_id = $identification;
403 return $this->storage->manage()->getResource($this->
getResourceId())->getStorageID();
413 $this->is_migrated = $migrated;
418 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.