ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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...
 
 doUpdate ()
 Update data. More...
 
 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)
 @description 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)
 
 getOnline ()
 
- Public Member Functions inherited from ilObject2
 __construct ($a_id=0, $a_reference=true)
 Constructor @access public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ($a_force_db=false)
 Read data from db. More...
 
 getId ()
 get object id @access public More...
 
 setId ($a_id)
 set object id @access public More...
 
 setRefId ($a_id)
 set reference id @access public More...
 
 getRefId ()
 get reference id @access public More...
 
 getType ()
 get object type @access public More...
 
 setType ($a_type)
 set object type @access public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title @access public More...
 
 getUntranslatedTitle ()
 get untranslated object title @access 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 @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class) More...
 
 create ($a_clone_mode=false)
 
 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) @access public 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 ()
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 cloneObject ($a_target_id, $a_copy_id=null, $a_omit_tree=false)
 Clone object permissions, put in tree ... More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor @access 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 @access public More...
 
 setId ($a_id)
 set object id @access public More...
 
 setRefId ($a_id)
 set reference id @access public More...
 
 getRefId ()
 get reference id @access public More...
 
 getType ()
 get object type @access public More...
 
 setType ($a_type)
 set object type @access public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title @access public More...
 
 getUntranslatedTitle ()
 get untranslated object title @access 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 @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 getDiskUsage ()
 
 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...
 
 setParentRolePermissions ($a_parent_ref)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g courses, groups for building permission intersections with non_member templates. 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) @access public 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...
 
 getPossibleSubObjects ($a_filter=true)
 get all possible subobjects of this type the object can decide which types of subobjects are possible jut in time overwrite if the decision distinguish from standard model 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)
 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 _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)
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type. More...
 
static _prepareCloneSelection ($a_ref_ids, $new_type)
 
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item. More...
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupImportId ($a_obj_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 @global 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@access public 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 fixMissingTitles ($a_type, array &$a_obj_title_map)
 Try to fix missing object titles. 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...
 

Protected Member Functions

 doCreate ()
 Create object. More...
 
 doRead ()
 
 doDelete ($leave_out_il_bibl_data=false, $leave_out_delete_file=false)
 
- 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 ()
 

Static Protected Member Functions

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

Protected Attributes

 $filename
 
 $entries
 
 $overviewModels
 
 $is_online
 

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
\ilObjBibliographic

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

68 {
69 if ($existant_bibl_id) {
70 $this->setId($existant_bibl_id);
71 $this->doRead();
72 }
73 parent::__construct($existant_bibl_id, false);
74 }
setId($a_id)
set object id @access public

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

+ 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 388 of file class.ilObjBibliographic.php.

388 {
389 $bibtex_special_chars['ä'] = '{\"a}';
390 $bibtex_special_chars['ë'] = '{\"e}';
391 $bibtex_special_chars['ï'] = '{\"i}';
392 $bibtex_special_chars['ö'] = '{\"o}';
393 $bibtex_special_chars['ü'] = '{\"u}';
394 $bibtex_special_chars['Ä'] = '{\"A}';
395 $bibtex_special_chars['Ë'] = '{\"E}';
396 $bibtex_special_chars['Ï'] = '{\"I}';
397 $bibtex_special_chars['Ö'] = '{\"O}';
398 $bibtex_special_chars['Ü'] = '{\"U}';
399 $bibtex_special_chars['â'] = '{\^a}';
400 $bibtex_special_chars['ê'] = '{\^e}';
401 $bibtex_special_chars['î'] = '{\^i}';
402 $bibtex_special_chars['ô'] = '{\^o}';
403 $bibtex_special_chars['û'] = '{\^u}';
404 $bibtex_special_chars['Â'] = '{\^A}';
405 $bibtex_special_chars['Ê'] = '{\^E}';
406 $bibtex_special_chars['Î'] = '{\^I}';
407 $bibtex_special_chars['Ô'] = '{\^O}';
408 $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}';
414 $bibtex_special_chars['À'] = '{\`A}';
415 $bibtex_special_chars['È'] = '{\`E}';
416 $bibtex_special_chars['Ì'] = '{\`I}';
417 $bibtex_special_chars['Ò'] = '{\`O}';
418 $bibtex_special_chars['Ù'] = '{\`U}';
419 $bibtex_special_chars['á'] = '{\\\'a}';
420 $bibtex_special_chars['é'] = '{\\\'e}';
421 $bibtex_special_chars['í'] = '{\\\'i}';
422 $bibtex_special_chars['ó'] = '{\\\'o}';
423 $bibtex_special_chars['ú'] = '{\\\'u}';
424 $bibtex_special_chars['Á'] = '{\\\'A}';
425 $bibtex_special_chars['É'] = '{\\\'E}';
426 $bibtex_special_chars['Í'] = '{\\\'I}';
427 $bibtex_special_chars['Ó'] = '{\\\'O}';
428 $bibtex_special_chars['Ú'] = '{\\\'U}';
429 $bibtex_special_chars['à'] = '{\`a}';
430 $bibtex_special_chars['è'] = '{\`e}';
431 $bibtex_special_chars['ì'] = '{\`i}';
432 $bibtex_special_chars['ò'] = '{\`o}';
433 $bibtex_special_chars['ù'] = '{\`u}';
434 $bibtex_special_chars['À'] = '{\`A}';
435 $bibtex_special_chars['È'] = '{\`E}';
436 $bibtex_special_chars['Ì'] = '{\`I}';
437 $bibtex_special_chars['Ò'] = '{\`O}';
438 $bibtex_special_chars['Ù'] = '{\`U}';
439 $bibtex_special_chars['ç'] = '{\c c}';
440 $bibtex_special_chars['ß'] = '{\ss}';
441 $bibtex_special_chars['ñ'] = '{\~n}';
442 $bibtex_special_chars['Ñ'] = '{\~N}';
443
444 return str_replace($bibtex_special_chars, array_keys($bibtex_special_chars), $file_content);
445 }

Referenced by __readBibFile().

+ Here is the caller graph for this function:

◆ __force_rmdir()

static ilObjBibliographic::__force_rmdir (   $path)
staticprotected

remove a directory recursively

Parameters
$path
Returns
bool

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

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

References $file, $path, $result, and __force_rmdir().

Referenced by __force_rmdir(), and deleteFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __readBibFile()

static ilObjBibliographic::__readBibFile (   $full_filename)
static
Parameters
$full_filename
Returns
array

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

317 {
318 self::__setCharsetToUtf8($full_filename);
319 require_once 'Modules/Bibliographic/lib/PEAR_BibTex_1.0.0RC5/Structures/BibTex.php';
320 $bibtex_reader = new Structures_BibTex();
321 //Loading and parsing the file example.bib
322 $bibtex_reader->loadFile($full_filename);
323 //replace bibtex special chars with the real characters
324 $bibtex_reader->content = self::__convertBibSpecialChars($bibtex_reader->content);
325 $bibtex_reader->setOption('extractAuthors', false);
326 $bibtex_reader->parse();
327 // Remove library-bug: if there is no cite, the library mixes up the key for the type and the first attribute.
328 // It also shows an empty and therefore unwanted cite in the array.
329 //
330 // The cite is the text coming right after the type. Example:
331 // @book {cite,
332 // author = { "...."},
333 foreach ($bibtex_reader->data as $key => $entry) {
334 if (empty($entry['cite'])) {
335 unset($bibtex_reader->data[$key]['cite']);
336 foreach ($entry as $attr_key => $attribute) {
337 if (strpos($attr_key, '{') !== false) {
338 unset($bibtex_reader->data[$key][$attr_key]);
339 $attr_key_exploaded = explode('{', $attr_key);
340 $bibtex_reader->data[$key]['entryType'] = trim($attr_key_exploaded[0]);
341 $bibtex_reader->data[$key][trim($attr_key_exploaded[1])] = $attribute;
342 }
343 }
344 }
345 // formating the author to the following type of string
346 // Smith, John / Comte, Gabriel / von Gunten Jr, Thomas
347 foreach ($entry as $attr_key => $attribute) {
348 if ($attr_key == 'author' && is_array($attribute)) {
349 $attribute_string = array();
350 foreach ($attribute as $author_key => $author) {
351 $lastname = array( $author['von'], $author['last'], $author['jr'] );
352 $attribute_string[$author_key] = implode(' ', array_filter($lastname));
353 if (! empty($author['first'])) {
354 $attribute_string[$author_key] .= ', ' . $author['first'];
355 }
356 }
357 $bibtex_reader->data[$key][$attr_key] = implode(' / ', $attribute_string);
358 }
359 }
360 }
361
362 return $bibtex_reader->data;
363 }
static __convertBibSpecialChars($file_content)
Replace BibTeX Special Characters with real characters Most systems do not use this encoding.
static __setCharsetToUtf8($full_filename)

References __convertBibSpecialChars(), and __setCharsetToUtf8().

Referenced by writeSourcefileEntriesToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __readRisFile()

static ilObjBibliographic::__readRisFile (   $full_filename)
static
Parameters
$full_filename
Returns
null
Exceptions

LibRIS\ParseException

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

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

References __setCharsetToUtf8().

Referenced by writeSourcefileEntriesToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __removeSpacesAndDashesAtBeginning()

static ilObjBibliographic::__removeSpacesAndDashesAtBeginning (   $input)
staticprotected
Parameters
$input
Deprecated:
Returns
string

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

497 {
498 for ($i = 0; $i < strlen($input); $i ++) {
499 if ($input[$i] != " " && $input[$i] != "-") {
500 return substr($input, $i);
501 }
502 }
503 }

◆ __setCharsetToUtf8()

static ilObjBibliographic::__setCharsetToUtf8 (   $full_filename)
static
Parameters
$full_filename

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

369 {
370 //If file charset does not seem to be Unicode, we assume that it is ISO-8859-1, and convert it to UTF-8.
371 $filedata = file_get_contents($full_filename);
372 if (strlen($filedata) == strlen(utf8_decode($filedata))) {
373 // file charset is not UTF-8
374 $filedata = mb_convert_encoding($filedata, 'UTF-8', 'ISO-8859-1');
375 file_put_contents($full_filename, $filedata);
376 }
377 }

Referenced by __readBibFile(), and __readRisFile().

+ Here is the caller graph for this function:

◆ cloneStructure()

ilObjBibliographic::cloneStructure (   $original_id)

@description 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 481 of file class.ilObjBibliographic.php.

481 {
482 $original = new ilObjBibliographic($original_id);
483 $this->moveFile($original->getFileAbsolutePath());
484 $this->setDescription($original->getDescription());
485 $this->setTitle($original->getTitle());
486 $this->setType($original->getType());
487 $this->doUpdate();
488 }
Class ilObjBibliographic.
moveFile($file_to_copy=false)
setType($a_type)
set object type @access public
setTitle($a_title)
set object title
setDescription($a_desc)
set object description

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

Referenced by doCloneObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteFile()

ilObjBibliographic::deleteFile ( )

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

187 {
188 $path = $this->getFilePath(true);
190 }
getFilePath($without_filename=false)

References $path, __force_rmdir(), and getFilePath().

Referenced by doDelete(), and doUpdate().

+ 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 458 of file class.ilObjBibliographic.php.

458 {
459
460 //copy online status if object is not the root copy object
461 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
462
463 if(!$cp_options->isRootNode($this->getRefId()))
464 {
465 $new_obj->setOnline($this->getOnline());
466 }
467
468 $new_obj->cloneStructure($this->getId());
469
470 return $new_obj;
471 }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
cloneStructure($original_id)
@description Attention only use this for objects who have not yet been created (use like: $x = new il...
getId()
get object id @access public

References ilCopyWizardOptions\_getInstance(), cloneStructure(), ilObject2\getId(), getOnline(), and setOnline().

+ Here is the call graph for this function:

◆ doCreate()

ilObjBibliographic::doCreate ( )
protected

Create object.

Returns
void

Reimplemented from ilObject2.

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

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

References $ilDB.

◆ doDelete()

ilObjBibliographic::doDelete (   $leave_out_il_bibl_data = false,
  $leave_out_delete_file = false 
)
protected
Parameters
bool | false$leave_out_il_bibl_data
bool | false$leave_out_delete_file

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

125 {
126 global $ilDB;
127 if (! $leave_out_delete_file) {
128 $this->deleteFile();
129 }
130 //il_bibl_attribute
131 $ilDB->manipulate("DELETE FROM il_bibl_attribute WHERE il_bibl_attribute.entry_id IN "
132 . "(SELECT il_bibl_entry.id FROM il_bibl_entry WHERE il_bibl_entry.data_id = " . $ilDB->quote($this->getId(), "integer") . ");");
133 //il_bibl_entry
134 $ilDB->manipulate("DELETE FROM il_bibl_entry WHERE data_id = " . $ilDB->quote($this->getId(), "integer"));
135 if (! $leave_out_il_bibl_data) {
136 //il_bibl_data
137 $ilDB->manipulate("DELETE FROM il_bibl_data WHERE id = " . $ilDB->quote($this->getId(), "integer"));
138 }
139 // delete history entries
140 require_once("./Services/History/classes/class.ilHistory.php");
142 }
_removeEntriesForObject($a_obj_id)
remove all history entries for an object

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

+ Here is the call graph for this function:

◆ doRead()

ilObjBibliographic::doRead ( )
protected

Reimplemented from ilObject2.

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

91 {
92 global $ilDB;
93 $set = $ilDB->query("SELECT * FROM il_bibl_data " . " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
94 while ($rec = $ilDB->fetchAssoc($set)) {
95 if (! $this->getFilename()) {
96 $this->setFilename($rec["filename"]);
97 }
98 $this->setOnline($rec['is_online']);
99 }
100 }

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

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doUpdate()

ilObjBibliographic::doUpdate ( )

Update data.

Reimplemented from ilObject2.

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

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

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

Referenced by ilObjBibliographicGUI\afterSave(), and cloneStructure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllOverviewModels()

static ilObjBibliographic::getAllOverviewModels ( )
static
Returns
array

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

250 {
251 global $ilDB;
252 $overviewModels = array();
253 $set = $ilDB->query('SELECT * FROM il_bibl_overview_model');
254 while ($rec = $ilDB->fetchAssoc($set)) {
255 if ($rec['literature_type']) {
256 $overviewModels[$rec['filetype']][$rec['literature_type']] = $rec['pattern'];
257 } else {
258 $overviewModels[$rec['filetype']] = $rec['pattern'];
259 }
260 }
261
262 return $overviewModels;
263 }

References $ilDB, and $overviewModels.

Referenced by ilBiblOverviewGUI\render().

+ 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 231 of file class.ilObjBibliographic.php.

231 {
232 return $this->getFileDirectory() . DIRECTORY_SEPARATOR . $this->getFilename();
233 }

References getFileDirectory(), and getFilename().

Referenced by writeSourcefileEntriesToDb().

+ 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 148 of file class.ilObjBibliographic.php.

148 {
149 return ilUtil::getDataDir() . DIRECTORY_SEPARATOR . $this->getType() . DIRECTORY_SEPARATOR . $this->getId();
150 }
getType()
get object type @access public
static getDataDir()
get data directory (outside webspace)

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

Referenced by getFileAbsolutePath(), and moveFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFilename()

ilObjBibliographic::getFilename ( )
Returns
int

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

References $filename.

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

+ 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 198 of file class.ilObjBibliographic.php.

198 {
199 global $ilDB;
200 $set = $ilDB->query("SELECT filename FROM il_bibl_data " . " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
201 $rec = $ilDB->fetchAssoc($set);
202 {
203 if ($without_filename) {
204 return substr($rec['filename'], 0, strrpos($rec['filename'], DIRECTORY_SEPARATOR));
205 } else {
206 return $rec['filename'];
207 }
208 }
209 }

References $ilDB.

Referenced by deleteFile().

+ Here is the caller graph for this function:

◆ getFiletype()

ilObjBibliographic::getFiletype ( )

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

236 {
237 //return bib for filetype .bibtex:
238 if (strtolower(substr($this->getFilename(), - 6)) == "bibtex") {
239 return "bib";
240 }
241
242 //else return its true filetype
243 return strtolower(substr($this->getFilename(), - 3));
244 }

References getFilename().

Referenced by ilBibliographicSetting\getButton(), and writeSourcefileEntriesToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOnline()

ilObjBibliographic::getOnline ( )
Returns
bool

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

References $is_online.

Referenced by doCloneObject().

+ Here is the caller graph for this function:

◆ initType()

ilObjBibliographic::initType ( )

initType

Returns
void

Reimplemented from ilObject2.

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

56 {
57 $this->type = "bibl";
58 }

◆ moveFile()

ilObjBibliographic::moveFile (   $file_to_copy = false)
Parameters
bool | false$file_to_copy
Exceptions
Exception

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

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

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

Referenced by cloneStructure(), and doUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFilename()

ilObjBibliographic::setFilename (   $filename)
Parameters
$filename

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

215 {
216 $this->filename = $filename;
217 }

References $filename.

Referenced by doRead(), and moveFile().

+ Here is the caller graph for this function:

◆ setOnline()

ilObjBibliographic::setOnline (   $a_online)
Parameters
$a_online

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

561 {
562 $this->is_online = $a_online;
563 }

Referenced by doCloneObject(), and doRead().

+ 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 511 of file class.ilObjBibliographic.php.

511 {
512 //Read File
513 $entries_from_file = array();
514 switch ($this->getFiletype()) {
515 case("ris"):
516 $entries_from_file = self::__readRisFile($this->getFileAbsolutePath());
517 break;
518 case("bib"):
519 $entries_from_file = self::__readBibFile($this->getFileAbsolutePath());
520 break;
521 }
522 //fill each entry into a ilBibliographicEntry object and then write it to DB by executing doCreate()
523 foreach ($entries_from_file as $file_entry) {
524 $type = NULL;
525 $x = 0;
526 $parsed_entry = array();
527 foreach ($file_entry as $key => $attribute) {
528 // if the attribute is an array, make a comma separated string out of it
529 if (is_array($attribute)) {
530 $attribute = implode(", ", $attribute);
531 }
532 // reduce the attribute strings to a maximum of 4000 (ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH) characters, in order to fit in the database
533 //if (mb_strlen($attribute, 'UTF-8') > self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH) {
534 if (ilStr::strLen($attribute) > self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH) {
535 // $attribute = mb_substr($attribute, 0, self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH - 3, 'UTF-8') . '...';
536 $attribute = ilStr::subStr($attribute, 0, self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH - 3) . '...';
537 }
538 // ty (RIS) or entryType (BIB) is the type and is treated seperately
539 if (strtolower($key) == 'ty' || strtolower($key) == 'entrytype') {
540 $type = $attribute;
541 continue;
542 }
543 //TODO - Refactoring for ILIAS 4.5 - get rid off array restructuring
544 //change array structure (name not as the key, but under the key "name")
545 $parsed_entry[$x]['name'] = $key;
546 $parsed_entry[$x ++]['value'] = $attribute;
547 }
548 //create the entry and fill data into database by executing doCreate()
549 $entry_model = ilBibliographicEntry::getInstance($this->getFiletype());
550 $entry_model->setType($type);
551 $entry_model->setAttributes($parsed_entry);
552 $entry_model->setBibliographicObjId($this->getId());
553 $entry_model->doCreate();
554 }
555 }
static getInstance($file_type, $entry_id=NULL)
static __readRisFile($full_filename)
static __readBibFile($full_filename)
static strLen($a_string)
Definition: class.ilStr.php:79
static subStr($a_str, $a_start, $a_length=NULL)
Definition: class.ilStr.php:15
$x
Definition: example_009.php:98

References ilObject\$type, $x, __readBibFile(), __readRisFile(), getFileAbsolutePath(), getFiletype(), ilObject2\getId(), ilBibliographicEntry\getInstance(), ilStr\strLen(), and ilStr\subStr().

Referenced by doUpdate().

+ 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 36 of file class.ilObjBibliographic.php.

◆ $filename

ilObjBibliographic::$filename
protected

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

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

◆ $is_online

ilObjBibliographic::$is_online
protected

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

Referenced by getOnline().

◆ $overviewModels

ilObjBibliographic::$overviewModels
protected

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

Referenced by getAllOverviewModels().

◆ ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH

const ilObjBibliographic::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH = 4000

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


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