ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ()
 
 getFileDirectory ()
 
 moveFile ($file_to_copy=false)
 
 deleteFile ()
 
 getFilePath ($without_filename=false)
 
 setFilename ($filename)
 
 getFilename ()
 
 getFileAbsolutePath ()
 
 getFiletype ()
 
 doCloneObject ($new_obj, $a_target_id, $a_copy_id=null, $a_omit_tree=false)
 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)
 
 getOnline ()
 
- Public Member Functions inherited from ilObject2
 __construct ($a_id=0, $a_reference=true)
 Constructor public. More...
 
 withReferences ()
 
 read ()
 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 ()
 
 setOwner ($a_owner)
 
 getCreateDate ()
 
 getLastUpdateDate ()
 
 create ($a_clone_mode=false)
 
 update ()
 
 MDUpdateListener ($a_element)
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 
 putInTree ($a_parent_ref)
 
 setPermissions ($a_parent_ref)
 
 createReference ()
 
 countReferences ()
 
 delete ()
 
 initDefaultRoles ()
 
 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
 __construct ($a_id=0, $a_reference=true)
 Constructor public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ()
 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 ()
 
 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...
 
 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...
 
 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) public More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. 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...
 
 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 Public Member Functions inherited from ilObject2
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupOwnerName ($a_owner_id)
 
static _getIdForImportId ($a_import_id)
 
static _getAllReferences ($a_id)
 
static _lookupTitle ($a_id)
 
static _lookupOwner ($a_id)
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 
static _lookupLastUpdate ($a_id, $a_as_string=false)
 
static _getLastUpdateOfObjects ($a_objs)
 
static _lookupObjId ($a_id)
 
static _setDeletedDate ($a_ref_id)
 
static _resetDeletedDate ($a_ref_id)
 
static _lookupDeletedDate ($a_ref_id)
 
static _writeTitle ($a_obj_id, $a_title)
 
static _writeDescription ($a_obj_id, $a_desc)
 
static _writeImportId ($a_obj_id, $a_import_id)
 
static _lookupType ($a_id, $a_reference=false)
 
static _isInTrash ($a_ref_id)
 
static _hasUntrashedReference ($a_obj_id)
 
static _lookupObjectId ($a_ref_id)
 
static _getObjectsDataForType ($a_type, $a_omit_trash=false)
 
static _exists ($a_id, $a_reference=false, $a_type=null)
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 
static _prepareCloneSelection ($a_ref_ids, $new_type, $a_show_path=true)
 
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 _lookupImportId ($a_obj_id)
 
static _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
static _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static _lookupOwner ($a_id)
 lookup object owner More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
static _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
static _lookupObjId ($a_id)
 
static _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
static setDeletedDates ($a_ref_ids)
 Set deleted date type $ilDB. More...
 
static _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
static _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
static _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
static _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type 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 fixMissingTitles ($a_type, array &$a_obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate ($a_id)
 Lookup creation date. More...
 
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course. More...
 

Data Fields

const FILETYPE_RIS = "ris"
 
const FILETYPE_BIB = "bib"
 
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
 

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

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

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

71  {
72  if ($existant_bibl_id) {
73  $this->setId($existant_bibl_id);
74  $this->doRead();
75  }
76  parent::__construct($existant_bibl_id, false);
77  }
+ Here is the call graph for this function:

Member Function Documentation

◆ __force_rmdir()

static ilObjBibliographic::__force_rmdir (   $path)
staticprotected

remove a directory recursively

Parameters
$path
Returns
bool

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

References $file, $path, and $result.

284  {
285  if (!file_exists($path)) {
286  return false;
287  }
288  if (is_file($path) || is_link($path)) {
289  return unlink($path);
290  }
291  if (is_dir($path)) {
292  $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
293  $result = true;
294  $dir = new DirectoryIterator($path);
295  foreach ($dir as $file) {
296  if (!$file->isDot()) {
297  $result &= self::__force_rmdir($path . $file->getFilename(), false);
298  }
299  }
300  $result &= rmdir($path);
301 
302  return $result;
303  }
304  }
$path
Definition: aliased.php:25
$result
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ __removeSpacesAndDashesAtBeginning()

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

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

355  {
356  for ($i = 0; $i < strlen($input); $i ++) {
357  if ($input[$i] != " " && $input[$i] != "-") {
358  return substr($input, $i);
359  }
360  }
361  }

◆ 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 339 of file class.ilObjBibliographic.php.

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

339  {
340  $original = new ilObjBibliographic($original_id);
341  $this->moveFile($original->getFileAbsolutePath());
342  $this->setDescription($original->getDescription());
343  $this->setTitle($original->getTitle());
344  $this->setType($original->getType());
345  $this->doUpdate();
346  }
moveFile($file_to_copy=false)
setType($a_type)
setDescription($a_desc)
setTitle($a_title)
Class ilObjBibliographic.
+ Here is the call graph for this function:

◆ deleteFile()

ilObjBibliographic::deleteFile ( )

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

References $path, and getFilePath().

Referenced by doDelete(), and doUpdate().

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

◆ doCloneObject()

ilObjBibliographic::doCloneObject (   $new_obj,
  $a_target_id,
  $a_copy_id = null,
  $a_omit_tree = false 
)

Clone BIBL.

Parameters
ilObjBibliographic$new_obj
$a_target_id
int$a_copy_idcopy id
Returns
ilObjPoll

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

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

316  {
317  assert($new_obj instanceof ilObjBibliographic);
318  //copy online status if object is not the root copy object
319  $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
320 
321  if (!$cp_options->isRootNode($this->getRefId())) {
322  $new_obj->setOnline($this->getOnline());
323  }
324 
325  $new_obj->cloneStructure($this->getId());
326 
327  return $new_obj;
328  }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
Class ilObjBibliographic.
+ Here is the call graph for this function:

◆ doCreate()

ilObjBibliographic::doCreate ( )
protected

Create object.

Returns
void

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

References $DIC, and $ilDB.

85  {
86  global $DIC;
87  $ilDB = $DIC['ilDB'];
88  $ilDB->manipulate("INSERT INTO il_bibl_data " . "(id, filename, is_online) VALUES (" . $ilDB->quote($this->getId(), "integer") . "," . // id
89  $ilDB->quote($this->getFilename(), "text") . "," . // filename
90  $ilDB->quote($this->getOnline(), "integer") . // is_online
91  ")");
92  }
global $ilDB
global $DIC

◆ 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 129 of file class.ilObjBibliographic.php.

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

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

◆ doRead()

ilObjBibliographic::doRead ( )
protected

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

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

Referenced by __construct().

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

◆ doUpdate()

ilObjBibliographic::doUpdate ( )

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

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

Referenced by cloneStructure().

108  {
109  global $DIC;
110  $ilDB = $DIC['ilDB'];
111  $file_changed = !empty($_FILES['bibliographic_file']['name']);
112  if ($file_changed) {
113  $this->deleteFile();
114  $this->moveFile();
115  }
116  // Delete the object, but leave the db table 'il_bibl_data' for being able to update it using WHERE, and also leave the file
117  $this->doDelete(true, true);
118  $ilDB->manipulate("UPDATE il_bibl_data SET " . "filename = " . $ilDB->quote($this->getFilename(), "text") . ", " . // filename
119  "is_online = " . $ilDB->quote($this->getOnline(), "integer") . // is_online
120  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
122  }
moveFile($file_to_copy=false)
writeSourcefileEntriesToDb()
Reads out the source file and writes all entries to the database.
global $ilDB
global $DIC
+ 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 260 of file class.ilObjBibliographic.php.

References $DIC, $ilDB, $overviewModels, and array.

Referenced by ilBiblOverviewGUI\render().

260  {
261  global $DIC;
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'];
268  } else {
269  $overviewModels[$rec['filetype']] = $rec['pattern'];
270  }
271  }
272 
273  return $overviewModels;
274  }
Create styles array
The data for the language used.
global $ilDB
global $DIC
+ 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 238 of file class.ilObjBibliographic.php.

References getFileDirectory(), and getFilename().

Referenced by writeSourcefileEntriesToDb().

238  {
239  return $this->getFileDirectory() . DIRECTORY_SEPARATOR . $this->getFilename();
240  }
+ 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 154 of file class.ilObjBibliographic.php.

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

Referenced by getFileAbsolutePath(), and moveFile().

154  {
155  return ilUtil::getDataDir() . DIRECTORY_SEPARATOR . $this->getType() . DIRECTORY_SEPARATOR . $this->getId();
156  }
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 ( )
Returns
int

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

References $filename.

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

230  {
231  return $this->filename;
232  }
+ 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 204 of file class.ilObjBibliographic.php.

References $DIC, and $ilDB.

Referenced by deleteFile().

204  {
205  global $DIC;
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);
209  {
210  if ($without_filename) {
211  return substr($rec['filename'], 0, strrpos($rec['filename'], DIRECTORY_SEPARATOR));
212  } else {
213  return $rec['filename'];
214  }
215  }
216  }
global $ilDB
global $DIC
+ Here is the caller graph for this function:

◆ getFiletype()

ilObjBibliographic::getFiletype ( )
Returns
string

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

References getFilename().

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

246  {
247  //return bib for filetype .bibtex:
248  if (strtolower(substr($this->getFilename(), - 6)) == "bibtex") {
249  return self::FILETYPE_BIB;
250  }
251 
252  //else return its true filetype
253  return strtolower(substr($this->getFilename(), - 3));
254  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOnline()

ilObjBibliographic::getOnline ( )
Returns
bool

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

References $is_online.

Referenced by doCloneObject().

433  {
434  return $this->is_online;
435  }
+ Here is the caller graph for this function:

◆ initType()

ilObjBibliographic::initType ( )

initType

Returns
void

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

59  {
60  $this->type = "bibl";
61  }

◆ moveFile()

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

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  $target_dir = $this->getFileDirectory();
166  if (!is_dir($target_dir)) {
167  ilUtil::makeDirParents($target_dir);
168  }
169  if ($_FILES['bibliographic_file']['name']) {
170  $filename = $_FILES['bibliographic_file']['name'];
171  } elseif ($file_to_copy) {
172  //file is not uploaded, but a clone is made out of another bibl
173  $split_path = explode(DIRECTORY_SEPARATOR, $file_to_copy);
174  $filename = $split_path[sizeof($split_path) - 1];
175  } else {
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");
177  }
178  $target_full_filename = $target_dir . DIRECTORY_SEPARATOR . $filename;
179  //If there is no file_to_copy (which is used for clones), copy the file from the temporary upload directory (new creation of object).
180  //Therefore, a warning predicates nothing and can be suppressed.
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);
184  } else {
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.");
186  }
187  }
188  $this->setFilename($filename);
189  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
190  }
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)
Parameters
$filename

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

References $filename.

Referenced by doRead(), and moveFile().

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

◆ setOnline()

ilObjBibliographic::setOnline (   $a_online)
Parameters
$a_online

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

Referenced by doRead().

425  {
426  $this->is_online = $a_online;
427  }
+ 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 369 of file class.ilObjBibliographic.php.

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

Referenced by doUpdate().

369  {
370  //Read File
371  $entries_from_file = array();
372  switch ($this->getFiletype()) {
373  case(self::FILETYPE_RIS):
374  $ilRis = new ilRis();
375  $ilRis->readContent($this->getFileAbsolutePath());
376 
377  $entries_from_file = $ilRis->parseContent();
378  break;
379  case(self::FILETYPE_BIB):
380  $bib = new ilBibTex();
381  $bib->readContent($this->getFileAbsolutePath());
382 
383  $entries_from_file = $bib->parseContent();
384  break;
385  }
386  //fill each entry into a ilBibliographicEntry object and then write it to DB by executing doCreate()
387  foreach ($entries_from_file as $file_entry) {
388  $type = null;
389  $x = 0;
390  $parsed_entry = array();
391  foreach ($file_entry as $key => $attribute) {
392  // if the attribute is an array, make a comma separated string out of it
393  if (is_array($attribute)) {
394  $attribute = implode(", ", $attribute);
395  }
396  // reduce the attribute strings to a maximum of 4000 (ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH) characters, in order to fit in the database
397  //if (mb_strlen($attribute, 'UTF-8') > self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH) {
398  if (ilStr::strLen($attribute) > self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH) {
399  // $attribute = mb_substr($attribute, 0, self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH - 3, 'UTF-8') . '...';
400  $attribute = ilStr::subStr($attribute, 0, self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH - 3) . '...';
401  }
402  // ty (RIS) or entryType (BIB) is the type and is treated seperately
403  if (strtolower($key) == 'ty' || strtolower($key) == 'entrytype') {
404  $type = $attribute;
405  continue;
406  }
407  //TODO - Refactoring for ILIAS 4.5 - get rid off array restructuring
408  //change array structure (name not as the key, but under the key "name")
409  $parsed_entry[$x]['name'] = $key;
410  $parsed_entry[$x ++]['value'] = $attribute;
411  }
412  //create the entry and fill data into database by executing doCreate()
413  $entry_model = ilBibliographicEntry::getInstance($this->getFiletype());
414  $entry_model->setType($type);
415  $entry_model->setAttributes($parsed_entry);
416  $entry_model->setBibliographicObjId($this->getId());
417  $entry_model->doCreate();
418  }
419  }
static strLen($a_string)
Definition: class.ilStr.php:91
$x
Definition: example_009.php:98
Class ilBibTex.
Class ilRis.
Definition: class.ilRis.php:11
static getInstance($file_type, $entry_id=null)
Create styles array
The data for the language used.
static subStr($a_str, $a_start, $a_length=NULL)
Definition: class.ilStr.php:15
+ 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 39 of file class.ilObjBibliographic.php.

◆ $filename

ilObjBibliographic::$filename
protected

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

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

◆ $is_online

ilObjBibliographic::$is_online
protected

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

Referenced by getOnline().

◆ $overviewModels

ilObjBibliographic::$overviewModels
protected

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

Referenced by getAllOverviewModels().

◆ ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH

const ilObjBibliographic::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH = 4000

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

◆ FILETYPE_BIB

const ilObjBibliographic::FILETYPE_BIB = "bib"

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

◆ FILETYPE_RIS

const ilObjBibliographic::FILETYPE_RIS = "ris"

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


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