42 protected \ILIAS\ResourceStorage\Services
$storage;
58 $this->storage = $DIC[
"resource_storage"];
64 $stream = $this->storage->consume()->stream($identification)->getStream();
72 if (!function_exists(
'mb_detect_encoding') || !function_exists(
'mb_detect_order')
73 || !function_exists(
"mb_convert_encoding")
80 $mb_detect_encoding = mb_detect_encoding($string);
81 mb_detect_order(array(self::ENCODING_UTF_8, self::ENCODING_ISO_8859_1));
82 switch ($mb_detect_encoding) {
83 case self::ENCODING_UTF_8:
85 case self::ENCODING_ASCII:
86 $string = utf8_encode(iconv(self::ENCODING_ASCII,
'UTF-8//IGNORE', $string));
89 $string = mb_convert_encoding($string, self::ENCODING_UTF_8, $mb_detect_encoding);
113 $this->entry_factory->deleteEntriesById($bib->
getId());
116 $entry_instances = [];
119 foreach ($entries_from_file as $file_entry) {
122 $parsed_entry = array();
123 foreach ($file_entry as
$key => $attribute) {
125 if (is_string($attribute)) {
126 $attribute = $this->secure($attribute);
129 if (is_array($attribute)) {
130 $attribute = array_map(
function (
string $a):
string {
131 return $this->secure($a);
133 $attribute = implode(
", ", $attribute);
137 if (
ilStr::strLen($attribute) > self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH) {
139 $attribute =
ilStr::subStr($attribute, 0, self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH - 3) .
'...';
142 if (strtolower(
$key) ===
'ty' || strtolower(
$key) ===
'entrytype') {
148 $parsed_entry[$x][
'name'] =
$key;
149 $parsed_entry[$x][
'value'] = $attribute;
153 if (
$type === null) {
158 $entry_model = $entry_factory->getEmptyInstance();
159 $entry_model->setType(
$type);
160 $entry_model->setDataId($bib->
getId());
161 $entry_model->store();
162 foreach ($parsed_entry as $entry) {
163 $this->
getAttributeFactory()->createAttribute($entry[
'name'], $entry[
'value'], $entry_model->getId());
165 $entry_instances[] = $entry_model;
168 return $entry_instances;
Interface ilBiblFileReaderInterface.
const ENCODING_ISO_8859_1
static subStr(string $a_str, int $a_start, ?int $a_length=null)
__construct(ilBiblEntryFactoryInterface $entry_factory, ilBiblFieldFactoryInterface $field_factory, ilBiblAttributeFactoryInterface $attribute_factory)
ilBiblFileReaderBase constructor.
Class ilBiblFileReaderBase.
ilBiblAttributeFactoryInterface $attribute_factory
static strLen(string $a_string)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH
Class ResourceIdentification.
setFileContent(string $file_content)
parseContentToEntries(ilObjBibliographic $bib)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readContent(ResourceIdentification $identification)
ILIAS ResourceStorage Services $storage
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
convertStringToUTF8(string $string)
ilBiblEntryFactoryInterface $entry_factory
ilBiblFieldFactoryInterface $field_factory
Class ilObjBibliographic.