ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilBibliographicEntry Class Reference

Class ilObjBibliographic. More...

+ Collaboration diagram for ilBibliographicEntry:

Public Member Functions

 doCreate ()
 Create object. More...
 
 doRead ()
 Read data from database tables il_bibl_entry and il_bibl_attribute. More...
 
 doUpdate ()
 Update database tables il_bibl_entry and il_bibl_attribute. More...
 
 doDelete ()
 Delete data from db. More...
 
 setAttributes ($attributes)
 
 getAttributes ()
 
 setOverwiew ()
 
 getOverwiew ()
 
 setBibliographicObjId ($bibliographic_obj_id)
 
 getBibliographicObjId ()
 
 setEntryId ($entry_id)
 
 getEntryId ()
 
 setType ($type)
 
 getType ()
 

Static Public Member Functions

static getInstance ($file_type, $entry_id=NULL)
 
static getAllEntries ($object_id)
 Read all entries from the database. More...
 

Protected Member Functions

 __construct ($file_type, $entry_id=NULL)
 
 loadAttributes ()
 Reads all the entrys attributes from database. More...
 

Protected Attributes

 $bibliographic_obj_id
 
 $entry_id
 
 $type
 
 $attributes
 
 $file_type
 

Static Protected Attributes

static $instances = array()
 

Detailed Description

Class ilObjBibliographic.

Author
Gabriel Comte
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
Id
class.ilBibliographicEntry.php 2012-11-15 16:11:42Z gcomte

Definition at line 12 of file class.ilBibliographicEntry.php.

Constructor & Destructor Documentation

◆ __construct()

ilBibliographicEntry::__construct (   $file_type,
  $entry_id = NULL 
)
protected
Parameters
$file_type
null$entry_id

Definition at line 73 of file class.ilBibliographicEntry.php.

References $entry_id, $file_type, doRead(), and setEntryId().

73  {
74  $this->file_type = $file_type;
75  if ($entry_id) {
76  $this->setEntryId($entry_id);
77  $this->doRead();
78  }
79  }
doRead()
Read data from database tables il_bibl_entry and il_bibl_attribute.
+ Here is the call graph for this function:

Member Function Documentation

◆ doCreate()

ilBibliographicEntry::doCreate ( )

Create object.

Definition at line 87 of file class.ilBibliographicEntry.php.

References $ilDB, getAttributes(), and setEntryId().

87  {
88  global $ilDB;
89  //auto-increment il_bibl_entry
90  $this->setEntryId($ilDB->nextID('il_bibl_entry'));
91  //table il_bibl_entry
92  $ilDB->manipulate("INSERT INTO il_bibl_entry " . "(data_id, id, type) VALUES (" . $ilDB->quote($this->getBibliographicObjId(), "integer")
93  . "," . // data_id
94  $ilDB->quote($this->getEntryId(), "integer") . "," . // id
95  $ilDB->quote($this->getType(), "text") . // type
96  ")");
97  //table il_bibl_attribute
98  foreach ($this->getAttributes() as $attribute) {
99  //auto-increment il_bibl_attribute
100  $id = $ilDB->nextID('il_bibl_attribute');
101  $ilDB->manipulate("INSERT INTO il_bibl_attribute " . "(entry_id, name, value, id) VALUES (" . $ilDB->quote($this->getEntryId(), "integer")
102  . "," . // entry_id
103  $ilDB->quote($attribute['name'], "text") . "," . // name
104  $ilDB->quote($attribute['value'], "text") . "," . // value
105  $ilDB->quote($id, "integer") . // id
106  ")");
107  }
108  }
global $ilDB
+ Here is the call graph for this function:

◆ doDelete()

ilBibliographicEntry::doDelete ( )

Delete data from db.

Definition at line 146 of file class.ilBibliographicEntry.php.

References $ilDB.

146  {
147  global $ilDB;
148  $this->emptyCache();
149  $this->deleteOptions();
150  $ilDB->manipulate("DELETE FROM il_bibl_entry WHERE id = " . $ilDB->quote($this->getEntryId(), "integer"));
151  $ilDB->manipulate("DELETE FROM il_bibl_attribute WHERE entry_id = " . $ilDB->quote($this->getEntryId(), "integer"));
152  }
global $ilDB

◆ doRead()

ilBibliographicEntry::doRead ( )

Read data from database tables il_bibl_entry and il_bibl_attribute.

Definition at line 114 of file class.ilBibliographicEntry.php.

References $ilDB, loadAttributes(), setAttributes(), setOverwiew(), and setType().

Referenced by __construct().

114  {
115  global $ilDB;
116  //table il_bibl_entry
117  $set = $ilDB->query("SELECT * FROM il_bibl_entry " . " WHERE id = " . $ilDB->quote($this->getEntryId(), "integer"));
118  while ($rec = $ilDB->fetchAssoc($set)) {
119  $this->setType($rec['type']);
120  }
121  $this->setAttributes($this->loadAttributes());
122  $this->setOverwiew();
123  }
loadAttributes()
Reads all the entrys attributes from database.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doUpdate()

ilBibliographicEntry::doUpdate ( )

Update database tables il_bibl_entry and il_bibl_attribute.

Definition at line 129 of file class.ilBibliographicEntry.php.

References $ilDB, and getAttributes().

129  {
130  global $ilDB;
131  //table il_bibl_entry
132  $ilDB->manipulate($up = "UPDATE il_bibl_entry SET " . " type = " . $ilDB->quote($this->getType(), "integer") . // type
133  " WHERE id = " . $ilDB->quote($this->getEntryId(), "integer"));
134  //table il_bibl_attribute
135  foreach ($this->getAttributes() as $attribute) {
136  $ilDB->manipulate($up = "UPDATE il_bibl_attribute SET " . " name = " . $ilDB->quote($attribute['name'], "integer") . "," . // name
137  " value = " . $ilDB->quote($attribute['value'], "integer") . "," . // value
138  " WHERE id = " . $ilDB->quote($attribute['id'], "integer"));
139  }
140  }
global $ilDB
+ Here is the call graph for this function:

◆ getAllEntries()

static ilBibliographicEntry::getAllEntries (   $object_id)
static

Read all entries from the database.

Parameters
$object_id
Returns
array

Definition at line 320 of file class.ilBibliographicEntry.php.

References $ilDB.

Referenced by ilDataBibliographicRecordListTableGUI\initData().

320  {
321  global $ilDB;
322  $entries = array();
323  $set = $ilDB->query("SELECT id FROM il_bibl_entry " . " WHERE data_id = " . $ilDB->quote($object_id, "integer"));
324  while ($rec = $ilDB->fetchAssoc($set)) {
325  $entries[]['entry_id'] = $rec['id'];
326  }
327 
328  return $entries;
329  }
global $ilDB
+ Here is the caller graph for this function:

◆ getAttributes()

ilBibliographicEntry::getAttributes ( )
Returns
string[]

Definition at line 197 of file class.ilBibliographicEntry.php.

References $attributes.

Referenced by doCreate(), doUpdate(), ilBibliographicSetting\generateLibraryLink(), and setOverwiew().

197  {
198  return $this->attributes;
199  }
+ Here is the caller graph for this function:

◆ getBibliographicObjId()

ilBibliographicEntry::getBibliographicObjId ( )
Returns
int

Definition at line 276 of file class.ilBibliographicEntry.php.

References $bibliographic_obj_id.

◆ getEntryId()

ilBibliographicEntry::getEntryId ( )
Returns
int

Definition at line 292 of file class.ilBibliographicEntry.php.

References $entry_id.

292  {
293  return $this->entry_id;
294  }

◆ getInstance()

static ilBibliographicEntry::getInstance (   $file_type,
  $entry_id = NULL 
)
static
Parameters
$file_type
null$entry_id
Returns
ilBibliographicEntry

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

References $entry_id, and $file_type.

Referenced by ilDataBibliographicRecordListTableGUI\fillRow(), ilBibliographicDetailsGUI\getInstance(), ilDataBibliographicRecordListTableGUI\initData(), and ilObjBibliographic\writeSourcefileEntriesToDb().

56  {
57  if (!$entry_id) {
58  return new self($file_type, $entry_id);
59  }
60 
61  if (!isset(self::$instances[$entry_id])) {
62  self::$instances[$entry_id] = new self($file_type, $entry_id);
63  }
64 
65  return self::$instances[$entry_id];
66  }
+ Here is the caller graph for this function:

◆ getOverwiew()

ilBibliographicEntry::getOverwiew ( )
Returns
string

Definition at line 260 of file class.ilBibliographicEntry.php.

260  {
261  return $this->Overwiew;
262  }

◆ getType()

ilBibliographicEntry::getType ( )
Returns
string

Definition at line 308 of file class.ilBibliographicEntry.php.

References $type.

Referenced by ilBibliographicSetting\generateLibraryLink(), loadAttributes(), and setOverwiew().

308  {
309  return $this->type;
310  }
+ Here is the caller graph for this function:

◆ loadAttributes()

ilBibliographicEntry::loadAttributes ( )
protected

Reads all the entrys attributes from database.

Returns
array Attributes of an entry

Definition at line 160 of file class.ilBibliographicEntry.php.

References $ilDB, $type, and getType().

Referenced by doRead().

160  {
161  global $ilDB;
162  $all_attributes = array();
163  //table il_bibl_attribute
164  $set = $ilDB->query("SELECT * FROM il_bibl_attribute " . " WHERE entry_id = " . $ilDB->quote($this->getEntryId(), "integer"));
165  while ($rec = $ilDB->fetchAssoc($set)) {
166  $all_attributes[$rec['name']] = $rec['value'];
167  }
168  if ($this->file_type == "ris") {
169  //for RIS-Files also add the type;
170  $type = $this->getType();
171  } else {
172  $type = 'default';
173  }
174  $parsed_attributes = array();
175  foreach ($all_attributes as $key => $value) {
176  // surround links with <a href="">
177  // Allowed signs in URL: a-z A-Z 0-9 . ? & _ / - ~ ! ' * ( ) + , : ; @ = $ # [ ] %
178  $value = preg_replace('!(http)(s)?:\/\/[a-zA-Z0-9.?&_/\-~\!\'\*()+,:;@=$#\[\]%]+!', "<a href=\"\\0\" target=\"_blank\">\\0</a>", $value);
179  $parsed_attributes[strtolower($this->file_type . '_' . $type . '_' . $key)] = $value;
180  }
181 
182  return $parsed_attributes;
183  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAttributes()

ilBibliographicEntry::setAttributes (   $attributes)
Parameters
$attributes

Definition at line 189 of file class.ilBibliographicEntry.php.

References $attributes.

Referenced by doRead().

189  {
190  $this->attributes = $attributes;
191  }
+ Here is the caller graph for this function:

◆ setBibliographicObjId()

ilBibliographicEntry::setBibliographicObjId (   $bibliographic_obj_id)
Parameters
int$bibliographic_obj_id

Definition at line 268 of file class.ilBibliographicEntry.php.

References $bibliographic_obj_id.

268  {
269  $this->bibliographic_obj_id = $bibliographic_obj_id;
270  }

◆ setEntryId()

ilBibliographicEntry::setEntryId (   $entry_id)
Parameters
int$entry_id

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

References $entry_id.

Referenced by __construct(), and doCreate().

284  {
285  $this->entry_id = $entry_id;
286  }
+ Here is the caller graph for this function:

◆ setOverwiew()

ilBibliographicEntry::setOverwiew ( )

Definition at line 202 of file class.ilBibliographicEntry.php.

References $attributes, $file_type, ilObjBibliographic\getAllOverviewModels(), getAttributes(), and getType().

Referenced by doRead().

202  {
203  $attributes = $this->getAttributes();
204  //Get the model which declares which attributes to show in the overview table and how to show them
205  //example for overviewModels: $overviewModels['bib']['default'] => "[<strong>|bib_default_author|</strong>: ][|bib_default_title|. ]<Emph>[|bib_default_publisher|][, |bib_default_year|][, |bib_default_address|].</Emph>"
206  $overviewModels = ilObjBibliographic::getAllOverviewModels();
207  //get design for specific entry type or get filetypes default design if type is not specified
208  $entryType = $this->getType();
209  //if there is no model for the specific entrytype (book, article, ....) the entry overview will be structured by the default entrytype from the given filetype (ris, bib, ...)
210  if (!$overviewModels[$this->file_type][$entryType]) {
211  $entryType = 'default';
212  }
213  $single_entry = $overviewModels[$this->file_type][$entryType];
214  //split the model into single attributes (which begin and end with a bracket, eg [|bib_default_title|. ] )
215  //such values are saved in $placeholders[0] while the same values but whithout brackets are saved in $placeholders[1] (eg |bib_default_title|. )
216  preg_match_all('/\[(.*?)\]/', $single_entry, $placeholders);
217  foreach ($placeholders[1] as $key => $placeholder) {
218  //cut a moedel attribute like |bib_default_title|. in three pieces while $cuts[1] is the attribute key for the actual value and $cuts[0] is what comes before respectively $cuts[2] is what comes after the value if it is not empty.
219  $cuts = explode('|', $placeholder);
220  //if attribute key does not exist, because it comes from the default entry (e.g. ris_default_u2), we replace 'default' with the entrys type (e.g. ris_book_u2)
221  if (!$attributes[$cuts[1]]) {
222  $attribute_elements = explode('_', $cuts[1]);
223  $attribute_elements[1] = strtolower($this->getType());
224  $cuts[1] = implode('_', $attribute_elements);
225  }
226  if ($attributes[$cuts[1]]) {
227  //if the attribute for the attribute key exists, replace one attribute in the overview text line of a single entry with its actual value and the text before and after the value given by the model
228  $single_entry = str_replace($placeholders[0][$key], $cuts[0] . $attributes[$cuts[1]] . $cuts[2], $single_entry);
229  // replace the <emph> tags with a span, in order to make text italic by css
230  do {
231  $first_sign_after_begin_emph_tag = strpos(strtolower($single_entry), '<emph>') + 6;
232  $last_sign_after_end_emph_tag = strpos(strtolower($single_entry), '</emph>');
233  $italic_text_length = $last_sign_after_end_emph_tag - $first_sign_after_begin_emph_tag;
234  //would not be true if there is no <emph> tag left
235  if ($last_sign_after_end_emph_tag) {
236  $italic_text = substr($single_entry, $first_sign_after_begin_emph_tag, $italic_text_length);
237  //parse
238  $it_tpl = new ilTemplate("tpl.bibliographic_italicizer.html", true, true, "Modules/Bibliographic");
239  $it_tpl->setCurrentBlock("italic_section");
240  $it_tpl->setVariable('ITALIC_STRING', $italic_text);
241  $it_tpl->parseCurrentBlock();
242  //replace the emph tags and the text between with the parsed text from il_tpl
243  $text_before_emph_tag = substr($single_entry, 0, $first_sign_after_begin_emph_tag - 6);
244  $text_after_emph_tag = substr($single_entry, $last_sign_after_end_emph_tag + 7);
245  $single_entry = $text_before_emph_tag . $it_tpl->get() . $text_after_emph_tag;
246  }
247  } while ($last_sign_after_end_emph_tag);
248  } else {
249  //if the attribute for the attribute key does not exist, just remove this attribute-key from the overview text line of a single entry
250  $single_entry = str_replace($placeholders[0][$key], '', $single_entry);
251  }
252  }
253  $this->Overwiew = $single_entry;
254  }
special template class to simplify handling of ITX/PEAR
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setType()

ilBibliographicEntry::setType (   $type)
Parameters
string$type

Definition at line 300 of file class.ilBibliographicEntry.php.

References $type.

Referenced by doRead().

300  {
301  $this->type = $type;
302  }
+ Here is the caller graph for this function:

Field Documentation

◆ $attributes

ilBibliographicEntry::$attributes
protected

Definition at line 37 of file class.ilBibliographicEntry.php.

Referenced by getAttributes(), setAttributes(), and setOverwiew().

◆ $bibliographic_obj_id

ilBibliographicEntry::$bibliographic_obj_id
protected

Definition at line 19 of file class.ilBibliographicEntry.php.

Referenced by getBibliographicObjId(), and setBibliographicObjId().

◆ $entry_id

ilBibliographicEntry::$entry_id
protected

Definition at line 25 of file class.ilBibliographicEntry.php.

Referenced by __construct(), getEntryId(), getInstance(), and setEntryId().

◆ $file_type

ilBibliographicEntry::$file_type
protected

Definition at line 43 of file class.ilBibliographicEntry.php.

Referenced by __construct(), getInstance(), and setOverwiew().

◆ $instances

ilBibliographicEntry::$instances = array()
staticprotected

Definition at line 47 of file class.ilBibliographicEntry.php.

◆ $type

ilBibliographicEntry::$type
protected

Definition at line 31 of file class.ilBibliographicEntry.php.

Referenced by getType(), loadAttributes(), and setType().


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