5 require_once 
"Services/Object/classes/class.ilObject2.php";
 
    6 require_once 
"Modules/Bibliographic/classes/class.ilBibliographicEntry.php";
 
   67                 if ($existant_bibl_id) {
 
   68                         $this->
setId($existant_bibl_id);
 
   84                 $ilDB->manipulate(
"INSERT INTO il_bibl_data " . 
"(id, filename, is_online) VALUES (" 
   85                         . $ilDB->quote($this->getId(), 
"integer") . 
"," . 
 
   86                         $ilDB->quote($this->getFilename(), 
"text") . 
"," . 
 
   87                         $ilDB->quote($this->getOnline(), 
"integer") . 
 
   95                 $set = $ilDB->query(
"SELECT * FROM il_bibl_data " . 
" WHERE id = " . $ilDB->quote($this->getId(), 
"integer"));
 
   96                 while ($rec = $ilDB->fetchAssoc($set)) {
 
  111                 if (! empty($_FILES[
'bibliographic_file'][
'name'])) {
 
  118                 $ilDB->manipulate(
"UPDATE il_bibl_data SET " . 
"filename = " . $ilDB->quote($this->getFilename(), 
"text") . 
", " 
  120                         "is_online = " . $ilDB->quote($this->getOnline(), 
"integer") . 
 
  121                         " WHERE id = " . $ilDB->quote($this->getId(), 
"integer"));
 
  130         function doDelete($leave_out_il_bibl_data = 
false, $leave_out_delete_file = 
false) {
 
  133                 if (! $leave_out_delete_file) {
 
  138                 $ilDB->manipulate(
"DELETE FROM il_bibl_attribute WHERE il_bibl_attribute.entry_id IN " 
  139                         . 
"(SELECT il_bibl_entry.id FROM il_bibl_entry WHERE il_bibl_entry.data_id = " 
  140                         . $ilDB->quote($this->getId(), 
"integer") . 
");");
 
  143                 $ilDB->manipulate(
"DELETE FROM il_bibl_entry WHERE data_id = " . $ilDB->quote($this->getId(), 
"integer"));
 
  145                 if (! $leave_out_il_bibl_data) {
 
  147                         $ilDB->manipulate(
"DELETE FROM il_bibl_data WHERE id = " . $ilDB->quote($this->getId(), 
"integer"));
 
  151                 require_once(
"./Services/History/classes/class.ilHistory.php");
 
  168                 if (! is_dir($target_dir)) {
 
  172                 if ($_FILES[
'bibliographic_file'][
'name']) {
 
  173                         $filename = $_FILES[
'bibliographic_file'][
'name'];
 
  174                 } elseif ($file_to_copy) {
 
  176                         $split_path = explode(DIRECTORY_SEPARATOR, $file_to_copy);
 
  177                         $filename = $split_path[
sizeof($split_path) - 1];
 
  179                         throw new Exception(
"Either a file must be delivered via \$_POST/\$_FILE or the file must be delivered via the method argument file_to_copy");
 
  182                 $target_full_filename = $target_dir . DIRECTORY_SEPARATOR . 
$filename;
 
  186                 if (@! copy($file_to_copy, $target_full_filename)) {
 
  187                         ilUtil::moveUploadedFile($_FILES[
'bibliographic_file'][
'tmp_name'], $_FILES[
'bibliographic_file'][
'name'], $target_full_filename);
 
  209                 $set = $ilDB->query(
"SELECT filename FROM il_bibl_data " . 
" WHERE id = " 
  210                         . $ilDB->quote($this->getId(), 
"integer"));
 
  212                 $rec = $ilDB->fetchAssoc($set);
 
  214                         if ($without_filename) {
 
  215                                 return substr($rec[
'filename'], 0, strrpos($rec[
'filename'], DIRECTORY_SEPARATOR));
 
  217                                 return $rec[
'filename'];
 
  243                 if (strtolower(substr($this->
getFilename(), - 6)) == 
"bibtex") {
 
  248                 return strtolower(substr($this->
getFilename(), - 3));
 
  255                 $set = $ilDB->query(
'SELECT * FROM il_bibl_overview_model');
 
  256                 while ($rec = $ilDB->fetchAssoc($set)) {
 
  257                         if ($rec[
'literature_type']) {
 
  258                                 $overviewModels[$rec[
'filetype']][$rec[
'literature_type']] = $rec[
'pattern'];
 
  276                 if (! file_exists(
$path)) {
 
  281                         return unlink(
$path);
 
  285                         $path = rtrim(
$path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
 
  291                         foreach ($dir as 
$file) {
 
  292                                 if (! $file->isDot()) {
 
  308                 require_once 
"./Modules/Bibliographic/lib/LibRIS/src/LibRIS/RISReader.php";
 
  311                 $ris_reader->parseFile($full_filename);
 
  313                 return $ris_reader->getRecords();
 
  321                 require_once 
'Modules/Bibliographic/lib/PEAR_BibTex_1.0.0RC5/Structures/BibTex.php';
 
  326                 $bibtex_reader->loadFile($full_filename);
 
  331                 $bibtex_reader->setOption(
'extractAuthor', 
false);
 
  332                 $bibtex_reader->parse();
 
  341                 foreach ($bibtex_reader->data as $key => $entry) {
 
  342                         if (empty($entry[
'cite'])) {
 
  343                                 unset($bibtex_reader->data[$key][
'cite']);
 
  345                                 foreach ($entry as $attr_key => $attribute) {
 
  346                                         if (strpos($attr_key, 
'{') !== 
false) {
 
  347                                                 unset($bibtex_reader->data[$key][$attr_key]);
 
  348                                                 $attr_key_exploaded = explode(
'{', $attr_key);
 
  349                                                 $bibtex_reader->data[$key][
'entryType'] = trim($attr_key_exploaded[0]);
 
  350                                                 $bibtex_reader->data[$key][trim($attr_key_exploaded[1])] = $attribute;
 
  357                         foreach ($entry as $attr_key => $attribute) {
 
  358                                 if ($attr_key == 
'author' && is_array($attribute)) {
 
  359                                         $attribute_string = array();
 
  360                                         foreach ($attribute as $author_key => $author) {
 
  361                                                 $lastname = array($author[
'von'], $author[
'last'], $author[
'jr']);
 
  362                                                 $attribute_string[$author_key] = implode(
' ', array_filter($lastname));
 
  363                                                 if(!empty($author[
'first'])){
 
  364                                                         $attribute_string[$author_key] .= 
', ' . $author[
'first'];
 
  367                                         $bibtex_reader->data[$key][$attr_key] = implode(
' / ', $attribute_string);
 
  372                 return $bibtex_reader->data;
 
  378                 $filedata = file_get_contents($full_filename);
 
  379                 if (strlen($filedata) == strlen(utf8_decode($filedata))) {
 
  381                         $filedata = mb_convert_encoding($filedata, 
'UTF-8', 
'ISO-8859-1');
 
  382                         file_put_contents($full_filename, $filedata);
 
  397                 $bibtex_special_chars[
'ä'] = 
'{\"a}';
 
  398                 $bibtex_special_chars[
'ë'] = 
'{\"e}';
 
  399                 $bibtex_special_chars[
'ï'] = 
'{\"i}';
 
  400                 $bibtex_special_chars[
'ö'] = 
'{\"o}';
 
  401                 $bibtex_special_chars[
'ü'] = 
'{\"u}';
 
  403                 $bibtex_special_chars[
'Ä'] = 
'{\"A}';
 
  404                 $bibtex_special_chars[
'Ë'] = 
'{\"E}';
 
  405                 $bibtex_special_chars[
'Ï'] = 
'{\"I}';
 
  406                 $bibtex_special_chars[
'Ö'] = 
'{\"O}';
 
  407                 $bibtex_special_chars[
'Ü'] = 
'{\"U}';
 
  409                 $bibtex_special_chars[
'â'] = 
'{\^a}';
 
  410                 $bibtex_special_chars[
'ê'] = 
'{\^e}';
 
  411                 $bibtex_special_chars[
'î'] = 
'{\^i}';
 
  412                 $bibtex_special_chars[
'ô'] = 
'{\^o}';
 
  413                 $bibtex_special_chars[
'û'] = 
'{\^u}';
 
  415                 $bibtex_special_chars[
'Â'] = 
'{\^A}';
 
  416                 $bibtex_special_chars[
'Ê'] = 
'{\^E}';
 
  417                 $bibtex_special_chars[
'Î'] = 
'{\^I}';
 
  418                 $bibtex_special_chars[
'Ô'] = 
'{\^O}';
 
  419                 $bibtex_special_chars[
'Û'] = 
'{\^U}';
 
  421                 $bibtex_special_chars[
'à'] = 
'{\`a}';
 
  422                 $bibtex_special_chars[
'è'] = 
'{\`e}';
 
  423                 $bibtex_special_chars[
'ì'] = 
'{\`i}';
 
  424                 $bibtex_special_chars[
'ò'] = 
'{\`o}';
 
  425                 $bibtex_special_chars[
'ù'] = 
'{\`u}';
 
  427                 $bibtex_special_chars[
'À'] = 
'{\`A}';
 
  428                 $bibtex_special_chars[
'È'] = 
'{\`E}';
 
  429                 $bibtex_special_chars[
'Ì'] = 
'{\`I}';
 
  430                 $bibtex_special_chars[
'Ò'] = 
'{\`O}';
 
  431                 $bibtex_special_chars[
'Ù'] = 
'{\`U}';
 
  433                 $bibtex_special_chars[
'á'] = 
'{\\\'a}';
 
  434                 $bibtex_special_chars[
'é'] = 
'{\\\'e}';
 
  435                 $bibtex_special_chars[
'í'] = 
'{\\\'i}';
 
  436                 $bibtex_special_chars[
'ó'] = 
'{\\\'o}';
 
  437                 $bibtex_special_chars[
'ú'] = 
'{\\\'u}';
 
  439                 $bibtex_special_chars[
'Á'] = 
'{\\\'A}';
 
  440                 $bibtex_special_chars[
'É'] = 
'{\\\'E}';
 
  441                 $bibtex_special_chars[
'Í'] = 
'{\\\'I}';
 
  442                 $bibtex_special_chars[
'Ó'] = 
'{\\\'O}';
 
  443                 $bibtex_special_chars[
'Ú'] = 
'{\\\'U}';
 
  445                 $bibtex_special_chars[
'à'] = 
'{\`a}';
 
  446                 $bibtex_special_chars[
'è'] = 
'{\`e}';
 
  447                 $bibtex_special_chars[
'ì'] = 
'{\`i}';
 
  448                 $bibtex_special_chars[
'ò'] = 
'{\`o}';
 
  449                 $bibtex_special_chars[
'ù'] = 
'{\`u}';
 
  451                 $bibtex_special_chars[
'À'] = 
'{\`A}';
 
  452                 $bibtex_special_chars[
'È'] = 
'{\`E}';
 
  453                 $bibtex_special_chars[
'Ì'] = 
'{\`I}';
 
  454                 $bibtex_special_chars[
'Ò'] = 
'{\`O}';
 
  455                 $bibtex_special_chars[
'Ù'] = 
'{\`U}';
 
  457                 $bibtex_special_chars[
'ç'] = 
'{\c c}';
 
  458                 $bibtex_special_chars[
'ß'] = 
'{\ss}';
 
  459                 $bibtex_special_chars[
'ñ'] = 
'{\~n}';
 
  460                 $bibtex_special_chars[
'Ñ'] = 
'{\~N}';
 
  462                 return str_replace($bibtex_special_chars, array_keys($bibtex_special_chars), $file_content);
 
  493                 $this->
moveFile($original->getFileAbsolutePath());
 
  495                 $this->
setOnline($original->getOnline());
 
  497                 $this->
setTitle($original->getTitle());
 
  498                 $this->
setType($original->getType());
 
  505                 for ($i = 0; $i < strlen($input); $i ++) {
 
  506                         if ($input[$i] != 
" " && $input[$i] != 
"-") {
 
  507                                 return substr($input, $i);
 
  531                 foreach ($entries_from_file as $file_entry) {
 
  534                         $parsed_entry = array();
 
  536                         foreach ($file_entry as $key => $attribute) {
 
  538                                 if (is_array($attribute)) {
 
  539                                         $attribute = implode(
", ", $attribute);
 
  542                                 if(mb_strlen($attribute, 
'UTF-8') > self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH){
 
  543                                         $attribute = mb_substr($attribute, 0, self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH - 3, 
'UTF-8') . 
'...';
 
  547                                 if (strtolower($key) == 
'ty' || strtolower($key) == 
'entrytype') {
 
  554                                 $parsed_entry[$x][
'name'] = $key;
 
  555                                 $parsed_entry[$x ++][
'value'] = $attribute;
 
  559                         $entry_model->setType(
$type);
 
  560                         $entry_model->setAttributes($parsed_entry);
 
  561                         $entry_model->setBibliographicObjId($this->
getId());
 
  562                         $entry_model->doCreate();
 
  575                 $this->is_online = $a_online;