66 $filesystem = $DIC[
"filesystem"];
81 if (!function_exists(
'mb_detect_encoding') || !function_exists(
'mb_detect_order')
82 || !function_exists(
"mb_convert_encoding")
87 $mb_detect_encoding = mb_detect_encoding($string);
88 mb_detect_order(array(self::ENCODING_UTF_8, self::ENCODING_ISO_8859_1));
89 switch ($mb_detect_encoding) {
90 case self::ENCODING_UTF_8:
92 case self::ENCODING_ASCII:
93 $string = utf8_encode(iconv(self::ENCODING_ASCII,
'UTF-8//IGNORE', $string));
96 $string = mb_convert_encoding($string, self::ENCODING_UTF_8, $mb_detect_encoding);
146 $entry_instances = [];
148 foreach ($entries_from_file as $file_entry) {
151 $parsed_entry = array();
152 foreach ($file_entry as $key => $attribute) {
154 if (is_array($attribute)) {
155 $attribute = implode(
", ", $attribute);
159 if (
ilStr::strLen($attribute) > self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH) {
161 $attribute =
ilStr::subStr($attribute, 0, self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH - 3) .
'...';
164 if (strtolower($key) ==
'ty' || strtolower($key) ==
'entrytype') {
170 $parsed_entry[$x][
'name'] = $key;
171 $parsed_entry[$x][
'value'] = $attribute;
180 $entry_model->setType(
$type);
181 $entry_model->setDataId($bib->
getId());
182 $entry_model->store();
183 foreach ($parsed_entry as $entry) {
184 $this->
getAttributeFactory()->createAttribute($entry[
'name'], $entry[
'value'], $entry_model->getId());
187 $entry_instances[] = $entry_model;
190 return $entry_instances;
Interface ilBiblFileReaderInterface.
const ENCODING_ISO_8859_1
__construct(ilBiblEntryFactoryInterface $entry_factory, ilBiblFieldFactoryInterface $field_factory, ilBiblAttributeFactoryInterface $attribute_factory)
ilBiblFileReaderBase constructor.
Class ilBiblFileReaderBase.
static subStr($a_str, $a_start, $a_length=null)
getEntryFactory()
ilBiblEntryFactoryInterface
Interface ilBiblEntryFactoryInterface.
getId()
get object id public
setFileContent($file_content)
const ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH
readContent($path_to_file)
Interface ilBiblFieldFactoryInterface.
convertStringToUTF8($string)
Interface ilBiblAttributeFactoryInterface.
setPathToFile($path_to_file)
getFieldFactory()
ilBiblFieldFactoryInterface
Class ilObjBibliographic.