66 $filesystem = $DIC[
"filesystem"];
81 if (!function_exists(
'mb_detect_encoding') || !function_exists(
'mb_detect_order')
82 || !function_exists(
"mb_convert_encoding")) {
86 $mb_detect_encoding = mb_detect_encoding($string);
87 mb_detect_order(array( self::ENCODING_UTF_8, self::ENCODING_ISO_8859_1 ));
88 switch ($mb_detect_encoding) {
89 case self::ENCODING_UTF_8:
91 case self::ENCODING_ASCII:
92 $string = utf8_encode(iconv(self::ENCODING_ASCII,
'UTF-8//IGNORE', $string));
95 $string = mb_convert_encoding($string, self::ENCODING_UTF_8, $mb_detect_encoding);
145 $entry_instances = [];
147 foreach ($entries_from_file as $file_entry) {
150 $parsed_entry = array();
151 foreach ($file_entry as
$key => $attribute) {
153 if (is_array($attribute)) {
154 $attribute = implode(
", ", $attribute);
158 if (
ilStr::strLen($attribute) > self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH) {
160 $attribute =
ilStr::subStr($attribute, 0, self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH - 3) .
'...';
163 if (strtolower(
$key) ==
'ty' || strtolower(
$key) ==
'entrytype') {
169 $parsed_entry[
$x][
'name'] =
$key;
170 $parsed_entry[
$x][
'value'] = $attribute;
179 $entry_model->setType(
$type);
180 $entry_model->setDataId($bib->
getId());
181 $entry_model->store();
182 foreach ($parsed_entry as $entry) {
183 $this->
getAttributeFactory()->createAttribute($entry[
'name'], $entry[
'value'], $entry_model->getId());
186 $entry_instances[] = $entry_model;
189 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.
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.