ILIAS  release_4-4 Revision
ilObjBibliographic Class Reference

Class ilObjBibliographic. More...

+ Inheritance diagram for ilObjBibliographic:
+ Collaboration diagram for ilObjBibliographic:

Public Member Functions

 initType ()
 initType More...
 
 __construct ($existant_bibl_id=0)
 If bibliographic object exists, read it's data from database, otherwise create it. More...
 
 doCreate ()
 Create object. More...
 
 doRead ()
 
 doUpdate ()
 Update data. More...
 
 doDelete ($leave_out_il_bibl_data=false, $leave_out_delete_file=false)
 
 getFileDirectory ()
 
 moveFile ($file_to_copy=false)
 
 deleteFile ()
 
 getFilePath ($without_filename=false)
 
 setFilename ($filename)
 
 getFilename ()
 
 getFileAbsolutePath ()
 
 getFiletype ()
 
 doCloneObject (ilObjBibliographic $new_obj, $a_target_id, $a_copy_id=0)
 Clone BIBL. More...
 
 cloneStructure ($original_id)
 Attention only use this for objects who have not yet been created (use like: $x = new ilObjDataCollection; $x->cloneStructure($id)) More...
 
 writeSourcefileEntriesToDb ()
 Reads out the source file and writes all entries to the database. More...
 
 setOnline ($a_online)
 Set Online. More...
 
 getOnline ()
 Get Online. More...
 
- Public Member Functions inherited from ilObject2
 __construct ($a_id=0, $a_reference=true)
 Constructor public. More...
 
 withReferences ()
 
 read ($a_force_db=false)
 Read data from db. More...
 
 getId ()
 
 setId ($a_id)
 
 setRefId ($a_id)
 
 getRefId ()
 
 getType ()
 
 setType ($a_type)
 
 getPresentationTitle ()
 
 getTitle ()
 
 getUntranslatedTitle ()
 
 setTitle ($a_title)
 
 getDescription ()
 
 setDescription ($a_desc)
 
 getLongDescription ()
 
 getImportId ()
 
 setImportId ($a_import_id)
 
 getOwner ()
 
 getOwnerName ()
 
 _lookupOwnerName ($a_owner_id)
 
 setOwner ($a_owner)
 
 getCreateDate ()
 
 getLastUpdateDate ()
 
 setObjDataRecord ($a_record)
 
 create ($a_clone_mode=false)
 
 update ()
 
 MDUpdateListener ($a_element)
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 
 _getIdForImportId ($a_import_id)
 
 _lookupOwner ($a_id)
 
 _lookupLastUpdate ($a_id, $a_as_string=false)
 
 _getLastUpdateOfObjects ($a_objs)
 
 _setDeletedDate ($a_ref_id)
 
 _resetDeletedDate ($a_ref_id)
 
 _lookupDeletedDate ($a_ref_id)
 
 _writeTitle ($a_obj_id, $a_title)
 
 _writeDescription ($a_obj_id, $a_desc)
 
 _writeImportId ($a_obj_id, $a_import_id)
 
 _isInTrash ($a_ref_id)
 
 _hasUntrashedReference ($a_obj_id)
 
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 
 putInTree ($a_parent_ref)
 
 setPermissions ($a_parent_ref)
 
 createReference ()
 
 countReferences ()
 
 delete ()
 
 initDefaultRoles ()
 
 createRoleFolder ()
 
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 
 cloneMetaData ($target_obj)
 
 cloneObject ($a_target_id, $a_copy_id=null, $a_omit_tree=false)
 
 cloneDependencies ($a_target_id, $a_copy_id)
 
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ($a_force_db=false)
 read object data from db into object More...
 
 getId ()
 get object id public More...
 
 setId ($a_id)
 set object id public More...
 
 setRefId ($a_id)
 set reference id public More...
 
 getRefId ()
 get reference id public More...
 
 getType ()
 get object type public More...
 
 setType ($a_type)
 set object type public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title public More...
 
 getUntranslatedTitle ()
 get untranslated object title public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date public More...
 
 getLastUpdateDate ()
 get last update date public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class) More...
 
 create ()
 create More...
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
 _lookupOwner ($a_id)
 lookup object owner More...
 
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
 _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object More...
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) public More...
 
 createRoleFolder ()
 creates a local role folder More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event passed, each object may decide how it reacts. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 Clone object permissions, put in tree ... More...
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 _lookupCreationDate ($a_id)
 Lookup creation date. More...
 

Static Public Member Functions

static __getAllOverviewModels ()
 
static __readRisFile ($full_filename)
 
static __readBibFile ($full_filename)
 
static __setCharsetToUtf8 ($full_filename)
 
static __convertBibSpecialChars ($file_content)
 Replace BibTeX Special Characters with real characters Most systems do not use this encoding. More...
 
- Static Public Member Functions inherited from ilObject2
static _lookupObjIdByImportId ($a_import_id)
 
static _getAllReferences ($a_id)
 
static _lookupTitle ($a_id)
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 
static _lookupObjId ($a_id)
 
static _lookupType ($a_id, $a_reference=false)
 
static _lookupObjectId ($a_ref_id)
 
static _exists ($a_id, $a_reference=false)
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 
static _prepareCloneSelection ($a_ref_ids, $new_type)
 
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupObjId ($a_id)
 
static setDeletedDates ($a_ref_ids)
 Set deleted date type $ilDB. More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _exists ($a_id, $a_reference=false, $a_type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type. More...
 
static _prepareCloneSelection ($a_ref_ids, $new_type, $show_path=true)
 Prepare copy wizard object selection. More...
 
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $a_obj_ids)
 Get long description data. More...
 
static getAllOwnedRepositoryObjects ($a_user_id)
 Get all ids of objects user owns. More...
 
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course. More...
 

Data Fields

const ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH = 4000
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $ilias
 
 $lng
 
 $id
 
 $ref_id
 
 $type
 
 $title
 
 $untranslatedTitle
 
 $desc
 
 $long_desc
 
 $owner
 
 $create_date
 
 $last_update
 
 $import_id
 
 $register = false
 
 $referenced
 
 $objectList
 
 $max_title
 
 $max_desc
 
 $add_dots
 
 $obj_data_record
 object_data record More...
 

Static Protected Member Functions

static __force_rmdir ($path)
 remove a directory recursively More...
 
static __removeSpacesAndDashesAtBeginning ($input)
 

Protected Attributes

 $filename
 
 $entries
 
 $overviewModels
 
 $is_online
 

Additional Inherited Members

- Protected Member Functions inherited from ilObject2
 initType ()
 
 doRead ()
 
 doCreate ()
 
 beforeCreate ()
 
 doUpdate ()
 
 beforeUpdate ()
 
 doMDUpdateListener ($a_element)
 
 beforeMDUpdateListener ($a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDelete ()
 
 beforeDelete ()
 
 doCloneObject ($new_obj, $a_target_id, $a_copy_id=null)
 
 beforeCloneObject ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjBibliographic::__construct (   $existant_bibl_id = 0)

If bibliographic object exists, read it's data from database, otherwise create it.

Parameters
$existant_bibl_idint is not set when object is getting created
Returns

Definition at line 66 of file class.ilObjBibliographic.php.

References doRead(), and ilObject2\setId().

66  {
67  if ($existant_bibl_id) {
68  $this->setId($existant_bibl_id);
69  $this->doRead();
70  }
71 
72  parent::__construct($existant_bibl_id, false);
73  }
+ Here is the call graph for this function:

Member Function Documentation

◆ __convertBibSpecialChars()

static ilObjBibliographic::__convertBibSpecialChars (   $file_content)
static

Replace BibTeX Special Characters with real characters Most systems do not use this encoding.

In those cases, nothing will be replaced

Parameters
String$file_contentThe string with containing encodings
Returns
String (UTF-8) without encodings

Definition at line 395 of file class.ilObjBibliographic.php.

395  {
396 
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}';
402 
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}';
408 
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}';
414 
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}';
420 
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}';
426 
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}';
432 
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}';
438 
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}';
444 
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}';
450 
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}';
456 
457  $bibtex_special_chars['ç'] = '{\c c}';
458  $bibtex_special_chars['ß'] = '{\ss}';
459  $bibtex_special_chars['ñ'] = '{\~n}';
460  $bibtex_special_chars['Ñ'] = '{\~N}';
461 
462  return str_replace($bibtex_special_chars, array_keys($bibtex_special_chars), $file_content);
463  }

◆ __force_rmdir()

static ilObjBibliographic::__force_rmdir (   $path)
staticprotected

remove a directory recursively

Parameters
$path
Returns
bool

Definition at line 275 of file class.ilObjBibliographic.php.

References $file, $path, and $result.

275  {
276  if (! file_exists($path)) {
277  return false;
278  }
279 
280  if (is_file($path) || is_link($path)) {
281  return unlink($path);
282  }
283 
284  if (is_dir($path)) {
285  $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
286 
287  $result = true;
288 
289  $dir = new DirectoryIterator($path);
290 
291  foreach ($dir as $file) {
292  if (! $file->isDot()) {
293  $result &= self::__force_rmdir($path . $file->getFilename(), false);
294  }
295  }
296 
297  $result &= rmdir($path);
298 
299  return $result;
300  }
301  }
print $file
$result
$path
Definition: index.php:22

◆ __getAllOverviewModels()

static ilObjBibliographic::__getAllOverviewModels ( )
static

Definition at line 252 of file class.ilObjBibliographic.php.

References $overviewModels.

Referenced by ilBibliographicEntry\setOverwiew().

252  {
253  global $ilDB;
254 
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'];
259  } else {
260  $overviewModels[$rec['filetype']] = $rec['pattern'];
261  }
262  }
263 
264  return $overviewModels;
265  }
+ Here is the caller graph for this function:

◆ __readBibFile()

static ilObjBibliographic::__readBibFile (   $full_filename)
static

Definition at line 317 of file class.ilObjBibliographic.php.

317  {
318 
319  self::__setCharsetToUtf8($full_filename);
320 
321  require_once 'Modules/Bibliographic/lib/PEAR_BibTex_1.0.0RC5/Structures/BibTex.php';
322 
323  $bibtex_reader = new Structures_BibTex();
324 
325  //Loading and parsing the file example.bib
326  $bibtex_reader->loadFile($full_filename);
327 
328  //replace bibtex special chars with the real characters
329  $bibtex_reader->content = self::__convertBibSpecialChars($bibtex_reader->content);
330 
331  $bibtex_reader->setOption('extractAuthor', false);
332  $bibtex_reader->parse();
333 
334  // Remove library-bug: if there is no cite, the library mixes up the key for the type and the first attribute.
335  // It also shows an empty and therefore unwanted cite in the array.
336  //
337  // The cite is the text coming right after the type. Example:
338  // @book {cite,
339  // author = { "...."},
340 
341  foreach ($bibtex_reader->data as $key => $entry) {
342  if (empty($entry['cite'])) {
343  unset($bibtex_reader->data[$key]['cite']);
344 
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;
351  }
352  }
353  }
354 
355  // formating the author to the following type of string
356  // Smith, John / Comte, Gabriel / von Gunten Jr, Thomas
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'];
365  }
366  }
367  $bibtex_reader->data[$key][$attr_key] = implode(' / ', $attribute_string);
368  }
369  }
370  }
371 
372  return $bibtex_reader->data;
373  }

◆ __readRisFile()

static ilObjBibliographic::__readRisFile (   $full_filename)
static

Definition at line 304 of file class.ilObjBibliographic.php.

304  {
305 
306  self::__setCharsetToUtf8($full_filename);
307 
308  require_once "./Modules/Bibliographic/lib/LibRIS/src/LibRIS/RISReader.php";
309 
310  $ris_reader = new RISReader();
311  $ris_reader->parseFile($full_filename);
312 
313  return $ris_reader->getRecords();
314  }
The main class for parsing RIS files.
Definition: RISReader.php:60

◆ __removeSpacesAndDashesAtBeginning()

static ilObjBibliographic::__removeSpacesAndDashesAtBeginning (   $input)
staticprotected

Definition at line 504 of file class.ilObjBibliographic.php.

504  {
505  for ($i = 0; $i < strlen($input); $i ++) {
506  if ($input[$i] != " " && $input[$i] != "-") {
507  return substr($input, $i);
508  }
509  }
510  }

◆ __setCharsetToUtf8()

static ilObjBibliographic::__setCharsetToUtf8 (   $full_filename)
static

Definition at line 376 of file class.ilObjBibliographic.php.

376  {
377  //If file charset does not seem to be Unicode, we assume that it is ISO-8859-1, and convert it to UTF-8.
378  $filedata = file_get_contents($full_filename);
379  if (strlen($filedata) == strlen(utf8_decode($filedata))) {
380  // file charset is not UTF-8
381  $filedata = mb_convert_encoding($filedata, 'UTF-8', 'ISO-8859-1');
382  file_put_contents($full_filename, $filedata);
383  }
384  }

◆ cloneStructure()

ilObjBibliographic::cloneStructure (   $original_id)

Attention only use this for objects who have not yet been created (use like: $x = new ilObjDataCollection; $x->cloneStructure($id))

Parameters
$original_idThe original ID of the dataselection you want to clone it's structure
Returns
void

Definition at line 490 of file class.ilObjBibliographic.php.

References doUpdate(), moveFile(), ilObject2\setDescription(), setOnline(), ilObject2\setTitle(), and ilObject2\setType().

Referenced by doCloneObject().

490  {
491  $original = new ilObjBibliographic($original_id);
492 
493  $this->moveFile($original->getFileAbsolutePath());
494 
495  $this->setOnline($original->getOnline());
496  $this->setDescription($original->getDescription());
497  $this->setTitle($original->getTitle());
498  $this->setType($original->getType());
499 
500  $this->doUpdate();
501  }
moveFile($file_to_copy=false)
setType($a_type)
setDescription($a_desc)
setTitle($a_title)
setOnline($a_online)
Set Online.
Class ilObjBibliographic.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteFile()

ilObjBibliographic::deleteFile ( )

Definition at line 195 of file class.ilObjBibliographic.php.

References $path, and getFilePath().

Referenced by doDelete(), and doUpdate().

195  {
196  $path = $this->getFilePath(true);
197  self::__force_rmdir($path);
198  }
$path
Definition: index.php:22
getFilePath($without_filename=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doCloneObject()

ilObjBibliographic::doCloneObject ( ilObjBibliographic  $new_obj,
  $a_target_id,
  $a_copy_id = 0 
)

Clone BIBL.

Parameters
ilObjBibliographic$new_obj
$a_target_id
int$a_copy_idcopy id

Definition at line 476 of file class.ilObjBibliographic.php.

References cloneStructure(), and ilObject2\getId().

476  {
477  $new_obj->cloneStructure($this->getId());
478 
479  return $new_obj;
480  }
cloneStructure($original_id)
Attention only use this for objects who have not yet been created (use like: $x = new ilObjDataCollec...
+ Here is the call graph for this function:

◆ doCreate()

ilObjBibliographic::doCreate ( )

Create object.

Returns
void

Definition at line 81 of file class.ilObjBibliographic.php.

81  {
82  global $ilDB;
83 
84  $ilDB->manipulate("INSERT INTO il_bibl_data " . "(id, filename, is_online) VALUES ("
85  . $ilDB->quote($this->getId(), "integer") . "," . // id
86  $ilDB->quote($this->getFilename(), "text") . "," . // filename
87  $ilDB->quote($this->getOnline(), "integer") . // is_online
88  ")");
89  }

◆ doDelete()

ilObjBibliographic::doDelete (   $leave_out_il_bibl_data = false,
  $leave_out_delete_file = false 
)

Definition at line 130 of file class.ilObjBibliographic.php.

References ilHistory\_removeEntriesForObject(), deleteFile(), and ilObject2\getId().

130  {
131  global $ilDB;
132 
133  if (! $leave_out_delete_file) {
134  $this->deleteFile();
135  }
136 
137  //il_bibl_attribute
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") . ");");
141 
142  //il_bibl_entry
143  $ilDB->manipulate("DELETE FROM il_bibl_entry WHERE data_id = " . $ilDB->quote($this->getId(), "integer"));
144 
145  if (! $leave_out_il_bibl_data) {
146  //il_bibl_data
147  $ilDB->manipulate("DELETE FROM il_bibl_data WHERE id = " . $ilDB->quote($this->getId(), "integer"));
148  }
149 
150  // delete history entries
151  require_once("./Services/History/classes/class.ilHistory.php");
153  }
_removeEntriesForObject($a_obj_id)
remove all history entries for an object
+ Here is the call graph for this function:

◆ doRead()

ilObjBibliographic::doRead ( )

Definition at line 92 of file class.ilObjBibliographic.php.

References getFilename(), setFilename(), and setOnline().

Referenced by __construct().

92  {
93 
94  global $ilDB;
95  $set = $ilDB->query("SELECT * FROM il_bibl_data " . " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
96  while ($rec = $ilDB->fetchAssoc($set)) {
97  if (! $this->getFilename()) {
98  $this->setFilename($rec["filename"]);
99  }
100  $this->setOnline($rec['is_online']);
101  }
102  }
setOnline($a_online)
Set Online.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doUpdate()

ilObjBibliographic::doUpdate ( )

Update data.

Definition at line 108 of file class.ilObjBibliographic.php.

References deleteFile(), ilObject2\doDelete(), moveFile(), and writeSourcefileEntriesToDb().

Referenced by cloneStructure().

108  {
109  global $ilDB;
110 
111  if (! empty($_FILES['bibliographic_file']['name'])) {
112  $this->deleteFile();
113  $this->moveFile();
114  }
115  // Delete the object, but leave the db table 'il_bibl_data' for being able to update it using WHERE, and also leave the file
116  $this->doDelete(true, true);
117 
118  $ilDB->manipulate("UPDATE il_bibl_data SET " . "filename = " . $ilDB->quote($this->getFilename(), "text") . ", "
119  . // filename
120  "is_online = " . $ilDB->quote($this->getOnline(), "integer") . // is_online
121  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
122 
123  $this->writeSourcefileEntriesToDb($this);
124  }
moveFile($file_to_copy=false)
writeSourcefileEntriesToDb()
Reads out the source file and writes all entries to the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFileAbsolutePath()

ilObjBibliographic::getFileAbsolutePath ( )
Returns
string returns the absolute filepath of the bib/ris file. it's build as follows: $ILIAS-data-folder/bibl/$id/$filename

Definition at line 236 of file class.ilObjBibliographic.php.

References getFileDirectory(), and getFilename().

Referenced by writeSourcefileEntriesToDb().

236  {
237  return $this->getFileDirectory() . DIRECTORY_SEPARATOR . $this->getFilename();
238  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFileDirectory()

ilObjBibliographic::getFileDirectory ( )
Returns
string the folder is: $ILIAS-data-folder/bibl/$id

Definition at line 159 of file class.ilObjBibliographic.php.

References ilUtil\getDataDir(), ilObject2\getId(), and ilObject2\getType().

Referenced by getFileAbsolutePath(), and moveFile().

159  {
160  return ilUtil::getDataDir() . DIRECTORY_SEPARATOR . $this->getType() . DIRECTORY_SEPARATOR . $this->getId();
161  }
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFilename()

ilObjBibliographic::getFilename ( )

Definition at line 228 of file class.ilObjBibliographic.php.

References $filename.

Referenced by doRead(), getFileAbsolutePath(), and getFiletype().

228  {
229  return $this->filename;
230  }
+ Here is the caller graph for this function:

◆ getFilePath()

ilObjBibliographic::getFilePath (   $without_filename = false)
Parameters
bool$without_filename
Returns
array with all filepath

Definition at line 206 of file class.ilObjBibliographic.php.

Referenced by deleteFile().

206  {
207  global $ilDB;
208 
209  $set = $ilDB->query("SELECT filename FROM il_bibl_data " . " WHERE id = "
210  . $ilDB->quote($this->getId(), "integer"));
211 
212  $rec = $ilDB->fetchAssoc($set);
213  {
214  if ($without_filename) {
215  return substr($rec['filename'], 0, strrpos($rec['filename'], DIRECTORY_SEPARATOR));
216  } else {
217  return $rec['filename'];
218  }
219  }
220  }
+ Here is the caller graph for this function:

◆ getFiletype()

ilObjBibliographic::getFiletype ( )

Definition at line 241 of file class.ilObjBibliographic.php.

References getFilename().

Referenced by ilBibliographicDetailsGUI\showDetails(), and writeSourcefileEntriesToDb().

241  {
242  //return bib for filetype .bibtex:
243  if (strtolower(substr($this->getFilename(), - 6)) == "bibtex") {
244  return "bib";
245  }
246 
247  //else return its true filetype
248  return strtolower(substr($this->getFilename(), - 3));
249  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOnline()

ilObjBibliographic::getOnline ( )

Get Online.

Returns
boolean Online

Definition at line 584 of file class.ilObjBibliographic.php.

References $is_online.

584  {
585  return $this->is_online;
586  }

◆ initType()

ilObjBibliographic::initType ( )

initType

Returns
void

Definition at line 54 of file class.ilObjBibliographic.php.

54  {
55  $this->type = "bibl";
56  }

◆ moveFile()

ilObjBibliographic::moveFile (   $file_to_copy = false)

Definition at line 164 of file class.ilObjBibliographic.php.

References $filename, getFileDirectory(), ilUtil\makeDirParents(), ilUtil\moveUploadedFile(), ilUtil\sendSuccess(), and setFilename().

Referenced by cloneStructure(), and doUpdate().

164  {
165 
166  $target_dir = $this->getFileDirectory();
167 
168  if (! is_dir($target_dir)) {
169  ilUtil::makeDirParents($target_dir);
170  }
171 
172  if ($_FILES['bibliographic_file']['name']) {
173  $filename = $_FILES['bibliographic_file']['name'];
174  } elseif ($file_to_copy) {
175  //file is not uploaded, but a clone is made out of another bibl
176  $split_path = explode(DIRECTORY_SEPARATOR, $file_to_copy);
177  $filename = $split_path[sizeof($split_path) - 1];
178  } else {
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");
180  }
181 
182  $target_full_filename = $target_dir . DIRECTORY_SEPARATOR . $filename;
183 
184  //If there is no file_to_copy (which is used for clones), copy the file from the temporary upload directory (new creation of object).
185  //Therefore, a warning predicates nothing and can be suppressed.
186  if (@! copy($file_to_copy, $target_full_filename)) {
187  ilUtil::moveUploadedFile($_FILES['bibliographic_file']['tmp_name'], $_FILES['bibliographic_file']['name'], $target_full_filename);
188  }
189 
190  $this->setFilename($filename);
191  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
192  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFilename()

ilObjBibliographic::setFilename (   $filename)

Definition at line 223 of file class.ilObjBibliographic.php.

References $filename.

Referenced by doRead(), and moveFile().

223  {
224  $this->filename = $filename;
225  }
+ Here is the caller graph for this function:

◆ setOnline()

ilObjBibliographic::setOnline (   $a_online)

Set Online.

Parameters
boolean$a_onlineOnline
Returns
void

Definition at line 574 of file class.ilObjBibliographic.php.

Referenced by cloneStructure(), and doRead().

574  {
575  $this->is_online = $a_online;
576  }
+ Here is the caller graph for this function:

◆ writeSourcefileEntriesToDb()

ilObjBibliographic::writeSourcefileEntriesToDb ( )

Reads out the source file and writes all entries to the database.

Returns
void

Definition at line 518 of file class.ilObjBibliographic.php.

References ilObject\$type, getFileAbsolutePath(), getFiletype(), and ilObject2\getId().

Referenced by doUpdate().

518  {
519 
520  //Read File
521  switch ($this->getFiletype()) {
522  case("ris"):
523  $entries_from_file = self::__readRisFile($this->getFileAbsolutePath());
524  break;
525  case("bib"):
526  $entries_from_file = self::__readBibFile($this->getFileAbsolutePath());
527  break;
528  }
529 
530  //fill each entry into a ilBibliographicEntry object and then write it to DB by executing doCreate()
531  foreach ($entries_from_file as $file_entry) {
532  $type = NULL;
533  $x = 0;
534  $parsed_entry = array();
535 
536  foreach ($file_entry as $key => $attribute) {
537  // if the attribute is an array, make a comma separated string out of it
538  if (is_array($attribute)) {
539  $attribute = implode(", ", $attribute);
540  }
541 
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') . '...';
544  }
545 
546  // ty (RIS) or entryType (BIB) is the type and is treated seperately
547  if (strtolower($key) == 'ty' || strtolower($key) == 'entrytype') {
548  $type = $attribute;
549  continue;
550  }
551 
552  //TODO - Refactoring for ILIAS 4.5 - get rid off array restructuring
553  //change array structure (name not as the key, but under the key "name")
554  $parsed_entry[$x]['name'] = $key;
555  $parsed_entry[$x ++]['value'] = $attribute;
556  }
557  //create the entry and fill data into database by executing doCreate()
558  $entry_model = new ilBibliographicEntry($this->getFiletype());
559  $entry_model->setType($type);
560  $entry_model->setAttributes($parsed_entry);
561  $entry_model->setBibliographicObjId($this->getId());
562  $entry_model->doCreate();
563  }
564  }
Class ilObjBibliographic.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $entries

ilObjBibliographic::$entries
protected

Definition at line 34 of file class.ilObjBibliographic.php.

◆ $filename

ilObjBibliographic::$filename
protected

Definition at line 28 of file class.ilObjBibliographic.php.

Referenced by getFilename(), moveFile(), and setFilename().

◆ $is_online

ilObjBibliographic::$is_online
protected

Definition at line 46 of file class.ilObjBibliographic.php.

Referenced by getOnline().

◆ $overviewModels

ilObjBibliographic::$overviewModels
protected

Definition at line 40 of file class.ilObjBibliographic.php.

Referenced by __getAllOverviewModels().

◆ ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH

const ilObjBibliographic::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH = 4000

Definition at line 21 of file class.ilObjBibliographic.php.


The documentation for this class was generated from the following file: