4 require_once
"Services/Object/classes/class.ilObject2.php";
5 require_once
"Modules/Bibliographic/classes/class.ilBibliographicEntry.php";
6 require_once(
'./Modules/Bibliographic/classes/Types/Ris/class.ilRis.php');
7 require_once(
'./Modules/Bibliographic/classes/Types/BibTex/class.ilBibTex.php');
72 if ($existant_bibl_id) {
73 $this->
setId($existant_bibl_id);
76 parent::__construct($existant_bibl_id,
false);
88 $ilDB->manipulate(
"INSERT INTO il_bibl_data " .
"(id, filename, is_online) VALUES (" .
$ilDB->quote($this->getId(),
"integer") .
"," .
89 $ilDB->quote($this->getFilename(),
"text") .
"," .
90 $ilDB->quote($this->getOnline(),
"integer") .
98 $set =
$ilDB->query(
"SELECT * FROM il_bibl_data " .
" WHERE id = " .
$ilDB->quote($this->getId(),
"integer"));
99 while ($rec =
$ilDB->fetchAssoc($set)) {
110 $ilDB = $DIC[
'ilDB'];
111 $file_changed = !empty($_FILES[
'bibliographic_file'][
'name']);
118 $ilDB->manipulate(
"UPDATE il_bibl_data SET " .
"filename = " .
$ilDB->quote($this->getFilename(),
"text") .
", " .
119 "is_online = " .
$ilDB->quote($this->getOnline(),
"integer") .
120 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer"));
129 protected function doDelete($leave_out_il_bibl_data =
false, $leave_out_delete_file =
false) {
131 $ilDB = $DIC[
'ilDB'];
132 if (!$leave_out_delete_file) {
136 $ilDB->manipulate(
"DELETE FROM il_bibl_attribute WHERE il_bibl_attribute.entry_id IN " 137 .
"(SELECT il_bibl_entry.id FROM il_bibl_entry WHERE il_bibl_entry.data_id = " .
$ilDB->quote($this->getId(),
"integer")
140 $ilDB->manipulate(
"DELETE FROM il_bibl_entry WHERE data_id = " .
$ilDB->quote($this->getId(),
"integer"));
141 if (!$leave_out_il_bibl_data) {
143 $ilDB->manipulate(
"DELETE FROM il_bibl_data WHERE id = " .
$ilDB->quote($this->getId(),
"integer"));
146 require_once(
"./Services/History/classes/class.ilHistory.php");
166 if (!is_dir($target_dir)) {
169 if ($_FILES[
'bibliographic_file'][
'name']) {
170 $filename = $_FILES[
'bibliographic_file'][
'name'];
171 } elseif ($file_to_copy) {
173 $split_path = explode(DIRECTORY_SEPARATOR, $file_to_copy);
174 $filename = $split_path[
sizeof($split_path) - 1];
176 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");
178 $target_full_filename = $target_dir . DIRECTORY_SEPARATOR .
$filename;
181 if (@!copy($file_to_copy, $target_full_filename)) {
182 if (!empty($_FILES[
'bibliographic_file'][
'tmp_name'])) {
183 ilUtil::moveUploadedFile($_FILES[
'bibliographic_file'][
'tmp_name'], $_FILES[
'bibliographic_file'][
'name'], $target_full_filename);
185 throw new Exception(
"The file delivered via the method argument file_to_copy could not be copied. The file '{$file_to_copy}' does probably not exist.");
195 self::__force_rmdir(
$path);
206 $ilDB = $DIC[
'ilDB'];
207 $set =
$ilDB->query(
"SELECT filename FROM il_bibl_data " .
" WHERE id = " .
$ilDB->quote($this->getId(),
"integer"));
208 $rec =
$ilDB->fetchAssoc($set);
210 if ($without_filename) {
211 return substr($rec[
'filename'], 0, strrpos($rec[
'filename'], DIRECTORY_SEPARATOR));
213 return $rec[
'filename'];
248 if (strtolower(substr($this->
getFilename(), - 6)) ==
"bibtex") {
249 return self::FILETYPE_BIB;
253 return strtolower(substr($this->
getFilename(), - 3));
262 $ilDB = $DIC[
'ilDB'];
264 $set =
$ilDB->query(
'SELECT * FROM il_bibl_overview_model');
265 while ($rec =
$ilDB->fetchAssoc($set)) {
266 if ($rec[
'literature_type']) {
267 $overviewModels[$rec[
'filetype']][$rec[
'literature_type']] = $rec[
'pattern'];
285 if (!file_exists(
$path)) {
289 return unlink(
$path);
292 $path = rtrim(
$path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
294 $dir =
new DirectoryIterator(
$path);
295 foreach ($dir as
$file) {
296 if (!$file->isDot()) {
297 $result &= self::__force_rmdir(
$path . $file->getFilename(),
false);
316 public function doCloneObject($new_obj, $a_target_id, $a_copy_id = null, $a_omit_tree =
false) {
321 if (!$cp_options->isRootNode($this->getRefId())) {
325 $new_obj->cloneStructure($this->
getId());
341 $this->
moveFile($original->getFileAbsolutePath());
343 $this->
setTitle($original->getTitle());
344 $this->
setType($original->getType());
356 for ($i = 0; $i < strlen($input); $i ++) {
357 if ($input[$i] !=
" " && $input[$i] !=
"-") {
358 return substr($input, $i);
371 $entries_from_file =
array();
373 case(self::FILETYPE_RIS):
374 $ilRis =
new ilRis();
377 $entries_from_file = $ilRis->parseContent();
379 case(self::FILETYPE_BIB):
383 $entries_from_file = $bib->parseContent();
387 foreach ($entries_from_file as $file_entry) {
390 $parsed_entry =
array();
391 foreach ($file_entry as $key => $attribute) {
393 if (is_array($attribute)) {
394 $attribute = implode(
", ", $attribute);
398 if (
ilStr::strLen($attribute) > self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH) {
400 $attribute =
ilStr::subStr($attribute, 0, self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH - 3) .
'...';
403 if (strtolower($key) ==
'ty' || strtolower($key) ==
'entrytype') {
409 $parsed_entry[
$x][
'name'] = $key;
410 $parsed_entry[
$x ++][
'value'] = $attribute;
414 $entry_model->setType(
$type);
415 $entry_model->setAttributes($parsed_entry);
416 $entry_model->setBibliographicObjId($this->
getId());
417 $entry_model->doCreate();
426 $this->is_online = $a_online;
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
moveFile($file_to_copy=false)
const ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH
doCloneObject($new_obj, $a_target_id, $a_copy_id=null, $a_omit_tree=false)
Clone BIBL.
doDelete($leave_out_il_bibl_data=false, $leave_out_delete_file=false)
static __force_rmdir($path)
remove a directory recursively
__construct($existant_bibl_id=0)
If bibliographic object exists, read it's data from database, otherwise create it.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
writeSourcefileEntriesToDb()
Reads out the source file and writes all entries to the database.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static __removeSpacesAndDashesAtBeginning($input)
static getInstance($file_type, $entry_id=null)
Create styles array
The data for the language used.
cloneStructure($original_id)
Attention only use this for objects who have not yet been created (use like: $x = new ilObjDataCollec...
static getDataDir()
get data directory (outside webspace)
static _removeEntriesForObject($a_obj_id)
remove all history entries for an object
Class ilObject2 This is an intermediate progress of ilObject class.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
Class ilObjBibliographic.
static subStr($a_str, $a_start, $a_length=NULL)
getFilePath($without_filename=false)
static getAllOverviewModels()